/* ============================================================================
 * justin.vin
 *
 * Steel-blue hero with Justin's dot eyes. Below the fold: scroll-driven
 * typewriter scenes — large editorial text reveals character-by-character
 * as you scroll, with occasional illustrations fading in.
 * ========================================================================== */

:root {
  --justin-bg: #6383C4;
  --justin-fg: #16294F;

  --paper: #FAFAF6;
  --paper-tint: #F1EFE7;
  --ink: #16294F;
  --ink-soft: #2F3D5E;
  --ink-faint: #7A8198;
  --ink-ghost: rgba(22, 41, 79, 0.08);
  --rule: rgba(22, 41, 79, 0.10);
  --accent: #6383C4;

  --measure: 56rem;

  --display: "Fraunces", "GT Sectra", ui-serif, Georgia, serif;
  --body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(99, 131, 196, 0.32); color: var(--ink); }

a {
  color: inherit;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  transition: color 160ms ease;
}

/* ============================== Hero ============================== */

.hero {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--justin-bg);
}

.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.eye-shape {
  transform-box: fill-box;
  transform-origin: center;
  transform: translate(0, 0) scaleY(1);
  will-change: transform;
}

.hero-foot {
  position: absolute;
  left: 50%;
  bottom: max(env(safe-area-inset-bottom, 0px), 28px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(250, 250, 246, 0.66);
  pointer-events: none;
  /* The nudge bobs vertically; opacity is driven by scroll position via JS
     (sets --scroll-fade on this element) so the indicator fades as Dom
     starts scrolling down. */
  animation: nudge 2.6s ease-in-out infinite;
  opacity: var(--scroll-fade, 1);
  transition: opacity 120ms linear;
}
.hero-foot svg { display: block; }

@keyframes nudge {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.55; }
  50%      { transform: translate(-50%, 6px); opacity: 1; }
}

/* ============================== Paper ============================== */

.paper {
  background: var(--paper);
  color: var(--ink);
  position: relative;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--rule);
}

/* ============================== Scenes ============================== */

.scene {
  position: relative;
  /* No sticky pin — scenes flow normally and content reveals as it scrolls
     through the viewport. Padding controls breathing room between scenes. */
  padding: clamp(48px, 9vh, 110px) 0;
}
/* First scene sits well below the hero so "Hi I'm Justin" has breathing
   room before it starts revealing. */
.scene:first-of-type {
  padding-top: 35vh;
}
/* Last scene sits proud of the bottom so it ends near the middle of the
   viewport when the page is scrolled all the way down. */
.scene:last-of-type {
  padding-top: 70vh;
  padding-bottom: 50vh;
}

.scene-sticky {
  /* Container that lays out text + (optional) figure vertically. Despite the
     legacy name, this is not sticky any more. */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(24px, 6vw, 80px);
  gap: clamp(32px, 6vh, 80px);
}

.scene-text {
  width: 100%;
  max-width: var(--measure);
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 96, "wght" 420, "SOFT" 60, "WONK" 0;
  font-size: clamp(25px, 4.4vw, 54px);
  line-height: 1.08;
  letter-spacing: -0.018em;
  color: var(--ink);
  /* No text-wrap: balance — the caret moving between chars made the
     balancer recompute line breaks mid-reveal, which read as the text
     jumping around. Default wrap is stable. */
}

/* The typed text uses invisible characters that fade in as you scroll.
   No ghost layout — chars are transparent until revealed, so it feels
   like they're appearing onto the screen directly. Layout is fixed by
   the full text from the start (no reflow). */
.scene-text .ch {
  color: var(--ink);
  opacity: 0;
  transition: opacity 180ms ease;
}
.scene-text .ch.is-on {
  opacity: 1;
}

.scene-text a .ch.is-on { color: var(--accent); }
.scene-text a { text-decoration-thickness: 1.5px; text-underline-offset: 0.1em; }

/* Caret takes no inline space — uses width:0 and a positioned pseudo so it
   can't push surrounding chars onto a new line as it moves. */
.scene-text .caret {
  display: inline-block;
  position: relative;
  width: 0;
  height: 0.9em;
  vertical-align: -0.08em;
  opacity: 0;
}
.scene-text .caret::after {
  content: "";
  position: absolute;
  left: 0.04em;
  top: 0;
  width: 0.05em;
  height: 100%;
  background: var(--accent);
}
.scene-text.is-typing .caret {
  opacity: 1;
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.scene-art {
  margin: 0;
  width: 100%;
  max-width: 640px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 700ms cubic-bezier(.2, .8, .2, 1), transform 700ms cubic-bezier(.2, .8, .2, 1);
}
.scene-art.is-on {
  opacity: 1;
  transform: none;
}
.scene-art svg {
  width: 100%;
  height: auto;
  max-height: 56vh;
  display: block;
  filter: drop-shadow(0 24px 48px rgba(22, 41, 79, 0.06));
}
/* Portrait illustrations (iPhone) get a tighter cap so they don't dominate. */
.scene-art-tall svg { max-height: 52vh; max-width: 360px; margin: 0 auto; }

/* Ethereal travellers along the thread strands — soft blue glow */
.thread-travellers circle {
  filter: drop-shadow(0 0 2px rgba(99, 131, 196, 0.55));
}

/* ============================== Reduced motion ============================== */

@media (prefers-reduced-motion: reduce) {
  .eye-shape { transform: none !important; animation: none !important; }
  .hero-foot { animation: none !important; }
  .scene-text .ch { color: var(--ink) !important; transition: none !important; }
  .scene-text .caret { display: none !important; }
  .scene-art { opacity: 1 !important; transform: none !important; }
}

/* ============================== Mobile ============================== */

@media (max-width: 600px) {
  .scene-art { max-width: 320px; }
  /* Push the final scene way down so "It's good to feel alive" lands
     with a lot of empty room above it on mobile. */
  .scene:last-of-type { padding-top: 55vh; }
}
