/* ============================================================
   GUELPH DRY BEAN — CINEMATIC SCROLL
   Adapted from the Golestan v2 build journal blueprint.
   Palette: pure black / Guelph crimson / antique gold / cream
   ============================================================ */

:root {
  --bg:        #000000;
  --bg-soft:   #0a0a0a;
  --crimson:   #8a0a0a;     /* deep dark crimson, in the spirit of Guelph red */
  --crimson-2: #4a0606;
  --gold:      #c9a961;     /* antique gold from the brand journal */
  --gold-soft: #a8893f;
  --cream:     #f5f1e8;
  --cream-dim: rgba(245, 241, 232, 0.65);
  --rule:      rgba(201, 169, 97, 0.35);

  --font-display: 'Cormorant Garamond', 'Garamond', serif;
  --font-body:    'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --easing: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html { scroll-behavior: smooth; }

body { overflow-x: hidden; }

img { max-width: 100%; display: block; }

a {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.3s var(--easing);
}
a:hover { color: var(--cream); }

/* Subtle film-grain on top of everything (PDF: ~4% opacity grain overlay) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/></svg>");
}

/* ============================================================
   NAVBAR — fixed, mix-blend-difference (PDF spec)
   ============================================================ */
.cine-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  mix-blend-mode: difference;
  color: var(--cream);
  transition: backdrop-filter 0.4s var(--easing), background 0.4s var(--easing);
}
.cine-nav.scrolled {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  mix-blend-mode: normal;
}
.cine-nav__brand {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.cine-nav__brand .accent { color: var(--gold); }
.cine-nav__menu {
  display: flex;
  gap: 1.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.cine-nav__menu a { color: inherit; opacity: 0.85; }
.cine-nav__menu a:hover { opacity: 1; color: var(--gold); }

@media (max-width: 720px) {
  .cine-nav { padding: 0.9rem 1.1rem; }
  .cine-nav__menu { display: none; }
}

/* ============================================================
   HERO — full-bleed cinematic stage with sticky scrubbing
   The .stage is sticky inside a tall .reel so scroll progress
   maps to the timeline (scroll = seek bar).
   ============================================================ */
.reel {
  position: relative;
  height: 600vh; /* total scroll length of the cinematic */
}
/* Use small-vh on mobile so iOS browser-chrome doesn't clip the stage. */
@supports (height: 100svh) {
  .stage { height: 100svh; }
}
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #0a0808 0%, #000 70%);
}

/* Vignette around hero (PDF spec) */
.stage::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
  z-index: 30;
}

/* Each scene layer sits centered, scaled and faded by JS via vars */
.scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: var(--scene-opacity, 0);
  transform: scale(var(--scene-scale, 1)) translate3d(0,0,0);
  transition: none; /* JS-driven, no CSS easing fight */
  will-change: transform, opacity;
}
.scene svg { width: min(92vw, 1200px); height: auto; max-height: 92vh; }

/* ============================================================
   HERO VIDEO — full-bleed, scroll-scrubbed
   PDF Ch.05: muted + playsinline + preload="auto" + explicit
   video.load() before seek so iOS Safari plays nice.
   ============================================================ */
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* `contain` — never crop. The full 16:9 frame is visible on every
     viewport; thin letterbox bars (top/bottom on wide screens, sides on
     narrow) blend with the dark vignette so you don't notice them. */
  object-fit: contain;
  object-position: center center;
  z-index: 5;
  pointer-events: none;
  background: #000;
}

/* Tiny radial mask in the bottom-right corner that hides the AI watermark
   sparkle. Tuned to the 1280x720 video — covers ~5% of the frame and
   blends with the existing vignette so it's invisible. */
.hero-watermark-mask {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12vmin;
  height: 12vmin;
  max-width: 140px;
  max-height: 140px;
  z-index: 8;
  background: radial-gradient(circle at 100% 100%,
              #000 0%,
              #000 45%,
              rgba(0,0,0,0.85) 65%,
              rgba(0,0,0,0) 100%);
  pointer-events: none;
}

/* ============================================================
   CAPTION TRACK — 5 timed captions, fade in/out by JS
   ============================================================ */
.caption-track {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
}
.scene-caption {
  position: absolute;
  left: 50%;
  bottom: 9vh;
  transform: translateX(-50%);
  text-align: center;
  width: min(90vw, 720px);
  opacity: var(--cap-opacity, 0);
  transition: opacity 0.55s var(--easing);
}
.scene-caption .eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.scene-caption .headline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  line-height: 1.18;
  color: var(--cream);
  margin: 0;
  text-shadow: 0 2px 24px rgba(0,0,0,0.85);
}
.scene-caption .sub {
  margin-top: 0.55rem;
  font-size: 0.85rem;
  color: var(--cream-dim);
  text-shadow: 0 2px 12px rgba(0,0,0,0.85);
}

/* Caption strap that floats over the stage */
.scene__caption {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  transform: translateX(-50%);
  text-align: center;
  z-index: 40;
  opacity: var(--cap-opacity, 0);
  transition: opacity 0.6s var(--easing);
  pointer-events: none;
  width: min(90vw, 700px);
}
.scene__caption .eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.scene__caption .headline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  line-height: 1.15;
  color: var(--cream);
  margin: 0;
}
.scene__caption .sub {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--cream-dim);
}

/* Scrub progress indicator — bottom rail */
.scrub {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(255,255,255,0.08);
  z-index: 90;
}
.scrub__bar {
  height: 100%;
  width: var(--reel-progress, 0%);
  background: linear-gradient(90deg, var(--crimson) 0%, var(--gold) 100%);
  transition: width 0.05s linear;
}

/* Scroll hint at the very top */
.hint {
  position: absolute;
  left: 50%;
  bottom: 2.5vh;
  transform: translateX(-50%);
  z-index: 50;
  font-size: 0.65rem;
  letter-spacing: 0.45em;
  color: var(--cream-dim);
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  opacity: var(--hint-opacity, 1);
  transition: opacity 0.6s var(--easing);
}
.hint .line {
  width: 1px;
  height: 36px;
  background: linear-gradient(180deg, var(--gold), transparent);
  animation: drip 2.4s var(--easing) infinite;
}
@keyframes drip {
  0%   { transform: scaleY(0); transform-origin: top; opacity: 0; }
  40%  { transform: scaleY(1); transform-origin: top; opacity: 1; }
  60%  { transform: scaleY(1); transform-origin: bottom; opacity: 1; }
  100% { transform: scaleY(0); transform-origin: bottom; opacity: 0; }
}

/* ============================================================
   INTRO TITLE — opening overlay before scrolling begins
   ============================================================ */
.intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 50;
  opacity: var(--intro-opacity, 1);
  transition: opacity 0.4s linear;
  pointer-events: none;
}
.intro__inner { max-width: 900px; padding: 0 1.5rem; }
.intro__eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.5em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}
.intro__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  margin: 0 0 0.9rem;
  color: var(--cream);
}
.intro__title em {
  font-style: italic;
  color: var(--gold);
  font-weight: 400;
}
.intro__rule {
  width: 80px;
  height: 1px;
  background: var(--gold);
  margin: 1.4rem auto 1.2rem;
}
.intro__sub {
  font-size: 0.95rem;
  color: var(--cream-dim);
  letter-spacing: 0.05em;
  max-width: 560px;
  margin: 0 auto;
}

/* ============================================================
   SECTION FRAMING — shared
   ============================================================ */
section {
  position: relative;
  padding: clamp(5rem, 10vh, 9rem) 1.5rem;
}
.container { max-width: 1200px; margin: 0 auto; }
.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.45em;
  color: var(--gold);
  text-transform: uppercase;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  line-height: 1.1;
  margin: 0.6rem 0 0;
  color: var(--cream);
}
.section-lede {
  margin-top: 1rem;
  font-size: 1rem;
  max-width: 640px;
  color: var(--cream-dim);
}

/* ============================================================
   CONNECTED-CIRCLES HUB
   A 9-node synaptic-network navigator. SVG layer draws the
   filigree connections between nodes (with traveling light
   pulses). HTML <a> nodes overlay the SVG at percentage coords
   so they stay aligned to the line endpoints at every size.
   ============================================================ */
.hub-section {
  background:
    radial-gradient(ellipse at top, rgba(138,10,10,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at bottom, rgba(201,169,97,0.05) 0%, transparent 55%),
    var(--bg);
  text-align: center;
  padding-top: 0;
}
.hub-head {
  max-width: 760px;
  margin: 0 auto;
  padding: 6rem 1.5rem 2.5rem;
}
.hub-head .section-lede { margin-left: auto; margin-right: auto; }

.hub-stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 1rem auto 5rem;
  aspect-ratio: 1200 / 800;
}
.hub-net {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

/* Network lines */
.hub-line {
  stroke: rgba(201,169,97, 0.32);
  stroke-width: 1.1;
  fill: none;
  stroke-dasharray: 4 14;
  animation: line-flow 6s linear infinite;
  animation-delay: var(--d, 0s);
}
.hub-line--dim {
  stroke: rgba(201,169,97, 0.18);
  stroke-width: 0.8;
  animation-duration: 9s;
}
@keyframes line-flow {
  to { stroke-dashoffset: -180; }
}
.hub-stars circle { animation: star-twinkle 4s ease-in-out infinite; }
.hub-stars circle:nth-child(2n) { animation-duration: 5s; animation-delay: 1s; }
.hub-stars circle:nth-child(3n) { animation-duration: 7s; animation-delay: 0.5s; }
@keyframes star-twinkle {
  0%,100% { opacity: 0.3; }
  50%     { opacity: 1; }
}

/* HTML node circles overlaid on the SVG */
.hub-node {
  position: absolute;
  left: var(--x, 50%);
  top:  var(--y, 50%);
  transform: translate(-50%, -50%);
  width: clamp(110px, 12vw, 158px);
  aspect-ratio: 1 / 1;
  z-index: 5;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  text-decoration: none;
  color: var(--cream);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(80,12,12,0.95) 0%, rgba(8,2,2,0.96) 70%),
    var(--bg);
  border: 1px solid rgba(201,169,97, 0.45);
  box-shadow:
    0 0 0  1px rgba(201,169,97, 0.10) inset,
    0 0 22px rgba(138,10,10, 0.35),
    0 0 60px rgba(0,0,0, 0.85);
  transition: transform 0.45s var(--easing),
              border-color 0.4s var(--easing),
              box-shadow 0.5s var(--easing),
              background 0.5s var(--easing);
  cursor: pointer;
  isolation: isolate;
  animation: node-breath 6s ease-in-out infinite;
}
.hub-node:nth-child(2n) { animation-delay: 1s; }
.hub-node:nth-child(3n) { animation-delay: 2s; }
.hub-node:nth-child(5n) { animation-delay: 2.8s; }

.hub-node::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,169,97,0.34) 0%, rgba(201,169,97,0) 70%);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.45s var(--easing);
}
.hub-node:hover,
.hub-node:focus-visible {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 30% 28%, rgba(120,18,18,0.95) 0%, rgba(20,4,4,0.96) 70%),
    var(--bg);
  box-shadow:
    0 0 0 1px rgba(201,169,97, 0.40) inset,
    0 0 38px rgba(201,169,97, 0.55),
    0 0 90px rgba(138,10,10, 0.60);
  transform: translate(-50%, -50%) scale(1.07);
  outline: none;
}
.hub-node:hover::before,
.hub-node:focus-visible::before { opacity: 1; }

.hub-num {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--gold);
  letter-spacing: 0.28em;
  margin-bottom: 0.15rem;
  transition: color 0.4s var(--easing);
}
.hub-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 1.55vw, 1.4rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--cream);
  line-height: 1.05;
  padding: 0 0.3rem;
}
.hub-sub {
  font-family: var(--font-body);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin-top: 0.4rem;
  max-width: 78%;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.45s var(--easing), transform 0.45s var(--easing);
  line-height: 1.3;
}
.hub-node:hover .hub-sub,
.hub-node:focus-visible .hub-sub { opacity: 1; transform: translateY(0); }

/* The center "Join Us" core — slightly larger and more luminous */
.hub-node--core {
  width: clamp(132px, 14vw, 188px);
  background:
    radial-gradient(circle at 30% 28%, rgba(140,18,18,0.95) 0%, rgba(20,4,4,0.96) 70%),
    var(--bg);
  border-color: rgba(201,169,97, 0.6);
  animation-name: core-pulse;
  animation-duration: 4.5s;
}
@keyframes core-pulse {
  0%,100% { box-shadow:
    0 0 0 1px rgba(201,169,97, 0.18) inset,
    0 0 32px rgba(201,169,97, 0.30),
    0 0 80px rgba(138,10,10, 0.55); }
  50%     { box-shadow:
    0 0 0 1px rgba(201,169,97, 0.32) inset,
    0 0 50px rgba(201,169,97, 0.60),
    0 0 100px rgba(138,10,10, 0.75); }
}

@keyframes node-breath {
  0%,100% { box-shadow:
    0 0 0  1px rgba(201,169,97, 0.10) inset,
    0 0 22px rgba(138,10,10, 0.35),
    0 0 60px rgba(0,0,0, 0.85); }
  50%     { box-shadow:
    0 0 0  1px rgba(201,169,97, 0.20) inset,
    0 0 32px rgba(201,169,97, 0.20),
    0 0 70px rgba(138,10,10, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  .hub-line, .hub-stars circle, .hub-node { animation: none !important; }
}

/* Phone fallback — the network gets too crowded at small widths,
   so we switch to a clean 3-column grid and hide the SVG lines. */
@media (max-width: 720px) {
  .hub-stage {
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 0 0.6rem;
    margin-bottom: 3rem;
  }
  .hub-net { display: none; }
  .hub-node {
    position: static;
    transform: none;
    width: 100%;
    max-width: 110px;
    margin: 0 auto;
    animation: none;
  }
  .hub-node:hover,
  .hub-node:focus-visible { transform: scale(1.05); }
  .hub-node--core {
    width: 100%;
    max-width: 124px;
  }
  .hub-sub { display: none; }
}

/* ============================================================
   TREE TOOLTIP — mouse-follows label
   ============================================================ */
.tree-tip {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 95;
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--rule);
  color: var(--cream);
  padding: 0.55rem 0.9rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transform: translate(-50%, -150%);
  opacity: 0;
  transition: opacity 0.2s var(--easing);
  white-space: nowrap;
  font-family: var(--font-body);
}
.tree-tip.show { opacity: 1; }
.tree-tip .tip-sub {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: none;
  margin-top: 0.2rem;
  font-style: italic;
  font-family: var(--font-display);
}

/* ============================================================
   FOOTER
   ============================================================ */
.cine-foot {
  border-top: 1px solid var(--rule);
  padding: 3rem 1.5rem;
  text-align: center;
}
.cine-foot__brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream);
}
.cine-foot__brand .accent { color: var(--gold); }
.cine-foot__rule {
  width: 60px; height: 1px;
  background: var(--gold);
  margin: 1rem auto;
}
.cine-foot__meta {
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.cine-foot__meta a { color: var(--gold); }

/* ============================================================
   REVEAL — small fade-up for content sections
   ============================================================ */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.9s var(--easing), transform 0.9s var(--easing); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ============================================================
   REDUCED MOTION
   Users who prefer reduced motion get a static poster instead of
   a scroll-scrubbed video, plus the captions stacked below it.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .reel { height: auto; }
  .stage { position: relative; height: auto; min-height: 100vh; }
  .intro { position: relative; opacity: 1 !important; padding: 6rem 1rem; }
  .hint, .scrub { display: none; }
  .hero-video { display: none; }
  .stage { background: url("/assets/video/hero-poster.jpg") center center / cover no-repeat, #000; }
  .caption-track { position: relative; padding: 2rem 1rem 4rem; }
  .scene-caption {
    position: relative;
    left: auto; bottom: auto;
    transform: none;
    opacity: 1 !important;
    margin: 2.5rem auto;
  }
}

/* ============================================================
   SMALL-SCREEN ADJUSTMENTS
   On narrow / portrait viewports:
   - Show the FULL video frame (object-fit: contain) instead of
     cropping the sides off — fixes the "video doesn't fit phone" bug
   - Shrink the reel so phone scrolling isn't endless
   - Captions move just above the bottom letterbox, larger touch-safe text
   - Center the watermark mask on the video's actual bottom-right
     (which when contained on a portrait phone sits at the mid-band edge,
     not the stage corner)
   ============================================================ */
@media (max-width: 720px) {
  .scene__caption .headline { font-size: 1.4rem; }
  .scene__caption .sub { font-size: 0.78rem; }
  .intro__title { font-size: 2.4rem; }
}

@media (max-aspect-ratio: 1/1) {
  /* Shorter reel — 5 viewports instead of 6 — phones don't want to scroll forever */
  .reel { height: 500vh; }

  /* Captions sit just above the bottom letterbox bar so they overlap the
     vignette, not the image content. Calculated as half the empty space
     left between the contained 16:9 video and the viewport. */
  .scene-caption {
    bottom: calc(50% - 28vw - 6vh);
    width: 92vw;
    padding: 0 1rem;
  }
  .scene-caption .headline { font-size: clamp(1.2rem, 5vw, 1.6rem); }
  .scene-caption .sub { font-size: 0.78rem; }
  .scene-caption .eyebrow { font-size: 0.62rem; letter-spacing: 0.32em; }

  /* On a contained portrait layout, the video's bottom-right corner sits
     above the stage's bottom-right by half the letterbox height. Move
     the mask up so it covers the baked-in black box. */
  .hero-watermark-mask {
    width: 16vw;
    height: 9vw;     /* 16:9 of width so mask stays in-corner of the video */
    right: 0;
    bottom: calc(50% - 28vw);
    max-width: none;
    max-height: none;
  }

  .intro__title { font-size: clamp(1.9rem, 8vw, 2.6rem); }
  .intro__sub   { font-size: 0.85rem; }
}

/* Very wide / ultrawide — pull the captions a little higher so they
   don't get lost in the deep vignette pool at the bottom edge. */
@media (min-aspect-ratio: 21/9) {
  .scene-caption { bottom: 12vh; }
}
