/* ============================================================
   Directional Symptom Dependencies — dashboard styles
   Clean, academic, accessible. Hand-written CSS (no framework).
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1a2230;
  --ink-soft: #4a5568;
  --ink-faint: #6b7280;
  --line: #e2e6ec;
  --brand: #1f4e79;          /* deep academic blue */
  --brand-soft: #eaf1f8;
  --pos: #2166ac;            /* positive beta (blue)  */
  --neg: #d6604d;            /* negative beta (orange)*/
  --hub: #b8860b;            /* hub accent (gold)     */
  --ms: #2c7fb8;
  --pd: #756bb1;
  --warn-bg: #fff7e6;
  --warn-bd: #e0a800;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 12px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.visually-h, .sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, .tab:focus-visible {
  outline: 3px solid var(--hub); outline-offset: 2px; border-radius: 4px;
}

h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  margin: 0 0 .5em; color: var(--brand); letter-spacing: -.01em;
}
h3 { font-size: 1.05rem; margin: 0 0 .4em; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(160deg, #1f4e79 0%, #163a5a 100%);
  color: #fff; padding: clamp(28px, 6vw, 56px) 0;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .08em; font-size: .74rem;
  color: #b9d0e6; margin: 0 0 14px; font-weight: 600;
}
.site-header h1 {
  font-size: clamp(1.6rem, 4.2vw, 2.6rem); line-height: 1.15; margin: 0 0 .25em;
  letter-spacing: -.02em;
}
.subtitle { font-size: clamp(1rem, 2.2vw, 1.25rem); color: #d6e4f0; margin: 0 0 1em; font-weight: 500; }
.authors { font-size: .95rem; color: #cdddec; margin: 0 0 1.2em; max-width: 70ch; }
.header-links { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }
.header-links a {
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none;
  padding: 8px 14px; border-radius: 8px; font-size: .88rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,.22); transition: background .15s;
}
.header-links a:hover { background: rgba(255,255,255,.24); }

/* ---------- Sections ---------- */
main section { padding: clamp(28px, 5vw, 48px) 0; border-bottom: 1px solid var(--line); }
.section-intro { color: var(--ink-soft); max-width: 75ch; margin: 0 0 1.4em; }

/* ---------- Lead / takeaway ---------- */
.takeaway {
  font-size: clamp(1.1rem, 2.4vw, 1.4rem); line-height: 1.4; max-width: 60ch;
  margin: .2em 0 1.4em; color: var(--ink);
}
.callout {
  display: flex; gap: 14px; padding: 18px 20px; border-radius: var(--radius);
  background: var(--warn-bg); border: 1px solid var(--warn-bd);
}
.callout-icon { font-size: 1.3rem; line-height: 1.4; color: #b8860b; }
.callout p { margin: 0; font-size: .96rem; }

/* ---------- Cards ---------- */
.card-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.card-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 700; }
.card-value { font-size: 1.45rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.card-note { font-size: .8rem; color: var(--ink-faint); }
.methods-note { font-size: .9rem; color: var(--ink-soft); margin: 16px 0 0; max-width: 75ch; }

/* ---------- Tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; border-bottom: 2px solid var(--line); }
.tab {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  padding: 10px 18px; font: inherit; font-weight: 600; color: var(--ink-soft);
  border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0;
}
.tab:hover { background: var(--brand-soft); color: var(--brand); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Legend ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  font-size: .85rem; color: var(--ink-soft); margin: 0 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 26px; height: 0; border-top: 4px solid; border-radius: 2px; }
.legend-swatch.pos { border-color: var(--pos); }
.legend-swatch.neg { border-color: var(--neg); }
.legend-swatch.dashed { border-top-style: dashed; border-color: var(--ink-faint); }
.legend-hub { width: 16px; height: 16px; border-radius: 50%; background: var(--hub); box-shadow: 0 0 0 3px rgba(184,134,11,.25); }
.legend-thick { font-style: italic; }

/* ---------- Graphs ---------- */
.graph-holder {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
#graph-ms, #graph-pd, #graph-ms2, #graph-pd2 { width: 100%; height: 520px; display: block; touch-action: manipulation; }
.graph-holder-sm svg { height: 420px; }
.compare-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .compare-grid { grid-template-columns: 1fr 1fr; } }
.net-caption { font-size: .92rem; color: var(--ink-soft); margin: 0 0 10px; }

.node-label { font-size: 12px; font-weight: 600; fill: var(--ink); pointer-events: none; }
.node-circle { cursor: pointer; stroke: #fff; stroke-width: 2px; }
.node-circle.hub { stroke: var(--hub); stroke-width: 3.5px; }
.edge-path { cursor: pointer; fill: none; }
.edge-path:hover, .node-circle:hover { filter: brightness(1.12); }

/* ---------- SR fallback ---------- */
.sr-fallback { margin-top: 18px; font-size: .9rem; }
.sr-fallback summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.sr-fallback ul { margin: 10px 0; padding-left: 20px; }
.sr-fallback li { margin: 3px 0; }

/* ---------- Table ---------- */
.filter-label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin: 0 0 12px; }
#edge-filter {
  display: block; margin-top: 6px; width: min(360px, 100%); padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--surface);
}
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
#edge-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .92rem; min-width: 640px; }
#edge-table th, #edge-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
#edge-table th { background: #f0f3f7; position: sticky; top: 0; }
#edge-table th button {
  appearance: none; background: none; border: 0; font: inherit; font-weight: 700; color: var(--brand);
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 5px; width: 100%;
}
#edge-table th button::after { content: "↕"; opacity: .4; font-size: .8em; }
#edge-table th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
#edge-table th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
#edge-table th.num, #edge-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#edge-table tbody tr:hover { background: var(--brand-soft); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill-ms { background: #e3f0f7; color: #1a5e84; }
.pill-pd { background: #ece9f5; color: #4f3f8f; }
.dir-pos { color: var(--pos); font-weight: 700; }
.dir-neg { color: var(--neg); font-weight: 700; }
.dir-na { color: var(--ink-faint); font-style: italic; }
.row-hidden { display: none; }

/* ---------- Synthesis ---------- */
.synth-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.synth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-top: 4px solid var(--brand); }
.synth-card p { margin: 0; font-size: .94rem; color: var(--ink-soft); }
.synth-shared { border-top-color: var(--hub); }
.synth-ms { border-top-color: var(--ms); }
.synth-pd { border-top-color: var(--pd); }
.synth-card h3 { color: var(--ink); }

/* ---------- Stability donuts ---------- */
.stability-grid { display: flex; flex-wrap: wrap; gap: 40px; justify-content: center; }
.donut-fig { margin: 0; text-align: center; }
.donut { width: 170px; height: 170px; }
.donut-track { fill: none; stroke: var(--line); stroke-width: 12; }
.donut-val { fill: none; stroke-width: 12; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 60px 60px;
  stroke-dasharray: 314.159; stroke-dashoffset: 314.159; transition: stroke-dashoffset 1.1s ease; }
.donut-val.ms { stroke: var(--ms); }
.donut-val.pd { stroke: var(--pd); }
.donut-pct { text-anchor: middle; font-size: 20px; font-weight: 700; fill: var(--ink); }
.donut-sub { text-anchor: middle; font-size: 11px; fill: var(--ink-faint); }
.donut-fig figcaption { font-size: .9rem; color: var(--ink-soft); margin-top: 8px; }

.conclusion-section p { max-width: 78ch; font-size: 1rem; }

/* ---------- Footer ---------- */
.site-footer { background: #11202f; color: #c7d4e0; padding: 36px 0; border: 0; }
.site-footer .citation { font-size: .9rem; margin: 0 0 12px; max-width: 90ch; }
.site-footer .citation em { color: #e6eef5; }
.site-footer a { color: #8fb8da; }
.site-footer .disclaimer { font-size: .82rem; color: #8a9bab; margin: 0; max-width: 90ch; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 260px;
  background: #11202f; color: #fff; padding: 10px 13px; border-radius: 8px;
  font-size: .85rem; line-height: 1.45; box-shadow: 0 6px 24px rgba(0,0,0,.28);
  transform: translate(-50%, calc(-100% - 12px));
}
.tooltip strong { color: #ffd778; }
.tooltip .tt-title { display: block; font-weight: 700; margin-bottom: 3px; }
.tooltip .tt-meta { color: #b9c8d6; }
