/* phamscore showcase — tokens follow the validated reference palette
   (light/dark are selected steps, not an automatic flip). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #cde2fb;
  --pos: #e34948;          /* diverging warm pole  (score > 0) */
  --neg: #2a78d6;          /* diverging cool pole  (score < 0) */
  --mid: #f0efec;          /* diverging neutral midpoint */
  --good: #006300;
  --term-bg: #1a1a19;
  --term-ink: #f0efec;
  --term-muted: #898781;
  --term-accent: #86b6ef;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-soft: #184f95;
    --pos: #e66767;
    --neg: #3987e5;
    --mid: #383835;
    --good: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242423;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-soft: #184f95;
  --pos: #e66767;
  --neg: #3987e5;
  --mid: #383835;
  --good: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: 0.92em; }
pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: auto;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 650; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.small { font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
section { padding: 56px 0; }
section + section { border-top: 1px solid var(--grid); }
.section-head { max-width: 720px; margin-bottom: 28px; }
.eyebrow {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}

/* ---- nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grid);
}
.nav .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand svg { width: 26px; height: 26px; }
.nav-links { display: flex; gap: 18px; margin-left: auto; font-size: 0.92rem; }
.nav-links a { color: var(--ink-2); }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
@media (max-width: 640px) { .nav-links a:not(.keep) { display: none; } }

/* ---- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 0.95rem;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: transform .08s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- hero */
.hero { padding: 72px 0 48px; }
.hero .lede { font-size: 1.2rem; color: var(--ink-2); max-width: 680px; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 32px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 0.8rem; color: var(--ink-2); }
.stat .value { font-size: 1.6rem; font-weight: 650; line-height: 1.15; }

/* ---- cards */
.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; overflow: hidden;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title h3 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ---- terminal */
.term {
  background: var(--term-bg); color: var(--term-ink); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.5;
  box-shadow: var(--shadow); overflow: hidden;
}
.term-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: var(--sans); font-size: 0.78rem; color: var(--term-muted);
}
.term-bar .dots { display: flex; gap: 6px; }
.term-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a3a38; display: block; }
.term-bar .replay { margin-left: auto; background: none; border: 1px solid rgba(255,255,255,0.15); color: var(--term-ink); border-radius: 6px; padding: 3px 8px; font-size: 0.75rem; cursor: pointer; }
.term-bar .replay:hover { background: rgba(255,255,255,0.06); }
.term-body { padding: 14px 16px; min-height: 300px; white-space: pre-wrap; word-break: break-word; }
.term-body .prompt { color: var(--term-accent); }
.term-body .dim { color: var(--term-muted); }
.term-body .ok { color: #7fd48a; }
.term-body .cursor { display: inline-block; width: 8px; height: 1em; background: var(--term-ink); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .term-body .cursor { animation: none; } }

/* ---- lookup widget */
.lookup { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 560px) { .lookup { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 0.8rem; color: var(--ink-2); margin-bottom: 4px; }
.field select, .field input {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--ring);
  background: var(--surface); color: var(--ink); font: inherit; font-family: var(--mono);
}
.result {
  margin-top: 14px; padding: 14px 16px; border-radius: 8px; background: var(--surface-2);
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.result .score { font-size: 2rem; font-weight: 650; }
.result .score.pos { color: var(--pos); }
.result .score.neg { color: var(--neg); }

/* ---- heatmap */
.heat-wrap { display: grid; grid-template-columns: 1fr; gap: 14px; }
.heat-canvas-box { position: relative; aspect-ratio: 1 / 1; width: 100%; max-width: 420px; margin: 0 auto; }
.heat-canvas-box canvas { width: 100%; height: 100%; display: block; border-radius: 6px; image-rendering: pixelated; cursor: crosshair; }
.heat-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; font-size: 0.9rem; align-items: start; }
@media (max-width: 560px) { .heat-side { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface); color: var(--ink-2); border: 0; padding: 7px 10px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.seg button + button { border-left: 1px solid var(--ring); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.legend-bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--neg), var(--mid), var(--pos)); border: 1px solid var(--ring); }
.legend-ticks { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--page); font-size: 0.8rem; line-height: 1.35;
  padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(12px, 12px);
  box-shadow: var(--shadow); opacity: 0; transition: opacity .08s;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 650; }
table.pairs { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
table.pairs th, table.pairs td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
table.pairs th { color: var(--ink-2); font-weight: 600; }
table.pairs td:last-child, table.pairs th:last-child { text-align: right; }
details.table-view summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; margin-top: 10px; }

/* ---- histogram */
.hist svg { width: 100%; height: auto; display: block; }
.hist .bar { fill: var(--accent); }
.hist .bar:hover { filter: brightness(1.15); }
.hist .hit { fill: transparent; }
.hist .grid { stroke: var(--grid); stroke-width: 1; }
.hist .axis { stroke: var(--axis); stroke-width: 1; }
.hist text { fill: var(--muted); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.hist .zero { stroke: var(--ink-2); stroke-width: 1; }

/* ---- pipeline diagram */
.pipe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: stretch; }
@media (max-width: 860px) { .pipe { grid-template-columns: 1fr; } }
.step { position: relative; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px; }
.step .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; }
.step h3 { font-size: 1rem; }
.step code { display: block; font-size: 0.78rem; color: var(--ink-2); margin-top: 8px; word-break: break-all; }
.step p { font-size: 0.9rem; color: var(--ink-2); margin: 6px 0 0; }
.formula { margin-top: 24px; padding: 20px; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); }
.formula .eq { font-family: var(--mono); font-size: 1.15rem; text-align: center; margin: 6px 0 14px; }
.formula sub { font-size: 0.7em; }
.formula dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 0.9rem; }
.formula dt { font-family: var(--mono); color: var(--accent); }
.formula dd { margin: 0; color: var(--ink-2); }

/* ---- code explorer */
.explorer { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 0; border: 1px solid var(--ring); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
@media (max-width: 760px) { .explorer { grid-template-columns: 1fr; } }
.files { border-right: 1px solid var(--grid); background: var(--surface-2); padding: 8px; }
@media (max-width: 760px) { .files { border-right: 0; border-bottom: 1px solid var(--grid); display: flex; overflow-x: auto; gap: 4px; } }
.files button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font: inherit; font-size: 0.88rem; }
.files button small { display: block; color: var(--muted); font-size: 0.74rem; margin-top: 1px; }
@media (max-width: 760px) { .files button { width: auto; white-space: nowrap; } .files button small { display: none; } }
.files button[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--ring); }
.code-pane { min-width: 0; }
.code-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--grid); font-size: 0.85rem; color: var(--ink-2); }
.code-head code { color: var(--ink); }
.code-head a { margin-left: auto; }
.code-pane pre { border-radius: 0; background: transparent; max-height: 520px; padding: 14px 16px; font-size: 0.82rem; }
.code-pane pre code { background: transparent; padding: 0; }
.code-pane .hljs { background: transparent; color: var(--ink); }

/* ---- downloads */
.dl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .dl-grid { grid-template-columns: 1fr; } }
.dl { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); }
.dl .os { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.dl .os svg { width: 20px; height: 20px; }
.dl .meta { font-size: 0.82rem; color: var(--muted); }
.dl .btn { margin-top: 8px; align-self: flex-start; }
.note { font-size: 0.88rem; color: var(--ink-2); padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; }

/* ---- embed snippet */
.snippet { position: relative; }
.snippet .btn { position: absolute; top: 8px; right: 8px; }

/* ---- footer */
footer { padding: 36px 0 48px; border-top: 1px solid var(--grid); color: var(--ink-2); font-size: 0.9rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; }

/* ---- embed mode */
body.embed { background: transparent; }
body.embed .wrap { max-width: none; padding: 12px; }
body.embed .embed-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; }
@media (max-width: 720px) { body.embed .embed-grid { grid-template-columns: 1fr; } }
body.embed .term-body { min-height: 220px; font-size: 0.8rem; }
body.embed .heat-canvas-box { max-width: none; }
body.embed .embed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
body.embed .embed-head .brand { font-size: 1.05rem; }
body.embed .embed-head .btn-row { margin-left: auto; }
body.embed .embed-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; font-size: 0.82rem; color: var(--ink-2); }
body.embed .embed-foot .btn-row { margin-left: auto; }
