/* ===========================================================================
   FSDP memory estimator · Issue 01
   A quiet editorial reset. Light cream paper. Fraunces + Newsreader serifs.
   One accent: terracotta. No chrome. No icons. Hairline rules.
   Tufte data-ink discipline.
   =========================================================================== */

:root {
  /* ── colour ── */
  --paper:        #f4f0e8;
  --paper-deep:   #ece7dc;
  --surface:      #fbf8f1;
  --rule:         #d9d2c2;
  --rule-soft:    rgba(26, 24, 20, 0.08);

  --ink:          #1a1814;
  --ink-strong:   #0d0c0a;
  --ink-mute:     #6d6457;
  --ink-faint:    #a39a8a;

  --accent:       #c14a16;          /* terracotta */
  --accent-soft:  #e9b186;
  --accent-wash:  rgba(193, 74, 22, 0.08);
  --accent-deep:  #8d3209;

  --critical:     #9b2418;

  /* ── type ── */
  --display: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --serif:   "Newsreader", "Iowan Old Style", Georgia, serif;

  /* tracking & rhythm */
  --measure: 64ch;
  --gutter:  32px;
}

/* ── reset & defaults ── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  font-feature-settings: "ss01", "kern", "liga", "onum";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body::before {                      /* a faint paper texture */
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(26, 24, 20, 0.04) 1px, transparent 1px),
    radial-gradient(rgba(26, 24, 20, 0.025) 1px, transparent 1px);
  background-size: 4px 4px, 7px 7px;
  background-position: 0 0, 1px 2px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.75;
  mix-blend-mode: multiply;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 100ms;
}
a:hover { color: var(--accent); }

::selection { background: var(--accent); color: var(--paper); }

/* ── page ── */
.page {
  position: relative; z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 56px 96px;
}

/* ─────────────────── MASTHEAD ─────────────────── */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 56px;
  margin-bottom: 56px;
}
.kicker {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
  margin: 0 0 28px;
  position: relative;
  padding-left: 22px;
}
.kicker::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 14px; height: 1px;
  background: var(--accent);
}
.title {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  font-size: clamp(40px, 5.4vw, 78px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
  color: var(--ink-strong);
  max-width: 22ch;
}
.title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
}
.acc-dot { color: var(--accent); }

.lede {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-mute);
  max-width: 56ch;
  margin: 0;
  font-weight: 400;
}

/* ─────────────────── BODY GRID ─────────────────── */
.body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 64px;
  align-items: start;
}
@media (max-width: 880px) {
  .page { padding: 36px 24px 64px; }
  .body { grid-template-columns: 1fr; gap: 48px; }
}

/* ─────────────────── CONTROLS (LEFT) ─────────────────── */
.controls {
  position: sticky;
  top: 28px;
  align-self: start;
}
@media (max-width: 880px) { .controls { position: static; } }

.group {
  border: none;
  border-top: 1px solid var(--rule);
  padding: 14px 0 22px;
  margin: 0;
}
.group:first-child { border-top: none; padding-top: 0; }

.group legend {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 14;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 0;
  margin-bottom: 14px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
}
.row label {
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-mute);
  font-weight: 400;
}
.row.check { grid-template-columns: 1fr; }

/* Form controls — quiet, no fills */
.control {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-strong);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-faint);
  border-radius: 0;
  padding: 4px 2px;
  width: 92px;
  text-align: right;
  outline: none;
  font-variant-numeric: tabular-nums lining-nums;
  transition: border-color 120ms, color 120ms;
}
.control.wide { width: 100%; text-align: left; }
.control:focus { border-bottom-color: var(--accent); color: var(--accent); }
.control:hover:not(:focus) { border-bottom-color: var(--ink); }

/* input + trailing unit (e.g. "4 k") — keeps the underline contiguous */
.control-suffix {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  border-bottom: 1px solid var(--ink-faint);
  transition: border-color 120ms;
}
.control-suffix:focus-within { border-bottom-color: var(--accent); }
.control-suffix:hover:not(:focus-within) { border-bottom-color: var(--ink); }
.control.suffixed {
  border-bottom: none;
  width: 70px;
  padding-right: 0;
}
.control.suffixed:focus { color: var(--accent); }
.control-suffix .suffix {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-faint);
  padding-right: 2px;
}
.control-suffix:focus-within .suffix { color: var(--accent); }

/* Derived (read-only) value, e.g. "DP = GPUs / (TP × CP)" */
.row.derived label { font-size: 13.5px; }
.row.derived .hint {
  font-style: italic;
  color: var(--ink-faint);
  font-size: 12px;
  margin-left: 4px;
}
.derived-out {
  display: inline-block;
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-mute);
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--ink-faint);
  padding: 4px 2px;
  width: 92px;
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}
.derived-out.invalid { color: var(--critical); border-bottom-color: var(--critical); }

select.control {
  appearance: none;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 8 6'><path d='M1 1.5L4 4.5L7 1.5' stroke='%23a39a8a' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>")
    no-repeat right 0px center;
  padding-right: 16px;
  cursor: pointer;
}

/* Native optgroup labels — styled per-OS, but we can hint at typography. */
select.control optgroup {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  background: var(--paper);
}
select.control option {
  font-family: var(--serif);
  font-style: normal;
  color: var(--ink-strong);
  background: var(--paper);
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* checkbox */
.chk {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-style: italic;
  font-size: 14.5px;
  color: var(--ink-mute);
}
.chk input { position: absolute; opacity: 0; pointer-events: none; }
.chk span {
  width: 14px; height: 14px;
  border: 1px solid var(--ink-faint);
  background: transparent;
  position: relative;
  flex-shrink: 0;
  transition: all 120ms;
}
.chk input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
}
.chk input:checked + span::after {
  content: "";
  position: absolute;
  inset: 3px 3px 3px 3px;
  background: var(--paper);
}
.chk:hover span { border-color: var(--ink); }

/* ─────────────────── READOUT (RIGHT) ─────────────────── */
.readout { min-width: 0; }   /* prevent grid blowout */

/* Headline answer */
.headline {
  margin-bottom: 80px;
}
.overline {
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin: 0 0 22px;
  position: relative;
  padding-left: 22px;
}
.overline::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 14px; height: 1px;
  background: var(--ink-mute);
}
.figure {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: var(--display);
  line-height: 0.9;
  letter-spacing: -0.04em;
}
.number {
  font-size: clamp(96px, 14vw, 188px);
  font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  color: var(--ink-strong);
  font-variant-numeric: lining-nums;
}
.unit {
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 300;
  font-style: italic;
  font-variation-settings: "opsz" 14;
  color: var(--ink-mute);
}
.caption {
  font-family: var(--serif);
  font-size: 17.5px;
  font-style: italic;
  color: var(--ink-mute);
  margin: 18px 0 28px;
  max-width: 60ch;
  line-height: 1.45;
}
.caption strong {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-strong);
}
.caption .acc { color: var(--accent); font-weight: 500; font-style: normal; }

/* Fit line — single thin line of GPU memory */
.fit-line {
  position: relative;
  height: 2px;
  background: var(--ink-faint);
  margin: 12px 0 12px;
}
.fit-line-fill {
  position: absolute;
  top: -1px; left: 0;
  height: 4px;
  width: 0%;
  background: var(--accent);
  transition: width 380ms cubic-bezier(0.5, 0, 0, 1), background 200ms;
}
.fit-line-fill.warn { background: var(--accent); }
.fit-line-fill.bad  { background: var(--critical); }
.fit-line-marker {
  position: absolute;
  top: -5px; right: 0;
  width: 1px; height: 12px;
  background: var(--ink);
}
.fit-text {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
  margin: 0;
  display: flex;
  justify-content: space-between;
}
.fit-text .end { color: var(--ink); }

/* ── Sections ── */
.section {
  margin-bottom: 72px;
  padding-top: 36px;
  border-top: 1px solid var(--rule);
}
.sec-head { margin-bottom: 24px; }
.sec-head h2 {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 64;
  font-size: clamp(24px, 2.4vw, 30px);
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink-strong);
}
.sec-head .sec-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-mute);
  margin: 0;
}

/* Charts */
.bar-wrap { margin-bottom: 40px; }
.chart-box {
  position: relative;
  width: 100%;
}
.chart-box.bar    { height: 86px; }
.chart-box.tall   { height: 320px; }
.chart-box.square { height: 280px; }

/* Side-by-side: doughnut + ledger */
.duo {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 56px;
  align-items: center;
}
@media (max-width: 720px) {
  .duo { grid-template-columns: 1fr; gap: 32px; }
}
.duo-chart { display: flex; align-items: center; justify-content: center; }

/* Ledger table — minimal */
table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--serif);
  font-size: 15px;
}
table.ledger thead th {
  text-align: left;
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--rule);
}
table.ledger tbody td {
  padding: 11px 0;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink);
  font-weight: 400;
}
table.ledger tbody tr:last-child td { border-bottom: none; }
table.ledger .num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}
table.ledger tbody td:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}
.swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
table.ledger tfoot td {
  padding: 12px 0 0;
  border-top: 1px solid var(--ink);
  font-style: italic;
  color: var(--ink-strong);
  font-weight: 500;
}

/* ─────────────────── COLOPHON ─────────────────── */
.colophon {
  margin-top: 72px;
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-mute);
  text-align: center;
}
.colophon hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0 auto 28px;
  max-width: 220px;
}
.colophon p { margin: 0 auto; max-width: 60ch; line-height: 1.55; }
.acc { color: var(--accent); font-style: normal; font-weight: 500; }

/* ─────────────────── CALCULATION DETAILS ─────────────────── */
details#calc-details summary {
  cursor: pointer;
  list-style: none;
}
details#calc-details summary::-webkit-details-marker { display: none; }
details#calc-details summary.sec-head { margin-bottom: 0; }
details#calc-details[open] summary.sec-head { margin-bottom: 24px; }
details#calc-details summary h2::after {
  content: ' \25B8';
  font-size: 14px;
  color: var(--ink-faint);
  transition: transform 200ms;
}
details#calc-details[open] summary h2::after {
  content: ' \25BE';
}
#calc-details-body {
  margin-top: 8px;
}
.detail-section {
  margin-bottom: 20px;
}
.detail-section:last-child { margin-bottom: 0; }
.detail-section h3 {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 14;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}
pre.calc {
  margin: 0;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper-deep);
  padding: 14px 16px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* ─────────────────── ERROR ─────────────────── */
.error {
  color: var(--critical);
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  margin: 12px 0;
}

/* ── A single, very subtle entrance ── */
.headline, .section, .controls, .masthead {
  animation: fade 480ms ease-out both;
}
.masthead   { animation-delay: 0ms;  }
.controls   { animation-delay: 80ms; }
.headline   { animation-delay: 80ms; }
.section:nth-of-type(2) { animation-delay: 160ms; }
.section:nth-of-type(3) { animation-delay: 220ms; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
