/* lastsafevalue.com. Tokens are theme C from docs/style.md (paper, charcoal, safety orange, ink navy, ink red, meterHealthy). */
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed/BarlowCondensed-Medium.ttf") format("truetype"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed/BarlowCondensed-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed/BarlowCondensed-Bold.ttf") format("truetype"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 100 800; font-style: normal; font-display: swap; src: url("../fonts/jetbrains-mono/JetBrainsMono-VF.ttf") format("truetype"); }

:root {
  --paper: #F3EEDF;
  --paper-shade: #D9CFB3;
  --panel: #FAF4E1;
  --rule: #BDB59C;
  --charcoal: #24262A;
  --charcoal-soft: #5F6268;
  --orange: #FF5F00;
  --orange-text: #B83F00;      /* orange darkened to read as text on paper */
  --navy: #14234F;
  --red: #D01F36;
  --healthy: #3C8F2E;
  --healthy-text: #2D6E22;
  --link: #14234F;
  --extrap: rgba(255, 95, 0, 0.14);
  --font-head: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1A1C20;
    --paper-shade: #2A2D33;
    --panel: #22252A;
    --rule: #444851;
    --charcoal: #EDE8D8;
    --charcoal-soft: #A9A99F;
    --orange-text: #FF8A3D;
    --navy: #A9BBFF;
    --link: #A9BBFF;
    --healthy: #5DB84C;
    --healthy-text: #7ACB6B;
    --red: #FF6075;
    --extrap: rgba(255, 138, 61, 0.16);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--charcoal); font: 400 1.0625rem/1.65 var(--font-body); }
img, svg { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 0.15em; }
a:focus-visible, input:focus-visible, select:focus-visible, .table-wrap:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--charcoal); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

h1, h2, h3, .brand, .eyebrow { font-family: var(--font-head); font-weight: 700; line-height: 1.1; letter-spacing: 0.01em; }
h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); margin: 0.2em 0 0.3em; }
h2 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); margin: 0 0 0.6em; padding-top: 0.2em; border-top: 3px solid var(--charcoal); padding-top: 0.5em; }
h3 { font-size: 1.35rem; margin: 1.6em 0 0.4em; font-weight: 600; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: 0.35em; }

.site-header, main, .site-footer { padding-left: 16px; padding-right: 16px; }
main, .site-header, .site-footer { max-width: 50rem; margin-left: auto; margin-right: auto; }
.site-header { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: baseline; justify-content: space-between; padding-top: 0.9rem; padding-bottom: 0.9rem; }
.brand { font-size: 1.6rem; text-decoration: none; color: var(--charcoal); }
.site-header nav { display: flex; gap: 1.25rem; font-weight: 600; }
.site-footer { border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1rem; padding-bottom: 2.5rem; color: var(--charcoal-soft); font-size: 0.95rem; }

.eyebrow { display: block; text-transform: uppercase; letter-spacing: 0.08em; color: var(--orange-text); font-size: 1.1rem; margin: 0; }
.lead { font-size: 1.2rem; line-height: 1.55; }
.hero { padding: 1.5rem 0 1rem; }
.button { display: inline-block; background: var(--charcoal); color: var(--paper); font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.03em; text-decoration: none; padding: 0.55rem 1.1rem; border: 2px solid var(--charcoal); }
.button:hover { background: var(--orange); border-color: var(--orange); color: #121315; }
.button.ghost { background: transparent; color: var(--charcoal); }
.ep-head { padding: 1rem 0 0.5rem; }

.toc { background: var(--panel); border: 1px solid var(--rule); padding: 0.9rem 1.1rem 0.4rem; margin: 1.5rem 0 2.5rem; }
.toc-title { font-size: 1.2rem; border: 0; margin: 0 0 0.4em; padding: 0; }
.toc ol { padding-left: 1.4rem; margin-bottom: 0.6rem; }
section { margin: 0 0 2.75rem; scroll-margin-top: 1rem; }

.cards { display: grid; gap: 1.25rem; }
.card { display: block; background: var(--panel); border: 2px solid var(--charcoal); color: inherit; text-decoration: none; }
.card:hover, .card:focus-visible { border-color: var(--orange); }
.card img { display: block; width: 100%; }
.card-body { display: block; padding: 0.9rem 1rem 1rem; }
.card-title { display: block; font-family: var(--font-head); font-weight: 700; font-size: 1.6rem; line-height: 1.15; margin: 0.15rem 0 0.4rem; }
.card-text { display: block; margin-bottom: 0.6rem; }
.card-go { display: block; font-weight: 600; color: var(--link); }

.eq { font-family: var(--font-mono); font-size: 0.98rem; background: var(--panel); border-left: 5px solid var(--navy); padding: 0.7rem 1rem; overflow-x: auto; }
.eq sup, .eq sub { font-size: 0.75em; line-height: 0; }
.note { background: var(--panel); border: 1px solid var(--rule); border-left: 5px solid var(--charcoal); padding: 0.75rem 1rem; margin: 0 0 1.1rem; }
.note.answer { border-left-color: var(--orange); font-size: 1.12rem; }
.note.warn { border-left-color: var(--red); }
.cite { font-family: var(--font-mono); font-size: 0.8em; text-decoration: none; white-space: nowrap; }
.sec { color: var(--charcoal-soft); font-size: 0.9em; }
.tag { display: inline-block; font-family: var(--font-head); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; color: #121315; background: var(--orange); padding: 0 0.4rem; line-height: 1.5; }
.empty { color: var(--charcoal-soft); font-style: italic; }
.sources { list-style: none; padding-left: 0; }
.sources .n { font-family: var(--font-mono); font-weight: 700; }
.sources li { padding-left: 2.4rem; text-indent: -2.4rem; }
.sources li > * { text-indent: 0; }
.sources li { overflow-wrap: anywhere; }
.sources .used { display: block; color: var(--charcoal-soft); font-size: 0.95rem; }

/* tables scroll inside their own container, never the page */
.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--rule); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
caption { text-align: left; padding: 0.6rem 0.75rem; color: var(--charcoal-soft); font-size: 0.92rem; caption-side: bottom; }
th, td { padding: 0.45rem 0.7rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.02em; background: var(--paper-shade); white-space: nowrap; }
tbody th { font-weight: 600; white-space: nowrap; }
td.num { font-family: var(--font-mono); font-size: 0.9rem; text-align: right; white-space: nowrap; }
.ladder thead th:not(:first-child) { text-align: right; }
.ladder td.x { background: var(--extrap); color: var(--orange-text); font-style: italic; }
.ladder tr.extrap th { box-shadow: inset 4px 0 0 var(--orange); }

/* meter */
.meter { background: var(--panel); border: 2px solid var(--charcoal); padding: 1rem; margin: 0 0 1.25rem; }
.meter-controls { display: grid; gap: 1rem; margin-bottom: 1rem; }
.field label { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; margin-bottom: 0.3rem; }
select { width: 100%; font: inherit; padding: 0.5rem; background: var(--paper); color: var(--charcoal); border: 2px solid var(--charcoal); }
input[type=range] { width: 100%; height: 2rem; accent-color: var(--orange); }
.field output { display: block; margin-top: 0.1rem; }
output { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 400; color: var(--charcoal); }
.readouts { display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr; margin-bottom: 0.75rem; }
.readout { background: var(--paper); border: 1px solid var(--rule); padding: 0.5rem 0.7rem; }
.r-label { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; }
.r-value { display: block; font-family: var(--font-mono); font-weight: 700; font-size: 1.7rem; line-height: 1.2; }
.r-bar { display: block; height: 10px; background: var(--paper-shade); margin-top: 0.4rem; }
.r-bar span { display: block; height: 100%; width: 0; }
.dies .r-bar span { background: var(--red); }
.badge { background: var(--orange); color: #121315; font-weight: 600; padding: 0.55rem 0.8rem; margin: 0 0 0.75rem; }
.badge[hidden], .meter-app[hidden] { display: none; }
.chart { display: block; width: 100%; background: var(--paper); border: 1px solid var(--rule); }
.chart text { font-family: var(--font-mono); font-size: 15px; fill: var(--charcoal-soft); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--charcoal); stroke-width: 1.5; }
.chart .zone { fill: var(--extrap); }
.chart .zone-label { fill: var(--orange-text); font-weight: 700; }
.chart .c-walk { fill: none; stroke: var(--healthy); stroke-width: 3; }
.chart .c-dies { fill: none; stroke: var(--red); stroke-width: 3; }
.chart .d-walk { fill: var(--healthy); stroke: var(--paper); stroke-width: 1.5; }
.chart .d-dies { fill: var(--red); stroke: var(--paper); stroke-width: 1.5; }
.chart .marker { stroke: var(--charcoal); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .m-dot { stroke: var(--charcoal); stroke-width: 2; }
.chart .m-dies { fill: var(--red); }
.chart-key { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; font-size: 0.88rem; color: var(--charcoal-soft); margin: 0.6rem 0 0; }
.chart-key .k-walk { color: var(--healthy-text); font-weight: 600; }
.chart-key .k-dies { color: var(--red); font-weight: 600; }
.chart-key .k-extrap { color: var(--orange-text); }
.meter-nojs { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (min-width: 640px) {
  body { font-size: 1.125rem; }
  .meter-controls { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .chart text { font-size: 12px; }
}
@media print { .site-header nav, .meter, .skip { display: none; } }
