/* ==================================================================
   BERMITO — THE DESCENT (styles)
   The canvas is the world; DOM is only voice-over. Tokens come from
   tokens.css. Overlay text uses brand type on transparent ground.
   ================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: auto; }
body {
  margin: 0;
  background: #FBFAF7;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}
body.is-loading { overflow: hidden; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400; text-transform: uppercase;
  line-height: var(--leading-display);
  font-feature-settings: "calt" 1, "liga" 1;
  margin: 0; text-wrap: balance;
}
p { margin: 0 0 var(--stack-md); }
a { color: inherit; }
img, svg { max-width: 100%; display: block; }

.sr-only { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden;
  clip:rect(0 0 0 0); white-space:nowrap; border:0; padding:0; }

:where(a,button):focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: fixed; top:.5rem; left:.5rem; z-index: 200;
  background: var(--yellow); color: var(--brown);
  padding:.7rem 1.1rem; border-radius:999px; font-weight:600; text-decoration:none;
  transform: translateY(-160%); transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus { transform:none; }

.btn {
  display:inline-flex; align-items:center; gap:.5em;
  font-weight:600; font-size:var(--t-small); letter-spacing:.04em;
  padding:.95em 1.6em; border-radius:999px; text-decoration:none;
  border:1.5px solid transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.btn--solid { background: var(--yellow); color: var(--brown); }
.btn--solid:hover { background: var(--paper); }
.btn--line { border-color: rgba(251,250,247,.3); color: var(--paper); }
.btn--line:hover { border-color: var(--yellow); color: var(--yellow); }

/* ==================================================================
   LOADER
   ================================================================== */
.loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--brown);
  display: grid; place-items: center;
  transition: opacity 800ms var(--ease), visibility 800ms;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__word {
  position: absolute; width: 136vw; max-width: none;
  color: var(--yellow); opacity: .16; pointer-events: none;
}
.loader__word svg { width: 100%; height: auto; }
.loader__mark { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.loader__mark i {
  width: 52px; background: var(--yellow); border-radius: 50%;
  opacity: .15; transform: scale(.55);
  transition: opacity 400ms var(--ease), transform 600ms var(--ease);
}
.loader__mark i:nth-child(1) { height: 52px; }
.loader__mark i:nth-child(2) { height: 40px; }
.loader__mark i:nth-child(3) { height: 24px; }
.loader__mark i:nth-child(4) { height: 10px; }
.loader__mark i.is-on { opacity: 1; transform: none; }
.loader__line {
  position: absolute; bottom: 21%;
  font-family: var(--font-display); font-size: var(--t-label);
  letter-spacing: var(--track-label); color: rgba(255,226,18,.75);
}
.loader__pct {
  position: absolute; bottom: 1.4rem; right: 1.6rem; margin: 0;
  font-family: var(--font-display); font-size: 1rem;
  letter-spacing: .1em; color: rgba(255,226,18,.65);
  font-variant-numeric: tabular-nums;
}
.loader__pct::after { content: "%"; font-size: .7em; }
.loader__skip {
  position: absolute; bottom: max(1.3rem, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: none; border: 1px solid rgba(255,226,18,.35); color: var(--yellow);
  font-family: var(--font-body); font-size: var(--t-small);
  padding: .55em 1.4em; border-radius: 999px; cursor: pointer;
}
.loader__skip:hover { background: var(--yellow); color: var(--brown); }

/* ==================================================================
   THE DESCENT
   ================================================================== */
.descent { position: fixed; inset: 0; z-index: 1; color: var(--paper); }
.descent[data-ink="brown"] { color: var(--brown); }
.descent[data-ink="brown"] .beat { text-shadow: none; }
.descent[data-ink="brown"] .gauge li { border-color: rgba(81,69,61,.45); }
.descent[data-ink="brown"] .hud__logo { color: var(--brown); }
.descent[data-ink="brown"] .beat--title .beat__eyebrow { color: var(--brown); }
.descent, .descent .hud, .descent .beat, .descent .hud__hint { transition: color 320ms var(--ease); }
.descent__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.track { height: 660vh; }

/* circle wipe — a brand dot that swallows the screen at set cuts */
.wipe {
  position: absolute; left: 50%; top: 50%;
  width: 240vmax; height: 240vmax;
  margin: -120vmax 0 0 -120vmax;
  border-radius: 50%;
  background: var(--yellow);
  transform: scale(0);
  pointer-events: none;
  z-index: 4;
}

/* --- HUD ---------------------------------------------------------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem 0;
  pointer-events: none;
}
.hud__logo { width: 108px; color: var(--paper); pointer-events: auto; }
.hud__logo svg { width: 100%; height: auto; }
.hud__shop {
  pointer-events: auto;
  background: var(--yellow); color: var(--brown);
  font-size: var(--t-label); font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; text-decoration: none;
  padding: .6rem 1rem; border-radius: 999px;
}
.hud--bottom {
  top: auto; bottom: 0; align-items: flex-end;
  padding: 0 1.5rem max(1.1rem, env(safe-area-inset-bottom));
}
.hud__stage {
  margin: 0; font-family: var(--font-display);
  font-size: clamp(.85rem, 1.6vw, 1.05rem); letter-spacing: var(--track-label);
}
.hud__stage span { opacity: .55; }
.hud__coord {
  margin: 0; font-size: var(--t-label); letter-spacing: .14em;
  opacity: .7; font-variant-numeric: tabular-nums; text-align: right;
}
.hud__hint {
  position: absolute; bottom: max(3.4rem, calc(env(safe-area-inset-bottom) + 2.6rem));
  left: 50%; transform: translateX(-50%); z-index: 6; margin: 0;
  font-family: var(--font-display); font-size: var(--t-label);
  letter-spacing: var(--track-label); text-transform: uppercase; opacity: .6;
  transition: opacity var(--dur-mid) var(--ease);
  animation: bob 2.6s ease-in-out infinite;
}
.hud__hint.is-hidden { opacity: 0; animation: none; }
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* --- roast gauge: five circles filling as the descent progresses -- */
.gauge {
  position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%);
  z-index: 6; list-style: none; margin: 0; padding: 0;
  display: grid; gap: .55rem; justify-items: center;
}
.gauge li {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.4px solid rgba(251,250,247,.5);
  transition: background var(--dur-mid) var(--ease), border-color var(--dur-mid) var(--ease);
}
.gauge li.is-on { background: var(--yellow); border-color: var(--yellow); }

/* --- story beats -------------------------------------------------- */
.beats { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.beat {
  position: absolute;
  max-width: min(46ch, 82vw);
  opacity: 0; transform: translateY(26px);
  transition: opacity 700ms var(--ease), transform 900ms var(--ease);
  text-shadow: 0 1px 22px rgba(0,0,0,.35);
}
.beat.is-on { opacity: 1; transform: none; }
.beat--left  { left: clamp(1.5rem, 7vw, 7rem); top: 50%; translate: 0 -50%; }
.beat--right { right: clamp(1.5rem, 7vw, 7rem); top: 50%; translate: 0 -50%; text-align: right; }
.beat--center{ left: 50%; top: 50%; translate: -50% -50%; text-align: center; }
.beat--low   { left: 50%; top: auto; bottom: 11vh; translate: -50% 0; text-align: center; }

.beat__eyebrow {
  font-family: var(--font-display); font-size: var(--t-label);
  letter-spacing: var(--track-label); text-transform: uppercase;
  opacity: .75; margin-bottom: .8rem;
}
.beat h2 {
  font-size: clamp(1.9rem, 4.6vw, 4rem);
  white-space: pre-line; margin-bottom: 1rem;
}
.beat p { font-size: clamp(.98rem, 1.25vw, 1.15rem); opacity: .92; margin-bottom: .55rem; }
.beat--title h2 { font-size: clamp(2.2rem, 5.6vw, 5rem); }
.beat--title .beat__eyebrow { color: var(--yellow); opacity: 1; }

/* ==================================================================
   THE GROUND — finale + footer after the cup
   ================================================================== */
.ground {
  position: relative; z-index: 2;
  background: var(--brown); color: var(--paper);
  margin-top: -2px;
}
.finale {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--section) var(--gutter);
}
.finale__disk { width: clamp(160px, 21vw, 250px); height: auto; margin-bottom: var(--stack-lg); }
.finale h1 { font-size: var(--t-h2); color: var(--yellow); margin-bottom: var(--stack-md); }
.finale__lead { font-size: var(--t-lead); max-width: 44ch; }
.finale__sub {
  font-family: var(--font-display); font-size: var(--t-small);
  letter-spacing: var(--track-label); text-transform: uppercase; opacity: .7;
}
.finale__actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; margin-top: var(--stack-lg); }
.finale__replay { margin-top: var(--stack-lg); display: flex; gap: 1.6rem; flex-wrap: wrap; justify-content: center; font-size: var(--t-small); }
.finale__replay button {
  background: none; border: 0; color: var(--yellow); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}
.finale__replay a { color: rgba(251,250,247,.75); }

.site-footer {
  display: grid; grid-template-columns: 1.3fr 1fr;
  gap: var(--stack-lg) var(--gutter);
  padding: var(--section) var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(251,250,247,.14);
}
.site-footer__brand span { display: block; width: 156px; color: var(--yellow); margin-bottom: var(--stack-md); }
.site-footer__brand svg { width: 100%; height: auto; }
.site-footer__brand p { color: rgba(251,250,247,.7); font-size: var(--t-small); }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; align-content: start; }
.site-footer__nav a { text-decoration: none; font-size: var(--t-small); color: rgba(251,250,247,.82); }
.site-footer__nav a:hover { color: var(--yellow); }
.site-footer__legal {
  grid-column: 1/-1; margin: 0; padding-top: var(--stack-lg);
  border-top: 1px solid rgba(251,250,247,.12);
  font-size: var(--t-label); letter-spacing: .06em; color: rgba(251,250,247,.5);
  display: flex; flex-wrap: wrap; gap: .3rem 1.4rem;
}

/* ==================================================================
   RESPONSIVE + FALLBACK
   ================================================================== */
@media (max-width: 760px) {
  /* on phones the object sits behind the text — halo both inks */
  .descent .beat { text-shadow: 0 1px 18px rgba(0,0,0,.3); }
  .descent[data-ink="brown"] .beat { text-shadow: 0 1px 16px rgba(251,250,247,.65); }
  .beat--left, .beat--right { left: 1.4rem; right: 1.4rem; text-align: left; translate: 0 -50%; }
  .beat--right { text-align: left; }
  .gauge { right: .8rem; }
  .site-footer { grid-template-columns: 1fr; }
  .track { height: 580vh; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .track { height: 520vh; }
  .beat h2 { font-size: clamp(1.4rem, 4.4vw, 2.4rem); }
}

/* reduced motion or no WebGL: the descent bows out gracefully */
body.no-descent .descent, body.no-descent .track, body.no-descent .loader { display: none; }
body.no-descent { overflow: auto; }
body.no-descent .ground { min-height: 100svh; }
