/* ==========================================================================
   Home — Domains #domains (24:21, H5: the brass plate) + the lyric manifesto.
   Ground: brass, four node lines at fifths. The panel and the plate sit on the
   section's own fifths (full bleed), so the plate's left and right edges are
   the 2/5 and 4/5 node lines. Tokens and anatomy live in css/home.css.
   ========================================================================== */

html[data-page="home"] .domains {
  --plate-ink: var(--ink);
  /* The section's four node lines (home.css .nodes, --n: 5), for surfaces that must
     be opaque yet let the lines run on through them. */
  --node-ink: rgb(16 24 58 / 0.06);
  --node-lines: linear-gradient(
    90deg,
    transparent calc(20% - 1px), var(--node-ink) calc(20% - 1px) 20%,
    transparent 20% calc(40% - 1px), var(--node-ink) calc(40% - 1px) 40%,
    transparent 40% calc(60% - 1px), var(--node-ink) calc(60% - 1px) 60%,
    transparent 60% calc(80% - 1px), var(--node-ink) calc(80% - 1px) 80%,
    transparent 80%
  );
  padding-bottom: calc(var(--section) * 1.15);
}

/* Afternoon light glancing across the brass (above the band, under the nodes). */
html[data-page="home"] .domains::before {
  content: "";
  position: absolute;
  inset: var(--band) 0 auto;
  height: min(1400px, 140svh);
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(56% 46% at 82% 30%, rgb(255 240 186 / 0.5), rgb(255 240 186 / 0) 72%),
    radial-gradient(40% 30% at 64% 62%, rgb(255 246 214 / 0.22), rgb(255 246 214 / 0) 70%);
}

/* --- Panel on the section's fifths --------------------------------------------- */
html[data-page="home"] .domains .domains__grid {
  position: relative;
}

html[data-page="home"] .domains .domains__panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: auto auto 1fr;
  align-items: start;
}

html[data-page="home"] .domains .domains__copy {
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 calc(var(--col-gap) * 1.6) 0 var(--gutter);
}

html[data-page="home"] .domains .domains__copy .h3 {
  font-size: clamp(1.5rem, 2.3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.015em;
  max-width: 16em;
}

html[data-page="home"]:is([lang="zh-Hans"], [lang="ja-JP"]) .domains .domains__copy .h3 {
  line-height: 1.3;
  letter-spacing: 0.01em;
}

html[data-page="home"] .domains .domains__copy .body-copy {
  max-width: 34em;
  line-height: 1.7;
}

html[data-page="home"]:is([lang="zh-Hans"], [lang="ja-JP"]) .domains .domains__copy .body-copy {
  line-height: 1.9;
}

/* --- The list: A–D, one row per mode --------------------------------------------- */
/* The kicker repeats the section eyebrow, so it is set as the caption of the figure
   A–D: a mono label on its own short rule, just above the first row. */
html[data-page="home"] .domains .domains__kicker {
  grid-column: 1 / 3;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: clamp(48px, 5.6vw, 88px) 0 0;
  padding: 0 calc(var(--col-gap) * 1.6) 0 var(--gutter);
  color: var(--fg-2);
}

html[data-page="home"] .domains .domains__kicker::before {
  content: "";
  flex: none;
  width: 28px;
  height: 1px;
  background: currentColor;
}

html[data-page="home"] .domains .domains__list {
  grid-column: 1 / 3;
  grid-row: 3;
  margin: 18px 0 0;
  padding: 0 calc(var(--col-gap) * 1.6) 24svh var(--gutter);
  list-style: none;
}

/* Letter | (tag above item): the n·m tag has its own row, so long items never run under it. */
html[data-page="home"] .domains .domains__list li {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  row-gap: 10px;
  align-items: end;
  align-content: start;
  column-gap: clamp(16px, 1.8vw, 28px);
  min-height: 24svh;
  padding: clamp(18px, 2vw, 28px) 0;
  border-top: 1px solid var(--line);
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

html[data-page="home"] .domains .domains__list li:last-child {
  border-bottom: 1px solid var(--line);
}

/* The rule above the active row reads as the string that is sounding. */
html[data-page="home"] .domains .domains__list li::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--d-scene) var(--ease-settle);
}

html[data-page="home"] .domains .domains__list li.is-active::before {
  transform: none;
}

/* Outline display letters (Archivo wdth 125 / 900, 1.2 px ink); the active one fills. */
html[data-page="home"] .domains .domains__list .timecode {
  grid-column: 1;
  grid-row: 1 / 3;
  font-family: var(--f-latin);
  font-size: clamp(4rem, 8.4vw, 9.5rem);
  font-weight: 900;
  font-stretch: 125%;
  font-variation-settings: "wdth" 125;
  font-synthesis: none;
  line-height: 0.78;
  letter-spacing: 0;
  color: transparent;
  -webkit-text-stroke: 1.2px var(--fg);
  transition: color var(--d-2) var(--ease-out);
  min-width: 0.86em;
}

html[data-page="home"] .domains .domains__list li.is-active .timecode {
  color: var(--fg);
}

@supports not (-webkit-text-stroke: 1px black) {
  html[data-page="home"] .domains .domains__list .timecode {
    color: var(--fg-4);
  }
}

html[data-page="home"] .domains .domains__item {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  padding-bottom: 0.1em;
  font-size: clamp(1.0625rem, 1.45vw, 1.4375rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--fg-2);
  text-wrap: balance;
  transition: color var(--d-2) var(--ease-out);
}

html[data-page="home"] .domains .domains__list li.is-active .domains__item {
  color: var(--fg);
}

html[data-page="home"] .domains .domains__nm {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
  font-family: var(--f-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-2);
  white-space: nowrap;
}

html[data-page="home"] .domains .domains__nm::before {
  content: "n·m ";
  opacity: 0.8;
}

/* --- The plate ---------------------------------------------------------------------- */
html[data-page="home"] .domains .plate {
  grid-column: 3 / 6;
  grid-row: 1 / 4;
  position: sticky;
  top: var(--bar-h);
  height: calc(100svh - var(--bar-h));
  display: grid;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
}

html[data-page="home"] .domains .plate__rig {
  display: grid;
  grid-template-columns: 2fr 1fr;
  align-items: stretch;
}

html[data-page="home"] .domains .plate__face {
  position: relative;
  justify-self: center;
  width: min(100%, calc(100svh - var(--bar-h) - 104px));
  aspect-ratio: 1;
  /* Polished brass: a warm sheen top-left, a slightly deeper fall-off bottom-right. */
  background:
    radial-gradient(80% 70% at 26% 18%, rgb(255 246 212 / 0.62), rgb(255 246 212 / 0) 62%),
    radial-gradient(70% 60% at 86% 92%, rgb(120 92 18 / 0.16), rgb(120 92 18 / 0) 70%),
    linear-gradient(150deg, #ecca5e 0%, #e2bf4d 52%, #d6b040 100%);
  box-shadow:
    inset 0 0 0 1px var(--plate-ink),
    inset 0 0 0 7px rgb(255 246 212 / 0.16),
    0 2px 0 rgb(255 246 212 / 0.35),
    0 44px 80px -44px rgb(92 74 18 / 0.6);
  transition: box-shadow var(--d-2) var(--ease-out);
  touch-action: pan-y;
}

/* Ruler ticks at tenths along the four rims, longer at the half. */
html[data-page="home"] .domains .plate__face::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  --tick: rgb(16 24 58 / 0.42);
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), var(--tick) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) top / 100% 13px no-repeat,
    linear-gradient(90deg, transparent calc(50% - 0.5px), var(--tick) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) bottom / 100% 13px no-repeat,
    linear-gradient(0deg, transparent calc(50% - 0.5px), var(--tick) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) left / 13px 100% no-repeat,
    linear-gradient(0deg, transparent calc(50% - 0.5px), var(--tick) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) right / 13px 100% no-repeat,
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 0.5px), var(--tick) calc(10% - 0.5px) 10%) top / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 0.5px), var(--tick) calc(10% - 0.5px) 10%) bottom / 100% 6px no-repeat,
    repeating-linear-gradient(180deg, transparent 0 calc(10% - 0.5px), var(--tick) calc(10% - 0.5px) 10%) left / 6px 100% no-repeat,
    repeating-linear-gradient(180deg, transparent 0 calc(10% - 0.5px), var(--tick) calc(10% - 0.5px) 10%) right / 6px 100% no-repeat;
}

html[data-page="home"] .domains .plate__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The bolt that holds the plate: (½, ½) is a node of every mode. */
html[data-page="home"] .domains .plate__bolt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(14px, 2.6%, 20px);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--plate-ink) 0 22%, #e8c65a 24% 58%, var(--plate-ink) 60% 70%, transparent 72%);
  box-shadow: 0 1px 0 rgb(255 246 212 / 0.5);
  pointer-events: none;
}

html[data-page="home"] .domains .plate.is-rim .plate__face {
  cursor: grab;
}

html[data-page="home"] .domains .plate.is-bowing .plate__face {
  cursor: grabbing;
}

html[data-page="home"] .domains .plate.is-bowed .plate__face {
  box-shadow:
    inset 0 0 0 1.5px var(--vermilion),
    inset 0 0 0 7px rgb(255 79 43 / 0.14),
    0 2px 0 rgb(255 246 212 / 0.35),
    0 44px 80px -44px rgb(92 74 18 / 0.6);
}

/* Readout (column 5): the mode and its nodal equation. */
html[data-page="home"] .domains .plate__readout {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  padding: 0 var(--gutter) 0 calc(var(--col-gap) * 1.2);
  color: var(--fg);
}

html[data-page="home"] .domains .plate__label {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  margin: 0;
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

html[data-page="home"] .domains .plate__letter {
  font-family: var(--f-latin);
  font-size: clamp(2.75rem, 4.4vw, 4.5rem);
  font-weight: 900;
  font-stretch: 125%;
  font-variation-settings: "wdth" 125;
  line-height: 0.8;
  letter-spacing: 0;
}

html[data-page="home"] .domains .plate__sep {
  color: var(--vermilion);
  font-weight: 700;
}

/* The nodal equation, set like a printed figure caption. */
html[data-page="home"] .domains .plate__formula {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-strong);
  font-family: "Newsreader", "Times New Roman", serif;
  font-size: clamp(0.875rem, 1.05vw, 1.0625rem);
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
  color: var(--fg);
}

html[data-page="home"] .domains .plate__formula i {
  font-style: italic;
}

html[data-page="home"] .domains .plate__formula small {
  display: block;
  margin-bottom: 6px;
  font-family: var(--f-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--fg-2);
}

/* --- Lyrics: the manifesto, filled like synced lyrics ---------------------------------- */
html[data-page="home"] .domains .lyrics {
  display: flex;
  flex-direction: column;
  gap: clamp(36px, 4.6vw, 76px);
  padding: clamp(24px, 3vw, 48px) var(--gutter) 0;
}

html[data-page="home"] .domains .lyrics__block {
  margin: 0;
  max-width: none;
}

/* One row per line; a long line wraps into even halves (no one-word orphans). */
html[data-page="home"] .domains .lyrics__row {
  display: block;
  text-wrap: balance;
}

html[data-page="home"][lang="ja-JP"] .domains .lyrics {
  word-break: auto-phrase;
  line-break: strict;
}

/* The response starts exactly on the first node line (W/5 = 20% of the padded box + 0.4 gutter − gutter). */
html[data-page="home"] .domains .lyrics__block--muted {
  margin-left: calc(20% - 0.6 * var(--gutter));
}

/* Inline and sliced: the fill runs across wrapped lines in reading order. Ink
   fills from the left behind a 0.3em vermilion front; the unfilled rest is the
   brass secondary ink (--fg-2, #5c4a12: 4.83:1 on #E2BF4D), so copy that has not
   been reached yet is still readable body text, not a decorative ghost. */
html[data-page="home"] .domains .lyrics__line {
  --fill: 0;
  --front: min(0.3em, calc(var(--fill) * 6em), calc((1 - var(--fill)) * 6em));
  display: inline;
  font-family: var(--f-serif);
  font-size: clamp(1.625rem, 3.4vw, 3.5rem);
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: 0.01em;
  color: transparent;
  background-image: linear-gradient(
    90deg,
    var(--ink) 0 calc(var(--fill) * 100% - var(--front)),
    var(--vermilion) 0 calc(var(--fill) * 100%),
    var(--fg-2) 0
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-box-decoration-break: slice;
  box-decoration-break: slice;
}

html[data-page="home"][lang="en"] .domains .lyrics__line {
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: -0.012em;
}

html[data-page="home"] .domains .lyrics__block--muted .lyrics__line {
  font-size: clamp(1.3125rem, 2.35vw, 2.5rem);
  line-height: 1.5;
}

html[data-page="home"][lang="en"] .domains .lyrics__block--muted .lyrics__line {
  font-style: italic;
  line-height: 1.24;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  html[data-page="home"] .domains .lyrics__line {
    color: var(--fg);
    background: none;
  }
}

/* --- ≤900: copy, then the plate pinned under the bar on tall phones while the rows
   scroll up beneath it, then the caption and the rows ------------------------------------ */
@media (max-width: 900px) {
  html[data-page="home"] .domains {
    --face: min(84vw, 42svh);
  }

  /* The afternoon light stays with the head: it has faded out before the plate,
     whose top sits ≥ 460 px into the section at every phone and tablet size. */
  html[data-page="home"] .domains::before {
    height: 380px;
    -webkit-mask-image: linear-gradient(#000 25%, transparent);
    mask-image: linear-gradient(#000 25%, transparent);
  }

  html[data-page="home"] .domains .domains__panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  html[data-page="home"] .domains .domains__copy {
    padding-inline: var(--gutter);
  }

  /* Pinned from the very top: its brass covers the strip under the bar too, so
     rows that pass beneath never reappear above it. It is opaque, so it carries
     the section's node lines through itself (it is full bleed: the fifths line up). */
  html[data-page="home"] .domains .plate {
    position: sticky;
    top: 0;
    z-index: 2;
    height: auto;
    padding: calc(var(--bar-h) + 8px) 0 8px;
    background: var(--node-lines), var(--bg);
  }

  /* Rows fade out under the pinned plate instead of being cut. */
  html[data-page="home"] .domains .plate::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 28px;
    background: var(--node-lines), var(--bg);
    -webkit-mask-image: linear-gradient(#000, transparent);
    mask-image: linear-gradient(#000, transparent);
    pointer-events: none;
  }

  html[data-page="home"] .domains .plate__rig {
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 8px;
  }

  html[data-page="home"] .domains .plate__face {
    width: var(--face);
  }

  html[data-page="home"] .domains .plate__readout {
    width: var(--face);
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
  }

  html[data-page="home"] .domains .plate__label {
    font-size: 0.75rem;
  }

  html[data-page="home"] .domains .plate__letter {
    font-size: 1.5rem;
  }

  /* One line under the plate: the equation reads straight across. */
  html[data-page="home"] .domains .plate__formula {
    min-width: 0;
    padding-top: 0;
    border-top: 0;
    text-align: right;
    font-size: min(0.8125rem, 3.3vw);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }

  html[data-page="home"] .domains .plate__formula :is(small, br) {
    display: none;
  }

  html[data-page="home"] .domains .domains__kicker {
    margin-top: 12px;
    padding-inline: var(--gutter);
  }

  html[data-page="home"] .domains .domains__list {
    margin-top: 8px;
    padding: 0 var(--gutter) calc((100svh - var(--bar-h) - var(--face)) * 0.42);
  }

  html[data-page="home"] .domains .domains__list li {
    min-height: calc((100svh - var(--bar-h) - var(--face) - 140px) * 0.72);
  }

  html[data-page="home"] .domains .domains__list .timecode {
    font-size: clamp(3.5rem, 17vw, 6rem);
  }

  html[data-page="home"] .domains .domains__item {
    font-size: 1.125rem;
  }

  html[data-page="home"] .domains .lyrics__block--muted {
    margin-left: calc(var(--gutter) * 1.5);
  }

  html[data-page="home"] .domains .lyrics__line {
    font-size: 1.5rem;
  }

  html[data-page="home"] .domains .lyrics__block--muted .lyrics__line {
    font-size: 1.25rem;
  }
}

/* Narrow phones: CJK lines step down a little so a long line wraps into two even halves. */
@media (max-width: 600px) {
  html[data-page="home"]:is([lang="zh-Hans"], [lang="ja-JP"]) .domains .lyrics__line {
    font-size: clamp(1.25rem, 5.6vw, 1.5rem);
  }

  html[data-page="home"]:is([lang="zh-Hans"], [lang="ja-JP"]) .domains .lyrics__block--muted .lyrics__line {
    font-size: 1.125rem;
  }
}

/* Short screens: nothing pins; rows are compact and scroll progress picks the mode. */
@media (max-width: 900px) and (max-height: 699px), (min-width: 901px) and (max-height: 599px) {
  html[data-page="home"] .domains .plate {
    position: relative;
    top: auto;
    height: auto;
    background: none;
  }

  html[data-page="home"] .domains .plate::after {
    display: none;
  }

  html[data-page="home"] .domains .domains__list {
    padding-bottom: 0;
  }

  html[data-page="home"] .domains .domains__list li {
    min-height: 0;
  }
}

@media (max-width: 900px) and (max-height: 699px) {
  html[data-page="home"] .domains {
    --face: min(92vw, 72svh);
  }

  html[data-page="home"] .domains .plate {
    padding-top: clamp(28px, 6vw, 48px);
  }
}

@media (min-width: 901px) and (max-height: 599px) {
  html[data-page="home"] .domains .plate__face {
    width: min(100%, 88svh);
  }
}

/* --- Reduced motion and the low tier ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html[data-page="home"] .domains .domains__list li::before {
    transition: none;
  }
}
