/* ============================================================
   ALLOY CINEMATIC v2 — 5-act captive scroll framework
   Owner: SA-3 (GSAP Captive Scroll Framework)
   ------------------------------------------------------------
   Token source of truth: site/design-system.html :root
   Visibility rule: CSS defaults VISIBLE. GSAP only enhances.
   If JS fails or motion is reduced, all content stays reachable.
   ------------------------------------------------------------
   Discord components (SA-2/SA-4), SOP copy (SA-5), Agent Studio
   (SA-6) and investor toggle (SA-7) live in their own files.
   This file owns ONLY: act layout, captive sizing, palette,
   progress bar, header, footer, reveal helpers, mobile snap.
   ============================================================ */

/* ---- TOKENS (duplicated from design-system.html for standalone load) ---- */
:root {
  --bg:           #f5f0e8;
  --surface:      #e8e0d4;
  --fg:           #1c1917;
  --fg-alt:       #292524;
  --muted:        #5a4e44;
  --border:       #d4c9bc;
  --accent:       #c17f59;   /* ochre — progress bar, labels */
  --accent-gold:  #b8860b;   /* CTA highlights */
  --walnut:       #5c4a3a;   /* secondary emphasis */
  --accent-hover: #b5734d;

  --glass-bg:     rgba(245, 240, 232, 0.78);
  --glass-border: rgba(92, 74, 58, 0.15);
  --glass-blur:   blur(18px) saturate(140%);

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-glass: 20px 18px 22px 17px;
  --radius-pill:  100px;

  --spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* framework metrics */
  --progress-h:  4px;
  --header-h:    62px;
  --act-pad:     clamp(1.25rem, 5vw, 4rem);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Paper-grain overlay (matches landing texture, non-interactive) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }

/* ============================================================
   PIPELINE PROGRESS BAR (#pipeline-progress)
   Fixed top, above everything. Fill width + active act tick
   are driven by site/js/cinematic-v2.js. Defaults: full track
   visible, fill at 0 (still valid without JS).
   ============================================================ */
.pipeline-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--progress-h);
  z-index: 200;
  background: color-mix(in srgb, var(--walnut) 14%, transparent);
  pointer-events: none;
}

.pipeline-progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-gold));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: width 0.08s linear;
}

.pipeline-progress__ticks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.pipeline-progress__tick {
  position: relative;
  border-left: 1px solid color-mix(in srgb, var(--walnut) 28%, transparent);
}
.pipeline-progress__tick:first-child { border-left: 0; }

/* Act label dot that floats just under each tick boundary */
.pipeline-progress__tick::after {
  content: attr(data-label);
  position: absolute;
  top: calc(var(--progress-h) + 4px);
  left: 8px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--walnut) 55%, transparent);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
  white-space: nowrap;
}
.pipeline-progress__tick.is-active::after {
  opacity: 1;
  transform: translateY(0);
  color: var(--accent);
}

/* ============================================================
   MINIMAL HEADER
   Alloy logo · Investors link (sets sessionStorage.investorMode)
   · Talk to Grunt CTA. SA-7 owns investor toggle behaviour.
   ============================================================ */
.cine-header {
  position: fixed;
  top: var(--progress-h);
  left: 0;
  width: 100%;
  height: var(--header-h);
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--act-pad);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid color-mix(in srgb, var(--walnut) 10%, transparent);
  transition: background 0.3s ease, border-color 0.3s ease;
}
.cine-header.is-condensed {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom-color: color-mix(in srgb, var(--walnut) 18%, transparent);
}

.cine-logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg);
}
.cine-logo span { color: var(--accent); }

.cine-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.6rem);
}

.cine-nav__link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
.cine-nav__link:hover { color: var(--accent); }

.cine-nav__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--accent);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: background 0.2s ease, transform 0.2s var(--spring);
}
.cine-nav__cta:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* ============================================================
   ACT LAYOUT + CAPTIVE SECTION SIZING
   Each <section data-act> is the ScrollTrigger trigger.
   .act-stage is the pinned 100vh viewport that holds parallax
   layers. Default (no JS): stages stack and scroll normally.
   ============================================================ */
.cine-main { position: relative; z-index: 2; }

.act {
  position: relative;
  width: 100%;
}

.act-stage {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--progress-h) + var(--header-h) + 2rem) var(--act-pad) 3rem;
  overflow: hidden;
}

/* Act tonal variants */
.act--discord  { background: var(--fg); color: color-mix(in srgb, var(--bg) 92%, transparent); }
.act--pipeline { background: var(--bg); }
.act--sop      { background: var(--bg); }
.act--studio   { background: var(--surface); }
.act--cta      { background: var(--fg); color: color-mix(in srgb, var(--bg) 92%, transparent); }

/* Parallax layers — labelled so JS can scrub them. Visible by default. */
.act-layer {
  position: relative;
  width: 100%;
  will-change: transform;
}
.act-layer--bg   { z-index: 1; }
.act-layer--mid  { z-index: 2; }
.act-layer--fore { z-index: 3; }

.act-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.act-headline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 18ch;
}
.act-headline em { font-style: italic; font-weight: 400; color: var(--accent); }

.act-lead {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  color: var(--muted);
  max-width: 56ch;
  margin-top: 1.2rem;
  line-height: 1.65;
}
.act--discord .act-lead,
.act--cta .act-lead { color: color-mix(in srgb, var(--bg) 62%, transparent); }

/* Generic mount node — neutral container that other agents fill.
   Shows a faint dashed placeholder ONLY while empty (:empty). */
.mount {
  position: relative;
  width: 100%;
}
.mount:empty {
  min-height: 120px;
  border: 1px dashed color-mix(in srgb, var(--walnut) 28%, transparent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mount:empty::after {
  content: attr(data-mount-label);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--walnut) 55%, transparent);
  text-transform: uppercase;
}

/* ============================================================
   ACT 3 — SOP CORE (7 grouped sub-blocks)
   One captive act; SA-5 fills each data-act-3-section block.
   Sub-blocks are full-height beats inside the act stage.
   ============================================================ */
.act3-track {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 6vh, 5rem);
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.sop-block {
  position: relative;
  width: 100%;
  scroll-margin-top: calc(var(--progress-h) + var(--header-h));
}

.sop-block__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-block;
  margin-bottom: 0.75rem;
}

/* ============================================================
   REVEAL HELPERS
   Default = visible. JS adds .cine-anim to opt elements INTO the
   hidden-then-reveal treatment, then .is-visible to show them.
   Without JS (or this class), nothing is hidden.
   ============================================================ */
.reveal { opacity: 1; transform: none; }

.cine-anim .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.cine-anim .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   FOOTER
   ============================================================ */
.cine-footer {
  position: relative;
  z-index: 2;
  background: var(--fg-alt);
  color: color-mix(in srgb, var(--bg) 55%, transparent);
  padding: 2.5rem var(--act-pad);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
}
.cine-footer__brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: color-mix(in srgb, var(--bg) 78%, transparent);
}
.cine-footer__links { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.cine-footer__links a { color: color-mix(in srgb, var(--bg) 48%, transparent); text-decoration: none; transition: color 0.2s ease; }
.cine-footer__links a:hover { color: var(--accent); }
.cine-footer__legal { width: 100%; border-top: 1px solid color-mix(in srgb, var(--bg) 8%, transparent); padding-top: 1rem; font-size: 0.7rem; color: color-mix(in srgb, var(--bg) 32%, transparent); }

/* ============================================================
   MOBILE (<= 768px) — CSS scroll-snap, NO pins, NO transforms.
   Acts become natural-height snap points; tall acts (Act 3)
   scroll through freely. Proximity snap = never traps content.
   ============================================================ */
@media (max-width: 768px) {
  html { scroll-snap-type: y proximity; scroll-padding-top: calc(var(--progress-h) + var(--header-h)); }

  .act { scroll-snap-align: start; scroll-snap-stop: normal; }

  .act-stage {
    min-height: auto;
    padding: calc(var(--progress-h) + var(--header-h) + 1.5rem) 1.25rem 2.5rem;
    display: block;
    overflow: visible;
  }

  /* Neutralise any inline transforms GSAP may have set before
     detecting mobile; mobile path never pins or parallaxes. */
  .act-layer { transform: none !important; }

  .cine-nav__link { display: none; }
  .act3-track { gap: 2.25rem; }
}

/* ============================================================
   REDUCED MOTION — everything visible, no transforms, no pins.
   JS also early-returns, but CSS guarantees the safe state.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .act-stage { min-height: auto; overflow: visible; }
  .act-layer { transform: none !important; will-change: auto; }

  .cine-anim .reveal,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .pipeline-progress__fill { transition: none; }
}
