/* ==========================================================================
   Hayst Kopi — Product Page
   Mobile-first. Desktop layout kicks in at 900px.
   ========================================================================== */

:root {
  --espresso: #3B2416;
  --mocha: #8B5E3C;
  --latte: #EFE4DC;
  --matcha: #A7B090;
  --bg: #F8F2EC;
  --text-muted: #6B5647;
  --white: #FFFCF9;
  --stock-out: #9A3B2E;
  --stock-out-bg: #F3DFD9;

  --font-display: 'Poppins', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--espresso);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--mocha);
  outline-offset: 3px;
}

/* ---------- Header ---------- */

.site-header {
  height: 72px;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  padding: 0 8px;
  border-bottom: 1px solid rgba(59, 36, 22, 0.14);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--espresso);
  border-radius: 50%;
}

.icon-btn:hover {
  background: rgba(59, 36, 22, 0.06);
}

.logo-link {
  display: flex;
  justify-content: center;
  text-decoration: none;
}

.logo {
  height: 48px;
  width: auto;
}

.header-spacer {
  width: 52px;
}

/* ---------- Product section ---------- */

.product {
  display: flex;
  flex-direction: column;
}

/* .product sets its own `display`, which otherwise beats the browser's
   default [hidden]{display:none} rule (same specificity, author
   stylesheet wins) — see the matching .events[hidden] rule below for the
   same issue. Without this, the hidden attribute silently fails to hide
   the section while real product data is still loading, which is the
   whole point of hiding it (avoids a flash of the static placeholder
   price/photo/description being replaced once Firestore responds). */
.product[hidden] {
  display: none;
}

.page-loading {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

.page-loading[hidden] {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(59, 36, 22, 0.18);
  border-top-color: var(--espresso);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.product-media {
  flex: none;
}

.main-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--latte);
  overflow: hidden;
}

.main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnails {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px 0;
}

.thumb {
  height: 82px;
  padding: 0;
  overflow: hidden;
  background: var(--latte);
  border-radius: 12px;
  border: 2px solid transparent;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.is-active {
  border-color: var(--espresso);
}

.product-details {
  padding: 28px 16px 56px;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mocha);
}

.eyebrow-light {
  color: var(--matcha);
}

.product-name {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 40px;
  letter-spacing: -0.01em;
}

.price-row {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.price {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  line-height: 32px;
  color: var(--mocha);
}

.volume {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-muted);
}

.volume-desktop {
  display: none;
}

.stock-badge {
  align-self: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--matcha);
  color: var(--espresso);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.stock-badge:empty {
  display: none;
}

.stock-badge.out-of-stock {
  background: var(--stock-out-bg);
  color: var(--stock-out);
}

.product-notice {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--stock-out);
}

.qty-limit-message {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-muted);
}

.cta-btn:disabled {
  opacity: 0.5;
  filter: none;
  cursor: not-allowed;
}

.step-btn:disabled,
.flavor-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Flavor selector ---------- */

.flavor-row {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.flavor-group {
  display: flex;
  gap: 14px;
}

.flavor-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
}

.flavor-swatch {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
}

.flavor-swatch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flavor-btn.is-active .flavor-swatch {
  border-color: var(--espresso);
}

.flavor-name {
  font-size: 12px;
  line-height: 16px;
  color: var(--espresso);
}

.quantity-row {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.quantity-label {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.stepper {
  display: flex;
  align-items: center;
  height: 48px;
  border: 1.5px solid rgba(59, 36, 22, 0.35);
  border-radius: 999px;
  background: var(--white);
}

.step-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--espresso);
}

.qty-value {
  min-width: 40px;
  text-align: center;
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
}

.cta-btn {
  margin-top: 20px;
  height: 56px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: var(--espresso);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.04em;
  transition: filter 0.15s ease;
}

.cta-btn:hover {
  filter: brightness(1.18);
}

.description-block {
  margin-top: 32px;
  padding: 20px 0;
  border-top: 1px solid rgba(59, 36, 22, 0.16);
}

.section-label {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.description-text {
  margin-top: 12px;
  font-size: 16px;
  line-height: 26px;
}

.description-text p {
  margin: 0;
}

/* ---------- Accordion ---------- */

.accordion {
  border-top: 1px solid rgba(59, 36, 22, 0.16);
  border-bottom: 1px solid rgba(59, 36, 22, 0.16);
}

.accordion-toggle {
  width: 100%;
  height: 60px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  color: var(--espresso);
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  text-align: left;
}

.icon-plus {
  transition: transform 0.2s ease;
}

.accordion-toggle[aria-expanded="true"] .icon-plus {
  transform: rotate(45deg);
}

.accordion-panel {
  padding: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pickup-row {
  display: flex;
  gap: 16px;
  min-height: 36px;
  align-items: baseline;
  font-size: 15px;
  line-height: 24px;
}

.pickup-label {
  width: 100px;
  flex: none;
  color: var(--text-muted);
}

/* ---------- Events section ---------- */

.events {
  display: flex;
  flex-direction: column;
  background: var(--espresso);
  color: var(--bg);
}

/* .events sets its own `display`, which otherwise beats the browser's
   default [hidden]{display:none} rule (same specificity, author stylesheet
   wins) — without this, the `hidden` attribute alone silently fails to
   hide an .events section. */
.events[hidden] {
  display: none;
}

.events-text {
  padding: 56px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.events-heading {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 36px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.events-copy {
  margin: 16px 0 0;
  font-size: 16px;
  line-height: 26px;
  color: var(--latte);
  text-wrap: pretty;
}

.tag-row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  height: 36px;
  box-sizing: border-box;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--matcha);
  color: var(--espresso);
  font-size: 14px;
  font-weight: 500;
}

.outline-btn {
  margin-top: 24px;
  height: 52px;
  box-sizing: border-box;
  padding: 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--latte);
  border-radius: 999px;
  color: var(--latte);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
}

.outline-btn:hover {
  background: rgba(239, 228, 220, 0.1);
}

.events-media {
  min-height: 300px;
  overflow: hidden;
}

.events-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   Desktop layout (900px and up)
   ========================================================================== */

@media (min-width: 900px) {

  .site-header {
    height: 88px;
    grid-template-columns: 120px 1fr 120px;
    padding: 0 40px;
  }

  .icon-btn {
    width: 48px;
    height: 48px;
  }

  .icon-btn svg {
    width: 28px;
    height: 28px;
  }

  .logo {
    height: 60px;
  }

  .header-spacer {
    width: 120px;
  }

  .product {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 72px;
    align-items: start;
    padding: 56px 120px 96px;
    max-width: 1440px;
    margin: 0 auto;
  }

  .main-image {
    border-radius: 24px;
    max-width: 564px;
  }

  .thumbnails {
    padding: 16px 0 0;
    max-width: 564px;
  }

  .thumb {
    height: 96px;
    border-radius: 14px;
  }

  .product-details {
    padding: 8px 0 0;
  }

  .eyebrow {
    font-size: 13px;
  }

  .product-name {
    margin-top: 10px;
    font-size: 52px;
    line-height: 60px;
    letter-spacing: -0.015em;
  }

  .price-row {
    margin-top: 12px;
  }

  .price {
    font-size: 28px;
    line-height: 36px;
  }

  .volume {
    font-size: 15px;
  }

  .volume-mobile {
    display: none;
  }

  .volume-desktop {
    display: inline;
  }

  .flavor-row {
    margin-top: 32px;
    gap: 10px;
  }

  .flavor-group {
    gap: 16px;
  }

  .flavor-swatch {
    width: 84px;
    height: 84px;
    border-radius: 14px;
  }

  .flavor-name {
    font-size: 13px;
    line-height: 18px;
  }

  .quantity-row {
    margin-top: 32px;
  }

  .stepper {
    height: 52px;
  }

  .step-btn {
    width: 52px;
    height: 52px;
  }

  .qty-value {
    min-width: 44px;
    font-size: 17px;
  }

  .cta-btn {
    margin-top: 24px;
    height: 60px;
    font-size: 17px;
  }

  .description-block {
    margin-top: 40px;
    padding: 24px 0;
  }

  .description-text {
    margin-top: 14px;
    font-size: 17px;
    line-height: 28px;
  }

  .accordion-toggle {
    height: 64px;
    font-size: 17px;
  }

  .accordion-panel {
    padding: 0 0 24px;
  }

  .pickup-row {
    font-size: 16px;
  }

  .pickup-label {
    width: 120px;
  }

  .events {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 560px;
  }

  .events-text {
    padding: 72px 72px 72px 120px;
    justify-content: center;
  }

  .events-heading {
    max-width: 480px;
    font-size: 44px;
    line-height: 52px;
    letter-spacing: -0.015em;
  }

  .events-copy {
    max-width: 500px;
    font-size: 18px;
    line-height: 30px;
  }

  .tag-row {
    margin-top: 24px;
    gap: 10px;
  }

  .tag {
    height: 38px;
    padding: 0 16px;
    font-size: 15px;
  }

  .outline-btn {
    margin-top: 32px;
    height: 56px;
    padding: 0 32px;
    font-size: 16px;
  }

  .events-media {
    min-height: 100%;
  }
}
