/* =========================================================================
   Fluks RV — Sajam 2026 landing
   Reference: graysunderland.com (see docs/REFERENCE_ANALYSIS.md)
   ========================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* Neutrals (reference: paper #e7e7e5 / ink #0a0a0a — client asked for e3e3e3 / 0a0a0a) */
  --paper:   #e3e3e3;
  --paper-2: #ececeb;   /* lifted surface */
  --paper-3: #d6d6d5;   /* sunken surface */
  --white:   #f6f6f5;   /* logo disc */
  --ink:     #0a0a0a;
  --ink-2:   #161618;   /* sidebar body, a hair off pure ink */
  --ink-soft: color-mix(in oklab, var(--ink) 62%, var(--paper));
  --line:    #0a0a0a29;

  /* Royal blue palette — anchors: #031273 (deep) and #4CC9F0 (sky) */
  --royal-950: #020a4d;
  --royal-900: #031273;  /* ANCHOR */
  --royal-800: #0a1f9e;
  --royal-700: #1736c9;
  --royal-600: #2f50e6;
  --royal-500: #4361ee;
  --royal-400: #4895ef;
  --royal-300: #4cc9f0;  /* ANCHOR */
  --royal-100: #d8f3fc;

  --signal: var(--royal-900);   /* rail dot + active tick */

  /* Layout grid (mirrors reference: 12 cols, 2.5vw margin, 1.25vw gutter) */
  --m: 2.5vw;
  --g: 1.25vw;
  --band: 70svh;
  --ph: calc(var(--band) * .63);
  --col: calc((100vw - 2 * var(--m) - 11 * var(--g)) / 12);
  --unit: calc(var(--col) + var(--g));
  --span: calc(var(--m) + var(--unit));

  /* Sidebar (flush full-bleed left header) */
  --side-inset: 0px;
  --side-w: clamp(220px, 19.8vw, 390px);
  --side-r: 0px;
  --rail-b: calc(var(--m) * .8);
  --rail-h: 1em;

  /* Type scale (reference) */
  --t-l: min(9.2vw, 16.5svh);
  --t-m: min(4.6vw, 8.2svh);
  --fs-m: clamp(15px, min(1.22vw, max(21px, 2.17svh)), 28px);
  --fs-s: clamp(13px, min(.92vw, max(15px, 1.64svh)), 20px);

  /* Easing (reference) */
  --ease-out:  cubic-bezier(.165, .84, .44, 1);
  --ease-io:   cubic-bezier(.645, .045, .355, 1);
  --ease-wipe: cubic-bezier(.77, 0, .175, 1);

  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  font-size: var(--fs-s);
  line-height: 1.32;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); overflow: hidden; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; margin: 0; }
a { color: inherit; }
.nw { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 2. Sidebar ---------- */
.sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--side-w);
  background: var(--ink-2);
  border-radius: 0;
  box-shadow:
    14px 0 32px -12px #0a0a0a38,
    0 30px 60px -30px #0a0a0a66;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: calc(var(--side-w) * .18);
  transition: opacity .9s var(--ease-out), translate .9s var(--ease-out);
}

.side-logo {
  width: 63%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  display: grid;
  place-items: center;
  text-decoration: none;
}
.side-logo-mark {
  width: 92%;
  height: auto;
  display: block;
  transform: translateY(1.2%);
}
.side-logo:focus-visible { outline: 2px solid var(--royal-300); outline-offset: 5px; }

/* intro (mirrors reference .is-loading → .is-arrived) */
.is-loading:not(.is-arrived) .sidebar { opacity: 0; translate: -1.2em 0; }
.is-loading:not(.is-arrived) .rail { opacity: 0; translate: 0 .6em; }

/* ---------- 3. Rail + period dot ---------- */
.rail {
  position: fixed;
  z-index: 50;
  left: var(--m);
  right: var(--m);
  bottom: var(--rail-b);
  height: var(--rail-h);
  pointer-events: none;
  transition: opacity .9s var(--ease-out), translate .9s var(--ease-out);
}
/* Line flips colour: light over the black sidebar, dark over the paper background */
.rail-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    #ffffff45 0,
    #ffffff45 calc(var(--side-w) - var(--m)),
    var(--line) calc(var(--side-w) - var(--m)),
    var(--line) 100%
  );
}
.rail-tick {
  position: absolute; top: -2px;
  width: 1px; height: 5px;
  background: var(--line);
  transition: background-color .4s var(--ease-out), height .4s var(--ease-out), top .4s var(--ease-out);
}
.rail-tick.is-on { background: var(--signal); height: 9px; top: -4px; }
.rail-tick.on-header { background: #ffffff45; }
.rail-tick.on-header.is-on { background: var(--white); }
/* ticks live inside .rail-line (1px tall), so top offsets centre them on the line */

.period {
  position: fixed; z-index: 60; top: 0; left: 0;
  width: var(--ps, 10px); height: var(--ps, 10px);
  margin: calc(var(--ps, 10px) / -2) 0 0 calc(var(--ps, 10px) / -2);
  border-radius: 50%;
  background: var(--signal);
  pointer-events: none;
  will-change: transform;
  opacity: 0;
  transition: opacity .3s var(--ease-out), background-color .2s var(--ease-out);
}
.period.on-header { background: var(--white); }
.is-ready .period { opacity: 1; }

/* ---------- 4. Horizontal reel ---------- */
.reel {
  position: fixed; inset: 0; z-index: 3;
  overflow: auto hidden;
  overscroll-behavior: none;
  scrollbar-width: none;
  outline: none;
}
/* Subtle fade zone where Layer 2 content glides beneath the fixed sidebar */
.reel::before {
  content: "";
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  bottom: calc(var(--rail-b) + var(--rail-h));
  width: calc(var(--side-inset) + var(--side-w) + var(--m));
  background: linear-gradient(
    90deg,
    var(--paper) 0%,
    var(--paper) calc(var(--side-inset) + var(--side-w)),
    color-mix(in oklab, var(--paper) 82%, transparent) calc(var(--side-inset) + var(--side-w) + var(--m) * .3),
    color-mix(in oklab, var(--paper) 35%, transparent) calc(var(--side-inset) + var(--side-w) + var(--m) * .68),
    transparent 100%
  );
  pointer-events: none;
}
.reel::-webkit-scrollbar { display: none; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }

.track {
  position: relative;
  display: flex;
  width: max-content;
  height: 100svh;
  padding-left: calc(var(--side-inset) + var(--side-w) + var(--m));
}
.panel { flex: none; height: 100%; position: relative; }

/* Hero (temporary — real hero is Phase 3) */
.panel--hero {
  width: calc(100vw - var(--side-inset) - var(--side-w) - var(--m));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14em, 20vw);
  column-gap: calc(var(--g) * 4);
  align-content: end;
  padding-right: var(--m);
  padding-bottom: calc(var(--rail-b) + var(--rail-h) + 12svh);
}
.hero-title {
  font-size: min(5vw, 10.6svh);
  font-weight: 800;
  line-height: .94;
  letter-spacing: -.055em;
  align-self: end;
}
.hero-dot {
  display: inline-block;
  width: .17em; height: .17em;
  margin-left: .04em;
  border-radius: 50%;
  background: var(--royal-900);
}
.hero-body {
  font-size: var(--fs-m);
  line-height: 1.28;
  letter-spacing: -.01em;
  align-self: end;
  padding-bottom: .35em;
  max-width: 19em;
}

/* Section: Set (reference .set layout — title top-left, text bottom-left, image plate right) */
.set {
  display: flex;
  align-items: center;
  gap: calc(var(--col) * .65);
  margin-left: calc(var(--m) * 1.5);
  padding: 0 var(--m) 0 0;
}
.set-head {
  width: calc(3 * var(--col) + 2 * var(--g));
  height: var(--ph);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: none;
}
.set-title {
  font-size: min(2.75vw, 5.2svh);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: .98;
  margin-top: -.12em;
}
.set-meta {
  display: grid;
  gap: 1.4em;
  margin-bottom: -.25em;
}
.set-line {
  font-size: var(--fs-m);
  letter-spacing: -.01em;
  font-weight: 400;
  line-height: 1.28;
}
.plates {
  display: flex;
  align-items: center;
  gap: var(--m);
  height: var(--ph);
}
.plate {
  height: var(--ph);
  aspect-ratio: var(--ar, 16/9);
  flex: none;
  position: relative;
  margin: 0;
}
.swing {
  position: absolute;
  inset: 0;
  transform-origin: 50%;
  will-change: transform;
}
.develop {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  filter: grayscale(calc(1 - var(--p, 0))) contrast(calc(1 + (1 - var(--p, 0)) * .15));
  transition: opacity .4s;
}
.plate-box {
  background:
    radial-gradient(120% 100% at 80% 20%, color-mix(in oklab, var(--royal-300) 28%, transparent), transparent 65%),
    linear-gradient(135deg, color-mix(in oklab, var(--royal-900) 14%, var(--paper)), color-mix(in oklab, var(--ink) 8%, var(--paper)));
  border: 2px solid var(--ink);
  border-radius: var(--side-r);
  display: grid;
  place-items: center;
}
.plate-label {
  font-size: var(--fs-s);
  color: var(--royal-900);
  font-weight: 500;
  letter-spacing: -.01em;
}

/* Split-line reveal animation (exact reference .split / .line-mask / .line) */
.split .line-mask {
  display: block;
  overflow: clip;
  overflow-clip-margin: .14em;
  padding-bottom: .04em;
}
.split .line {
  display: block;
  transform-origin: 0 100%;
  transition: translate 1.1s var(--ease-out), rotate 1.1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}
html.reveal .set-head:not(.is-in) .split .line {
  translate: 0 125%;
  rotate: 4deg;
}
.set-meta .split .line {
  transition-delay: calc(.14s + var(--i, 0) * 70ms);
}
.is-rearm .split .line {
  transition: none !important;
}

/* Placeholders */
.panel--ph {
  width: 72vw;
  margin-left: var(--m);
  display: grid;
  place-items: center;
}
.panel--ph::before {
  content: "";
  position: absolute;
  inset: 18svh 0 18svh 0;
  border: 1px dashed var(--line);
  border-radius: var(--side-r);
}
.ph-label { font-size: var(--t-m); font-weight: 600; letter-spacing: -.04em; color: var(--ink-soft); }
.panel--ph:last-child { margin-right: var(--m); }

/* ---------- 5. Mobile / portrait fallback (reference breakpoint) ----------
   Horizontal mode only when: min-width 900 AND landscape AND min-height 520 */
@media (max-width: 899px), (max-aspect-ratio: 999/1000), (max-height: 519px) {
  :root { --m: 5vw; --g: 4vw; --side-inset: 0px; --side-r: 0px; }
  body { height: auto; overflow: clip visible; }
  .reel { position: relative; overflow: visible; }
  .track { display: block; width: auto; height: auto; padding: 0; }
  .panel { height: auto; }

  /* sidebar becomes a top bar */
  .sidebar {
    inset: 0 0 auto 0;
    width: auto; height: 64px;
    flex-direction: row;
    padding: 0 var(--m);
    border-radius: 0;
  }
  .side-logo { width: 46px; }
  .rail, .period, .reel::before { display: none; }

  .panel--hero {
    width: auto;
    min-height: 100svh;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6svh;
    padding: calc(64px + 14svh) var(--m) 10svh;
  }
  .hero-title { font-size: min(10vw, 15svh); }
  .set { display: block; padding: 12svh var(--m) 6svh; }
  .set-head { width: auto; height: auto; margin-bottom: 5svh; gap: 3svh; }
  .set-title { font-size: min(8.5vw, 12svh); margin-top: 0; }
  .plates { height: auto; flex-direction: column; align-items: stretch; }
  .plate { width: 100%; height: auto; }
  .panel--ph { width: auto; margin: 0 var(--m) 6svh; min-height: 60svh; }
  .panel--ph::before { inset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; animation: none !important; }
