/* Family SOP: one stylesheet, system fonts only */
:root {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5b6168;
  --line: #e3dfd6;
  --accent: #1f5f5b;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0ee;
  --secret: #b42318;
  --secret-soft: #fdecea;
  --ok: #1f5f5b;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 42rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181b;
    --surface: #1c2024;
    --ink: #e8e6e1;
    --muted: #a3a8ad;
    --line: #2f343a;
    --accent: #7cc0b8;
    --accent-ink: #10201e;
    --accent-soft: #1d2d2b;
    --secret: #ff8a7a;
    --secret-soft: #3a1f1c;
    --ok: #7cc0b8;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 10; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.75rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--sans); font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand svg { width: 1.6rem; height: 1.6rem; flex: none; color: var(--accent); }
.site-nav { font-family: var(--sans); font-size: 0.95rem; display: flex; gap: 1.1rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* Article */
main { padding: 2rem 0 3rem; }
.crumbs { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); margin: 0 0 1rem; }
.crumbs a { color: var(--muted); }
h1, h2, h3 { font-family: var(--sans); line-height: 1.25; letter-spacing: -0.015em; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 0 0 1.25rem; }
h2 { font-size: 1.45rem; margin: 2.6rem 0 0.75rem; }
h3 { font-size: 1.15rem; margin: 1.8rem 0 0.5rem; }
p, ul, ol { margin: 0 0 1.1rem; }
li { margin-bottom: 0.4rem; }
li::marker { color: var(--muted); }

.summary { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 1rem 1.25rem 0.4rem; margin: 1.5rem 0 2rem; }
.summary-title { font-family: var(--sans); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin: 0 0 0.5rem; }
.summary ul { padding-left: 1.2rem; }

.faq h3 { margin-top: 1.4rem; }

/* Author box */
.author { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; margin: 3rem 0 0; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.author-mark { width: 3rem; height: 3rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--sans); font-weight: 700; font-size: 1.25rem; }
.author p { margin: 0 0 0.6rem; }
.author p:last-child { margin: 0; color: var(--muted); font-size: 0.95rem; }
.author-name { font-family: var(--sans); font-weight: 700; }

.guide-link { font-family: var(--sans); font-size: 0.95rem; margin: 2rem 0 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); font-family: var(--sans); font-size: 0.875rem; color: var(--muted); padding: 2rem 0 2.5rem; }
.site-footer p { margin: 0 0 0.75rem; }
.site-footer a { color: var(--muted); }

/* ---------- Graphics (figures) ---------- */
.fig { margin: 2rem 0; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-family: var(--sans); font-size: 0.95rem; line-height: 1.45; }
.fig figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 1rem; }
.fig-title { font-weight: 700; font-size: 1rem; margin: 0 0 1rem; }
.secret { color: var(--secret); font-weight: 700; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.45rem; border-radius: 3px; }
.tag-secret { background: var(--secret-soft); color: var(--secret); }
.tag-ok { background: var(--accent-soft); color: var(--ok); }
.tag-plain { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }

/* Levels (staircase) */
.levels { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; align-items: end; }
.levels li { margin: 0; border: 1px solid var(--line); border-radius: 6px 6px 0 0; padding: 0.75rem; background: var(--paper); display: flex; flex-direction: column; gap: 0.35rem; }
.levels li:nth-child(1) { min-height: 7rem; }
.levels li:nth-child(2) { min-height: 9.5rem; }
.levels li:nth-child(3) { min-height: 12rem; background: var(--accent-soft); border-color: var(--accent); }
.levels .num { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.levels strong { font-size: 1rem; }
.levels .note { color: var(--muted); font-size: 0.85rem; }
.levels .tag { align-self: flex-start; margin-top: auto; }
@media (max-width: 520px) {
  .levels { grid-template-columns: 1fr; }
  .levels li { min-height: 0 !important; border-radius: 6px; }
  .levels li:nth-child(1) { order: 3; }
  .levels li:nth-child(2) { order: 2; }
  .levels li:nth-child(3) { order: 1; }
}

/* Loop */
.loop { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2.25rem 2.75rem; position: relative; }
.loop li { margin: 0; position: relative; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); padding: 0.75rem; }
.loop .num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.85rem; margin-right: 0.4rem; }
.loop li::after { position: absolute; color: var(--accent); font-weight: 700; font-size: 1.3rem; line-height: 1; }
.loop li:nth-child(1)::after { content: "\2192"; right: -2rem; top: 50%; transform: translateY(-50%); }
.loop li:nth-child(2)::after { content: "\2193"; bottom: -1.9rem; left: 50%; transform: translateX(-50%); }
.loop li:nth-child(3) { grid-column: 2; grid-row: 2; }
.loop li:nth-child(3)::after { content: "\2190"; left: -2rem; top: 50%; transform: translateY(-50%); }
.loop li:nth-child(4) { grid-column: 1; grid-row: 2; }
.loop li:nth-child(4)::after { content: "\2191"; top: -1.9rem; left: 50%; transform: translateX(-50%); }
.loop-exit { margin-top: 1.25rem; padding: 0.75rem; border: 2px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
.loop-exit strong { color: var(--ok); }
@media (max-width: 520px) {
  .loop { grid-template-columns: 1fr; gap: 1.6rem; }
  .loop li:nth-child(3), .loop li:nth-child(4) { grid-column: 1; grid-row: auto; }
  .loop li::after { content: "\2193" !important; left: 50% !important; right: auto !important; top: auto !important; bottom: -1.45rem !important; transform: translateX(-50%) !important; }
  .loop li:nth-child(4)::after { content: "\21BA  back to 1" !important; font-size: 0.85rem; white-space: nowrap; }
  .loop-exit { margin-top: 2.25rem; }
}

/* Two-column comparisons */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.compare > div { border: 1px solid var(--line); border-radius: 6px; padding: 0.9rem; background: var(--paper); }
.compare h4 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.compare .sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.75rem; }
.compare ul { margin: 0; padding-left: 1.1rem; }
.compare li { margin-bottom: 0.35rem; }
.compare .key { border-color: var(--secret); }
.compare .lead { border-color: var(--accent); }
.compare-note { margin: 1rem 0 0; padding-top: 0.75rem; border-top: 1px dashed var(--line); }
.rows { display: grid; grid-template-columns: 9rem 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.rows > div { padding: 0.65rem 0.75rem; border-top: 1px solid var(--line); background: var(--paper); }
.rows > .h { border-top: 0; font-weight: 700; background: var(--accent-soft); }
.rows > .rl { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
@media (max-width: 560px) {
  .compare { grid-template-columns: 1fr; }
  .rows { grid-template-columns: 1fr 1fr; }
  .rows > .rl { grid-column: 1 / -1; background: var(--surface); padding-bottom: 0.2rem; }
  .rows > .h.blank { display: none; }
}

/* Pieces */
.pieces { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.piece { border: 1px solid var(--line); border-radius: 6px; padding: 0.8rem; background: var(--paper); }
.piece h4 { margin: 0 0 0.3rem; font-size: 1rem; display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.piece p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.piece.is-secret { border-color: var(--secret); }
.piece.is-guide { grid-column: 1 / -1; border: 2px solid var(--accent); background: var(--accent-soft); }
.piece.is-guide p { color: var(--ink); }
@media (max-width: 520px) { .pieces { grid-template-columns: 1fr; } }

/* ---------- Home ---------- */
.lede { font-size: 1.2rem; color: var(--muted); }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; text-decoration: none; color: var(--ink); margin: 1.5rem 0; }
.card:hover { border-color: var(--accent); }
.card strong { font-family: var(--sans); font-size: 1.15rem; color: var(--accent); display: block; margin-bottom: 0.25rem; }
.card span { color: var(--muted); font-size: 1rem; }
.list { list-style: none; padding: 0; }
.list li { border-bottom: 1px solid var(--line); padding: 0.55rem 0; margin: 0; }

/* ---------- Heir Test ---------- */
.quiz { font-family: var(--sans); font-size: 1rem; line-height: 1.5; }
.quiz fieldset { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 1rem 1.1rem 1.1rem; margin: 0 0 1rem; }
.quiz legend { font-weight: 700; padding: 0 0.35rem; font-size: 1rem; }
.quiz .qn { color: var(--muted); font-weight: 600; margin-right: 0.35rem; }
.quiz .hint { color: var(--muted); font-size: 0.9rem; margin: 0.15rem 0 0.75rem; }
.quiz .opts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quiz .opts label { position: relative; }
.quiz .opts input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.quiz .opts span { display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; }
.quiz .opts input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.quiz .opts input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.quiz .group-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; margin: 2rem 0 0.75rem; }
.btn { display: inline-block; font-family: var(--sans); font-weight: 700; font-size: 1rem; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 0.75rem 1.25rem; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.progress { color: var(--muted); font-size: 0.9rem; margin-left: 0.75rem; }
.result { margin-top: 2rem; padding: 1.25rem; background: var(--surface); border: 2px solid var(--accent); border-radius: 8px; }
.result h2 { margin-top: 0; }
.meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin: 1rem 0 1.25rem; }
.meter div { border-radius: 4px; padding: 0.5rem; font-size: 0.85rem; background: var(--paper); border: 1px solid var(--line); color: var(--muted); }
.meter div.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.gaps li { margin-bottom: 0.6rem; }
.private-note { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); }
[hidden] { display: none !important; }
