/* styles.css — theme_04 "Warm Paper Field Dossier" for bloodfromastone.com
   Zero external fonts/CDNs. Tokens per spec. */

:root {
  --bg: #f5efe6;
  --surface: #fffdf9;
  --ink: #292524;
  --accent: #b45309;
  --muted: #57534e;
  --line: #e0d6c8;
  --ok: #166534;
  --bad: #b91c1c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, #faf5ec 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.55;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* ---------- hero / dossier header ---------- */
.hero {
  text-align: center;
  padding: 2.2rem 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.2rem;
}
.hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  margin: 0 0 .4rem;
  letter-spacing: -0.01em;
}
.hero .accent { color: var(--accent); }
.hero .muted { color: var(--muted); font-weight: 400; font-size: .72em; }
.hero p { max-width: 46rem; margin: .6rem auto 0; color: var(--muted); font-size: 1.02rem; }
.hero .kicker {
  font-family: var(--sans);
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}

/* ---------- disclosure banner (above the fold) ---------- */
.disc-banner {
  background: #fbf3e4;
  border: 1px solid #ecd9b8;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: .7rem .9rem;
  font-size: .92rem;
  margin: 0 auto 1.4rem;
  max-width: 1080px;
}
.disc-banner a { color: var(--accent); }

/* ---------- dossier sheet ---------- */
.dossier {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 #fff inset, 0 10px 30px rgba(41, 37, 36, .07);
  overflow: hidden;
}

/* ---------- tabs ---------- */
[role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding: .6rem .8rem 0;
  border-bottom: 1px solid var(--line);
  background: #faf6ee;
}
[role="tab"] {
  font-family: var(--sans);
  font-size: .85rem;
  padding: .5rem .85rem;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
[role="tab"][aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  position: relative;
  top: 1px;
}
[role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[role="tabpanel"] { padding: 1.4rem 1.2rem 1.8rem; }

section h2 {
  font-size: 1.35rem;
  margin: 1.6rem 0 .4rem;
  padding-bottom: .3rem;
  border-bottom: 2px solid var(--line);
}
section h2:first-child { margin-top: 0; }
.tag {
  font-family: var(--sans);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .1rem .5rem;
  vertical-align: middle;
}
.tag.req { color: var(--bad); border-color: var(--bad); }
.tag.rec { color: var(--muted); border-color: var(--muted); }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.card h3 { margin-top: 0; font-size: 1.05rem; }

/* ---------- forms ---------- */
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem 1rem 1rem;
  margin: 1rem 0;
  background: #fffaf2;
}
legend {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 .4rem;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--sans);
  font-size: .88rem;
  margin: .25rem .9rem .25rem 0;
  cursor: pointer;
}
input[type="number"], select {
  font-family: var(--sans);
  font-size: .88rem;
  padding: .3rem .45rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#profile-flags, #profile-numbers, #rule-weights { display: flex; flex-wrap: wrap; }
#profile-numbers label, #rule-weights label {
  display: flex; align-items: center; gap: .4rem;
  font-family: var(--sans); font-size: .85rem; margin: .3rem .8rem .3rem 0;
}
.gates { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; }
.gates label {
  font-family: var(--sans); font-size: .82rem; color: var(--muted);
  display: flex; flex-direction: column; gap: .2rem;
}
.gates input, .gates select { width: 7rem; }
.gates .check-inline { flex-direction: row; align-items: center; }

/* ---------- score + bars ---------- */
.score-row { display: flex; align-items: baseline; gap: 1rem; margin: .4rem 0 1rem; }
#score-value { font-size: 3rem; font-weight: 700; color: var(--accent); line-height: 1; }
#score-grade {
  font-size: 1.6rem; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 8px; padding: .1rem .7rem;
}
#score-grade[data-grade="A"], #score-grade[data-grade="B"] { border-color: var(--ok); color: var(--ok); }
#score-grade[data-grade="D"], #score-grade[data-grade="F"] { border-color: var(--bad); color: var(--bad); }
.bar-row {
  display: grid; grid-template-columns: 12rem 1fr 7rem;
  gap: .6rem; align-items: center; margin: .35rem 0;
  font-family: var(--sans); font-size: .85rem;
}
.bar-track { background: #efe7da; border-radius: 4px; height: .9rem; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-num { color: var(--muted); font-size: .78rem; text-align: right; }

.err, .warn { color: var(--bad); }
.err { font-family: var(--sans); font-size: .85rem; }
#gate-fails.warn { color: var(--bad); font-family: var(--sans); font-size: .85rem; }
#gate-fails code { background: #f3e6d4; padding: .05rem .35rem; border-radius: 4px; }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .84rem; }
th, td { border: 1px solid var(--line); padding: .38rem .55rem; text-align: left; }
th { background: #faf4e8; font-weight: 600; }
.table-scroll { overflow-x: auto; }
.fit {
  display: inline-block; min-width: 2.2rem; text-align: center;
  background: var(--accent); color: #fff; border-radius: 4px; padding: .05rem .4rem;
}
td .warn, .warn { color: var(--bad); font-weight: 600; }
td .ok, .ok { color: var(--ok); font-weight: 600; }

/* ---------- checklist ---------- */
#checklist { columns: 2; column-gap: 2rem; }
#checklist .check { display: flex; break-inside: avoid; margin: .2rem 0; }
#check-results { list-style: none; padding: 0; font-family: var(--sans); font-size: .88rem; }
#check-results li { padding: .2rem 0; }
#check-results li.pass { color: var(--ok); }
#check-results li.fail { color: var(--bad); }

/* ---------- simulator ---------- */
.sim-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .6rem 1.4rem; margin: .6rem 0;
}
.sim-grid dt { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sim-grid dd { margin: .1rem 0 0; font-size: 1.02rem; }
#tradeoff-chart svg { max-width: 100%; height: auto; display: block; margin: .6rem auto; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans); font-size: .88rem; font-weight: 600;
  background: var(--accent); color: #fff;
  border: none; border-radius: 6px; padding: .5rem .95rem;
  cursor: pointer; margin: .25rem .4rem .25rem 0;
}
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn:hover { filter: brightness(1.07); }

/* ---------- receipt ---------- */
#receipt-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .74rem; white-space: pre-wrap; word-break: break-all;
  background: #292524; color: #f5efe6; border-radius: 8px;
  padding: .8rem 1rem; max-height: 22rem; overflow: auto;
}

/* ---------- summary card (printable) ---------- */
#summary-card {
  border: 2px dashed var(--accent); border-radius: 8px;
  padding: 1rem 1.2rem; margin-top: 1.2rem; background: #fffaf0;
}
#summary-card h3 { margin: .4rem 0 .2rem; font-size: 1rem; }
#summary-card h3:first-child { margin-top: 0; }
#summary-stamp { font-family: var(--sans); font-size: .72rem; color: var(--muted); margin-top: .6rem; }

/* ---------- prose sections (about / editorial) ---------- */
.prose p { max-width: 46rem; }
.prose ul { max-width: 46rem; }
.prose h3 { font-size: 1.1rem; margin: 1.2rem 0 .3rem; }

/* ---------- footer ---------- */
footer {
  margin-top: 2.4rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: .82rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; justify-content: center;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .dossier, .hero, .disc-banner, [role="tablist"], footer, .btn, fieldset, table { display: none !important; }
  #summary-card { display: block !important; border: 2px solid #000; }
  [role="tabpanel"] { display: block !important; }
}

@media (max-width: 640px) {
  .bar-row { grid-template-columns: 8rem 1fr 5.5rem; font-size: .78rem; }
  #checklist { columns: 1; }
  .gates { flex-direction: column; align-items: stretch; }
}
