/* ldu/pages-emails.css: Daniel's Emails page (emails/index, _list, _grid, show; Milan, 13 Nov 2026). Layout only, tokens only (bin/ds-lint); every
   control is a DS one (.btn, .ldu-seg, .ldu-table, .ldu-dd, the shared search, .input / .textarea in a .field, .chip, .card), so nothing here paints
   a button. Nothing lifts on hover: a card and a row take the DS hover (fill and edge colour only).

   Index: one bar (search, three filters, List / Grid on the right), then a framed .ldu-table whose row is a link, or a grid of cards each showing
   the email scaled down (an iframe at 1 / 0.44 of its box, scaled to fit, so a wider card shows more of the email's ink margin, never a cut email).
   Under 720px a row folds into a card and the grid is one column. Show: the preview (P1) beside the facts and the words; under 1080px they stack. */

.eml { gap: 24px; container-type: inline-size; } /* the detail page stacks by the room it has (side panel open or not), not the window */
.eml__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.eml__filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.eml__search { flex: 1 1 18rem; max-width: 24rem; }
.eml__dd { flex: none; }
.eml__views { flex: none; }
.eml__count { margin: 0; font-size: var(--fs-ui); color: var(--ink-2); }
.eml__live { color: var(--ink-2); }

/* ── List ─────────────────────────────────────────────────────── */
.eml-row { position: relative; }
.eml-row__name { display: flex; flex-direction: column; gap: 2px; min-width: 16rem; color: var(--ink); text-decoration: none; }
.eml-row__title { font-weight: 600; }
.eml-row__code { margin-left: 4px; font-size: var(--fs-meta); font-weight: 500; color: var(--ink-2); }
.eml-row__sub { font-size: var(--fs-meta); font-weight: 400; line-height: 1.5; color: var(--ink-2); }
.eml-row__name::after { content: ""; position: absolute; inset: 0; } /* the whole row is the link */
.eml-row__name:focus-visible { outline: none; }
.eml-row:has(.eml-row__name:focus-visible) { outline: var(--ring-w) solid var(--ring); outline-offset: -2px; }
/* the short facts never wrap; the name column takes the rest (Milan, round 2: no squeezed columns) */
.ldu-table.eml__table td.eml-row__fact { color: var(--ink-2); white-space: nowrap; }
/* the same widths in every section's table, so the five tables line up; each fits its longest value ("Optional · off by default") */
.ldu-table.eml__table :is(th, td):nth-child(2) { width: 9rem; }
.ldu-table.eml__table :is(th, td):nth-child(3) { width: 12.5rem; }
.ldu-table.eml__table :is(th, td):nth-child(4) { width: 9rem; }

/* Narrower than the table needs (a phone, a tablet, a laptop with the side panel open): each row is a card, the facts on one line under the name.
   A container query, so it follows the room the list really has, not the window. */
.eml__section { container-type: inline-size; }
@container (max-width: 820px) {
  .ldu-table.eml__table { border: 0; background: transparent; overflow: visible; }
  .ldu-table.eml__table thead { display: none; }
  .ldu-table.eml__table :is(table, tbody) { display: block; }
  .ldu-table.eml__table tbody { display: grid; gap: 8px; }
  .ldu-table.eml__table tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 12px 16px;
    border: 1px solid var(--line); border-radius: var(--r-3); background: var(--bg-2);
  }
  .ldu-table.eml__table tbody :is(th, td):nth-child(n) { display: block; width: auto; padding: 0; border: 0; } /* :nth-child(n) outranks the table widths above */
  .ldu-table.eml__table tbody th { flex-basis: 100%; min-width: 0; margin-bottom: 4px; }
  .eml-row__name { min-width: 0; }
  .ldu-table.eml__table tbody td.eml-row__fact { font-size: var(--fs-meta); white-space: normal; }
  .ldu-table.eml__table tbody td + td::before { content: "·"; margin-right: 8px; color: var(--ink-3); }
  .ldu-table.eml__table tbody td:has(.chip)::before { content: none; }
}

/* ── Grid ─────────────────────────────────────────────────────── */
.eml__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.eml__grid > li { display: flex; min-width: 0; }
.eml-card { flex: 1; gap: 4px; min-width: 0; }
.eml-card__thumb {
  position: relative; display: block; aspect-ratio: 4 / 3; margin-bottom: 8px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-2); background: var(--ink); /* the email's own ink behind it while it loads */
  contain: layout paint; /* Milan, 13 Nov: the card's hover (the DS fill and edge, ldu/components.css) must not reach the picture: it neither re-lays out nor repaints */
}
.eml-card__frame {
  position: absolute; top: 0; left: 0; width: calc(100% / 0.44); height: calc(100% / 0.44); border: 0;
  transform: scale(0.44); transform-origin: 0 0; pointer-events: none;
  will-change: transform; /* its own layer, so it never re-renders on hover; the scrollbar is stopped by scrolling="no" in _grid (CSS cannot) */
}
.eml-card__name { font-weight: 600; color: var(--ink); }
.eml-card__sub { font-size: var(--fs-meta); color: var(--ink-2); }
.eml-card__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* ── Show ─────────────────────────────────────────────────────── */
.eml-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem); align-items: start; gap: 24px; }
.eml-detail__preview { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; } /* stays in view while the words are typed */
.eml-detail__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.eml-detail__sample { font-size: var(--fs-meta); font-weight: 500; color: var(--ink-2); }
.eml-detail__stage { display: flex; justify-content: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--ldu-r-xl); background: var(--ink); }
.eml-detail__frame { display: block; width: 100%; height: 760px; border: 0; }
.eml-detail__stage--phone .eml-detail__frame { width: 390px; max-width: 100%; }
.eml-detail__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.eml-facts { gap: 0; margin: 0; }
.eml-facts > div { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); }
.eml-facts > div:first-child { padding-top: 0; border-top: 0; }
.eml-facts > div:last-child { padding-bottom: 0; }
.eml-facts dt { font-size: var(--fs-meta); font-weight: 500; color: var(--ink-2); }
.eml-facts dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; font-size: var(--fs-ui); line-height: 1.5; color: var(--ink); }

.eml-copy { gap: 16px; }
.eml-copy__head { display: flex; flex-direction: column; gap: 4px; }
.eml-copy__title { margin: 0; font-family: var(--display); font-size: var(--fs-h3); font-weight: 600; line-height: 1.4; color: var(--ink); }
.eml-copy__lede { margin: 0; font-size: var(--fs-ui); line-height: 1.5; color: var(--ink-2); }
.eml-copy__foot { display: flex; justify-content: flex-end; gap: 8px; }
.eml-copy__plain { margin: 0; font-size: var(--fs-ui); line-height: 1.5; color: var(--ink-2); }

@container (max-width: 1000px) {
  .eml-detail { grid-template-columns: minmax(0, 1fr); }
  .eml-detail__preview { position: static; }
}

/* ── phone ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .eml__search { flex-basis: 100%; max-width: none; }
  .eml__views { width: 100%; }
  .eml__views > .ldu-seg__opt { flex: 1; }
  .eml__grid { grid-template-columns: minmax(0, 1fr); }
  .eml-copy__foot > .btn { flex: 1; }
}

/* ── sections (both views) ─────────────────────────────────────── */
.eml__section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.eml__h { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: var(--fs-h3); font-weight: 600; line-height: 1.4; color: var(--ink); }
.eml__h-count { font-size: var(--fs-ui); font-weight: 500; color: var(--ink-2); }
