/* Home · hero, selected work, case rows, knots, thumbnails (docs/home-spec.md). Needs tokens.css, shell.css, thread.css. */

/* The headline size reads the page width (100cqi) from here: main is full width with no side padding */
.home { container-type: inline-size; }
.home :where(p, h1, h3) { margin: 0; }

/* ---------- Hero (§2) ---------- */
.home-hero { padding: var(--rh-section) var(--in-page-x) var(--rh-chapter); }
.home-hero__role { margin-bottom: var(--rh-element); color: var(--color-text-secondary); }

/* Fluid in the Figma frame's proportion (Update 4 Nov 2026): 122 at 1440, smaller below */
.home-hero__title {
  font-size: min(122px, (100cqi - 80px) / 11.15);
  --hl-gap: 0.2541em;        /* --type-hero-word-space 31 / 122 */
  --ul-left: -0.0693em;      /* underline starts 8.46 left of "intuitive" */
  --ul-extra: 0.1185em;      /* 8.46 + 6 past "products." */
}

/* Desktop: 2 lines. .hl-row is a flex row, block-level, so "into intuitive products." starts a new line without a <br> */
.hl-br { display: none; }
.hl-row { display: flex; gap: var(--hl-gap); }

/* Chrome adds the −0.05em tracking after the last letter too; each word part gets it back (shell spec §5) */
.hl-word { margin-inline-end: 0.05em; }

/* "intuitive products.": one no-wrap unit, the gap from the token instead of a space */
.hl-mark {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  gap: var(--hl-gap);
  white-space: nowrap;
}

/* Mark · Underline: behind the letters, just below the descender. Figma box 974.5 / 642 / 339.3 wide */
.hl-underline {
  position: absolute;
  z-index: -1;
  left: var(--ul-left);
  top: calc(1.05em + 3px);
  width: calc(100% + var(--ul-extra));
  height: 12px;
  overflow: visible;
}
.hl-underline path {
  fill: none;
  stroke: var(--color-line-exact);
  stroke-width: var(--stroke-exact);
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
}

.home-hero__lead {
  max-width: var(--hero-lead);
  margin-top: var(--rh-block);
  color: var(--color-text-secondary);
}

/* ---------- Load motion, once (§9.1) ----------
   fill-mode both: nothing shows its end state before it starts. The thread's first build
   waits for the headline and underline (data-thread-wait), so the line starts at the settled underline. */
@keyframes home-rise {
  from { transform: translateY(0.25em); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes home-draw {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes home-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.home-hero__title { animation: home-rise 0.6s ease 0.2s both; }      /* all lines as one block */
.hl-underline { animation: home-draw 0.7s cubic-bezier(0.5, 0, 0.2, 1) 0.65s both; }
.home-hero__lead { animation: home-fade 0.8s ease 1.45s both; }

/* ---------- Selected work (§3) ---------- */
.home-work { padding: 0 var(--in-page-x); }

/* Label text starts at 120 / 84 / 60: past the knot column and the gutter */
.home-work__label {
  display: flex;
  justify-content: space-between;
  padding: 0 0 var(--rh-tight) calc(var(--knot-column) + var(--grid-gutter));
  color: var(--color-text-secondary);
}

.home-work__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-64);
}

/* ---------- Case row (§3.3) · desktop: knot · text · thumbnail ---------- */
.case-row {
  display: grid;
  grid-template-columns: var(--knot-column) minmax(0, 816fr) minmax(0, 440fr);
  column-gap: var(--grid-gutter);
  align-items: center;
  padding: var(--in-l-y) 0;
  color: inherit;
  text-decoration: none;
}

.case-row__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.case-row__tags { margin-bottom: var(--space-12); color: var(--color-text-secondary); }
.case-row__title { margin-bottom: var(--space-24); }

/* ---------- Knot (§4) · the shape and the Reached state are in story.css (moved 5 Nov 2026, cs1-spec §1) ---------- */
/* Stage B (§9.3): both ways, 0.4s */
.knot::before,
.knot::after { transition: background-color 0.4s ease, transform 0.4s ease; }
/* The row hovered / keyboard-focused (§9.4): case color, 20.7, like Reached */
.case-row:focus-visible .knot {
  --ol-line: var(--case);
  --ol-fill: var(--case);
  --ol-scale: 1.15;
}

/* ---------- Thumbnail (§5) ---------- */
.thumb {
  display: block;
  justify-self: end;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-screen);
  background: var(--color-bg-surface);
}
.thumb svg { display: block; width: 100%; height: 100%; }
.thumb svg * { vector-effect: non-scaling-stroke; }
.thumb__rest { stroke: var(--color-line-guide); stroke-width: var(--stroke-guide); }
.thumb__res {
  opacity: 0;
  stroke: var(--color-line-exact);
  stroke-width: var(--stroke-exact);
  transition: opacity 0.7s ease 0.2s; /* §9.3, the same both ways */
}
.thumb__color { fill: var(--case); stroke: none; }
/* Resolved fades in over Rest (Rest stays under it) once the row's knot is reached, or on keyboard focus */
.case-row:has(.knot[data-reached]) .thumb__res,
.case-row:focus-visible .thumb__res { opacity: 1; }

/* The button lifts and grows on row keyboard focus, with the shell's Button timing; never on reach (§9.4) */
.case-row:focus-visible .case-row__btn { transform: translateY(-2px) scale(1.05); }

/* ---------- Row hover, hover devices only (§9.4): a tap on touch only follows the link ---------- */
@media (hover: hover) {
  .case-row:hover .knot {
    --ol-line: var(--case);
    --ol-fill: var(--case);
    --ol-scale: 1.15;
  }
  .case-row:hover .thumb__res { opacity: 1; }
  .case-row:hover .case-row__btn { transform: translateY(-2px) scale(1.05); }
}

/* ---------- Nav mark on Home (§9.2) ----------
   The shell hides the mark with display: none the moment Work stops being current, which would cut the fade.
   On Home the Work mark stays in the layout and shows by opacity; home.js draws it along its path. */
.nav-links .nav-link[data-nav="work"] .nav-mark {
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease; /* fade-out when Work leaves */
}
.nav-links .nav-link[data-nav="work"][aria-current="page"] .nav-mark {
  opacity: 1;
  transition: none; /* appears at once; the draw is the motion */
}

/* ---------- Tablet · 601–900 ---------- */
@media (max-width: 900px) {
  /* 3 lines: "Turning complex" / "needs into" / "intuitive products." */
  .home-hero__title {
    font-size: min(80px, (100cqi - 64px) / 9.325);
    --hl-gap: 0.25em;        /* 20 / 80 */
    --ul-left: -0.075em;     /* 6 */
    --ul-extra: 0.15em;      /* 6 + 6 */
  }
  .hl-br { display: inline; }
  .hl-row { display: contents; }

  .home-work__list { gap: var(--space-48); }

  /* Knot column, then text with the thumbnail under it. Column gap 24, not the gutter (accepted exception) */
  .case-row {
    grid-template-columns: var(--knot-column) minmax(0, 1fr);
    column-gap: 24px;
    row-gap: var(--rh-block);
    align-items: start;
  }
  .knot { grid-column: 1; grid-row: 1; margin-top: 20px; } /* centre 32 below the top of the content */
  .case-row__text { grid-column: 2; grid-row: 1; }
  .thumb {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    width: min(480px, 100%);
    max-width: none;
  }
}

/* ---------- Mobile · up to 600 ---------- */
@media (max-width: 600px) {
  /* 42 at 390, shrinks below so "intuitive products." never breaks */
  .home-hero__title {
    font-size: min(42px, (100cqi - 40px) / 8.33);
    --hl-gap: 0.2857em;      /* 12 / 42 */
    --ul-left: -0.0714em;    /* 3 */
    --ul-extra: 0.15em;      /* 3 + 3.3 */
  }
  /* 326 as in Figma at 390, so 391–600 keep the 390 hero and the lead's first line stays clear of the line's start */
  .home-hero__lead { max-width: min(var(--hero-lead), 326px); }
  /* Update 6 Nov 2026 (Eden): room for the thread's 24 px corners under the lead (64 → 96) */
  .home-hero { padding-bottom: var(--space-96); }

  .home-work__list { gap: var(--space-40); }

  .case-row { column-gap: var(--grid-gutter); }
  .thumb { width: min(306px, 100%); }
}

/* ---------- Thread drawAll (QA screenshots): reached states at once, like the loop (thread.css) ---------- */
[data-thread-static] .knot::before,
[data-thread-static] .knot::after,
[data-thread-static] .knot > .ol,
[data-thread-static] .knot > .ol path,
[data-thread-static] .thumb__res { transition: none; }

/* ---------- Reduced motion (§9.5): no animations, no transitions, final state at once.
   Hover color changes stay; no lift or grow. Live: switching it while the page is open applies at once. ---------- */
@media (prefers-reduced-motion: reduce) {
  .home-hero__title,
  .hl-underline,
  .home-hero__lead { animation: none; }
  .knot::before,
  .knot::after,
  .knot > .ol,
  .knot > .ol path,
  .thumb__res,
  .nav-links .nav-link[data-nav="work"] .nav-mark { transition: none; }
  .case-row:focus-visible .case-row__btn,
  .case-row:hover .case-row__btn { transform: none; }
}
