/* styles/sections/stage-coverage.css
 * Mission on flat fern (About frames kVQQm 1440, KKqay 390, gRGMN 1920): the h2
 * (.display-heading), a deck at 17/26 (M), 20/30 (D, 640 measure) or 24/36 (W, 820 measure),
 * then the lifecycle coverage figure.
 *
 * Figure (W61Rkq, TiSZA, wlGQQ): one grid. The STAGE key, the stage list (ol) and the coverage
 * rows (dl: coding agents, Brief) sit in it through subgrid, so every cell lines up with its stage.
 * - M (390 frame TiSZA): the stages run as 84px rows in a column, the coding-agent cells and the
 *   Brief bar as two 64px columns beside them under a 52px key row. The Build cell is orange; the
 *   Brief bar is mist with its label set vertically. "CODING AGENTS" and "BUILD ONLY" break at
 *   the space, as drawn.
 * - From D (1440 and 1920 frames): a 150px margin of keys, seven stage columns (min 167 tall),
 *   then the coding-agent row and the Brief row, 56 each. Under the 1440 frame's 1280 figure the
 *   figure is that frame scaled to its own width (the margin, pads, type and swatch follow the
 *   figure's inline size), each value floored where it would stop reading (margin 112, pads 8,
 *   stage 16, description 12, mono 10), so all seven stages, BUILD ONLY and the Brief bar stay in
 *   view from 900. Long labels may wrap inside their cells at the narrow end.
 * Rules are 1px white at 25%, inset shadows inside each box; an opaque fill (orange, mist) covers
 * the row rule under it, as in the frames. Borders again in forced colours. */
@layer sections {
  .stage-coverage-section {
    padding-block: var(--section-3xl) var(--section-2xl);
  }

  .stage-coverage-section__inner {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: var(--space-32);
  }

  .stage-coverage-section__deck {
    margin: 0;
    font-size: var(--t-body-size);
    line-height: 26px;
    color: var(--white-85);
  }

  .stage-coverage {
    container-type: inline-size;
    margin: 0;
  }

  .stage-coverage__grid {
    --sc-rule: var(--white-25);

    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px 64px;
    grid-template-rows: 52px auto;
  }

  .stage-coverage__key {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    line-height: 12px;
    letter-spacing: 0.8px;
    color: var(--mist);
  }

  .stage-coverage__key--stage {
    display: flex;
    align-items: center;
    grid-area: 1 / 1;
    color: var(--white-70);
    box-shadow: inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule);
  }

  .stage-coverage__stages {
    grid-area: 2 / 1;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .stage-coverage__stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
    align-items: baseline;
    gap: 6px 10px;
    min-height: 84px;
    padding: 14px 12px 14px 0;
  }

  .stage-coverage__stage + .stage-coverage__stage {
    box-shadow: inset 0 1px var(--sc-rule);
  }

  .stage-coverage__stage:last-child {
    box-shadow: inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule);
  }

  .stage-coverage__index {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    line-height: 13px;
    letter-spacing: 0.8px;
    color: var(--mist);
  }

  .stage-coverage__name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 21px;
    letter-spacing: -0.2px;
    color: var(--white);
  }

  .stage-coverage__desc {
    grid-column: 1 / -1;
    font-size: 13px;
    line-height: 18px;
    color: var(--white-80);
    /* Short label: balanced, so it does not end on one word (BRI-7805 J14) */
    --frame-wrap-style: balance;
    text-wrap-style: balance;
  }

  /* The dl and each of its rows pass the grid through: on M a row is a column (key on top, cells
     below); from D it is a row (key in the margin, cells under the stages). */
  .stage-coverage__rows {
    grid-area: 1 / 2 / 3 / 4;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-rows: subgrid;
    margin: 0;
  }

  .stage-coverage__row {
    grid-row: 1 / 3;
    display: grid;
    grid-template-rows: subgrid;
  }

  .stage-coverage__key--agents,
  .stage-coverage__key--brief {
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule), inset 1px 0 var(--sc-rule);
  }

  .stage-coverage__key--agents {
    gap: var(--space-4);
    padding: 0 8px;
  }

  .stage-coverage__key--brief {
    align-items: center;
  }

  .stage-coverage__swatch {
    width: 8px;
    height: 8px;
    background: var(--orange);
  }

  .stage-coverage__agents,
  .stage-coverage__brief {
    margin: 0;
  }

  .stage-coverage__agents {
    display: flex;
    flex-direction: column;
  }

  .stage-coverage__cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 84px;
    padding: 0 6px;
    background: var(--white-6);
    box-shadow: inset 1px 0 var(--sc-rule);
  }

  .stage-coverage__cell + .stage-coverage__cell {
    box-shadow: inset 1px 0 var(--sc-rule), inset 0 1px var(--sc-rule);
  }

  .stage-coverage__cell:last-child {
    box-shadow: inset 1px 0 var(--sc-rule), inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule);
  }

  .stage-coverage__cell--on {
    background: var(--orange);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    line-height: 12px;
    letter-spacing: 0.8px;
    text-align: center;
    color: var(--ink);
  }

  .stage-coverage__brief {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mist);
    box-shadow: inset 1px 0 var(--sc-rule);
  }

  .stage-coverage__bar {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    line-height: 13px;
    letter-spacing: 0.8px;
    color: var(--fern);
    writing-mode: vertical-rl;
  }

  .stage-coverage__caption {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding-top: var(--space-20);
    font-size: 14px;
    line-height: 20px;
    color: var(--mist);
  }

  .stage-coverage__caption-title {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    line-height: 14px;
    letter-spacing: 0.9px;
  }

  @media (min-width: 900px) {
    .stage-coverage {
      --sc-margin: clamp(112px, 11.72cqi, 150px);
      --sc-pad: clamp(8px, 1.25cqi, 16px);
      --sc-name: clamp(16px, 1.875cqi, 24px);
      --sc-desc: clamp(12px, 1.094cqi, 14px);
      --sc-mono: clamp(10px, 0.9375cqi, 12px);
      --sc-mono-ls: clamp(0.8px, 0.07032cqi, 0.9px);
      --sc-swatch: clamp(8px, 0.7813cqi, 10px);
    }

    .stage-coverage__grid {
      grid-template-columns: var(--sc-margin) repeat(7, minmax(0, 1fr));
      grid-template-rows: minmax(167px, auto) 56px 56px;
    }

    .stage-coverage__break {
      display: none;
    }

    .stage-coverage__key {
      font-size: var(--sc-mono);
      line-height: round(nearest, 1.2em, 1px);
      letter-spacing: var(--sc-mono-ls);
    }

    .stage-coverage__key--stage {
      align-items: flex-start;
      padding-top: var(--space-24);
    }

    .stage-coverage__stages {
      grid-area: 1 / 2 / 2 / -1;
      display: grid;
      grid-template-columns: subgrid;
    }

    .stage-coverage__stage,
    .stage-coverage__stage + .stage-coverage__stage {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 14px;
      min-height: 0;
      padding: 22px var(--sc-pad) 26px;
      box-shadow: inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule), inset 1px 0 var(--sc-rule);
    }

    .stage-coverage__stage:last-child {
      box-shadow: inset 0 1px var(--sc-rule), inset 0 -1px var(--sc-rule), inset 1px 0 var(--sc-rule), inset -1px 0 var(--sc-rule);
    }

    .stage-coverage__index {
      font-size: var(--sc-mono);
      line-height: round(nearest, 1.2em, 1px);
      letter-spacing: var(--sc-mono-ls);
    }

    .stage-coverage__name {
      font-size: var(--sc-name);
      line-height: round(nearest, 1.05em, 1px);
      letter-spacing: -0.01em;
    }

    .stage-coverage__desc {
      font-size: var(--sc-desc);
      line-height: round(nearest, 1.45em, 1px);
    }

    .stage-coverage__rows {
      grid-area: 2 / 1 / 4 / -1;
    }

    .stage-coverage__row {
      grid-row: auto;
      grid-column: 1 / -1;
      grid-template-columns: subgrid;
      grid-template-rows: none;
    }

    .stage-coverage__key--agents,
    .stage-coverage__key--brief {
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      padding: 0;
      box-shadow: inset 0 -1px var(--sc-rule);
    }

    .stage-coverage__key--agents {
      gap: var(--sc-swatch);
    }

    .stage-coverage__swatch {
      flex: none;
      width: var(--sc-swatch);
      height: var(--sc-swatch);
    }

    .stage-coverage__agents {
      grid-column: 2 / -1;
      display: grid;
      grid-template-columns: subgrid;
    }

    .stage-coverage__cell,
    .stage-coverage__cell + .stage-coverage__cell {
      justify-content: flex-start;
      min-height: 0;
      padding: 0 var(--sc-pad);
      box-shadow: inset 1px 0 var(--sc-rule), inset 0 -1px var(--sc-rule);
    }

    .stage-coverage__cell:last-child {
      box-shadow: inset 1px 0 var(--sc-rule), inset -1px 0 var(--sc-rule), inset 0 -1px var(--sc-rule);
    }

    .stage-coverage__cell--on {
      font-size: var(--sc-mono);
      line-height: round(nearest, 1.2em, 1px);
      letter-spacing: var(--sc-mono-ls);
    }

    .stage-coverage__cell.stage-coverage__cell--on {
      box-shadow: inset 1px 0 var(--sc-rule);
    }

    .stage-coverage__brief {
      grid-column: 2 / -1;
      justify-content: flex-start;
      padding: 0 var(--sc-pad);
    }

    .stage-coverage__bar {
      font-size: var(--sc-mono);
      line-height: round(nearest, 1.2em, 1px);
      letter-spacing: var(--sc-mono-ls);
      writing-mode: horizontal-tb;
    }

    .stage-coverage__caption {
      flex-direction: row;
      gap: var(--space-8);
      padding-top: var(--space-24);
      line-height: 17px;
    }

    .stage-coverage__caption-title {
      flex: none;
      line-height: 18px;
    }
  }

  @media (min-width: 900px) {
    .stage-coverage-section__inner {
      gap: var(--space-40);
    }

    .stage-coverage-section__deck {
      max-width: 640px;
      font-size: var(--t-body-lg-size);
      line-height: 30px;
    }
  }

  @media (min-width: 1680px) {
    .stage-coverage-section__deck {
      max-width: 820px;
      font-size: 24px;
      line-height: 36px;
    }

    .stage-coverage__name {
      font-size: 28px;
      line-height: 29px;
      letter-spacing: -0.28px;
    }
  }

  @media (forced-colors: active) {
    .stage-coverage__grid {
      border-block: 1px solid;
    }

    .stage-coverage__stage,
    .stage-coverage__cell,
    .stage-coverage__brief {
      border: 1px solid;
    }
  }
}
