/* Homepage — layered on case-study.css. Reuses its tokens, nav, page
   column, img-slot frames, tags, h2 eyebrows and footer; only the
   homepage-specific blocks live here. */

/* ---------- Hero ---------- */

/* Full-height landing screen, content centred vertically and left
   aligned like the reference: eyebrow, oversized two-line headline,
   then a single subtitle. Top padding clears the fixed nav. */
.home-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 96px 0 72px;
}

/* Small uppercase role line above the headline; extra items would be
   separated by a muted dot. */
.hero-eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.hero-eyebrow li { color: var(--muted); }

.hero-eyebrow li + li::before {
  content: "·";
  margin: 0 8px;
  color: var(--muted);
}

.home-hero h1 {
  font-size: 88px;
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

/* Desktop vs phone wording of the headline (see index.html); phones
   swap them in the 640px query below. The changing word's line never
   wraps, so typing only changes that line's width. */
.hero-m { display: none; }
.hero-word { white-space: nowrap; }

/* Typed word: JS types each word out, backspaces it, then types the
   next. It's plain inline text, so the rest of the line reflows to the
   word's width as it grows and shrinks. */
.typer { white-space: nowrap; }

/* Caret in the current word's colour; blinks while idle, holds solid
   while typing or deleting. */
.typer-caret {
  display: inline-block;
  width: 0.06em;
  height: 0.8em;
  margin-left: 0.05em;
  vertical-align: -0.04em;
  background: currentColor;
  animation: caret-blink 1s steps(1) infinite;
}

.typer.is-typing .typer-caret { animation: none; }

@keyframes caret-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .typer-caret { animation: none; }
}

/* Hero intro: masked word reveal. JS wraps each headline and subtitle
   word in .word-clip (an overflow mask) > .word-inner, numbered --i,
   and drives three states on .home-hero:
   - armed:  words parked below their mask (115%)
   - .is-in: words rise into place, staggered; eyebrow fades up
   - .is-out (scrolled past ~38% of the viewport): words lift out the
     top (-145%) with a quick ease-in; scrolling back up drops them in
     from there.
   Transitions live on .is-in / .is-out only, so arming is instant. */
/* .word-clip / .word-inner base styles live in case-study.css. */
.home-hero.will-reveal .word-inner { transform: translateY(115%); }

.home-hero.will-reveal.is-in .word-inner {
  transform: none;
  transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(0.05s + var(--i) * 0.055s);
}

.home-hero.will-reveal.is-out .word-inner {
  transform: translateY(-145%);
  transition: transform 0.5s cubic-bezier(0.55, 0, 1, 0.45);
  transition-delay: calc(var(--i) * 0.03s);
}

/* Subtitle trails the headline: shorter rise, tighter stagger. */
.home-hero.will-reveal.is-in .subtitle .word-inner {
  transition-duration: 0.6s;
  transition-delay: calc(0.55s + var(--i) * 0.035s);
}

.home-hero.will-reveal.is-out .subtitle .word-inner {
  transition-duration: 0.4s;
  transition-delay: calc(0.1s + var(--i) * 0.02s);
}

/* Eyebrow: a simple fade up just ahead of the headline. */
.home-hero.will-reveal .hero-eyebrow {
  opacity: 0;
  transform: translateY(14px);
}

.home-hero.will-reveal.is-in .hero-eyebrow {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s,
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.15s;
}

.home-hero.will-reveal.is-out .hero-eyebrow {
  opacity: 0;
  transform: translateY(-14px);
  transition:
    opacity 0.4s cubic-bezier(0.55, 0, 1, 0.45),
    transform 0.4s cubic-bezier(0.55, 0, 1, 0.45);
}

/* ---------- Proof ticker ---------- */

/* Full-bleed strip just below the fold (the hero fills the first
   screen): the page clips horizontal
   overflow so the 100vw strip can't add a sideways scroll. The edges
   fade out through a mask (transparent for 100px, solid by 200px). */
body { overflow-x: clip; }

.ticker {
  width: 100vw;
  margin: 0 calc(50% - 50vw);
  padding: 20px 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0 100px, #000 200px calc(100% - 200px), transparent calc(100% - 100px) 100%);
  mask-image: linear-gradient(90deg, transparent 0 100px, #000 200px calc(100% - 200px), transparent calc(100% - 100px) 100%);
}

.ticker-track {
  display: flex;
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Every item (clones included) keeps its divider so the loop is even. */
.ticker-track li {
  padding: 0 48px;
  border-right: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  color: var(--muted);
}

.ticker-track li.is-highlight { color: var(--text); }

/* Animation only once the script has cloned the list. */
.ticker.is-running .ticker-track {
  animation: ticker 55s linear infinite;
}

@media (hover: hover) {
  .ticker.is-running .ticker-track:hover { animation-play-state: paused; }
}

@keyframes ticker {
  to { transform: translateX(-50%); }
}

/* Without motion (or the script) the items simply wrap. */
.ticker:not(.is-running) .ticker-track {
  flex-wrap: wrap;
  width: auto;
  row-gap: 12px;
}

/* Fades in the first time it scrolls into view, then stays (same soft
   fade as the project cards). */
.ticker.will-fade { opacity: 0; }

.ticker.will-fade.is-shown {
  opacity: 1;
  transition: opacity 0.9s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (max-width: 640px) {
  .ticker {
    -webkit-mask-image: linear-gradient(90deg, transparent 0 20px, #000 calc(20px + 10%) calc(90% - 20px), transparent calc(100% - 20px) 100%);
    mask-image: linear-gradient(90deg, transparent 0 20px, #000 calc(20px + 10%) calc(90% - 20px), transparent calc(100% - 20px) 100%);
  }
  .ticker-track li { padding: 0 24px; }
}

/* max-width is a fallback; home.js sets it to the headline's width. */
.home-hero .subtitle {
  max-width: 740px;
  margin-top: 36px;
  font-size: 24px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ---------- Home sections ---------- */

.home-section {
  padding-top: 128px;
  scroll-margin-top: 80px;
}

.home-section > h2 { color: var(--muted); }

/* Breathing room before the footer, matching the case studies' 140px. */
.home-section:last-child { padding-bottom: 140px; }

/* Extra room between the Selected Work label and the first card. */
#work > h2 { margin-bottom: 64px; }

/* ---------- Project cards ---------- */

/* One full-width 16:9 card per project, stacked: image, then a tags
   line, the project title and a one-sentence descriptor. Hovering the card slides a short
   closing phrase up into the end of the descriptor, in the project's accent
   (each card carries its case study's theme class). */
.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 64px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.work-card a {
  display: block;
  text-decoration: none;
}

.work-card .img-slot { aspect-ratio: 16 / 9; }

/* translateZ promotes the frame to its own layer so the rounded crop
   holds during the zoom (Safari otherwise flashes square corners). */
.work-card .img-slot { transform: translateZ(0); }

/* Long, gentle ease-in-out so the zoom glides in and back out instead
   of jumping at the start. */
.work-card .img-slot img {
  transition: transform 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.work-card a:hover .img-slot img { transform: scale(1.04); }

.work-body { padding: 16px 0 24px; }

/* Reset the case-study list spacing (section li: 32px lines, 16px
   gaps) that otherwise opens a big gap under the tags. */
.work-card .tags { margin: 0 0 6px; }
.work-card .tags li { margin: 0; line-height: 18px; }

.work-title {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* One-sentence descriptor under the title; the hover phrase ends it. */
.work-desc {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.5;
  color: var(--muted);
  /* Always one line: in a narrow window the end is clipped at the
     column edge rather than wrapping. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The phrase sits in a one-line mask and rises into it on hover. */
.work-suffix {
  display: inline-block;
  height: 1.5em;
  margin-left: 0.3em;
  overflow: hidden;
  vertical-align: bottom;
}

.work-suffix span {
  display: block;
  color: var(--accent);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.76, 0, 0.24, 1);
}

.work-card a:hover .work-suffix span,
.work-card a:focus-visible .work-suffix span { transform: none; }

.work-card a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: var(--radius);
}

/* No hover on touch screens: show the phrase inline from the start. */
@media (hover: none) {
  .work-desc { white-space: normal; }
  .work-suffix {
    display: inline;
    height: auto;
    overflow: visible;
  }
  .work-suffix span {
    display: inline;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .work-card .img-slot img,
  .work-suffix span { transition: none; }
  .work-card a:hover .img-slot img { transform: none; }
}

/* Scroll fade-in: JS arms .will-reveal on the grid (cards stay visible
   without JS) and adds .is-revealed to each card once it scrolls into
   view; it stays revealed. A plain, soft opacity fade, with the image
   leading and the text following just behind it. */
.work-grid.will-reveal .work-card .img-slot,
.work-grid.will-reveal .work-card .tags,
.work-grid.will-reveal .work-card .work-title,
.work-grid.will-reveal .work-card .work-desc { opacity: 0; }

.work-grid.will-reveal .work-card.is-revealed .img-slot,
.work-grid.will-reveal .work-card.is-revealed .tags,
.work-grid.will-reveal .work-card.is-revealed .work-title,
.work-grid.will-reveal .work-card.is-revealed .work-desc {
  opacity: 1;
  transition: opacity 0.9s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.work-card.is-revealed .tags { transition-delay: 0.08s; }
.work-card.is-revealed .work-title { transition-delay: 0.12s; }
.work-card.is-revealed .work-desc { transition-delay: 0.16s; }

@media (max-width: 640px) {
  .work-title { font-size: 20px; }
  .work-desc { font-size: 16px; }
}

/* ---------- How I work ---------- */

/* Stacking principles, after the reference. The label wrapper is as
   tall as the stack's scroll distance and pulled back up by a negative
   margin, so its sticky header (label + step number) stays put while
   the cards run past. Each card is sticky just below the header and
   opaque (page background), so the next one slides up over it; the
   script fades the outgoing card and rolls the number. */
.principles {
  /* Scroll distance per principle (each card's height). */
  --card-h: 44vh;
  position: relative;
  padding-top: 128px;
}

.principles-label {
  height: calc(var(--count) * var(--card-h) - var(--card-h) + 132px);
  margin-bottom: calc(var(--card-h) - var(--count) * var(--card-h) + 1rem);
  pointer-events: none;
}

.principles-sticky {
  position: sticky;
  top: calc(32vh - 170px);
  z-index: 10;
}

.principles-sticky h2 {
  margin: 0 0 80px;
  color: var(--muted);
}

/* "0" plus a digit that rolls up/down as the step changes; the mask
   height crops the roll. */
.principles-num {
  display: flex;
  align-items: baseline;
  height: 28px;
  overflow: hidden;
  font-size: 24px;
  font-weight: 700;
  line-height: 28px;
  letter-spacing: 0.14em;
  color: #93ffff;
  font-variant-numeric: tabular-nums;
}

.principles-num span { display: block; }

.principles-stack {
  margin: 0;
  padding: 0;
  list-style: none;
}

.principle {
  position: sticky;
  top: calc(32vh - 25px);
  display: flex;
  flex-direction: column;
  height: var(--card-h);
  /* Never shorter than its own text, or the next card would cover it
     before it fades. */
  min-height: fit-content;
  background: var(--bg);
  transform-origin: top;
  will-change: transform;
}

.principle h3 {
  max-width: 22ch;
  margin: 0 0 28px;
  font-size: clamp(40px, calc(2.21vw + 31.71px), 60px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.05em;
}

.principle p {
  max-width: 36ch;
  margin: 0;
  font-size: clamp(28px, calc(1.326vw + 23.03px), 40px);
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.principle-word { display: inline-block; }

@media (max-width: 768px) {
  .principles {
    margin-bottom: calc(80px - 80svh);
    overflow: clip;
  }
  .principles-label {
    height: calc(var(--count) * 100svh - 100svh + 132px);
    margin-bottom: calc(100svh - var(--count) * 100svh + 1rem);
  }
  .principle { height: 100svh; }
  .principle p { font-size: 24px; }
}

/* ---------- Experience ---------- */

/* Company on the left, role and dates stacked on the right, each row
   closed off by a hairline. */
.exp-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 48px;
  padding: 32px 0;
  border-bottom: 1px solid var(--line);
}

.exp-row:first-child { border-top: 1px solid var(--line); }

/* Cancel the case-study list spacing (section li: 16px gaps, 32px
   lines) on the homepage's row and chip lists. */
.exp-list > li,
.skills > li {
  margin: 0;
  line-height: inherit;
}

.exp-company {
  margin: 0;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.exp-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin: 0;
  text-align: right;
}

.exp-role {
  font-size: 18px;
  line-height: 1.4;
}

.exp-dates {
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Skills ---------- */

/* Wrapping chips on the surface fill with a hairline border, same
   12px radius as the stat cards. */
.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill {
  display: inline-block;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-family: inherit;
  font-size: 18px;
  line-height: 1.4;
  color: var(--text);
}

.skill--more:not([hidden]) { animation: skill-in 0.5s var(--ease-out) both; }

@keyframes skill-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* "+ More" / "– Less": same chip, muted until hovered. */
.skills-toggle {
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.skills-toggle:hover {
  color: var(--text);
  border-color: rgb(60, 60, 60);
}

.skills-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .skill--more:not([hidden]) { animation: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .work-card .img-slot { aspect-ratio: 4 / 3; }
}

@media (max-width: 640px) {
  .home-hero { padding: 104px 0 64px; }
  /* 88px overflows a phone screen. Size the type to the screen so
     "They recommend" (the longest line, about 7.6em wide) always fits
     inside the 20px gutters. */
  .home-hero h1 { font-size: clamp(26px, calc((100vw - 40px) / 8.2), 48px); }
  .hero-d { display: none; }
  .hero-m { display: inline; }
  .home-hero .subtitle { font-size: 20px; }
  .home-section { padding-top: 88px; }
  .work-grid { gap: 56px; }
  /* Stack company over role/dates on phones. */
  .exp-row {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 0;
  }
  .exp-company { font-size: 22px; }
  .exp-meta { align-items: flex-start; text-align: left; }
  .skill { padding: 10px 16px; font-size: 16px; }
}
