:root {
  --ink: #0F2233;
  --ink-soft: #3A4F60;
  --muted: #566F80;
  --hairline: #DCE6EC;
  --hairline-strong: #C3D3DD;
  --paper: #FFFFFF;
  --surface: #F5F9FB;
  --surface-2: #E7F0F6;
  --brand: #0A6E9E;
  --brand-deep: #093F5D;
  --amber: #C8801F;
  --amber-ink: #94520A;
  /* rating ramp: one hue, light to dark = less to more important */
  --r-vi: #093F5D;
  --r-i: #1B84B5;
  --r-c: #A6D2E8;
  --r-nc: #E7F0F6;
  --r-vi-ink: #FFFFFF;
  --r-i-ink: #FFFFFF;
  --r-c-ink: #0F2233;
  --r-nc-ink: #566F80;
  --shadow: 0 2px 4px rgba(15,34,51,.05), 0 12px 28px -14px rgba(15,34,51,.22);
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Public Sans", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E6EEF3;
    --ink-soft: #C2D2DD;
    --muted: #93A9B8;
    --hairline: #1E3446;
    --hairline-strong: #2A465C;
    --paper: #0B1A26;
    --surface: #0F2233;
    --surface-2: #132C40;
    --brand: #6FB6D6;
    --brand-deep: #A6D2E8;
    --amber: #DA9A3A;
    --amber-ink: #F3D5AC;
    --r-vi: #D3E9F3;
    --r-i: #6FB6D6;
    --r-c: #1B5F84;
    --r-nc: #16304A;
    --r-vi-ink: #071F2E;
    --r-i-ink: #071F2E;
    --r-c-ink: #E6EEF3;
    --r-nc-ink: #93A9B8;
    --shadow: 0 12px 28px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.6vw, 3.25rem); margin-bottom: .75rem; }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); margin-bottom: .5rem; }
h3 { font-size: 1.2rem; margin-bottom: .35rem; }
p { margin: 0 0 1rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.narrow { max-width: 760px; }
.center { text-align: center; }
section { padding: 64px 0; }
.band { background: var(--surface); border-block: 1px solid var(--hairline); }
.section-lede { color: var(--ink-soft); max-width: 66ch; margin-bottom: 1.5rem; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--hairline); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 600 1.05rem var(--serif); }
.top-nav { display: flex; gap: 20px; }
.top-nav a { color: var(--ink-soft); text-decoration: none; font-size: .92rem; font-weight: 500; }
.top-nav a:hover { color: var(--brand); }
@media (max-width: 560px) { .top-nav a:nth-child(2), .top-nav a:nth-child(4) { display: none; } .brand span { font-size: .95rem; } }

/* hero */
.hero { padding: 48px 0 56px; }
.hero-grid { display: grid; gap: 28px; }
.hero-photo { margin: 0; order: -1; }
.hero-photo img { border-radius: 14px; box-shadow: var(--shadow); aspect-ratio: 3 / 2; object-fit: cover; width: 100%; }
@media (min-width: 900px) {
  .hero { padding: 72px 0; }
  .hero-grid { grid-template-columns: 1.05fr 1fr; align-items: center; gap: 48px; }
  .hero-photo { order: 0; }
}
.lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 58ch; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 1.5rem; }
.stat { border-top: 3px solid var(--amber); padding-top: 10px; }
.stat b { display: block; font: 600 clamp(1.6rem, 3.4vw, 2.2rem)/1.1 var(--serif); }
.stat span { font-size: .85rem; color: var(--muted); }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 18px; font-size: .88rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch.nc { box-shadow: inset 0 0 0 1px var(--hairline-strong); }

/* factor chart */
.factor-chart { display: grid; gap: 6px; }
.frow { display: grid; grid-template-columns: minmax(118px, 210px) 1fr 52px; align-items: center; gap: 12px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; border: 0; background: none; font: inherit; color: inherit; text-align: left; width: calc(100% + 16px); transition: background-color .15s; }
.frow:hover, .frow:focus-visible { background: var(--surface-2); outline: none; }
.frow.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--amber); }
.fname { font-size: .92rem; font-weight: 500; }
.fbar { display: flex; height: 22px; gap: 2px; }
.seg { height: 100%; min-width: 0; transition: flex-grow .5s ease; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg.nc { box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.fpct { font-size: .85rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .frow { grid-template-columns: 1fr 44px; row-gap: 4px; }
  .fname { grid-column: 1 / -1; }
}
.table-view { margin-top: 18px; font-size: .9rem; }
.table-view summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.table-view table { border-collapse: collapse; margin-top: 10px; width: 100%; max-width: 640px; }
.table-view th, .table-view td { padding: 6px 10px; border-bottom: 1px solid var(--hairline); text-align: right; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }

/* findings */
.findings { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 24px; }
.card { background: var(--paper); border: 1px solid var(--hairline); border-radius: 14px; padding: 24px 22px; text-align: center; box-shadow: var(--shadow); }
.card .big { font: 600 2.6rem/1 var(--serif); color: var(--brand-deep); margin-bottom: 10px; }
.card h3 { margin-bottom: .5rem; }
.card p { color: var(--ink-soft); font-size: .93rem; margin: 0; text-align: left; }
.card .names { margin-top: .6rem; font-size: .85rem; color: var(--muted); }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.field { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); min-width: 150px; flex: 1 1 150px; }
.field.grow { flex: 2 1 240px; }
.field input, .field select { font: 400 .95rem var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--hairline-strong); border-radius: 8px; padding: 9px 11px; min-height: 42px; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.count { font-size: .85rem; color: var(--muted); margin: 6px 0 10px; }

/* grid */
.grid-scroll { overflow: auto; max-height: 78vh; border: 1px solid var(--hairline); border-radius: 12px; background: var(--paper); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; }
.grid thead th { position: sticky; top: 0; z-index: 3; background: var(--paper); border-bottom: 1px solid var(--hairline-strong); padding: 8px 2px; font-weight: 600; font-size: .7rem; line-height: 1.2; color: var(--ink-soft); vertical-align: bottom; }
.grid thead th.fh { width: 46px; min-width: 46px; height: 112px; cursor: pointer; }
.grid thead th.fh div { writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 auto; white-space: nowrap; }
.grid thead th.fh.on { color: var(--amber-ink); }
.grid thead th.fh.on div::after { content: " ▲"; }
.grid th.sticky, .grid td.sticky { position: sticky; left: 0; z-index: 2; background: var(--paper); text-align: left; }
.grid thead th.sticky { z-index: 4; padding-left: 14px; }
.grid td { padding: 3px 2px; border-bottom: 1px solid var(--hairline); }
.grid td.sticky { padding: 6px 12px 6px 14px; min-width: 196px; max-width: 230px; box-shadow: 1px 0 0 var(--hairline); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: var(--surface); }
.grid tbody tr:hover td.cell div { filter: brightness(1.06); }
.sname { font-weight: 600; display: block; color: var(--ink); }
.smeta { font-size: .75rem; color: var(--muted); }
.rk { font-variant-numeric: tabular-nums; color: var(--amber-ink); font-weight: 600; margin-right: 6px; }
.cell div { height: 30px; border-radius: 4px; margin: 0 1px; display: flex; align-items: center; justify-content: center; font-size: .66rem; font-weight: 700; letter-spacing: .02em; }
.cell.col-on div { outline: 2px solid var(--amber); outline-offset: -2px; }
.empty { color: var(--muted); }

.v-VI { background: var(--r-vi); color: var(--r-vi-ink); }
.v-I { background: var(--r-i); color: var(--r-i-ink); }
.v-C { background: var(--r-c); color: var(--r-c-ink); }
.v-NC { background: var(--r-nc); color: var(--r-nc-ink); box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.v-x { background: transparent; color: var(--muted); }

/* tooltip */
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--paper); font-size: .82rem; line-height: 1.4; padding: 8px 10px; border-radius: 8px; max-width: 260px; box-shadow: var(--shadow); }
.tip b { display: block; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(7,31,46,.42); z-index: 40; }
.drawer { position: fixed; z-index: 50; inset: auto 0 0 0; max-height: 88vh; transform: translateY(102%); transition: transform .28s ease; visibility: hidden; }
.drawer.open { transform: none; visibility: visible; }
.drawer-panel { background: var(--paper); border-radius: 18px 18px 0 0; max-height: 88vh; overflow: auto; padding: 26px 18px 32px; box-shadow: var(--shadow); outline: none; }
@media (min-width: 900px) {
  .drawer { inset: 0 0 0 auto; width: 520px; max-height: none; transform: translateX(102%); }
  .drawer-panel { border-radius: 0; height: 100vh; max-height: none; padding: 32px 30px 40px; }
}
.drawer-close { position: absolute; top: 12px; right: 14px; border: 0; background: var(--surface-2); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.d-rank { color: var(--amber-ink); font-weight: 700; font-size: .9rem; }
.d-place { color: var(--muted); margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 22px; }
.kv div { background: var(--surface); border-radius: 10px; padding: 10px 12px; }
.kv dt { font-size: .74rem; color: var(--muted); font-weight: 600; }
.kv dd { margin: 2px 0 0; font: 600 1.15rem var(--serif); }
.d-h { font: 600 1.05rem var(--serif); margin: 18px 0 10px; }
.flist { display: grid; gap: 6px; margin-bottom: 8px; }
.fitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .9rem; }
.pill-rate { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.d-note { font-size: .82rem; color: var(--muted); }
.d-link { display: inline-block; margin-top: 8px; font-weight: 600; }

/* methods, cta, footer */
#method p { color: var(--ink-soft); }
.downloads { font-weight: 500; }
.cta { background: var(--brand-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .cta { background: #093F5D; } }
.cta p { color: #D3E9F3; max-width: 52ch; margin: 0 auto 1.4rem; }
.btn { display: inline-block; background: var(--amber); color: #1B1205; font-weight: 700; text-decoration: none; padding: 13px 22px; border-radius: 8px; transition: background-color .15s; }
.btn:hover { background: #DA9A3A; }
.site-footer { padding: 24px 0; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--hairline); }
.site-footer p { margin: 0; }

/* entrance */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } .seg, .drawer { transition: none; } html { scroll-behavior: auto; } }
#factor-table { overflow-x: auto; }
.table-view th { font-size: .78rem; }
.table-view { max-width: 100%; overflow-x: auto; }
.table-view table { min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; }
.controls .field { min-width: 0; }
@media (max-width: 560px) { .controls .field { flex: 1 1 140px; } .controls .field.grow { flex-basis: 100%; } }
