/* Pew-Takedown — one stylesheet, theme-aware, no build step. */

:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --border: #e0ddd6;
  --border-strong: #c9c4b8;
  --text: #1c1a17;
  --text-dim: #5f5a51;
  --accent: #8a4b2a;
  --accent-soft: #f3e6dd;
  --danger: #a32d1f;
  --danger-soft: #fbe9e6;
  --warn: #8a6516;
  --warn-soft: #fdf3dd;
  --ok: #2f6b3a;
  --ok-soft: #e6f2e8;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1d1b17;
    --surface-2: #26231e;
    --border: #35312a;
    --border-strong: #4a453c;
    --text: #ece8e1;
    --text-dim: #a49d91;
    --accent: #d99b6c;
    --accent-soft: #33261d;
    --danger: #e8836f;
    --danger-soft: #38211d;
    --warn: #dcb35a;
    --warn-soft: #332a17;
    --ok: #7fbb8c;
    --ok-soft: #1e2b21;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* ---------- Header ---------- */

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
header.site .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-block: 12px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
nav.site { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.9rem; margin-left: auto; }
nav.site a { color: var(--text-dim); text-decoration: none; }
nav.site a:hover, nav.site a[aria-current="page"] { color: var(--accent); }

/* ---------- Disclaimer banner ---------- */

.disclaimer-bar {
  background: var(--warn-soft);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
}
.disclaimer-bar .wrap { padding-block: 10px; }
.disclaimer-bar strong { color: var(--warn); }

/* ---------- Blocks ---------- */

main { padding-block: 32px 64px; }
h1 { font-size: 1.9rem; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 1.3rem; letter-spacing: -0.01em; margin: 40px 0 12px; }
h3 { font-size: 1.05rem; margin: 28px 0 8px; }
p { margin: 0 0 14px; }
.lede { color: var(--text-dim); font-size: 1.05rem; max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.callout {
  border-left: 4px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.callout .label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-dim);
}
.callout.danger .label { color: var(--danger); }
.callout.warn .label { color: var(--warn); }

/* ---------- Badges ---------- */

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  background: var(--surface-2);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.badge.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* ---------- Search / browse ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.controls { display: grid; gap: 12px; margin: 24px 0; }
.controls input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.controls input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters button {
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.filters button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.result-count { color: var(--text-dim); font-size: 0.9rem; margin: 8px 0 16px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); list-style: none; padding: 0; margin: 0; }
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.entry-card h3 { margin: 0; font-size: 1.05rem; }
.entry-card h3 a { text-decoration: none; color: var(--text); }
.entry-card h3 a:hover { color: var(--accent); }
.entry-card .meta { font-size: 0.85rem; color: var(--text-dim); }

/* ---------- Procedure steps ---------- */

.proc { margin: 28px 0; }
.proc-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.proc-head h3 { margin: 0; font-size: 1.15rem; }

ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 14px 0 14px 52px;
  border-bottom: 1px solid var(--border);
}
ol.steps > li:last-child { border-bottom: none; }
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.step-note {
  margin-top: 8px;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
}
.step-note.warning { border-left-color: var(--danger); background: var(--danger-soft); }
.step-note.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.step-note b { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.parts-freed { margin-top: 8px; font-size: 0.85rem; color: var(--text-dim); }
.parts-freed code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- Tables & lists ---------- */

.table-scroll { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }

ul.plain { list-style: none; padding: 0; margin: 0 0 14px; }
ul.plain > li { padding: 7px 0 7px 22px; position: relative; border-bottom: 1px solid var(--border); }
ul.plain > li:last-child { border-bottom: none; }
ul.plain > li::before { content: "▸"; position: absolute; left: 4px; color: var(--accent); }

dl.spec { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 0.93rem; }
dl.spec dt { color: var(--text-dim); }
dl.spec dd { margin: 0; }

/* ---------- Footer ---------- */

footer.site {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding-block: 28px 48px;
}
footer.site a { color: var(--text-dim); }

.toc { font-size: 0.92rem; }
.toc a { display: block; padding: 4px 0; text-decoration: none; color: var(--text-dim); }
.toc a:hover { color: var(--accent); }

@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  dl.spec { grid-template-columns: 1fr; gap: 2px 0; }
  dl.spec dd { margin-bottom: 8px; }
  ol.steps > li { padding-left: 44px; }
}

@media print {
  header.site, nav.site, .controls, footer.site { display: none; }
  body { background: #fff; color: #000; }
  .callout, .card { border: 1px solid #999; }
}

/* --- Figures -------------------------------------------------------------- */
/* Line art from public-domain technical manuals. Bilevel PNGs on white, so they
   get a light panel in both themes rather than being inverted into mush. */

.fig {
  margin: 1.25rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.fig figcaption {
  margin-top: 0.6rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #333;
}

.fig figcaption b { display: block; color: #111; }

.fig .fig-credit {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: #555;
}

.fig .fig-credit a { color: #444; }

/* Inside a numbered step, keep the drawing subordinate to the instruction. */
.fig-compact { margin: 0.7rem 0 0.2rem; max-width: 34rem; }

/* --- Make / model picker --------------------------------------------------- */

.picker {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.picker-title { margin: 0 0 0.7rem; font-size: 1rem; }

.picker-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.picker-field { flex: 1 1 15rem; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.picker-field label { font-size: 0.8rem; color: var(--muted); }

.picker-field select {
  width: 100%;
  padding: 0.55rem 0.6rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: inherit;
}

.picker-field select:disabled { opacity: 0.55; }

.picker-go {
  padding: 0.55rem 1.3rem;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.picker-go:disabled { opacity: 0.45; cursor: default; }
.picker-note { margin: 0.7rem 0 0; font-size: 0.82rem; color: var(--muted); }

/* --- Reassembly failure modes ---------------------------------------------- */

.fails { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.8rem; }

.fail {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  background: var(--surface);
}

.fail p { margin: 0 0 0.4rem; }
.fail p:last-child { margin-bottom: 0; }

.fail-symptom { font-weight: 650; font-size: 1.02rem; }
.fail-where { font-size: 0.85rem; color: var(--muted); }
.fail-cause, .fail-fix, .fail-damage { font-size: 0.93rem; line-height: 1.55; }

.fail-cause b, .fail-fix b, .fail-damage b {
  display: inline-block;
  min-width: 4.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fail-damage { color: var(--danger); }
.fail-damage b { color: var(--danger); }

@media (max-width: 34rem) {
  .fail-cause b, .fail-fix b, .fail-damage b { display: block; min-width: 0; margin-bottom: 0.1rem; }
  .picker-go { width: 100%; }
}

/* Torque table and parts list */
.muted { color: var(--text-dim); font-size: 0.9em; }
table.torque td { vertical-align: top; }
table.torque td p { margin: 0 0 0.4em; }
.torque-value { white-space: nowrap; }
.quote { color: var(--text-dim); font-size: 0.85em; font-style: italic; }
details.parts > summary { cursor: pointer; font-weight: 600; margin: 0.5em 0; }
details.parts tr.section th { text-align: left; background: var(--surface-2, transparent); padding-top: 0.8em; }

/* Citations: title, publisher, page, and the website, so a reader can look it up. */
.cite { display: inline; }
.src-host { display: inline-block; font-size: 0.8em; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.ref-num { font-size: 0.8em; color: var(--text-dim); text-decoration: none; white-space: nowrap; }
.src-url { font-size: 0.85em; word-break: break-all; }
ul.references li { margin-bottom: 0.7em; }
table.torque td:first-child { min-width: 11em; }

/* Work-order sheet: blanks, checkboxes, and a page that prints cleanly. */
.wo-fields { border-collapse: collapse; width: 100%; margin: 12px 0; }
.wo-fields th { text-align: left; width: 30%; padding: 6px 8px; font-weight: 600; }
.wo-fields td, .wo-blank { border-bottom: 1px solid var(--border-strong); min-width: 6em; height: 1.8em; }
.wo-box { display: inline-block; width: 0.9em; height: 0.9em; border: 1.5px solid var(--text); border-radius: 2px; margin-right: 0.55em; vertical-align: -0.1em; flex: none; }
ol.wo-steps { padding-left: 1.6em; }
ol.wo-steps li { margin: 0 0 0.45em; }
ol.wo-steps li > .wo-box { margin-left: -0.1em; }
ul.wo-plain { list-style: none; padding-left: 0; }
ul.wo-plain li { margin: 0 0 0.4em; }
.wo-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
.wo-table th, .wo-table td { border: 1px solid var(--border); padding: 6px 8px; vertical-align: top; text-align: left; }
.wo-warn { color: var(--danger); }
.wo-sources li { margin-bottom: 0.5em; }
.wo-signoff { margin-top: 24px; }
.wo-link { display: inline-block; margin: 8px 0; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 6px; text-decoration: none; }
@media print {
  header, footer, nav, .disclaimer-bar, .no-print, .site-nav { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  a { color: #000; text-decoration: none; }
  h2 { break-after: avoid; margin-top: 14pt; }
  tr, li { break-inside: avoid; }
  .callout { border: 1.5px solid #000 !important; background: #fff !important; }
}
.wo-table.torque { table-layout: fixed; }
.wo-table.torque th:nth-child(1) { width: 24%; }
.wo-table.torque th:nth-child(2) { width: 15%; }
.wo-table.torque th:nth-child(3) { width: 35%; }
.wo-table.torque th:nth-child(4) { width: 8%; }
.wo-table.torque th:nth-child(5) { width: 10%; }
.wo-table.torque th:nth-child(6) { width: 8%; }
@media print { .wo-table { font-size: 9pt; } .wo-table th, .wo-table td { padding: 4px 5px; } }
.wo-table th { letter-spacing: 0; text-transform: none; font-size: 0.85em; white-space: normal; }
.wo-table.torque th:nth-child(2) { width: 16%; }
.wo-table.torque th:nth-child(4) { width: 9%; }
.wo-table.torque th:nth-child(3) { width: 33%; }

/* Recall banner and materials table */
.callout.recall em { font-style: normal; font-weight: 600; }
table.materials td:first-child { white-space: nowrap; }
.proc-source { font-size: 0.9em; color: var(--muted, #555); margin: 0 0 8px; }

/* Manufacturer videos: linked, never embedded */
ul.videos { padding-left: 1.2em; }
ul.videos li { margin: 0 0 8px; }
.wo-video { font-size: 0.9em; margin: 0 0 8px; }

/* Shop tiers */
.tier-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tier-col h3 { margin-top: 0; }
ul.pains li { margin: 0 0 10px; }
