/* sim.css — layout for the cost-simulator pages, on top of tokens.css.
 * Register: an instrument you operate, not a document; hierarchy by type and space, few boxes. */
html { font-family: var(--font-sans); font-size: 17px; }
body { margin: 0; background: var(--bg0); color: var(--ink); line-height: var(--lh); }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
h1 { font-size: 2rem; line-height: 1.15; margin: .5rem 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 2rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .35rem; }
p { max-width: 72ch; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 72ch; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.privacy { border-left: 3px solid var(--accent); padding: .35rem .9rem; color: var(--muted); margin: 1rem 0 1.5rem; max-width: 72ch; }

.layout { display: grid; grid-template-columns: 320px 1fr; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.controls { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .9rem; }
/* stage 2c: the column is taller than a laptop screen (the notes under the start-size slider sat below the fold while it was pinned), so while pinned it scrolls inside itself */
@media (min-width: 901px) { .controls { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 0 10px 0 8px; margin: 0 -10px 0 -8px; } }
@media (max-width: 900px) { .controls { position: static; } }
.ctl { display: flex; flex-direction: column; gap: .2rem; }
.ctl-l { display: flex; justify-content: space-between; align-items: baseline; font-size: .95rem; }
.ctl-l b { font-variant-numeric: tabular-nums; font-weight: 600; }
.ctl-h { font-size: .85rem; color: var(--muted); }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctl select, .ctl input[type=number], .ctl input[type=text] { background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .45rem .6rem; font-size: 1rem; font-family: inherit; }
.ctl-group { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .2rem; }
.ctl-group > .ctl-gt { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.5rem; margin: 1rem 0 1.5rem; }
.kpi-v { font-size: 1.9rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-l { color: var(--muted); font-size: .92rem; margin-top: .15rem; }
.kpi-s { font-size: .85rem; color: var(--muted); }

.chart { position: relative; height: 340px; margin: .5rem 0 1rem; }
.chart.short { height: 220px; }
.events { list-style: none; padding: 0; margin: .25rem 0 1rem; font-size: .92rem; color: var(--muted); }
.events li::before { content: "·"; margin-right: .5rem; }

.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin: .5rem 0 1rem; max-width: 640px; }
.breakdown th, .breakdown td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.breakdown td.n, .breakdown th.n { text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .5rem; vertical-align: middle; }

.explain { margin: .35rem 0; }
.explain summary { cursor: pointer; color: var(--accent); }
.explain p { margin: .4rem 0 .4rem 1rem; font-size: .95rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1.5rem 0 1rem; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 1.05rem; padding: .5rem .9rem; cursor: pointer; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; }
.drop p { margin: .25rem 0; }
.linkish { color: var(--accent); cursor: pointer; text-decoration: underline; }
button.linkish { background: none; border: 0; padding: 0; font: inherit; }
.drop button.sample { background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .92rem; cursor: pointer; }
.drop button.sample:hover { border-color: var(--accent); color: var(--accent); }
.drop button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.presets { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .25rem 0 .5rem; }
.presets button { background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .92rem; cursor: pointer; }
.presets button.on { border-color: var(--accent); color: var(--accent); }
.preset-note { margin: 0 0 .75rem; }
.allow { margin: 1rem 0; max-width: 72ch; }
.allow .big { font-size: 1.4rem; font-weight: 600; }
.band { display: inline-block; height: 10px; background: var(--bg2); border-radius: 5px; width: 100%; max-width: 420px; position: relative; overflow: hidden; vertical-align: middle; }
.band > span { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: .85; }

.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.col { border-top: 3px solid var(--line); padding-top: .75rem; }
.col h3 { margin-top: 0; }
.col .kpi-v { font-size: 1.6rem; }
.col .chart { height: 200px; }
.pill { display: inline-block; font-size: .8rem; padding: .1rem .5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); margin-left: .4rem; vertical-align: middle; }
footer { margin-top: 3rem; color: var(--muted); font-size: .9rem; max-width: 72ch; }

/* language toggle, errors, the "how this is computed" section */
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.langs { display: flex; gap: .35rem; margin-top: .6rem; }
.lang { display: inline-flex; align-items: center; gap: .45rem; background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem .3rem .6rem; font: inherit; font-size: .92rem; cursor: pointer; }
.lang.on { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.lang:focus-visible, .tabs button:focus-visible, .presets button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.flag { display: inline-flex; align-items: center; }
.flag svg { display: block; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }
.err { color: var(--err); max-width: 72ch; }
.how h2 { scroll-margin-top: 1rem; outline: none; }
.how ul { max-width: 72ch; padding-left: 1.25rem; }
.how li { margin: .35rem 0; }
.bands { border-collapse: collapse; font-variant-numeric: tabular-nums; margin: .5rem 0 1rem; max-width: 520px; width: 100%; }
.bands th, .bands td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--line); }
.bands th { font-weight: 600; color: var(--muted); font-size: .92rem; }
footer p { margin: .4rem 0; }
@media (max-width: 480px) { .kpi-v { font-size: 1.6rem; } h1 { font-size: 1.6rem; } }
/* a long translated option must not widen the page: grid items and selects may shrink */
.layout > * { min-width: 0; }
.ctl select { width: 100%; min-width: 0; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .breakdown th, .breakdown td { padding: .3rem .25rem; font-size: .88rem; }
  .breakdown td:first-child { overflow-wrap: anywhere; }
  .bands th, .bands td { padding: .3rem .25rem; }
}
/* a money value never breaks inside (the Portuguese "US$ 10,77" is wider); the range wraps at its arrow */
.kpi-v { overflow-wrap: normal; }   /* break only at spaces (around the arrow), never inside a number */
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.langs { margin-bottom: .6rem; }

/* stage 2: the cache-line calibration, the compaction note, the per-model and per-thread tables */
.ctl-note { margin: .15rem 0 0; }
.startsize { margin: .75rem 0 1rem; padding: .6rem .8rem; max-width: 72ch; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.startsize p { margin: 0 0 .35rem; }
.startsize button.sample { margin-top: .15rem; }
.cacheline { margin: 1.25rem 0; max-width: 72ch; }
.cacheline h4 { font-size: 1rem; margin: 0 0 .35rem; }
.cacheline textarea { display: block; width: 100%; box-sizing: border-box; background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .5rem .6rem; font: inherit; font-size: .92rem; line-height: 1.4; resize: vertical; }
.cacheline textarea::placeholder { color: var(--muted); }
.cacheline textarea:focus-visible, .cacheline button:focus-visible, .startsize button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cacheline .cache-read { max-width: 640px; margin-top: .75rem; }
.cacheline .cache-read caption { text-align: left; padding: 0 .5rem .25rem; }
.cacheline ul.plan { margin: .2rem 0 .6rem; padding-left: 1.25rem; }
.cacheline button.sample, .startsize button.sample { background: var(--bg1); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .92rem; cursor: pointer; }
.cacheline button.sample:hover, .startsize button.sample:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 480px) {
  /* five narrow columns: smaller type and padding, numbers never break, so a long translated header cannot widen the page */
  .breakdown.models th, .breakdown.threads th { font-size: .74rem; padding: .3rem .15rem; }
  .breakdown.models td, .breakdown.threads td { font-size: .8rem; padding: .3rem .15rem; }
  .breakdown.models td:first-child, .breakdown.threads td:first-child { overflow-wrap: normal; }
  .breakdown.models td.n, .breakdown.threads td.n, .breakdown.models th.n, .breakdown.threads th.n { white-space: nowrap; }
}

/* stage 2b: the standing-context card, the start-size landmarks and the window guard */
.standing { margin: 1rem 0 1.5rem; padding: .25rem 0 0; border-top: 1px solid var(--line); }
.standing h3 { margin-top: .75rem; }
.standing .kpis { margin: .5rem 0 .5rem; }
.standing-foot { margin: 0 0 .5rem; }
.landmarks ul { list-style: none; margin: .35rem 0 0; padding: 0; }
.landmarks li { margin: .15rem 0; }
.landmarks p { margin: .35rem 0 0; }
.ctl-guard { margin: .25rem 0 0; padding-left: .6rem; border-left: 3px solid var(--err); color: var(--err); }
.ctl-clamp { margin: .25rem 0 0; padding-left: .6rem; border-left: 3px solid var(--accent); }

/* stage 2c: the compaction-loop warning, the window note, the card's two sentences, the calibration field */
.ctl-loop { margin: .25rem 0 0; padding-left: .6rem; border-left: 3px solid var(--warn); }
.ctl-window { margin: .25rem 0 0; padding-left: .6rem; border-left: 3px solid var(--line); color: var(--muted); }
.chart-loop { margin: .25rem 0; padding-left: .6rem; border-left: 3px solid var(--warn); }
.standing-extremes, .standing-lever { margin: .35rem 0; }
/* the calibration percent is a labelled field (a box, a visible example, a % sign), not a gap in a sentence */
.calib-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.pctfield { display: inline-flex; align-items: center; background: var(--bg1); border: 1px solid var(--muted); border-radius: var(--radius-sm); }
.pctfield:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.allow .pctfield input[type=number] { width: 5.5rem; background: transparent; color: var(--ink); border: 0; font: inherit; font-size: 1rem; padding: .4rem .2rem .4rem .6rem; }
.allow .pctfield input[type=number]::placeholder { color: var(--muted); opacity: 1; }
.allow .pctfield input[type=number]:focus { outline: none; }
.pctfield .suffix { padding: 0 .6rem 0 .15rem; color: var(--muted); }
