/* =====================================================================
   SCENE 2 · SCROLL THE ROAST
   Scroll position becomes a number s from 0 (green) to 3 (dark).
   A bright line wipes one roast photo into the next; a curve underneath shows where you are.
   ===================================================================== */
.roast {
  position: relative;
  height: 520vh;                /* 1 screen of stage + 4.2 screens of scroll */
  height: 520svh;
  border-top: 1px solid rgba(184, 137, 43, 0.25);
}
.roast__stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  background: #120b07;
  isolation: isolate;
  --pad: 64px;
  --curve-h: clamp(176px, 27svh, 230px);
  --bag: #F3D77A;
  --glow: rgba(243, 215, 122, 0.45);
}

/* Moving background: the roasting tray video, seen under the curve */
.roast__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: brightness(0.7);
}

/* The four roast photos, stacked. JS decides which are visible and where the line cuts. */
.roast__photos {
  position: absolute; left: 0; right: 0; top: 0;
  bottom: calc(var(--curve-h) - 24px);
  overflow: hidden;
}
.roast__ph { position: absolute; inset: 0; }
.roast__ph img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(var(--zoom, 1.04));
  will-change: transform;
}
.roast__ph--0 img { object-position: 35% 40%; }
.roast__ph--1 img { object-position: 50% 45%; }
.roast__ph--2 img { object-position: 50% 55%; }
.roast__ph--3 img { object-position: 50% 40%; }
/* Soft darkening so the words stay readable on bright beans, and a fade into the curve area */
.roast__shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(18, 11, 7, 0.62), rgba(18, 11, 7, 0) 58%),
    linear-gradient(180deg, rgba(18, 11, 7, 0.62), rgba(18, 11, 7, 0) 34%),
    linear-gradient(0deg, #1b1109, rgba(27, 17, 9, 0) 38%);
  pointer-events: none;
}

/* The bright line and its handle (a vertical line on wide screens, a horizontal one on phones) */
.roast__line {
  position: absolute; top: 0; bottom: 0;
  left: 50%; width: 3px; margin-left: -1px;
  background: #FFE7A8;
  box-shadow: 0 0 24px 8px rgba(255, 190, 90, 0.8), 0 0 90px 30px rgba(255, 150, 50, 0.3);
  pointer-events: none;
  will-change: left, opacity;
}
.roast__knob {
  position: absolute; left: 50%; top: 46%;
  width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: var(--cream); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font: 600 20px/1 var(--font-body);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  will-change: left, top, opacity;
}
.roast__tag {
  position: absolute; bottom: 36px;
  padding: 6px 12px;
  font: 12px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase;
  background: rgba(42, 28, 19, 0.75);
  border-radius: 4px;
  pointer-events: none;
  transition: opacity 0.2s;
}
.roast__tag--a { left: var(--pad); }
.roast__tag--b { right: var(--pad); }

/* Words */
.roast__head {
  position: absolute; left: var(--pad); top: calc(var(--strip-h) + 54px);
  max-width: min(640px, 55vw);
  text-shadow: 0 2px 18px rgba(18, 11, 7, 0.7);
}
.roast__title {
  margin: 8px 0 12px;
  font: 500 clamp(2.25rem, 4.2vw, 3.6rem)/1.05 var(--font-display);
}
.roast__title em { color: var(--butter); font-style: italic; }
.roast__sub { margin: 0; font-size: 1rem; max-width: 360px; color: rgba(246, 235, 217, 0.9); }

/* "Your cup" card */
.roast__card {
  position: absolute; right: var(--pad); top: calc(var(--strip-h) + 54px);
  width: 300px; padding: 22px 24px;
  border-radius: 14px;
  background: rgba(27, 17, 9, 0.84);
  border: 1px solid rgba(184, 137, 43, 0.45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: opacity 0.18s;
}
.roast__card.is-swapping { opacity: 0; }
.roast__card .label { margin: 0; }
.roast__name { margin: 4px 0 6px; font: 500 2.25rem/1.1 var(--font-display); }
.roast__text { margin: 0; font-size: 0.9rem; line-height: 1.5; color: rgba(246, 235, 217, 0.88); }
.roast__note {
  margin: 12px 0 0;
  font: 11px/1.4 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--butter);
}

/* The bag: flat colour, locked mark. The real 3D bag comes in scene 3. */
.roast__bag {
  position: absolute; right: calc(var(--pad) + 32px); top: 46svh;
  width: 104px; height: 148px;
  border-radius: 10px 10px 6px 6px;
  background: var(--bag);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), 0 0 70px var(--glow);
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.5s, box-shadow 0.5s, opacity 0.4s, transform 0.4s;
}
.roast__bag::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 12%;
  background: rgba(0, 0, 0, 0.18); border-radius: 10px 10px 0 0;
}
.roast__bag img { width: 58%; height: auto; }
.roast__bag.is-off { opacity: 0; transform: translateY(14px); }

/* Curve control */
.roast__ctl {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--curve-h);
}
/* Darkens the moving video so the curve and words read clearly */
.roast__ctl::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(27, 17, 9, 0), rgba(27, 17, 9, 0.72) 32%, rgba(27, 17, 9, 0.8));
  pointer-events: none;
}
.roast__wrap {
  position: absolute; left: var(--pad); right: var(--pad); top: 0; bottom: 0;
}
.roast__graph {
  position: absolute; left: 0; right: 0; top: 0; bottom: 56px;
  cursor: grab; touch-action: pan-y;
}
.roast__graph.is-dragging { cursor: grabbing; }
.roast__graph svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.roast__curve-base { opacity: 0.3; }
.roast__curve-done { filter: drop-shadow(0 0 7px rgba(255, 190, 90, 0.7)); }
.roast__grid line { stroke: rgba(246, 235, 217, 0.08); vector-effect: non-scaling-stroke; }
.roast__head-dot {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 0 7px rgba(255, 231, 168, 0.35), 0 0 24px 6px rgba(255, 190, 90, 0.7);
  will-change: left, top;
}
.roast__crack {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: #FFD27A;
  box-shadow: 0 0 0 6px rgba(255, 210, 122, 0.3), 0 0 16px 4px rgba(255, 170, 60, 0.9);
}
.roast__crack-label {
  position: absolute; transform: translate(-50%, -26px);
  font: 11px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: #FFD27A; white-space: nowrap;
}
.roast__words { position: absolute; left: 0; right: 0; bottom: 8px; height: 46px; }
.roast__word {
  position: absolute; bottom: 0; transform: translateX(-50%);
  padding: 4px 8px; min-height: 44px; min-width: 44px;
  background: none; border: 0; cursor: pointer;
  text-align: center; white-space: nowrap;
  font: 500 0.95rem/1.2 var(--font-display);
  color: rgba(246, 235, 217, 0.62);
}
.roast__word small {
  display: block; margin-bottom: 2px;
  font: 10px/1.2 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brass);
}
.roast__w-short { display: none; }
.roast__word.is-on { color: var(--cream); }
.roast__word.is-on small { color: var(--butter); }
.roast__word:focus-visible { outline: 2px solid var(--butter); outline-offset: 2px; border-radius: 6px; }
.roast__hint {
  position: absolute; left: var(--pad); bottom: calc(var(--curve-h) - 2px);
  margin: 0;
  font: 11px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(246, 235, 217, 0.6);
}
.roast__sparks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Phones and tall screens: the line runs sideways, the card sits low ---------- */
@media (max-aspect-ratio: 3/4) {
  .roast__stage { --pad: 18px; --curve-h: 168px; }
  .roast__photos { bottom: calc(var(--curve-h) - 6px); }
  .roast__line { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 3px; margin: -1px 0 0; }
  .roast__knob { left: 50%; top: 50%; }
  .roast__head { top: calc(var(--strip-h) + 28px); max-width: calc(100% - 36px); }
  .roast__title { font-size: clamp(2rem, 9.5vw, 2.6rem); }
  .roast__sub { display: none; }
  .roast__tag { bottom: auto; top: auto; }
  .roast__tag--b { right: auto; left: var(--pad); }
  .roast__card {
    left: 14px; right: 14px; top: auto;
    bottom: calc(var(--curve-h) + 4px);
    width: auto; padding: 12px 16px 12px 100px;
    min-height: 92px;
  }
  .roast__name { font-size: 1.6rem; margin: 2px 0 2px; }
  .roast__text { font-size: 0.8rem; }
  .roast__note { display: none; }
  .roast__bag {
    right: auto; left: 28px; top: auto;
    bottom: calc(var(--curve-h) + 14px);
    width: 56px; height: 80px;
    z-index: 2;
  }
  .roast__word { font-size: 0.85rem; padding: 4px 4px; }
  .roast__w-full { display: none; }
  .roast__w-short { display: inline; }
  .roast__ph--1 img { object-position: 50% 22%; }
  .roast__card.no-bag { padding-left: 16px; }
  .roast__hint { display: none; }
}

/* ---------- Reduced motion: no pinned scroll, no wipe. Pick a roast with the words under the curve. ---------- */
.roast.is-static { height: auto; }
.roast.is-static .roast__stage { position: relative; height: 100svh; min-height: 560px; }
.roast.is-static .roast__line, .roast.is-static .roast__knob, .roast.is-static .roast__tag { display: none; }
.roast.is-static .roast__graph { cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .roast__bag, .roast__card { transition: none; }
}
