/* Run the Macros — shared stylesheet
   Palette: slate ink, chalk paper, citron accent. Measurement-scale identity. */

:root {
  --paper:      #F5F6F0;
  --surface:    #FCFCF9;
  --surface-2:  #EFF1E8;
  --ink:        #1B2430;
  --ink-soft:   #3E4A3A;
  --muted:      #5F6757;
  --hairline:   #DFE2D4;
  --accent:     #63741A;
  --accent-ink: #4B5911;
  --accent-wash:#E8EDCB;
  --on-accent:  #FCFCF9;
  --good:       #14705A;
  --warn:       #9A5B12;
  --alert:      #A33327;
  --band:       #C9D2AE;
  --track:      #E9ECDF;
  --fat:        #B79753;
  --shadow:     0 1px 2px rgba(27,36,48,.06), 0 8px 24px -12px rgba(27,36,48,.18);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body:    "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 66ch;
  --radius: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #12150F;
    --surface:    #1A1E16;
    --surface-2:  #232819;
    --ink:        #E9EBE0;
    --ink-soft:   #C6CBB8;
    --muted:      #969C88;
    --hairline:   #333A28;
    --accent:     #BDD24A;
    --accent-ink: #D2E465;
    --accent-wash:#2A3117;
    --on-accent:  #12150F;
    --good:       #5FC5A5;
    --warn:       #D8A24E;
    --alert:      #E28C7F;
    --band:       #414D28;
    --track:      #232819;
    --fat:        #C7A55E;
    --shadow:     0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper:      #12150F;
  --surface:    #1A1E16;
  --surface-2:  #232819;
  --ink:        #E9EBE0;
  --ink-soft:   #C6CBB8;
  --muted:      #969C88;
  --hairline:   #333A28;
  --accent:     #BDD24A;
  --accent-ink: #D2E465;
  --accent-wash:#2A3117;
  --on-accent:  #12150F;
  --good:       #5FC5A5;
  --warn:       #D8A24E;
  --alert:      #E28C7F;
  --band:       #414D28;
  --track:      #232819;
  --fat:        #C7A55E;
  --shadow:     0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

/* ---------- shell ---------- */

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 20px;
}

.narrow { max-width: var(--measure); }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding-block: 14px;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.015em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.wordmark .tick {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(1px);
}

.mainnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 500;
}

.mainnav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding-block: 3px;
  border-bottom: 2px solid transparent;
}

.mainnav a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.mainnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- type ---------- */

h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--ink);
  text-wrap: balance;
  letter-spacing: -.02em;
  margin: 0;
}

h1 { font-size: clamp(31px, 5.2vw, 46px); font-weight: 700; line-height: 1.1; }
h2 { font-size: clamp(23px, 3.2vw, 29px); font-weight: 650; line-height: 1.2; }
h3 { font-size: 20px; font-weight: 650; line-height: 1.3; }
h4 { font-size: 16px; font-weight: 650; }

p { margin: 0; }

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

.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.lede {
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.prose { display: flex; flex-direction: column; gap: 20px; max-width: var(--measure); }
.prose h2 { margin-top: 22px; }
.prose h3 { margin-top: 12px; }

.plain-say {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: 16px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.plain-say .eyebrow { color: var(--accent-ink); }

/* ---------- page furniture ---------- */

.page-head {
  padding-block: 44px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 42ch;
}

.page-head .lede { max-width: var(--measure); }

section { scroll-margin-top: 20px; }

.section {
  padding-block: 42px;
  border-top: 1px solid var(--hairline);
}

/* ---------- calculator ---------- */

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 8px;
}

@media (max-width: 800px) { .calc { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-title {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
  margin: 0;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field > label,
.fieldset-label {
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.hint {
  font-family: var(--display);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 130px; }

input[type="number"], input[type="text"], select {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 9px 10px;
  width: 100%;
  min-width: 0;
}

select { font-family: var(--display); font-size: 14px; }

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .seg label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seg { position: relative; display: flex; border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.seg input {
  position: absolute;
  width: 1px; height: 1px;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}
.seg label {
  flex: 1;
  text-align: center;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px;
  cursor: pointer;
  color: var(--muted);
  background: var(--paper);
  border-right: 1px solid var(--hairline);
}
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--accent); color: var(--on-accent); }

fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
legend { padding: 0; }

/* ---------- results ---------- */

.results {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.headline-figure { display: flex; flex-direction: column; gap: 2px; }

.headline-figure .value {
  font-family: var(--display);
  font-size: clamp(38px, 7vw, 52px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.headline-figure .value small {
  font-size: .38em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 5px;
}

.headline-figure .caption {
  font-family: var(--display);
  font-size: 13.5px;
  color: var(--muted);
}

/* the scale: a published range with your marker on it */
.scale { display: flex; flex-direction: column; gap: 7px; }

.scale-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.scale-name { font-family: var(--display); font-size: 13.5px; font-weight: 600; }

.scale-you {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}

.scale-track {
  position: relative;
  height: 30px;
  background: var(--track);
  border-radius: 2px;
}

.scale-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--band);
  border-left: 1px solid var(--muted);
  border-right: 1px solid var(--muted);
}

.scale-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--accent);
  transform: translateX(-1.5px);
  border-radius: 2px;
}

.scale-marker::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
}

.scale-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.scale-note { font-family: var(--display); font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* macro split */
.split { display: flex; flex-direction: column; gap: 8px; }

.split-bar { display: flex; height: 34px; border-radius: 2px; overflow: hidden; }
.split-bar > span { display: block; }

.split-key { display: flex; flex-wrap: wrap; gap: 6px 20px; }

.split-key div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.split-key i {
  width: 9px;
  height: 9px;
  border-radius: 1px;
  display: inline-block;
  transform: translateY(0);
}

.split-key b { font-weight: 600; color: var(--ink); }

/* readout rows */
.readout { display: flex; flex-direction: column; }

.readout div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-block: 9px;
  border-bottom: 1px solid var(--hairline);
}

.readout div:last-child { border-bottom: 0; }

.readout dt, .readout .k {
  font-family: var(--display);
  font-size: 13.5px;
  color: var(--ink-soft);
}

.readout dd, .readout .v {
  margin: 0;
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.flag {
  display: flex;
  gap: 10px;
  font-family: var(--display);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-soft);
  border-left: 3px solid var(--muted);
}

.flag.warn { border-left-color: var(--warn); }
.flag.alert { border-left-color: var(--alert); }
.flag.good { border-left-color: var(--good); }
.flag[hidden] { display: none !important; }

.method-line {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
}

.method-line b { color: var(--ink-soft); font-weight: 600; }

/* ---------- cards / index ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.tool-grid a {
  background: var(--surface);
  padding: 22px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.tool-grid a:hover { background: var(--accent-wash); }

.tool-grid .n {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  color: var(--accent-ink);
}

.tool-grid h3 { font-size: 18px; }

.tool-grid p { font-family: var(--display); font-size: 13.5px; line-height: 1.5; color: var(--muted); }

/* ---------- faq ---------- */

details {
  border-bottom: 1px solid var(--hairline);
  padding-block: 14px;
}

details summary {
  cursor: pointer;
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  list-style: none;
  display: flex;
  gap: 12px;
  align-items: baseline;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
  content: "+";
  font-family: var(--mono);
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
}

details[open] summary::before { content: "\2212"; }

details .answer { padding-top: 10px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- references ---------- */

.refs { counter-reset: ref; display: flex; flex-direction: column; gap: 13px; padding: 0; margin: 0; list-style: none; }

.refs li {
  counter-increment: ref;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.refs li::before {
  content: "[" counter(ref) "]";
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-ink);
  padding-top: 3px;
}

sup.cite { font-family: var(--mono); font-size: 11px; }
sup.cite a { text-decoration: none; }

/* ---------- ad slots ---------- */

.adslot {
  margin-block: 34px;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
}

/* ---------- footer ---------- */

.sitefoot {
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  margin-top: 20px;
  padding-block: 34px 44px;
  font-family: var(--display);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
}

.sitefoot .cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 26px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.sitefoot h4 { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); font-family: var(--mono); font-weight: 500; margin-bottom: 10px; }
.sitefoot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sitefoot a { color: var(--muted); text-decoration: none; }
.sitefoot a:hover { color: var(--accent-ink); text-decoration: underline; }
.sitefoot .fine { display: flex; flex-direction: column; gap: 12px; font-size: 12.5px; max-width: 78ch; }

.byline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--display);
  font-size: 13px;
  color: var(--muted);
  padding: 14px 0 0;
}

.byline b { font-weight: 600; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .masthead, .sitefoot, .adslot { display: none; }
}
