/* ============================================================
   adapt-ive. 2026
   One journey through the wordmark.
   Order: tokens > base > loader > sky and canvas > chrome > stage
          > stations > hud > menu > cursor > fallback tiers > mobile
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  --bone: #ECE9E2;
  --bone-2: #E3E0D8;
  --mist: #D7DBE1;
  --ink: #121213;
  --ink-2: #3A3A3D;
  --signal: #FF5A1F;

  /* theme tokens, remapped for the dusk finale */
  --t-bg: var(--bone);
  --t-fg: var(--ink);
  --t-fg-2: #67676C;
  --t-line: rgba(18, 18, 19, 0.16);
  --t-fill: rgba(18, 18, 19, 0.06);
  --t-pill-bg: var(--ink);
  --t-pill-fg: var(--bone);
  --halo: rgba(236, 233, 226, 0.78);   /* soft glow behind type, same as the ground it sits on */

  --sans: 'Instrument Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.87, 0, 0.13, 1);

  --gutter: clamp(18px, 2.4vw, 40px);

  --z-sky: 0;
  --z-gl: 1;
  --z-stage: 5;
  --z-hud: 20;
  --z-chrome: 30;
  --z-menu: 60;
  --z-loader: 100;
  --z-cursor: 200;
}

html[data-theme="dark"] {
  --t-bg: #0F1013;
  --t-fg: #ECE9E2;
  --t-fg-2: #9B9BA2;
  --t-line: rgba(236, 233, 226, 0.18);
  --t-fill: rgba(236, 233, 226, 0.08);
  --t-pill-bg: var(--bone);
  --t-pill-fg: var(--ink);
  --halo: rgba(15, 16, 19, 0.62);
}

/* contrast: a block that reads a dark scene behind it goes bone, a light one goes ink */
[data-ink="bone"] {
  --t-fg: var(--bone);
  --t-fg-2: rgba(236, 233, 226, 0.72);
  --t-line: rgba(236, 233, 226, 0.24);
  --halo: rgba(15, 16, 19, 0.62);
}
[data-ink="ink"] {
  --t-fg: var(--ink);
  --t-fg-2: #67676C;
  --t-line: rgba(18, 18, 19, 0.16);
  --halo: rgba(236, 233, 226, 0.78);
}
.station__box, .brand, .nav { color: var(--t-fg); transition: color 0.5s var(--ease); }
.hud > * { color: var(--t-fg-2); transition: color 0.5s var(--ease); }
.st-index, .st-title, .st-line, .st-tags, .st-extra, .hero__tag, .hero__sub,
.nav-link, .menu-btn, .hud {
  text-shadow: 0 0 1px var(--halo), 0 0 10px var(--halo), 0 0 24px var(--halo);
}
.brand svg { filter: drop-shadow(0 0 4px var(--halo)); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: clamp(14px, 1.111vw, 18px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scrollbar-width: none;
}
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-fg);
  font-family: var(--sans);
  line-height: 1.4;
  overflow-x: clip;
  overscroll-behavior: none;
  transition: background-color 0.9s var(--ease), color 0.9s var(--ease);
}

[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
::selection { background: var(--signal); color: #fff; }

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

/* shared type styles */
.label {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.7rem;
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* masked line reveal: .line is the mask, the inner span is what moves */
/* the mask has room for descenders, so g, p, y and J never get cut */
.line { display: block; overflow: hidden; padding-bottom: 0.16em; margin-bottom: -0.16em; }
.line > span { display: block; will-change: transform; }

/* text links: the only kind of button on the site. A word, a hairline. */
.textlink {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0 0 0.35em;
  border: 0;
  background: none;
  color: inherit;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  position: relative;
}
.textlink::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}
.textlink:hover::after { transform: scaleX(0); transform-origin: right; }
.textlink svg { width: 0.75em; height: 0.75em; transition: transform 0.6s var(--ease); }
.textlink:hover svg { transform: translate(2px, -2px); }

/* keyboard focus: a thin ring in the current text colour, only for keyboard users */
a:focus-visible, button:focus-visible {
  outline: 1.5px solid currentColor;
  outline-offset: 5px;
  border-radius: 2px;
}
.menu__item:focus-visible { outline-offset: 8px; }

/* skip link: hidden until it receives keyboard focus */
.skip {
  position: fixed;
  top: var(--gutter);
  left: 50%;
  z-index: 300;
  padding: 0.8rem 1.2rem;
  background: var(--ink);
  color: var(--bone);
  transform: translate(-50%, -300%);
  transition: transform 0.4s var(--ease);
}
.skip:focus { transform: translate(-50%, 0); outline: none; }

/* ---------- 3. Loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  background: var(--bone);
  color: var(--ink);
  display: grid;
  place-items: center;
}
.loader__mark {
  width: min(62vw, 760px);
  transform-origin: center;
}
.loader__mark svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.loader__mark path {
  fill: var(--ink);
  fill-opacity: 0;
  stroke: var(--ink);
  stroke-width: 0.55;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.loader__meta {
  position: absolute;
  left: 50%;
  top: calc(50% + min(9vw, 110px));
  transform: translateX(-50%);
  text-align: center;
  width: max-content;
}
.loader__count {
  color: var(--t-fg-2);
  font-variant-numeric: tabular-nums;
}
.loader__line {
  margin: 0.9rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(10px);
}
.loader__enter {
  margin-top: 1.6rem;
  opacity: 0;
  visibility: hidden;
}
.loader__bar {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  height: 1px;
  background: var(--t-line);
}
.loader__bar i {
  display: block;
  height: 100%;
  background: var(--ink);
  transform-origin: left;
  transform: scaleX(0);
}
.loader__corner {
  position: absolute;
  bottom: calc(var(--gutter) + 0.9rem);
  color: var(--t-fg-2);
}
.loader__corner--l { left: var(--gutter); }
.loader__corner--r { right: var(--gutter); text-align: right; }

/* ---------- 4. Sky and canvas ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: var(--z-sky);
  background: linear-gradient(180deg, var(--bone) 0%, var(--mist) 58%, var(--bone-2) 100%);
  transition: opacity 0.9s var(--ease);
}
html[data-theme="dark"] .sky { background: #0F1013; }

#gl {
  position: fixed;
  inset: 0;
  z-index: var(--z-gl);
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
}

/* film grain over everything below the chrome */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(3) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-4%, 3%); }
  66% { transform: translate(3%, -5%); }
  100% { transform: translate(0, 0); }
}

@media (min-width: 992px) { .grain { display: none; } }

/* ---------- 5. Chrome (fixed header) ---------- */
.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-chrome);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--gutter) * 0.85) var(--gutter);
  pointer-events: none;
  color: var(--t-fg);
  transition: color 0.9s var(--ease);
}
.chrome > * { pointer-events: auto; }
body.menu-open .chrome { color: var(--bone); }

.brand {
  display: block;
  width: 7rem;
  color: inherit;
}
.brand svg {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-link {
  position: relative;
  display: block;
  padding: 0.55rem 0.8rem;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  line-height: 1;
  overflow: hidden;
}
.nav-link .roll {
  display: block;
  position: relative;
  height: 1em;
  overflow: hidden;
}
.nav-link .roll span {
  display: block;
  height: 1em;
  transition: transform 0.6s var(--ease);
}
.nav-link .roll span:last-child {
  position: absolute;
  top: 100%;
  left: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.12em;
  line-height: 0.9;
}
.nav-link:hover .roll span { transform: translateY(-100%); }
.nav-link.is-current .roll span:first-child { text-decoration: underline; text-underline-offset: 0.3em; text-decoration-thickness: 1px; }

.menu-btn {
  margin-left: 1rem;
  padding: 0.55rem 0 0.55rem 0.8rem;
  border: 0;
  background: none;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  position: relative;
}
.menu-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 0.9em;
  transform: translateY(-50%);
  background: var(--t-line);
}
.menu-btn .roll { display: block; position: relative; height: 1em; overflow: hidden; }
.menu-btn .roll span { display: block; height: 1em; transition: transform 0.6s var(--ease-io); }
.menu-btn .roll span:last-child { position: absolute; top: 100%; left: 0; }
.menu-btn[aria-expanded="true"] .roll span { transform: translateY(-100%); }

/* ---------- 6. Stage and stations ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: var(--z-stage);
  pointer-events: none;
}
.station {
  position: absolute;
  inset: 0;
  padding: calc(var(--gutter) * 3.4) var(--gutter) calc(var(--gutter) * 3.6);
  display: flex;
  flex-direction: column;
  visibility: hidden;
}
.station.is-active { visibility: visible; }
.station__box {
  max-width: 31rem;
  pointer-events: auto;
}
.station[data-pos="tl"] { justify-content: flex-start; align-items: flex-start; }
.station[data-pos="tr"] { justify-content: flex-start; align-items: flex-end; text-align: right; }
.station[data-pos="bl"] { justify-content: flex-end; align-items: flex-start; }
.station[data-pos="br"] { justify-content: flex-end; align-items: flex-end; text-align: right; }
.station[data-pos="cl"] { justify-content: center; align-items: flex-start; }
.station[data-pos="cr"] { justify-content: center; align-items: flex-end; text-align: right; }
.st-index {
  margin: 0 0 1.1rem;
  color: var(--t-fg-2);
  font-variant-numeric: tabular-nums;
}
.st-index b { color: var(--t-fg); font-weight: 600; }
.st-title {
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(2.6rem, 4.6vw, 4.8rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}
.st-title .alt {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
}
.st-line {
  margin: 1.2rem 0 0;
  max-width: 25rem;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.42rem;
  line-height: 1.22;
}
.station[data-pos="tr"] .st-line,
.station[data-pos="br"] .st-line,
.station[data-pos="cr"] .st-line { margin-left: auto; }
.st-tags {
  margin: 1.6rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--t-line);
  color: var(--t-fg-2);
  max-width: 25rem;
}
.st-tags i, .st-index i { font-style: normal; margin: 0 0.45em; opacity: 0.45; }
.station[data-pos="tr"] .st-tags,
.station[data-pos="br"] .st-tags,
.station[data-pos="cr"] .st-tags { margin-left: auto; }
.st-extra { margin: 1.7rem 0 0; }
.st-extra + .st-extra { margin-top: 1rem; }

/* hero station */
.hero__eyebrow { color: var(--t-fg-2); margin: 0 0 1rem; }
.hero__tag {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.5rem, 2.3vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.hero__sub { margin: 0.9rem 0 0; color: var(--t-fg-2); }
.hero-fallback {
  display: none;
  width: min(84vw, 980px);
  margin: 0 auto 3rem;
  color: var(--ink);
}
.hero-fallback svg { width: 100%; height: auto; fill: currentColor; display: block; }

/* contact station */
.contact__mail {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(1.1rem, 1.8vw, 1.6rem);
  letter-spacing: -0.02em;
  line-height: 1;
  padding-bottom: 0.25em;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 100% 1px;
  transition: background-size 0.6s var(--ease);
}
.contact__mail:hover { background-size: 0 1px; background-position: 100% 100%; }
.contact__links {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  color: var(--t-fg-2);
}
.contact__links a { position: relative; }
.contact__links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -0.25em;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease);
}
.contact__links a:hover::after { transform: scaleX(1); transform-origin: left; }

/* invisible scroll track that gives the page its length */
.track { position: relative; height: calc(100vh * 12.7); pointer-events: none; }

/* ---------- 7. HUD (fixed bottom strip) ---------- */
.hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-hud);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: var(--gutter);
  pointer-events: none;
  color: var(--t-fg-2);
  transition: color 0.9s var(--ease);
}
.hud > * { pointer-events: auto; }
.hud__counter { display: flex; align-items: baseline; gap: 0.7rem; font-variant-numeric: tabular-nums; }
.hud__counter b { color: var(--t-fg); font-weight: 600; }
.hud__name { color: var(--t-fg); display: inline-block; min-width: 5em; }
.hud__center { text-align: center; }
.hud__progress {
  width: 10rem;
  height: 1px;
  margin: 0 auto 0.8rem;
  background: var(--t-line);
  overflow: hidden;
}
.hud__progress i {
  display: block;
  height: 100%;
  background: var(--t-fg);
  transform-origin: left;
  transform: scaleX(0);
}
.hud__hint { white-space: nowrap; }
.hud__right { text-align: right; }
.hud__right span { display: block; }
.hud__clock { color: var(--t-fg); font-variant-numeric: tabular-nums; }

/* ---------- 8. Menu overlay ---------- */
.menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-menu);
  visibility: hidden;
  pointer-events: none;
}
.menu.is-open { visibility: visible; pointer-events: auto; }
.menu__bg {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: translateX(100%);
}
.menu__inner {
  position: absolute;
  inset: 0;
  padding: calc(var(--gutter) * 3.4) var(--gutter) var(--gutter);
  color: var(--bone);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  column-gap: 6vw;
  row-gap: 0.2rem;
}
.menu__item {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-weight: 600;
  font-size: clamp(1.9rem, 3.9vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  opacity: 0;
  transform: translateY(24px);
}
.menu__item i {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 0.42em;
  letter-spacing: 0;
  min-width: 1.9em;
  color: rgba(236, 233, 226, 0.5);
  transition: color 0.4s var(--ease);
}
.menu__item .roll { display: block; position: relative; height: 1em; overflow: hidden; }
.menu__item .roll span { display: block; height: 1em; transition: transform 0.6s var(--ease); }
.menu__item .roll span:last-child {
  position: absolute; top: 100%; left: 0;
  font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em;
}
.menu__item:hover .roll span { transform: translateY(-100%); }
.menu__item:hover i { color: var(--signal); }
.menu__foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  color: rgba(236, 233, 226, 0.6);
  opacity: 0;
}
.menu__foot a { color: var(--bone); }

/* ---------- 9. Cursor (desktop only) ---------- */
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-cursor);
  pointer-events: none;
  mix-blend-mode: difference;
  color: #fff;
  will-change: transform;
}
.cursor__ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid #fff;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}
.cursor__dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.32rem;
  height: 0.32rem;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.cursor__hold {
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
}
.cursor__label {
  position: absolute;
  left: 1.6rem;
  top: -0.45rem;
  white-space: nowrap;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0;
}
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
body.is-dragging, body.is-dragging * { user-select: none; -webkit-user-select: none; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- 10. Fallback tiers ----------
   .static      = JavaScript decided the 3D world cannot run (no WebGL,
                  reduced motion, library failed). Everything stacks.
   .loader-timeout = the 7 second failsafe fired before scripts booted.
   :not(.js)    = no JavaScript at all.
------------------------------------------------ */
html:not(.js) .loader,
html.static .loader,
html.loader-timeout .loader { display: none; }

html:not(.js) #gl, html.static #gl, html.loader-timeout #gl,
html:not(.js) .track, html.static .track, html.loader-timeout .track,
html:not(.js) .cursor, html.static .cursor, html.loader-timeout .cursor,
html:not(.js) .hud__center, html.static .hud__center, html.loader-timeout .hud__center { display: none; }

html:not(.js) .stage, html.static .stage, html.loader-timeout .stage {
  position: relative;
  inset: auto;
  pointer-events: auto;
}
html:not(.js) .station, html.static .station, html.loader-timeout .station {
  position: relative;
  inset: auto;
  min-height: 100vh;
  visibility: visible;
  border-top: 1px solid var(--t-line);
}
html:not(.js) .station:first-child, html.static .station:first-child, html.loader-timeout .station:first-child { border-top: 0; }
html:not(.js) .hero-fallback, html.static .hero-fallback, html.loader-timeout .hero-fallback { display: block; }
html:not(.js) .hud, html.static .hud, html.loader-timeout .hud {
  position: relative;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--t-line);
}
html:not(.js) .line > span, html.loader-timeout .line > span { transform: none !important; }

html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after {
  animation-duration: 0.01s !important;
  transition-duration: 0.01s !important;
}

/* ---------- 11. Mobile ---------- */
@media (max-width: 991px) {
  html { font-size: 14px; }
  .brand { width: 5.6rem; }
  .nav .nav-link { display: none; }
  .menu-btn { margin-left: 0; padding-left: 0; }
  .menu-btn::before { display: none; }
  .station { padding: calc(var(--gutter) * 4.2) var(--gutter) calc(var(--gutter) * 5.2); }
  .station__box { max-width: 100%; }
  .station[data-pos] { justify-content: flex-end; align-items: flex-start; text-align: left; }
  .station[data-pos] .st-line { margin-left: 0; }
  .station[data-pos] .st-tags { margin-left: 0; }
  .st-title { font-size: 2.3rem; }
  .st-line { font-size: 1.12rem; max-width: 22rem; }
  .st-tags li { font-size: 0.6rem; padding: 0.5rem 0.7rem; }
  .hero__tag { font-size: 1.45rem; }
  .hud { grid-template-columns: 1fr auto; row-gap: 0.6rem; }
  .hud__center { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .hud__progress { margin: 0 0 0.6rem; width: 100%; }
  .hud__hint { display: none; }
  .hud__right span:first-child { display: none; }
  .menu__list { grid-template-columns: 1fr; }
  .menu__item { font-size: 1.9rem; }
  .menu__foot { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .loader__mark { width: 78vw; }
  .loader__line { font-size: 1.1rem; }
  .loader__corner { display: none; }
}
@media (max-width: 991px) and (orientation: landscape) and (max-height: 480px) {
  .station { padding-top: calc(var(--gutter) * 3); padding-bottom: calc(var(--gutter) * 3.4); }
  .st-title { font-size: 1.9rem; }
}
