/* =========================================================
   GLAZE & CO. — DESIGN TOKENS
   Palette:
     --plum      #2B1B2E  deep eggplant — hero / night-bakery backdrop
     --plum-2    #3B2540  lifted plum for panels within the hero
     --cream     #FFF8ED  daylight bakery-case background
     --ink       #241220  near-black plum used for body text on cream
     --glaze-pink   #FF6F91  strawberry glaze accent
     --glaze-butter #FFC857  custard/honey accent
     --glaze-mint   #8FD8C4  pistachio accent
   Type:
     Display — "Fraunces" (warm, variable-optical-size serif; bakery signage energy)
     Body/UI — "Work Sans" (quiet, legible workhorse)
   ========================================================= */

:root {
  --plum: #2B1B2E;
  --plum-2: #3B2540;
  --cream: #FFF8ED;
  --ink: #241220;
  --glaze-pink: #FF6F91;
  --glaze-butter: #FFC857;
  --glaze-mint: #8FD8C4;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-lg: 8px;
  --radius-md: 8px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ============ NAV ============ */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 5vw;
  color: var(--cream);
  mix-blend-mode: normal;
  transition: color 0.2s ease, background 0.2s ease;
}

.site-nav.is-light {
  color: var(--ink);
  background: rgba(255,248,237,0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.site-nav.is-light .nav-cta { border-color: rgba(36,18,32,0.3); }

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.wordmark-dot {
  color: var(--glaze-pink);
  font-style: italic;
  padding: 0 2px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.92rem;
}

.nav-links a {
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}
.nav-links a:hover,
.nav-links a:focus-visible { opacity: 1; }

.nav-cta {
  border: 1px solid rgba(255,248,237,0.5);
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 1 !important;
}

/* ============ HERO / 3D STAGE ============ */
.hero {
  position: relative;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 78% 32%, var(--plum-2) 0%, var(--plum) 62%, #1c1120 100%);
  display: flex;
  align-items: center;
}

#donut-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* let OrbitControls own drag/pinch gestures */
  cursor: grab;
  background: url('fallback/hero-donut.png') center center / cover no-repeat;
}
#donut-canvas:active { cursor: grabbing; }

#loading-veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--plum);
  color: var(--cream);
  z-index: 30;
  transition: opacity 0.6s ease;
  font-family: var(--font-body);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  animation: loading-timeout 0.5s ease 4s forwards;
}
#loading-veil.hidden { opacity: 0; visibility: hidden; pointer-events: none; animation: none; }

@keyframes loading-timeout {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

.loading-ring {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,248,237,0.2);
  border-top-color: var(--glaze-pink);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hero-copy {
  position: relative;
  z-index: 10;
  max-width: 560px;
  padding: 0 6vw;
  color: var(--cream);
  pointer-events: none; /* let clicks pass through to canvas except on real controls */
}
.hero-copy > * { pointer-events: auto; }

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--glaze-mint);
  margin: 0 0 18px;
  font-weight: 500;
}

.hero-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.02;
  margin: 0 0 22px;
}

.hero-tagline {
  font-size: 1.05rem;
  line-height: 1.55;
  color: rgba(255,248,237,0.82);
  max-width: 44ch;
  margin: 0 0 34px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 26px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--glaze-pink);
  color: #2B1220;
}
.btn-primary:hover { background: #ff86a2; }

.btn-ghost {
  background: transparent;
  color: var(--cream);
  border-color: rgba(255,248,237,0.45);
}
.btn-ghost:hover { border-color: var(--cream); }

.btn-large {
  padding: 16px 34px;
  font-size: 1.02rem;
  margin-top: 10px;
}

/* ============ CONTROL CLUSTER (overlays canvas) ============ */
.control-cluster {
  position: absolute;
  z-index: 20;
  right: 5vw;
  bottom: 108px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

/* Signature element: flavor dial styled like a bakery case price tag */
.flavor-dial {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,248,237,0.08);
  border: 1px solid rgba(255,248,237,0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 8px 8px 8px 20px;
  color: var(--cream);
}

.flavor-dial-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.65;
}

.flavor-dial-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  min-width: 108px;
}

.flavor-dial-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--glaze-pink);
  color: #2B1220;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.2,0.8,0.2,1), background 0.2s ease;
}
.flavor-dial-btn:hover { background: var(--glaze-butter); }
.flavor-dial-btn.spin { transform: rotate(180deg); }

.view-controls {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,248,237,0.28);
  background: rgba(255,248,237,0.08);
  color: var(--cream);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.icon-btn:hover { background: rgba(255,248,237,0.18); border-color: rgba(255,248,237,0.5); }

.drag-hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(255,248,237,0.55);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-align: center;
  width: 100%;
  pointer-events: none;
}

/* Hotspot markers are drawn as CSS-positioned dots synced to 3D screen coords in app.js */
.hotspot-marker {
  position: absolute;
  z-index: 18;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: rgba(255,248,237,0.9);
  border: 2px solid var(--glaze-pink);
  cursor: pointer;
  transition: transform 0.2s ease;
}
.hotspot-marker::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(255,248,237,0.4);
  animation: pulse 2.2s ease-out infinite;
}
.hotspot-marker:hover { transform: scale(1.15); }

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.hotspot-tooltip {
  position: absolute;
  z-index: 25;
  left: 5vw;
  bottom: 108px;
  max-width: 280px;
  background: var(--cream);
  color: var(--ink);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}
.hotspot-title {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.hotspot-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #4a3a46;
}
.hotspot-close {
  position: absolute;
  top: 8px; right: 10px;
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #7a6874;
}

/* ============ INGREDIENTS SECTION ============ */
.ingredients-section {
  padding: 110px 6vw 90px;
  max-width: 1180px;
  margin: 0 auto;
}

.ingredient-experience {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.8fr);
  gap: 22px;
  margin-bottom: 24px;
}

.scene-panel,
.gallery-experience,
.order-scene {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.scene-panel {
  min-height: 520px;
  background: #302334;
  color: var(--cream);
}

.section-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  touch-action: none;
  cursor: grab;
}
.section-canvas.is-live,
#donut-canvas.is-live { background-image: none !important; }
#ingredients-canvas { background: #302334 url('fallback/ingredients-donut.png') center / cover no-repeat; }
#gallery-canvas { background: #173d37 url('fallback/flavor-donuts.png') center / cover no-repeat; }
#box-canvas { background: #fff8ed url('fallback/donut-box.png') center / contain no-repeat; }
.section-canvas:active { cursor: grabbing; }

.scene-caption {
  position: absolute;
  top: 24px;
  left: 24px;
  display: grid;
  gap: 4px;
  pointer-events: none;
}
.scene-caption strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
}
.scene-kicker {
  color: var(--glaze-mint);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.scene-controls {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 4;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255,248,237,0.1);
  border: 1px solid rgba(255,248,237,0.2);
  backdrop-filter: blur(12px);
}

.scene-control {
  border: 0;
  border-radius: 5px;
  padding: 9px 12px;
  color: var(--cream);
  background: transparent;
  font: 600 0.78rem var(--font-body);
  cursor: pointer;
}
.scene-control.is-active {
  color: var(--ink);
  background: var(--glaze-mint);
}

.scene-hint {
  position: absolute;
  right: 24px;
  bottom: 30px;
  z-index: 3;
  margin: 0;
  color: rgba(255,248,237,0.62);
  font-size: 0.76rem;
  pointer-events: none;
}

.section-head { max-width: 640px; margin-bottom: 56px; }

.eyebrow-dark { color: #C0517A; }

.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  margin: 0 0 14px;
  line-height: 1.1;
}

.section-sub {
  font-size: 1rem;
  line-height: 1.6;
  color: #5c4a56;
  margin: 0;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 56px;
}

.component-card {
  background: #fff;
  border: 1px solid #f0e4d3;
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.component-card:hover,
.component-card:focus-visible,
.component-card.is-active {
  transform: translateY(-3px);
  border-color: var(--glaze-pink);
  box-shadow: 0 14px 28px rgba(43,27,46,0.08);
  outline: none;
}

.component-tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--plum);
  background: var(--glaze-mint);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.component-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 10px;
}

.component-card p {
  font-size: 0.92rem;
  line-height: 1.55;
  color: #5c4a56;
  margin: 0 0 16px;
}

.component-list {
  list-style: none;
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid #f0e4d3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: #7a6874;
}

/* ============ NUTRITION CARD ============ */
.nutrition-card {
  background: var(--plum);
  color: var(--cream);
  border-radius: var(--radius-lg);
  padding: 34px 36px;
  max-width: none;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.nutrition-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 6px solid var(--cream);
  padding-bottom: 10px;
  margin-bottom: 6px;
}
.nutrition-head h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0;
}
.nutrition-serving { font-size: 0.82rem; opacity: 0.7; }

.nutrition-list { margin: 0; }
.nutrition-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,248,237,0.14);
  font-size: 0.92rem;
}
.nutrition-row dt { font-weight: 400; opacity: 0.85; }
.nutrition-row dd { margin: 0; font-weight: 600; }
.nutrition-row--big {
  font-size: 1.3rem;
  padding: 12px 0;
}
.nutrition-row--big dt, .nutrition-row--big dd { font-weight: 700; }

.nutrition-footnote {
  font-size: 0.76rem;
  opacity: 0.55;
  margin: 14px 0 0;
  line-height: 1.5;
}

/* ============ 3D FLAVOR GALLERY ============ */
.gallery-section {
  padding: 96px 6vw 110px;
  background: #f6fbf7;
}

.gallery-section > .section-head,
.gallery-experience {
  width: min(1120px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.gallery-experience {
  height: min(620px, 72vw);
  min-height: 470px;
  background: #173d37;
}

.gallery-experience > .section-canvas {
  position: absolute;
  inset: 0;
}

.flavor-choices {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 700px;
}

.flavor-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255,248,237,0.18);
  border-radius: 7px;
  color: var(--cream);
  background: rgba(23,61,55,0.72);
  backdrop-filter: blur(12px);
  text-align: left;
  cursor: pointer;
}
.flavor-choice.is-active { border-color: var(--cream); background: rgba(255,248,237,0.14); }
.flavor-choice > span:last-child { display: grid; gap: 2px; min-width: 0; }
.flavor-choice strong { font-family: var(--font-display); font-size: 0.95rem; }
.flavor-choice small { opacity: 0.68; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flavor-swatch { flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%; }
.swatch-strawberry { background: var(--glaze-pink); }
.swatch-butter { background: var(--glaze-butter); }
.swatch-pistachio { background: var(--glaze-mint); }
.scene-hint-dark { color: rgba(255,248,237,0.6); top: 24px; bottom: auto; }
}

/* ============ ORDER / FOOTER ============ */
.order-section {
  padding: 80px 6vw;
  background: #fdeee2;
}
.order-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.4fr);
  align-items: center;
  gap: 54px;
}
.order-copy { text-align: left; }
.order-section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 3.6vw, 2.5rem);
  margin: 0 0 12px;
}
.order-section p {
  color: #5c4a56;
  margin: 0 0 26px;
}
.order-scene {
  height: 500px;
  min-height: 500px;
  background: #fff8ed;
  border: 1px solid #efd8ca;
}
.shuffle-button {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  padding: 10px 14px;
  border: 1px solid rgba(36,18,32,0.18);
  border-radius: 6px;
  background: rgba(255,248,237,0.86);
  color: var(--ink);
  font: 600 0.8rem var(--font-body);
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.order-section .order-status {
  min-height: 1.4em;
  margin: 16px 0 0;
  color: #357060;
  font-weight: 600;
}
.order-section button { font-family: inherit; }

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 26px 6vw 34px;
  font-size: 0.8rem;
  color: #9a8894;
  background: #fdeee2;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .ingredient-experience,
  .order-inner { grid-template-columns: 1fr; }
  .nutrition-card { min-height: auto; }
  .component-grid { grid-template-columns: 1fr; }
  .hero-copy { max-width: 100%; padding-right: 6vw; }
  .control-cluster { bottom: 84px; right: 4vw; }
  .hotspot-tooltip { left: 4vw; right: 4vw; max-width: none; bottom: 190px; }
}

@media (max-width: 560px) {
  .site-nav { padding: 16px 5vw; }
  .nav-links { gap: 10px; font-size: 0.74rem; }
  .nav-links a:not(.nav-cta) { display: none; }
  .nav-cta { padding: 7px 14px; }
  .hero { align-items: flex-start; }
  .hero-copy { position: absolute; top: 104px; left: 0; right: 0; }
  .hero-copy .eyebrow { margin-bottom: 10px; font-size: 0.68rem; }
  .hero-title { font-size: 2.35rem; line-height: 1; margin-bottom: 14px; }
  .hero-tagline { max-width: 38ch; margin-bottom: 18px; font-size: 0.88rem; line-height: 1.4; }
  .hero-actions { gap: 8px; }
  .hero-actions .btn { padding: 11px 16px; font-size: 0.82rem; }
  .control-cluster {
    left: 12px;
    right: 12px;
    bottom: 24px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .flavor-dial { gap: 6px; padding: 6px 6px 6px 12px; }
  .flavor-dial-label { display: none; }
  .flavor-dial-name { min-width: 72px; font-size: 0.86rem; }
  .flavor-dial-btn { width: 34px; height: 34px; }
  .icon-btn { width: 34px; height: 34px; }
  .drag-hint { display: none; }
  .site-footer { flex-direction: column; gap: 6px; text-align: center; }
  .scene-panel { min-height: 460px; }
  .scene-controls { left: 12px; right: 12px; bottom: 14px; justify-content: center; }
  .scene-control { padding: 8px 9px; }
  .scene-hint { display: none; }
  .gallery-experience { min-height: 560px; height: 560px; }
  .flavor-choices { left: 12px; right: 12px; bottom: 12px; grid-template-columns: 1fr; }
  .flavor-choice { padding: 9px 11px; }
  .order-scene { height: 410px; min-height: 410px; }
}
