/* ═══════════════════════════════════════════════
   WILLIAM GRAY — CINEMATIC SCROLL PORTFOLIO
   ink black · emerald accent · cream type
   ═══════════════════════════════════════════════ */

:root {
  --ink: #060807;
  --ink-2: #0b0f0d;
  --cream: #f3eddf;
  --cream-dim: rgba(243, 237, 223, 0.55);
  --cream-faint: rgba(243, 237, 223, 0.22);
  --emerald: #17e68f;
  --emerald-deep: #0a5c3c;
  --emerald-glow: rgba(23, 230, 143, 0.35);
  --display: "Anton", "Arial Narrow", sans-serif;
  --body: "Space Grotesk", "Helvetica Neue", sans-serif;
}

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

html { background: var(--ink); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  font-weight: 300;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--emerald); color: var(--ink); }

/* ── PRELOADER ─────────────────────────────── */
#preloader {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#preloader.done { opacity: 0; visibility: hidden; }
.preloader-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.preloader-name {
  font-family: var(--display); font-size: 72px; color: var(--cream);
  letter-spacing: 0.08em;
}
.preloader-bar {
  width: 180px; height: 2px; background: var(--cream-faint);
  overflow: hidden; display: block;
}
.preloader-fill {
  display: block; height: 100%; width: 0%;
  background: var(--emerald);
  transition: width 0.25s ease;
}
.preloader-status {
  font-size: 10px; letter-spacing: 0.4em; color: var(--cream-dim);
}

/* ── GRAIN ─────────────────────────────────── */
.grain {
  position: fixed; inset: -100px; z-index: 900; pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-jitter 0.6s steps(4) infinite;
}
@keyframes grain-jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-30px, 24px); }
  50% { transform: translate(22px, -18px); }
  75% { transform: translate(-14px, -26px); }
  100% { transform: translate(0, 0); }
}

/* ── HEADER ────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 800;
  display: flex; justify-content: space-between; align-items: center;
  padding: 26px 40px;
}
.logo {
  font-family: var(--display); font-size: 26px; color: var(--cream);
  text-decoration: none; letter-spacing: 0.06em;
}
.logo-dot { color: var(--emerald); }
.site-nav { display: flex; gap: 30px; }
.site-nav a {
  color: var(--cream); text-decoration: none;
  font-size: 12px; letter-spacing: 0.28em; font-weight: 500;
  position: relative;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: -6px;
  width: 100%; height: 1px; background: var(--emerald);
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.site-nav a:hover::after { transform: scaleX(1); transform-origin: left; }
.site-nav .nav-resume { color: var(--emerald); }

/* ── SECTION HEADS ─────────────────────────── */
.section-head {
  display: flex; align-items: baseline; gap: 24px;
  padding: 0 40px; margin-bottom: 70px;
}
.section-index {
  font-size: 13px; letter-spacing: 0.3em; color: var(--emerald);
  font-weight: 500;
}
.section-title {
  font-family: var(--display);
  font-size: clamp(44px, 7vw, 110px);
  letter-spacing: 0.02em; line-height: 0.95;
  color: var(--cream);
}
.section-head--overlay {
  position: absolute; top: 8vh; left: 0; z-index: 5; margin-bottom: 0;
}
/* title anchors at the top and stays until its section is fully scrolled
   through (matches the pinned Three Pillars behavior); the gradient scrim
   keeps it legible as content passes beneath */
.section-head--sticky {
  position: sticky; top: 0; z-index: 20;
  padding-top: 96px; padding-bottom: 26px; margin-bottom: 44px;
  background: linear-gradient(to bottom, var(--ink) 58%, rgba(6, 8, 7, 0));
}

/* ── HERO ──────────────────────────────────── */
.hero { height: 520vh; position: relative; }
.hero-sticky {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
}
#orbit-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block;
}
.hero-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 75% at 50% 45%, transparent 40%, rgba(6, 8, 7, 0.85) 100%),
    linear-gradient(to top, rgba(6, 8, 7, 0.95) 0%, transparent 28%);
}
.hero-content {
  position: absolute; left: 0; right: 0; bottom: 9vh; z-index: 4;
  padding: 0 40px;
}
.hero-kicker {
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; letter-spacing: 0.42em; color: var(--emerald);
  font-weight: 500; margin-bottom: 14px;
}
.hero-kicker .line { width: 48px; height: 1px; background: var(--emerald); display: inline-block; }
.hero-title {
  font-family: var(--display);
  font-size: clamp(72px, 14.5vw, 230px);
  line-height: 0.86; letter-spacing: 0.01em;
  color: var(--cream);
  display: flex; flex-direction: column;
}
.hero-word { display: block; overflow: hidden; white-space: nowrap; }
.hero-word--accent { color: var(--emerald); }
.hero-letter { display: inline-block; will-change: transform, opacity; }
.hero-sub {
  max-width: 560px; margin-top: 26px;
  font-size: 15px; line-height: 1.65; color: var(--cream-dim);
}
.hero-hud {
  position: absolute; top: 50%; right: 40px; transform: translateY(-50%);
  z-index: 4; text-align: right;
  display: flex; flex-direction: column; gap: 6px;
}
.hud-deg {
  font-family: var(--display); font-size: 34px; color: var(--cream);
  font-variant-numeric: tabular-nums;
}
.hud-label { font-size: 10px; letter-spacing: 0.5em; color: var(--emerald); }
.hero-scrollcue {
  position: absolute; bottom: 9vh; right: 40px; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 10px; letter-spacing: 0.45em; color: var(--cream-dim);
}
.scrollcue-line {
  width: 1px; height: 56px; background: var(--cream-faint);
  position: relative; overflow: hidden;
}
.scrollcue-line::after {
  content: ""; position: absolute; top: -50%; left: 0;
  width: 100%; height: 50%; background: var(--emerald);
  animation: scroll-drip 1.6s ease-in-out infinite;
}
@keyframes scroll-drip { to { top: 110%; } }

.preview-badge {
  position: absolute; top: 92px; right: 40px; z-index: 6;
  font-size: 9px; letter-spacing: 0.28em; color: rgba(243, 237, 223, 0.4);
  border: 1px solid rgba(243, 237, 223, 0.15);
  padding: 7px 12px; border-radius: 2px;
  backdrop-filter: blur(4px);
}

/* ── MARQUEE ───────────────────────────────── */
.marquee {
  overflow: hidden; white-space: nowrap;
  border-top: 1px solid var(--cream-dim);
  border-bottom: 1px solid var(--cream-dim);
  padding: 22px 0;
  background: var(--ink);
  position: relative; z-index: 10;
}
.marquee-track {
  display: inline-block;
  animation: marquee-roll 24s linear infinite;
}
.marquee-track span {
  font-family: var(--display);
  font-size: clamp(22px, 3vw, 40px);
  letter-spacing: 0.06em; color: transparent;
  -webkit-text-stroke: 1px var(--cream-dim);
}
@keyframes marquee-roll { to { transform: translateX(-50%); } }

/* ── STATS ─────────────────────────────────── */
.stats {
  padding: 44px 0 160px;
  background:
    radial-gradient(ellipse 60% 40% at 85% 0%, rgba(10, 92, 60, 0.18), transparent 65%),
    var(--ink);
  position: relative; z-index: 10;
}
/* deliberate breakpoints so 5 cards always distribute evenly:
   1 col → 2+2+full → 3 over 2 → 5 across */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--cream-faint);
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid .stat:nth-child(5) { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
  .stats-grid .stat { grid-column: span 2; }
  .stats-grid .stat:nth-child(4),
  .stats-grid .stat:nth-child(5) { grid-column: span 3; }
}
@media (min-width: 1600px) {
  .stats-grid { grid-template-columns: repeat(5, 1fr); }
  .stats-grid .stat,
  .stats-grid .stat:nth-child(4),
  .stats-grid .stat:nth-child(5) { grid-column: auto; }
}
.stat {
  padding: 54px 40px 60px;
  border-bottom: 1px solid var(--cream-faint);
  border-right: 1px solid var(--cream-faint);
  position: relative;
  transition: background 0.4s ease;
}
.stat:hover { background: rgba(23, 230, 143, 0.04); }
.stat::before {
  content: ""; position: absolute; top: -1px; left: 0;
  width: 0; height: 1px; background: var(--emerald);
  transition: width 0.6s cubic-bezier(0.65, 0, 0.35, 1);
}
.stat:hover::before { width: 100%; }
.stat-figure {
  font-family: var(--display);
  font-size: clamp(64px, 6.5vw, 108px);
  line-height: 1; color: var(--cream);
  display: flex; align-items: baseline; flex-wrap: wrap;
}
/* scale figures to their own card width so they can never wrap,
   regardless of how many columns the grid resolves to */
@supports (container-type: inline-size) {
  .stat { container-type: inline-size; }
  .stat-figure { flex-wrap: nowrap; white-space: nowrap; font-size: clamp(48px, 22cqw, 104px); }
  .stat-figure--dual { font-size: clamp(38px, 16.5cqw, 88px); }
}
.stat-num { font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 0.45em; color: var(--emerald); margin-left: 4px; }
.stat-prefix { font-size: 0.45em; color: var(--emerald); margin-right: 12px; }
.stat-figure-plus { font-size: 0.4em; color: var(--cream-dim); }
.stat-name {
  margin-top: 22px; font-size: 15px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--cream);
}
.stat-desc {
  margin-top: 14px; font-size: 13.5px; line-height: 1.7; color: var(--cream-dim);
  max-width: 46ch;
}

/* ── MEDIA SLOTS (clip backgrounds) ────────── */
.media-slot { position: absolute; inset: 0; overflow: hidden; }
.clip-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: none;
}
.clip-video.live { display: block; }
.media-placeholder { position: absolute; inset: 0; }
.media-placeholder--builder {
  background:
    radial-gradient(ellipse 70% 55% at 30% 55%, rgba(10, 92, 60, 0.4), transparent 70%),
    radial-gradient(ellipse 45% 40% at 78% 30%, rgba(23, 230, 143, 0.12), transparent 70%),
    linear-gradient(160deg, #0a0d0c 0%, #05110c 55%, #060807 100%);
}
.media-placeholder--builder::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(23, 230, 143, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 230, 143, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 45%, black 30%, transparent 75%);
}
.media-placeholder--closer {
  background:
    radial-gradient(ellipse 30% 90% at 50% 30%, rgba(23, 230, 143, 0.14), transparent 70%),
    radial-gradient(ellipse 65% 55% at 50% 100%, rgba(10, 92, 60, 0.3), transparent 75%),
    linear-gradient(180deg, #05110c 0%, #060807 70%);
}
.media-placeholder--closer::after {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg,
    transparent 0 120px, rgba(23, 230, 143, 0.07) 120px 122px);
  mask-image: linear-gradient(to bottom, black 10%, transparent 80%);
  transform: perspective(600px) rotateX(45deg);
  transform-origin: top;
}

/* ── PILLARS ───────────────────────────────── */
.pillars { height: 420vh; position: relative; }
.pillars-sticky {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
}
.pillars-shade {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(6, 8, 7, 0.88) 0%, rgba(6, 8, 7, 0.45) 55%, rgba(6, 8, 7, 0.75) 100%);
}
.pillar-stage {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 0 40px;
}
.pillar {
  grid-area: 1 / 1;
  max-width: 900px; width: 100%;
  opacity: 0; visibility: hidden;
}
.pillar-no {
  font-size: 14px; letter-spacing: 0.4em; color: var(--emerald); font-weight: 600;
}
.pillar-title {
  font-family: var(--display);
  font-size: clamp(46px, 7.5vw, 118px);
  line-height: 0.92; letter-spacing: 0.01em;
  color: var(--cream); margin-top: 18px;
}
.pillar-title .amp { color: var(--emerald); }
.pillar-desc {
  margin-top: 26px; max-width: 520px;
  font-size: 16px; line-height: 1.7; color: var(--cream-dim);
}
.pillar-progress {
  position: absolute; bottom: 7vh; left: 40px; z-index: 5;
  display: flex; gap: 10px;
}
.pillar-tick {
  width: 44px; height: 2px; background: var(--cream-faint);
  position: relative; overflow: hidden;
}
.pillar-tick::after {
  content: ""; position: absolute; inset: 0;
  background: var(--emerald);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.4s ease;
}
.pillar-tick.on::after { transform: scaleX(1); }

/* ── WORK ──────────────────────────────────── */
.work { position: relative; padding: 0 0 20vh; }
/* the clip stays viewport-sized and pinned while the deck scrolls over it —
   painting a video stretched across the whole tall section is what caused
   the scroll jank here */
.work-bg {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}
.work-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--ink) 0%, rgba(6, 8, 7, 0.72) 25%, rgba(6, 8, 7, 0.72) 75%, var(--ink) 100%);
}
.work .section-head--work { margin-top: -100vh; margin-top: -100dvh; }
.work-deck {
  position: relative; z-index: 5;
  display: flex; flex-direction: column; gap: 46px;
  padding: 0 40px;
  max-width: 1100px; margin: 0 auto;
}
.work-card {
  border: 1px solid var(--cream-faint);
  /* solid-ish fill instead of backdrop-filter: blur() — live-blurring a
     playing video behind three cards is a guaranteed scroll-jank source */
  background: rgba(8, 11, 10, 0.88);
  padding: 48px 52px 52px;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.5s ease, box-shadow 0.5s ease;
  will-change: transform;
}
.work-card:hover {
  transform: translateY(-10px);
  border-color: var(--emerald);
  box-shadow: 0 30px 80px -30px var(--emerald-glow);
}
.work-card-no {
  font-size: 11px; letter-spacing: 0.4em; color: var(--emerald); font-weight: 600;
}
.work-card-title {
  font-family: var(--display);
  font-size: clamp(34px, 4.6vw, 64px);
  line-height: 0.95; color: var(--cream);
  margin-top: 14px;
  transition: letter-spacing 0.5s ease;
}
.work-card:hover .work-card-title { letter-spacing: 0.035em; }
.work-card-pitch {
  margin-top: 12px; font-size: 15px; color: var(--emerald);
  letter-spacing: 0.04em; font-weight: 500;
}
.work-card-body {
  margin-top: 30px; display: grid; gap: 16px;
  grid-template-columns: 1fr 1fr;
}
.work-card-body p {
  font-size: 13.5px; line-height: 1.75; color: var(--cream-dim);
}
.work-card-body strong { color: var(--cream); font-weight: 600; letter-spacing: 0.06em; }

/* ── FINALE ────────────────────────────────── */
.finale {
  position: relative; z-index: 10;
  padding: 22vh 40px 0;
  background:
    radial-gradient(ellipse 55% 45% at 50% 110%, rgba(10, 92, 60, 0.25), transparent 70%),
    var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
.finale-title {
  font-family: var(--display);
  font-size: clamp(40px, 7.2vw, 116px);
  line-height: 1.0; letter-spacing: 0.01em;
  color: var(--cream);
  display: flex; flex-direction: column;
}
.finale-line { display: block; overflow: hidden; white-space: nowrap; width: fit-content; max-width: 100%; }
.finale-line em { font-style: normal; color: transparent; -webkit-text-stroke: 1.5px var(--cream); }
.finale-line--accent { color: var(--emerald); }
.finale-cta { display: flex; gap: 22px; margin-top: 64px; margin-bottom: 14vh; flex-wrap: wrap; }
.btn {
  font-family: var(--body); font-weight: 600;
  font-size: 13px; letter-spacing: 0.3em;
  text-decoration: none; padding: 20px 42px;
  border-radius: 999px;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}
.btn--solid {
  background: var(--emerald); color: var(--ink);
}
.btn--solid:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 50px -12px var(--emerald-glow);
}
.btn--ghost {
  border: 1px solid var(--cream-faint); color: var(--cream);
}
.btn--ghost:hover {
  transform: translateY(-4px);
  border-color: var(--emerald); color: var(--emerald);
}

/* ── FOOTER ────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--cream-faint);
  padding: 34px 0 38px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 18px;
}
.footer-links { display: flex; gap: 18px 34px; flex-wrap: wrap; }
.footer-links a {
  color: var(--cream); text-decoration: none;
  font-size: 12px; letter-spacing: 0.3em; font-weight: 500;
  transition: color 0.3s ease;
}
.footer-links a:hover { color: var(--emerald); }
.footer-note { font-size: 11px; letter-spacing: 0.2em; color: var(--cream-faint); }

/* ── RESPONSIVE ────────────────────────────── */
/* safe areas (notches, foldable hinges, curved edges) */
.site-header {
  padding-left: max(40px, env(safe-area-inset-left));
  padding-right: max(40px, env(safe-area-inset-right));
}
.site-footer { padding-bottom: max(38px, env(safe-area-inset-bottom)); }

@media (max-width: 820px) {
  .site-nav { display: none; }
  .section-head, .hero-content, .work-deck, .pillar-stage { padding-left: 22px; padding-right: 22px; }
  .hero-hud { right: 22px; }
  .hero-scrollcue { display: none; }
  .work-card { padding: 34px 26px 38px; }
  .work-card-body { grid-template-columns: 1fr; }
  .finale { padding: 18vh 22px 0; }
  .preview-badge { right: 22px; }
}

/* narrow phones + foldable cover screens (≤ ~380px) */
@media (max-width: 400px) {
  .site-header { padding-top: 18px; padding-bottom: 18px; }
  .section-head, .hero-content, .work-deck, .pillar-stage, .finale { padding-left: 16px; padding-right: 16px; }
  .hero-sub { font-size: 13.5px; }
  .hero-hud { display: none; }
  .hero-kicker { font-size: 10px; letter-spacing: 0.3em; }
  .stat { padding: 40px 20px 44px; }
  .stat-desc { font-size: 13px; }
  .work-card { padding: 26px 18px 30px; }
  .work-card-body p { font-size: 13px; }
  .pillar-desc { font-size: 14px; }
  .pillar-progress { left: 16px; }
  .finale-cta { gap: 14px; margin-top: 44px; }
  .btn { padding: 16px 28px; font-size: 12px; letter-spacing: 0.24em; width: 100%; text-align: center; }
  .footer-links { gap: 20px; }
  .footer-links a { font-size: 11px; letter-spacing: 0.2em; }
}

/* ── REDUCED MOTION ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .grain, .marquee-track, .scrollcue-line::after { animation: none; }
}
