/* James Huh — scroll prototype (opening, introduction, HexStep, Better Check-In).
   Static layout first. Scroll-linked effects are progressive: they only run where the browser supports
   CSS scroll-driven animations AND the visitor has not asked for reduced motion. Every effect starts
   from the static state at scroll position 0, so the first screen never waits on animation. */

:root {
  --night: #0B0E10;
  --on-night: #EEEBE4;
  --on-night-2: rgba(238, 235, 228, 0.66);
  --on-night-3: rgba(238, 235, 228, 0.42);
  --teal: #BDEFE3;
  --day: #ECEAE5;
  --on-day: #14161A;
  --on-day-2: #565A62;
  /* 48px at 1440 (Rooms canvas gutter) scaling down to 20px on a 390 phone: 48 / 1440 = 3.33vw */
  --gutter: clamp(20px, 3.34vw, 48px);
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--night); color-scheme: dark; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--night);
  color: var(--on-night);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 2px; }
p { margin: 0; }

.skip { position: absolute; left: -9999px; top: 12px; }
.skip:focus { left: 12px; z-index: 100; padding: 10px 14px; background: #fff; color: #000; }

/* ---------- Masthead: sits on the opening only, scrolls away with it ---------- */
.masthead {
  position: absolute; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 24px var(--gutter);
}
.masthead a { text-decoration: none; min-height: 24px; display: inline-flex; align-items: center; }
.masthead__name { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.masthead__nav { display: flex; gap: 28px; font-size: 15px; color: var(--on-night-2); }
.masthead__nav a:hover { color: var(--on-night); }
.masthead__nav a:last-child { color: var(--on-night); text-decoration: underline; }
@media (max-width: 720px) { .masthead__nav a:not(:last-child) { display: none; } }

/* ---------- Opening ---------- */
.opening { position: relative; }
.hero {
  position: sticky; top: 0; z-index: 0;
  height: 100vh; height: 100svh; min-height: 580px;
  overflow: hidden;
}
.hero__photo {
  position: absolute; right: 0; top: 0;
  width: min(68vw, 1000px); height: 100%;
  object-fit: cover; object-position: 50% 26%;
  /* Melt the photo into the night on its left edge (mask) and bottom edge (.hero::after) instead of framing it.
     One mask layer only: Chrome ignored the two-layer intersect and showed the left edge as a hard line. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 38%);
  mask-image: linear-gradient(to right, transparent 0, #000 38%);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(11, 14, 16, 0) 52%, rgba(11, 14, 16, 0.7) 82%, var(--night) 100%);
}
.hero__copy { position: absolute; z-index: 1; left: var(--gutter); right: var(--gutter); bottom: clamp(28px, 6svh, 64px); }
.hero__line { max-width: 31ch; margin-bottom: clamp(18px, 3svh, 34px); font-size: clamp(16px, 1.32vw, 19px); line-height: 1.5; color: var(--on-night-2); }
.hero__name {
  margin: 0;
  font-weight: 600;
  /* 204px at 1440 wide: the name spans ~70% of the width and runs into the photo's faded edge. */
  font-size: clamp(72px, 14.2vw, 212px);
  line-height: 0.82; letter-spacing: -0.055em;
}

.intro {
  position: relative; z-index: 1;
  /* Starts 30% of a screen above the hero's bottom edge, transparent at first, so the night rises over the photo. */
  /* It stays fully transparent over the visible hero at load (0-30svh), then turns to night as it rises. */
  margin-top: -30svh;
  padding: 66svh var(--gutter) 12svh;
  background: linear-gradient(to bottom, rgba(11, 14, 16, 0) 0, rgba(11, 14, 16, 0) 30svh, var(--night) 62svh);
}
.intro__lead {
  max-width: 23em;
  margin-left: clamp(0px, 16.6vw, 240px);
  font-size: clamp(28px, 3.5vw, 52px); line-height: 1.13; letter-spacing: -0.03em; font-weight: 500;
}
.intro__quiet { color: var(--on-night-3); }
.intro__now { margin: clamp(36px, 7svh, 72px) 0 0 clamp(0px, 16.6vw, 240px); color: var(--on-night-2); font-size: 16px; }

/* ---------- HexStep ---------- */
.hs { position: relative; z-index: 1; background: var(--night); padding-bottom: clamp(48px, 8svh, 96px); }
.hs__lead { position: relative; height: 100svh; min-height: 640px; max-height: 1080px; overflow: hidden; }
/* Two nested masks so the map can be placed freely without its edges ever showing:
   the wrapper fades top and bottom in section coordinates, the image fades its own left edge. */
.hs__mapwrap {
  position: absolute; inset: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 72%, transparent 100%);
}
.hs__map {
  /* 150% tall from -25%: 1350px x (2400/2444) = 1325px wide at 900 high. right -14% puts the glow's centre
     at ~x 980 on a 1440 screen, clear of the title column (48-560). */
  position: absolute; top: -25%; right: -14%;
  height: 150%; width: auto; max-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 24%);
  mask-image: linear-gradient(to right, transparent 0, #000 24%);
}
.hs__lead::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(11, 14, 16, 0.9) 0, rgba(11, 14, 16, 0.45) 34%, rgba(11, 14, 16, 0) 58%);
}
.hs__title { position: absolute; z-index: 1; left: var(--gutter); top: 52%; transform: translateY(-50%); max-width: 34rem; }
.hs__title h2 { margin: 0; font-size: clamp(60px, 8.6vw, 128px); line-height: 0.9; font-weight: 600; letter-spacing: -0.055em; }
.hs__tag { margin-top: 24px; max-width: 19em; font-size: clamp(21px, 1.95vw, 28px); line-height: 1.22; letter-spacing: -0.015em; color: var(--teal); }
.hs__meta { margin-top: 20px; font-size: 15px; color: var(--on-night-2); }
.hs__meta a { color: var(--on-night); }

.hs__replay {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: end;
  gap: clamp(32px, 6vw, 96px);
  max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter);
}
.replay { margin: 0; }
.replay__frames {
  position: relative; overflow: hidden; border-radius: 4px; background: #0F1316;
  /* 4:5 frames, never taller than 80% of the screen so the whole frame is visible while it plays. */
  width: min(100%, calc(80svh * 0.8)); aspect-ratio: 4 / 5;
}
.replay__frames img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.replay__date {
  position: absolute; left: 20px; top: 16px; display: grid;
  font-size: 15px; font-weight: 500; color: var(--on-night);
}
.replay__date span { grid-area: 1 / 1; opacity: 0; }
.replay__date span:last-child { opacity: 1; }
.replay__track { width: min(100%, calc(80svh * 0.8)); height: 2px; margin-top: 18px; background: rgba(238, 235, 228, 0.16); }
.replay__track i { display: block; height: 100%; background: var(--teal); transform-origin: left; }
.replay figcaption { margin-top: 12px; font-size: 14px; color: var(--on-night-3); }

.hs__aside { padding-bottom: 40px; }
.hs__say { max-width: 15em; font-size: clamp(24px, 2.3vw, 34px); line-height: 1.16; letter-spacing: -0.025em; font-weight: 500; }
.hs__note { margin-top: 14px; font-size: 15px; color: var(--on-night-2); }
.phone {
  width: clamp(180px, 17vw, 250px); margin-top: clamp(40px, 8svh, 88px);
  border-radius: 34px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 40px 80px rgba(0, 0, 0, 0.55);
}

/* ---------- Better Check-In ---------- */
.bci { position: relative; z-index: 1; background: var(--day); color: var(--on-day); }
.bci__dawn {
  min-height: 96svh; display: flex; align-items: flex-end;
  padding: 0 var(--gutter) clamp(64px, 12svh, 128px);
  /* Night to morning as one tonal ramp: the transition is the change of light, not a hard edge. */
  background: linear-gradient(to bottom, var(--night) 0%, #1A222D 18%, #3F4957 36%, #7D848E 52%, #BBBDBF 66%, #DEDDD9 78%, var(--day) 88%);
}
.bci__head {
  width: 100%; max-width: calc(1440px - 2 * var(--gutter)); margin: 0 auto;
  display: grid; grid-template-columns: auto minmax(0, 30rem); justify-content: space-between; align-items: end; gap: 32px 64px;
}
.bci__head h2 { margin: 0; font-size: clamp(54px, 7.2vw, 108px); line-height: 0.92; font-weight: 600; letter-spacing: -0.055em; }
.bci__tag { font-size: clamp(21px, 1.95vw, 28px); line-height: 1.22; letter-spacing: -0.015em; color: #263247; }
.bci__meta { margin-top: 16px; font-size: 15px; color: var(--on-day-2); }
.bci__meta a { color: var(--on-day); }

.bci__story {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 5vw, 80px);
  max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter);
}
.bci__steps { list-style: none; margin: 0; padding: 4svh 0 18svh; }
.step {
  min-height: 74svh; display: flex; flex-direction: column; justify-content: center;
  opacity: 0.26; transition: opacity 0.45s ease;
}
.step.is-active { opacity: 1; }
.step__say { max-width: 14em; font-size: clamp(26px, 2.6vw, 38px); line-height: 1.14; letter-spacing: -0.025em; font-weight: 500; }
.step__note { max-width: 27em; margin-top: 14px; font-size: 16px; color: var(--on-day-2); }
.step__shot { display: none; }

.bci__device {
  position: sticky; align-self: start;
  /* Device block height = column width (~730px at 1440) x 3/4 + 32px bezel = ~580px; centre it: 50svh - 290px. */
  top: max(64px, calc(50svh - 290px));
  margin-top: 8svh;
}
.tablet {
  /* iPad-like proportions: bezel ~2.2% of width (about 16px at 720px), outer radius = inner radius + bezel. */
  position: relative; padding: 16px; border-radius: 34px;
  background: #1C1E21;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 60px 90px -40px rgba(28, 34, 46, 0.5), 0 20px 34px -22px rgba(28, 34, 46, 0.4);
}
.tablet__screen { position: relative; aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden; background: #F4F5F7; }
.tablet__screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s ease; }
.bci__story[data-step="1"] [data-screen="1"],
.bci__story[data-step="2"] [data-screen="2"],
.bci__story[data-step="3"] [data-screen="3"],
.bci__story[data-step="4"] [data-screen="4"] { opacity: 1; }
.staffcard {
  /* Hangs ~70px below the tablet (12% of its ~580px height) so the caption sits on the page, not on the screen. */
  position: absolute; right: -3%; bottom: -12%; width: 42%; margin: 0;
  opacity: 0; transform: translateY(28px); transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.staffcard img { border-radius: 14px; box-shadow: 0 0 0 1px rgba(20, 22, 26, 0.08), 0 40px 70px -24px rgba(20, 26, 40, 0.45); }
.staffcard figcaption { margin-top: 10px; font-size: 13px; color: var(--on-day-2); }
.bci__story[data-step="4"] .staffcard { opacity: 1; transform: none; }

.bci__credit { max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter) 64px; font-size: 13px; color: var(--on-day-2); }

.end { background: var(--day); color: var(--on-day-2); padding: 12svh var(--gutter) 16svh; border-top: 1px solid rgba(20, 22, 26, 0.12); font-size: 16px; }
.end__title { color: var(--on-day); font-weight: 500; margin-bottom: 6px; }

/* ---------- No JavaScript, or narrow screens: the sequence becomes a plain stack of screens ---------- */
.no-js .bci__device { display: none; }
.no-js .bci__story { grid-template-columns: minmax(0, 1fr); }
.no-js .step { opacity: 1; min-height: 0; padding: 48px 0; }
.no-js .step__shot { display: block; max-width: 720px; margin-top: 24px; padding: 12px; border-radius: 26px; background: #1C1E21; }
.no-js .step__shot img { border-radius: 14px; }
.no-js .step__shot--card { max-width: 340px; margin: -60px 0 0 440px; padding: 0; background: none; position: relative; }
.no-js .step__shot--card img { box-shadow: 0 0 0 1px rgba(20, 22, 26, 0.08), 0 30px 50px -24px rgba(20, 26, 40, 0.45); }

@media (max-width: 899px) {
  .hero__photo { width: 100%; height: 78%; object-position: 50% 22%; -webkit-mask-image: none; mask-image: none; }
  .hero::after { background: linear-gradient(to bottom, rgba(11, 14, 16, 0) 40%, rgba(11, 14, 16, 0.75) 66%, var(--night) 80%); }
  .hero__name { letter-spacing: -0.05em; }
  .intro { margin-top: -18svh; padding: 46svh var(--gutter) 14svh; background: linear-gradient(to bottom, rgba(11, 14, 16, 0) 0, rgba(11, 14, 16, 0) 18svh, var(--night) 42svh); }
  .intro__lead, .intro__now { margin-left: 0; }

  .hs__lead { height: auto; min-height: 0; max-height: none; padding: 30svh 0 0; }
  .hs__mapwrap { bottom: auto; height: 100svh; }
  .hs__map { top: 0; right: auto; left: 50%; translate: -50% 0; height: auto; width: 170%; -webkit-mask-image: none; mask-image: none; }
  .hs__lead::after { background: linear-gradient(to bottom, rgba(11, 14, 16, 0) 0, rgba(11, 14, 16, 0.2) 45%, var(--night) 82%); }
  .hs__title { position: relative; top: auto; transform: none; padding: 34svh var(--gutter) 64px; max-width: none; left: 0; }
  .hs__replay { grid-template-columns: minmax(0, 1fr); gap: 56px; }
  .replay__frames, .replay__track { width: 100%; }
  .hs__aside { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: end; padding-bottom: 0; }
  .hs__aside .phone { grid-column: 2; grid-row: 1 / span 2; width: 132px; margin: 0; border-radius: 20px; }
  .hs__say, .hs__note { grid-column: 1; }

  .bci__dawn { min-height: 92svh; }
  .bci__head { grid-template-columns: minmax(0, 1fr); }
  /* "Better Check-In" is ~7.6em wide in Geist 600 at -0.055em tracking; 11.4vw keeps it on one line at 390 (44px). */
  .bci__head h2 { font-size: 11.4vw; }
  .bci__story { grid-template-columns: minmax(0, 1fr); }
  .bci__device { display: none; }
  .bci__steps { padding: 24px 0 64px; }
  .step { opacity: 1; min-height: 0; padding: 36px 0; }
  .step__shot {
    display: block; margin-top: 22px; padding: 10px; border-radius: 20px; background: #1E2125;
    box-shadow: 0 30px 50px -30px rgba(28, 34, 46, 0.45);
  }
  .step__shot img { border-radius: 10px; }
  .step__shot--card { width: 74%; margin-left: auto; margin-top: -40px; position: relative; padding: 0; background: none; box-shadow: none; }
  .step__shot--card img { border-radius: 12px; box-shadow: 0 0 0 1px rgba(20, 22, 26, 0.08), 0 30px 50px -24px rgba(20, 26, 40, 0.45); }
}

/* ---------- Scroll-linked effects (progressive, motion-safe) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* Opening: over the first screen of scrolling the portrait dims and settles back as the night rises. */
    .hero__photo { animation: recede linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
    .hero__copy { animation: lift linear both; animation-timeline: scroll(root); animation-range: 0 70vh; }
    @keyframes recede { to { transform: scale(1.06); filter: brightness(0.32); } }
    @keyframes lift { to { transform: translateY(-8vh); opacity: 0; } }

    /* Introduction: each clause comes up to full brightness as it reaches the reading line. */
    .intro__lead span { animation: read linear both; animation-timeline: view(); animation-range: entry 60% cover 42%; }
    .intro__lead .intro__quiet { animation-name: read-quiet; }
    @keyframes read { from { color: rgba(238, 235, 228, 0.18); } to { color: var(--on-night); } }
    @keyframes read-quiet { from { color: rgba(238, 235, 228, 0.12); } to { color: var(--on-night-3); } }

    /* HexStep: the city lights up as it arrives. */
    .hs__map { animation: light-up linear both; animation-timeline: view(); animation-range: entry 10% cover 46%; }
    @keyframes light-up { from { filter: brightness(0.18) saturate(0.2); transform: scale(1.04); } to { filter: none; transform: none; } }

    /* Replay scrubs with the scroll: three days, one frame. */
    .replay { view-timeline-name: --replay; view-timeline-axis: block; }
    .replay__frames img:nth-child(2) { animation: f2 linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    .replay__frames img:nth-child(3) { animation: f3 linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    .replay__date span:nth-child(1) { animation: d1 linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    .replay__date span:nth-child(2) { animation: d2 linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    .replay__date span:nth-child(3) { animation: d3 linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    .replay__track i { animation: track linear both; animation-timeline: --replay; animation-range: cover 22% cover 62%; }
    @keyframes f2 { 0%, 30% { opacity: 0; } 42%, 100% { opacity: 1; } }
    @keyframes f3 { 0%, 64% { opacity: 0; } 76%, 100% { opacity: 1; } }
    @keyframes d1 { 0%, 34% { opacity: 1; } 40%, 100% { opacity: 0; } }
    @keyframes d2 { 0%, 34% { opacity: 0; } 40%, 68% { opacity: 1; } 74%, 100% { opacity: 0; } }
    @keyframes d3 { 0%, 68% { opacity: 0; } 74%, 100% { opacity: 1; } }
    @keyframes track { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  }
}

@media (prefers-reduced-motion: reduce) {
  .step, .tablet__screen img, .staffcard { transition: none; }
  .staffcard { transform: none; }
}
