/* Ternus Day — daily card ("stock page"): one CSS grid, four canvases via data-fmt.
   No absolute positioning anywhere: text wraps, rows stretch, nothing can overlap. */

.card-body { background: #E8E8E6; display: grid; place-items: center; min-height: 100vh; }
.card-body.render { background: var(--bg); display: block; min-height: 0; }

.card {
  --pad: 64px;
  --w: 1080px; --h: 1350px;
  width: var(--w); height: var(--h);
  box-sizing: border-box;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  overflow: hidden;
  container-type: size;
}
.card[data-fmt="1x1"]  { --w: 1080px; --h: 1080px; }
.card[data-fmt="16x9"] { --w: 1200px; --h: 675px; --pad: 56px; }
.card[data-fmt="9x16"] { --w: 1080px; --h: 1920px; }

/* ---- masthead: black strip, condensed caps by tracking, not by a second face ---- */
.mast {
  background: var(--masthead-bg); color: var(--masthead-ink);
  padding: 40px var(--pad) 32px;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 24px; align-items: end;
}
.mast-brand { grid-column: 1; font-size: 34px; font-weight: 500; letter-spacing: 0.10em; text-transform: uppercase; line-height: 1; }
.mast-sub   { grid-column: 1; margin-top: 14px; font-size: 20px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--masthead-ink-2); line-height: 1.2; }
.mast-day   { grid-column: 2; grid-row: 1 / span 2; align-self: end; font-size: 20px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--masthead-ink); white-space: nowrap; }

/* ---- headline = the finding (FT rule), wraps freely ---- */
.headline { padding: 44px var(--pad) 0; }
.headline .h { margin: 0; font-size: 56px; font-weight: 500; line-height: 1.08; letter-spacing: var(--tracking-title); text-wrap: balance; max-width: 18ch; }
.headline .sub { margin: 14px 0 0; font-size: 26px; line-height: 1.35; color: var(--ink-2); max-width: 40ch; }

/* ---- the tape: fixed order, hairline rows, leader tinted ---- */
.tape { padding: 36px var(--pad) 0; display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.tape-head { display: grid; grid-template-columns: 1.1fr 1.2fr 0.9fr auto; column-gap: 24px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.tape-head .right { text-align: right; }
.rows { display: grid; grid-auto-rows: 1fr; }
.row {
  display: grid; grid-template-columns: 1.1fr 1.2fr 0.9fr auto; column-gap: 24px; align-items: center;
  padding: 0 12px; margin: 0 -12px;
  border-bottom: var(--hairline) solid var(--rule);
  min-height: 150px;
}
.row.lead { background: var(--tint); border-radius: var(--r-2); border-bottom-color: transparent; }
.row .who { font-size: 52px; font-weight: 500; letter-spacing: var(--tracking-title); line-height: 1; display: flex; align-items: center; gap: 14px; }
.row .who::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--c); flex: none; }
.row .same b { display: block; font-size: 30px; font-weight: 500; line-height: 1.15; }
.row .same span { display: block; font-size: 24px; color: var(--ink-3); line-height: 1.3; }
.row .era b { display: block; font-size: 30px; font-weight: 500; line-height: 1.15; }
.row .era span { display: block; font-size: 24px; color: var(--ink-3); line-height: 1.3; }
.row .val { font-size: 104px; font-weight: 500; line-height: 1; letter-spacing: -0.03em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- chart band (Observable Plot), only when the pipeline says so ---- */
.chart { padding: 28px var(--pad) 0; }
.chart figure { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; font-family: var(--font); }

/* ---- footnotes, stock-page dense ---- */
.foot { padding: 28px var(--pad) 44px; color: var(--ink-3); font-size: 20px; line-height: 1.5; display: grid; gap: 2px; }
.foot-line { display: flex; justify-content: space-between; gap: 24px; }
.foot-url { color: var(--ink); font-weight: 500; }

/* ---- 16:9: tighter vertical rhythm, three-up remains a table ---- */
.card[data-fmt="16x9"] .mast { padding: 26px var(--pad) 22px; }
.card[data-fmt="16x9"] .mast-brand { font-size: 26px; }
.card[data-fmt="16x9"] .mast-sub, .card[data-fmt="16x9"] .mast-day { font-size: 16px; margin-top: 8px; }
.card[data-fmt="16x9"] .headline { padding-top: 22px; }
.card[data-fmt="16x9"] .headline .h { font-size: 38px; }
.card[data-fmt="16x9"] .headline .sub { display: none; }
.card[data-fmt="16x9"] .tape { padding-top: 18px; }
.card[data-fmt="16x9"] .tape-head { padding-bottom: 8px; }
.card[data-fmt="16x9"] .row { min-height: 0; }
.card[data-fmt="16x9"] .row .who { font-size: 34px; }
.card[data-fmt="16x9"] .row .same b, .card[data-fmt="16x9"] .row .era b { font-size: 22px; }
.card[data-fmt="16x9"] .row .same span, .card[data-fmt="16x9"] .row .era span { font-size: 18px; }
.card[data-fmt="16x9"] .row .val { font-size: 64px; }
.card[data-fmt="16x9"] .foot { padding: 14px var(--pad) 22px; font-size: 15px; }
.card[data-fmt="16x9"] .foot-line:nth-child(2) { display: none; }
.card[data-fmt="16x9"] .chart { display: none; }

/* ---- 1:1 ---- */
.card[data-fmt="1x1"] .headline .h { font-size: 48px; }
.card[data-fmt="1x1"] .row { min-height: 0; }
.card[data-fmt="1x1"] .row .val { font-size: 88px; }
.card[data-fmt="1x1"] .row .who { font-size: 44px; }
.card[data-fmt="1x1"] .foot { font-size: 17px; }
.card[data-fmt="1x1"] .chart { display: none; }

/* ---- 9:16 Stories: content inside the safe zone (≈14 % top, 20 % bottom) ---- */
.card[data-fmt="9x16"] { grid-template-rows: 260px auto auto 1fr auto 340px; }
.card[data-fmt="9x16"]::before { content: ""; }
.card[data-fmt="9x16"]::after { content: ""; }
.card[data-fmt="9x16"] .headline .h { font-size: 64px; }
.card[data-fmt="9x16"] .row .val { font-size: 120px; }
.card[data-fmt="9x16"] .foot { padding-bottom: 0; }
