/* ===================================================================
   Daniel Norouzi · home page
   A film in six cuts: lights out, the hero, the driver, the kit, the
   builds, and the finish. Night bands stay dark in both themes; the
   sections between them follow the reader's theme.
   Pinned layout and the hero entrance live under html.motion (set in
   <head> unless reduced motion is on). Scroll-driven hidden states live
   under html.live, which home.js adds once Motion has loaded, so the page
   stays fully visible if a script fails.
   =================================================================== */

.night { background: var(--night); color: var(--on-night); }

/* ===================== Header over night bands ===================== */
.site-header .lap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  pointer-events: none;
}
.site-header .lap span {
  display: block;
  height: 100%;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
.site-header.over-night {
  background: transparent;
  color: var(--on-night);
  border-color: transparent;
}
.site-header.over-night .theme-toggle { border-color: rgba(237, 234, 226, 0.3); }
@media (max-width: 760px) {
  .site-header.over-night:has(.main-nav.open) { background: var(--bg); color: var(--ink); }
}

/* ===================== Opening sequence ===================== */
.intro { display: none; }
.intro-on .intro {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 400;
  animation: intro-failsafe 0.01s 5s forwards;
}
@keyframes intro-failsafe { to { visibility: hidden; } }

.intro-curtain {
  position: absolute;
  left: 0;
  right: 0;
  height: 50.5%;
  background: var(--night);
}
.intro-top { top: 0; }
.intro-bottom { bottom: 0; }

.intro-gantry {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: clamp(6px, 1.2vw, 12px);
  padding: clamp(8px, 1.2vw, 12px);
  background: #030810;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(237, 234, 226, 0.06);
}
.lamp-col {
  display: grid;
  gap: clamp(5px, 0.8vw, 8px);
  padding: clamp(5px, 0.7vw, 7px);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 7px;
}
.lamp-col i {
  display: block;
  width: clamp(18px, 3.4vw, 34px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--lamp-off);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6);
  transition: background-color 0.06s linear, box-shadow 0.06s linear;
}
.lamp-col.on i {
  background: var(--signal);
  box-shadow: 0 0 24px 4px var(--signal-glow), inset 0 -2px 3px rgba(0, 0, 0, 0.25);
}

/* ===================== Hero ===================== */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  margin-top: calc(-1 * var(--header-h) - 1px);
  padding-block: calc(var(--header-h) + 32px) clamp(40px, 8vh, 88px);
  overflow: hidden;
}

.hero-art {
  position: absolute;
  top: 0;
  bottom: 0;
  right: max(0px, calc((100vw - var(--max-width)) / 2));
  aspect-ratio: 760 / 1056;
  max-width: 62vw;
}
.hero-art::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, var(--night) 0%, transparent 30%),
    linear-gradient(0deg, var(--night) 0%, transparent 34%),
    linear-gradient(180deg, var(--night) 0%, transparent 16%);
}
.hero-photo,
.hero-ascii {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-photo {
  object-fit: cover;
  object-position: 50% 18%;
  filter: grayscale(1) contrast(1.05);
  opacity: 0.42;
  transition: opacity 0.6s var(--ease-out);
}
.ascii-ready .hero-photo { opacity: 0; }

.hero-inner { position: relative; z-index: 2; width: 100%; }

.hero-name {
  font-size: clamp(3.2rem, 12.4vw, 12.5rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.84;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  margin-bottom: clamp(28px, 6vh, 56px);
}
.hero-name .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.05em;
  margin-bottom: -0.05em;
}
.hero-name .line > span { display: inline-block; will-change: transform; }

.hero-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px 48px;
}
.hero-role {
  max-width: 36ch;
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
  color: var(--on-night-2);
}

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-light { background: var(--on-night); color: #07111F; }
.btn-light:hover { background: var(--on-night-gold); }
.btn-outline-light { color: var(--on-night); border-color: rgba(237, 234, 226, 0.32); background: rgba(7, 17, 31, 0.78); }
.btn-outline-light:hover { border-color: var(--on-night-gold); }

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: clamp(28px, 6vh, 56px);
  background: rgba(237, 234, 226, 0.16);
  overflow: hidden;
}
.scroll-cue span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--on-night-gold);
  animation: cue 2.2s var(--ease-out) infinite;
}
@keyframes cue {
  0% { transform: translateY(-100%); }
  60%, 100% { transform: translateY(100%); }
}
html:not(.motion) .scroll-cue { display: none; }

/* entrance states (Motion plays them; the failsafe shows them if it can't) */
.motion .hero-name .line > span {
  transform: translateY(105%);
  animation: show-failsafe 0.01s 3s forwards;
}
.motion .hero-foot {
  opacity: 0;
  animation: show-failsafe 0.01s 3s forwards;
}
.intro-on .hero-name .line > span,
.intro-on .hero-foot { animation-delay: 5s; }
@keyframes show-failsafe { to { transform: none; opacity: 1; } }

@media (max-width: 760px) {
  .hero { align-items: flex-end; }
  .hero-art {
    left: 0;
    right: 0;
    max-width: none;
    width: 100%;
    height: 72%;
    aspect-ratio: auto;
  }
  .hero-art::after {
    background:
      linear-gradient(0deg, var(--night) 8%, transparent 62%),
      linear-gradient(180deg, var(--night) 0%, transparent 18%);
  }
  .hero-foot { gap: 20px; }
  .cta-row .btn { flex: 1 1 auto; justify-content: center; }
}

/* ===================== About ===================== */
.about { position: relative; }
.about-pin { padding-block: clamp(88px, 14vh, 160px); }
.motion .about { height: 210vh; }
.motion .about-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  padding-block: calc(var(--header-h) + 16px) 24px;
}

.about-stage {
  display: grid;
  grid-template-columns: minmax(220px, 380px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  width: 100%;
}

.about-photo {
  position: relative;
  aspect-ratio: 760 / 1056;
  max-height: calc(100svh - var(--header-h) - 80px);
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--night);
}
.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}
.about-ascii {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.about-copy { min-width: 0; }

.reveal-text {
  max-width: 34ch;
  font-size: clamp(1.25rem, 2.25vw, 1.95rem);
  font-weight: 500;
  font-stretch: 104%;
  line-height: 1.32;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}
.reveal-text .w { transition: opacity 0.35s ease; }
.live .reveal-text .w { opacity: 0.16; }
.live .reveal-text .w.lit { opacity: 1; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 48px;
  margin-top: clamp(24px, 4vh, 40px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.facts dt {
  font-size: 0.8125rem;
  font-weight: 600;
  font-stretch: 88%;
  color: var(--muted);
}
.facts dd {
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.facts dd span { font-size: 0.55em; font-weight: 600; color: var(--muted); }

@media (max-width: 760px) {
  .motion .about { height: auto; }
  .motion .about-pin { position: relative; height: auto; display: block; padding-block: 88px; }
  .about-stage { grid-template-columns: 1fr; }
  .about-photo { width: min(100%, 300px); max-height: none; }
}

/* ===================== Toolkit ===================== */
.toolkit {
  padding: clamp(72px, 12vh, 140px) 0;
  overflow: hidden;
}
.toolkit .section-title { margin-bottom: clamp(24px, 4vh, 40px); }

.marquee { display: grid; gap: 2px; }
.marquee-row {
  display: flex;
  gap: clamp(22px, 3vw, 48px);
  width: max-content;
  white-space: nowrap;
  font-size: clamp(2.6rem, 8vw, 7rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  will-change: transform;
}
.marquee-row span {
  display: inline-flex;
  align-items: center;
  gap: clamp(22px, 3vw, 48px);
}
.marquee-row span::after {
  content: '';
  width: 0.14em;
  height: 0.14em;
  background: var(--gold);
}
.row-b { transform: translateX(-22%); }
.row-b span {
  color: transparent;
  -webkit-text-stroke: 1.2px var(--ink);
}

/* ===================== Builds ===================== */
.builds { padding: clamp(72px, 12vh, 140px) 0 clamp(72px, 10vh, 120px); }

.stack { display: grid; gap: 28px; }
.stack-end { display: none; }

.build-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  min-height: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 40px 80px -48px var(--shadow);
}
.motion .stack { gap: 34vh; }
.motion .stack-end { display: block; height: 10vh; }
.motion .build-card {
  position: sticky;
  top: calc(var(--header-h) + 24px + var(--i) * 18px);
  height: min(560px, calc(100svh - var(--header-h) - 64px));
  min-height: 0;
  transform: scale(var(--s, 1));
  transform-origin: 50% 0;
  will-change: transform;
}

.build-media {
  position: relative;
  min-height: 240px;
  overflow: hidden;
  background: var(--media-bg, var(--bg-alt));
}
.live .build-media { clip-path: inset(var(--clip, 0%) round 2px); }
.build-media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scale(var(--zoom, 1));
  transition: transform 0.6s var(--ease-out);
}
.build-media img.contain { object-fit: contain; padding: 7%; }
.build-media img.cover-left { object-fit: cover; object-position: 0 0; }

.build-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: clamp(24px, 3vw, 44px);
}
.build-body h3 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  font-weight: 750;
  font-stretch: 112%;
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.build-body > p { color: var(--ink-2); }

.build-shade {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: calc(var(--dim, 0) * 0.55);
  pointer-events: none;
}

.builds-more { margin-top: 40px; }
.builds-more a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 var(--line-strong);
  transition: box-shadow var(--transition);
}
.builds-more a:hover { box-shadow: inset 0 -2px 0 var(--gold); }

/* Reel Cards: a drawn copy of the app's review screen, in the app's own iOS palette */
.reel-mock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.2vh, 18px);
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", Arial, sans-serif;
  transform: scale(var(--zoom, 1));
  transition: transform 0.6s var(--ease-out);
}
.reel-mock .reel-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.reel-card {
  display: grid;
  gap: 2px;
  width: min(80%, 320px);
  padding: 22px 20px;
  border-radius: 22px;
  background: #FFFFFF;
  color: #000000;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}
.reel-src { font-size: 0.72rem; color: rgba(60, 60, 67, 0.7); }
.reel-word { font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.reel-meaning { font-size: 0.9rem; color: rgba(60, 60, 67, 0.7); }
.reel-grades {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(80%, 320px);
}
.reel-grades span {
  padding: 9px 0;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  color: #FFFFFF;
}
.reel-grades .g-again { background: #D92D20; }
.reel-grades .g-hard { background: #B25E00; }
.reel-grades .g-good { background: #1F7A36; }
.reel-grades .g-easy { background: #0062CC; }

@media (hover: hover) {
  .build-card:hover .build-media > img,
  .build-card:hover .reel-mock { --zoom: 1.03; }
}

@media (max-width: 760px) {
  .build-card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .build-media { min-height: 0; height: clamp(150px, 26svh, 240px); }
  .build-card .feature-list { display: none; }
  .reel-mock .reel-icon { display: none; }
  .reel-mock { padding: 12px; }
  .reel-card { padding: 12px 16px; }
  .reel-word { font-size: 1.6rem; }
}

/* ===================== Finish ===================== */
.finish { position: relative; --sq: clamp(14px, 2.4vh, 24px); }
.contact-anchor { position: absolute; top: 0; left: 0; }
.motion .finish { height: 330vh; }
.motion .contact-anchor { top: 70%; }

.finish-pin {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100svh;
  overflow: hidden;
  padding-block: calc(var(--header-h) + 32px) calc(var(--sq) * 2 + 40px);
}
.motion .finish-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  justify-content: flex-start;
  padding-top: calc(var(--header-h) + clamp(24px, 9vh, 96px));
}

.finish-inner { position: relative; z-index: 2; width: 100%; }

.finish-title {
  font-size: clamp(2.3rem, 9.2vw, 9.4rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.88;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}
.ft-line { display: block; width: fit-content; white-space: nowrap; padding-right: 0.04em; }
/* outlined until the car's nose passes, then painted in */
.live .ft-line {
  color: transparent;
  -webkit-text-stroke: 1.4px rgba(237, 234, 226, 0.55);
  background-image: linear-gradient(var(--on-night), var(--on-night));
  background-repeat: no-repeat;
  background-size: calc(var(--f, 0) * 100%) 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

.finish-rest {
  display: grid;
  gap: 20px;
  max-width: 640px;
  margin-top: clamp(24px, 4vh, 40px);
}
.finish-rest p { color: var(--on-night-2); }
.live .finish-rest { opacity: 0; }
.finish-email {
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.3rem, 3vw, 2.1rem);
  font-weight: 650;
  font-stretch: 110%;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--on-night-gold);
  transition: color var(--transition);
}
.finish-email:hover { color: var(--on-night-gold); }

.speedo {
  position: absolute;
  z-index: 3;
  top: calc(var(--header-h) + 20px);
  right: max(var(--gutter), env(safe-area-inset-right, 0px));
  text-align: right;
  font-family: var(--font-mono);
  color: var(--on-night-gold);
}
.speed-num {
  display: block;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.speed-unit { font-size: 0.8125rem; color: var(--on-night-muted); }
html:not(.motion) .speedo { display: none; }

.track {
  position: relative;
  height: clamp(90px, 20vh, 210px);
  margin-top: 48px;
  pointer-events: none;
}
.motion .track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--sq) * 2 + 3vh);
  margin: 0;
}
.track::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(237, 234, 226, 0.22) 0 28px, transparent 28px 56px);
}
.streaks { position: absolute; inset: 0; width: 100%; height: 100%; }
.car {
  position: absolute;
  left: 0;
  bottom: 6px;
  height: 100%;
  aspect-ratio: 1414 / 318;
  max-width: 96vw;
  will-change: transform;
}
html:not(.motion) .car { left: 50%; transform: translateX(-50%); }
.car-ascii { width: 100%; height: 100%; }

.chequer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--sq) * 2);
  background: repeating-conic-gradient(var(--on-night) 0 25%, transparent 0 50%) 0 0 / calc(var(--sq) * 2) calc(var(--sq) * 2);
  transform: translate3d(calc((1 - var(--cq, 1)) * 100%), 0, 0);
}

@media (max-width: 760px) {
  .motion .finish { height: 300vh; }
  .speedo { top: auto; bottom: calc(var(--sq) * 2 + 20vh + 24px); }
}
