/* Dead Mojo Society — scroll-driven 3D hero */

:root {
  --bg: #282422;
  --bg-deep: #1b1816;
  --ink: #f3eee8;
  --ink-dim: #b2aaa3;
  --ink-faint: #9d958e;   /* lowest tier that still clears 4.5:1 on the lightest backdrop (#302b28) */
  --title: #181513;
  --pill: #171413;
  --pill-line: rgba(255, 255, 255, 0.06);
  --ember: #ff8a3d;
  --ember-hot: #ffb071;
  --gutter: clamp(16px, 1.9vw, 30px);
  --label: 700 clamp(8.5px, 0.66vw, 11px) / 1.2 'Archivo', system-ui, sans-serif;
  color-scheme: dark;
}

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

html {
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background:
    radial-gradient(120% 90% at 50% 38%, #302b28 0%, var(--bg) 46%, var(--bg-deep) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  /* clip, not hidden: hidden makes body a scroll box whenever <html> locks scrolling (menu,
     trailer), and the pinned 3D stages then come unstuck behind the overlay */
  overflow-x: clip;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
p, h1, h2 { margin: 0; }

:focus-visible {
  outline: 1.5px solid var(--ember);
  outline-offset: 3px;
  border-radius: 999px;
}

/* ---------- shared label + pill ---------- */

.pill,
.topbar__tag,
.hero__note,
.beat__index,
.loader {
  font: var(--label);
  font-stretch: 125%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  height: 2.35em;
  padding: 0 0.42em 0 1.1em;
  border: 1px solid var(--pill-line);
  border-radius: 999px;
  background: var(--pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.pill:hover { background: #221e1c; border-color: rgba(255, 255, 255, 0.12); }

.pill__icon {
  display: inline-grid;
  place-items: center;
  width: 1.65em;
  height: 1.65em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.85em;
  line-height: 1;
}

.pill__icon--play::before {
  content: '';
  width: 0;
  height: 0;
  margin-left: 0.12em;
  border-style: solid;
  border-width: 0.32em 0 0.32em 0.5em;
  border-color: transparent transparent transparent currentColor;
}

.pill--icon {
  width: 2.35em;
  padding: 0;
  justify-content: center;
}

/* ---------- persistent chrome ---------- */

.chrome {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 22;                      /* the menu button stays above the open menu (21) */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--gutter) * 0.55 + env(safe-area-inset-top, 0px)) var(--gutter) 0;
  pointer-events: none;
}

.chrome > * { pointer-events: auto; }

.chrome__logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: clamp(15px, 1.15vw, 19px);
  font-weight: 500;
  letter-spacing: -0.02em;
  white-space: nowrap;
  opacity: var(--logo, 0);
  transform: translateY(calc((1 - var(--logo, 0)) * -6px));
  visibility: hidden;
}

.chrome__logo.is-on { visibility: visible; }

.chrome__bar {
  width: 1.5px;
  height: 0.95em;
  margin-right: 0.35em;
  background: currentColor;
}

.chrome__dot {
  width: 0.36em;
  height: 0.36em;
  margin-left: 0.1em;
  border-radius: 50%;
  background: var(--ink-dim);
}

.chrome__menu {
  display: inline-grid;
  place-content: center;
  gap: 3px;
  width: clamp(26px, 1.75vw, 32px);
  height: clamp(26px, 1.75vw, 32px);
  border: 1px solid var(--pill-line);
  border-radius: 50%;
  background: var(--pill);
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.chrome__menu span {
  display: block;
  width: 8px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* open: the two bars cross into an X inside a visible ring */
.chrome__menu[aria-expanded="true"] { border-color: rgba(255, 255, 255, 0.16); }
.chrome__menu[aria-expanded="true"] span:first-child { transform: translateY(2.25px) rotate(45deg); }
.chrome__menu[aria-expanded="true"] span:last-child { transform: translateY(-2.25px) rotate(-45deg); }

/* the menu brings its own top bar, so the mini logo steps aside */
.menu-open .chrome__logo { visibility: hidden; }

/* bottom right on every section: the counterpart of the menu button at the top right */
.chrome__members {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) * 0.55 + env(safe-area-inset-bottom, 0px));
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* ---------- hero scroll track ---------- */

.hero {
  position: relative;
  height: 640vh;
  height: 640svh;
}

/* intro layer — scrolls with the page, behind the stage */
.hero__intro {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 1;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  opacity: var(--intro, 1);
}

.topbar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--gutter) * 0.55 + env(safe-area-inset-top, 0px)) calc(var(--gutter) + clamp(34px, 2.6vw, 44px)) 0 var(--gutter);
}

.topbar > :first-child { justify-self: start; }
.topbar > :last-child { justify-self: end; }

.topbar__tag {
  color: var(--ink-faint);
  text-align: center;
}

.pill--solid { color: var(--ink); }

.hero__title {
  position: absolute;
  left: 0;
  right: 0;
  top: 13.5vh;
  top: 13.5svh;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.hero__title-inner {
  display: block;
  font-size: var(--title-size, 15vw);
  font-weight: 500;
  font-stretch: 100%;
  line-height: 0.8;
  letter-spacing: -0.045em;
  color: var(--title);
  white-space: nowrap;
}

.hero__mark {
  display: inline-block;
  font-size: 0.36em;
  font-weight: 400;
  letter-spacing: 0;
  vertical-align: top;
  margin: -0.02em 0.02em 0 0.04em;
  transform: translateY(0.1em);
}

.hero__note {
  position: absolute;
  top: 39.5vh;
  top: 39.5svh;
  color: var(--ink-faint);
  line-height: 1.22;
}

.hero__note em {
  font-style: normal;
  color: var(--ink);
}

.hero__note--a { left: var(--gutter); }
/* right edge held just clear of the knight's shoulder; he is centred and sized by the
   viewport height, so the gap is measured in vh from the middle */
.hero__note--b {
  right: calc(50% + 23vh);
  right: calc(50% + 23svh);
}

/* squarer screens leave no room for both notes left of him: the second moves to the
   right edge, as on phones */
@media (max-aspect-ratio: 7 / 5) {
  .hero__note--b { right: var(--gutter); text-align: right; }
}

/* ---------- sticky stage ---------- */

.stage {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  pointer-events: none;
}

.stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.4s ease;
}

.stage.is-ready .stage__canvas { opacity: 1; }

.stage__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(10, 8, 7, 0.55) 100%);
}


/* ---------- text beats ---------- */

.beat {
  position: absolute;
  top: 45.5%;
  width: max-content;
  max-width: 30vw;
  opacity: var(--v, 0);
  transform: translateY(calc(var(--y, 0) * 1px));
  filter: blur(calc((1 - var(--v, 0)) * 10px));
  visibility: hidden;
  will-change: opacity, transform, filter;
}

.beat.is-on { visibility: visible; }

.beat--right { left: 67%; }
.beat--left { left: 7.2%; }

.beat__index {
  color: var(--ink-faint);
  letter-spacing: 0.3em;
  margin-bottom: 0.9em;
}

.beat__title {
  font-size: clamp(22px, 2.05vw, 40px);
  font-weight: 850;
  font-stretch: 125%;
  line-height: 0.98;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  white-space: nowrap;
}

.beat__copy {
  margin-top: 1.15em;
  max-width: 34ch;
  color: #a39b94;
  font-size: clamp(10.5px, 0.72vw, 13px);
  line-height: 1.45;
}

/* ---------- loader ---------- */

.loader {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 0.9em;
  color: var(--ink-dim);
  transform: translate(-50%, -50%);
  transition: opacity 0.6s ease;
}

.loader__track {
  display: block;
  width: 140px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loader__fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ember);
  transform-origin: left;
  transform: scaleX(var(--load, 0));
}

.loader__pct { color: var(--ink-faint); }

.stage.is-ready .loader { opacity: 0; }

.stage.is-failed .loader__track,
.stage.is-failed .loader__pct { display: none; }

/* ---------- bottom dock ---------- */

.dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--gutter) calc(var(--gutter) * 0.55 + env(safe-area-inset-bottom, 0px));
}

.dock__group {
  display: flex;
  gap: 0.5em;
  font: var(--label);
}

/* ---------- film grain ---------- */

.grain {
  position: fixed;
  inset: -50%;
  z-index: 30;
  pointer-events: none;
  opacity: 0.075;
  background-image: var(--grain);
  background-size: 180px 180px;
  animation: grain 0.9s steps(6) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-6%, 4%); }
  40% { transform: translate(5%, -7%); }
  60% { transform: translate(-3%, 8%); }
  80% { transform: translate(7%, 2%); }
  100% { transform: translate(0, 0); }
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding-right: calc(var(--gutter) + 40px);
  }
  .topbar__tag { display: none; }

  .hero__title { top: 12svh; }

  /* sit just under the wordmark, either side of the knight's head */
  .hero__note { top: calc(12svh + 15vw); }
  .hero__note--b { left: auto; right: var(--gutter); text-align: right; }

  /* legibility scrim for the bottom-anchored beats */
  .stage__vignette {
    background:
      linear-gradient(to top, rgba(14, 12, 11, 0.82) 0%, rgba(14, 12, 11, 0.4) 26%, transparent 46%),
      radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(10, 8, 7, 0.55) 100%);
  }

  .beat,
  .beat--left,
  .beat--right {
    left: var(--gutter);
    right: var(--gutter);
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }
  .beat { max-width: none; }
  .beat__title { font-size: clamp(22px, 7vw, 30px); white-space: normal; }

  .dock {
    grid-template-columns: 1fr auto;
    row-gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .beat { filter: none; }
}
