/* Hedge demo: Ember's page structure (a slim rail, a live hero, wide bands, horizontal
   bars, big serif figures) in Hedge's own colors. Cobalt, the ink of calibration charts,
   is the one accent and marks what Hedge itself does. Vermilion marks only its mistakes.
   Ochre is a ticket handed to a person, plum a duplicate call, slate a baseline.
   Spectral for display, Inter Tight for text, IBM Plex Mono for keys and numbers. */
:root {
  color-scheme: light;
  --paper: #fafaf7;
  --paper-deep: #f1f1ec;
  --card: #ffffff;
  --rule: #e2e2db;
  --rule-strong: #c4c5bc;
  --ink: #171a21;
  --graphite: #5d6169;
  --cobalt: #2b3a9e;
  --cobalt-deep: #1f2a78;
  --cobalt-tint: #eceffb;
  --cobalt-pale: #c9cff0;
  --vermilion: #c63d24;
  --vermilion-ink: #b0321b;
  --vermilion-tint: #fcefec;
  --ochre: #8a5a00;
  --ochre-pale: #ecd7a6;
  --ochre-tint: #fbf4e3;
  --plum: #6b2f86;
  --plum-tint: #f4edf7;
  --slate: #6f7c8c;

  --serif: "Spectral", Georgia, serif;
  --sans: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --rail: 72px;
  --gutter: clamp(24px, 4vw, 64px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scrollbar-color: var(--rule-strong) var(--paper); -webkit-text-size-adjust: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; caret-color: var(--cobalt); font-variant-numeric: tabular-nums; }
::selection { background: var(--cobalt-pale); color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; border-radius: 3px; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: clamp(40px, 5.2vw, 76px); line-height: 1.03; }
h2 { font-size: clamp(30px, 3.4vw, 48px); line-height: 1.1; }
.muted { color: var(--graphite); }

a.arrow, a.plain { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: 5px; transition: color .15s linear, text-decoration-color .15s linear; }
a.arrow::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 11px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-3px) rotate(45deg); transition: transform .3s var(--ease); }
a.arrow:hover::after { transform: translateY(1px) rotate(45deg); }
a.arrow:hover, a.plain:hover { color: var(--cobalt); text-decoration-color: currentColor; }

/* ---------- rail ---------- */
.rail { position: fixed; z-index: 10; inset: 0 auto 0 0; width: var(--rail); overflow: hidden; display: flex; flex-direction: column; gap: 48px; padding: 24px 0; background: var(--paper); border-right: 1px solid var(--rule); transition: width .45s var(--ease); }
.rail:hover, .rail:focus-within { width: 180px; }
.rail-mark { display: flex; align-items: center; gap: 14px; padding-left: 24px; color: var(--ink); text-decoration: none; }
.rail-mark svg { flex: none; }
.rail-name { font-family: var(--serif); font-size: 22px; opacity: 0; transition: opacity .3s var(--ease); }
.rail:hover .rail-name, .rail:focus-within .rail-name { opacity: 1; }
.rail ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.rail li a { display: flex; align-items: center; height: clamp(48px, calc((100dvh - 160px) / 6), 110px); padding-left: 25px; color: var(--graphite); font-size: 14px; text-decoration: none; white-space: nowrap; transition: height .45s var(--ease), color .15s linear; }
.rail li a span { display: block; writing-mode: vertical-rl; transform: rotate(180deg); }
.rail:hover li a, .rail:focus-within li a { height: 40px; }
.rail:hover li a span, .rail:focus-within li a span { writing-mode: horizontal-tb; transform: none; }
.rail li a[aria-current="location"] { color: var(--ink); font-weight: 600; }
.rail li a[aria-current="location"] span { border-right: 2px solid var(--cobalt); padding-right: 0; }
.rail:hover li a[aria-current="location"] span { border-right: 0; }
.rail li a:hover, .rail li a:focus-visible { color: var(--cobalt); }

main, .site-foot { margin-left: var(--rail); }

/* ---------- hero ---------- */
.hero { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, min(44vw, calc(100svh - 160px))); gap: clamp(32px, 4vw, 72px); align-items: center; padding: clamp(32px, 4vh, 56px) var(--gutter); }
.hero-text { max-width: 44rem; }
.lead { margin-top: 32px; max-width: 34em; font-size: clamp(18px, 1.45vw, 21px); line-height: 1.5; }
.hero-honest { margin-top: 16px; max-width: 36em; color: var(--graphite); }
.hero-links { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 36px; }

.field { min-width: 0; display: grid; gap: 18px; }
.squares { display: grid; grid-template-columns: repeat(15, 1fr); gap: clamp(3px, .5vw, 6px); }
.sq { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--cobalt); transition: background-color .45s var(--ease), transform .2s var(--ease); }
button.sq:hover, button.sq:focus-visible { transform: scale(1.18); position: relative; z-index: 1; }
.sq.ask { background: var(--ochre-pale); }
.sq.link { background: var(--plum); }
.sq.wrong { background: var(--vermilion); }
.field figcaption { display: grid; gap: 10px; font-size: 14px; color: var(--graphite); line-height: 1.45; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--ink); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sq { width: 12px; height: 12px; }
.field-readout { min-height: 2.9em; color: var(--ink); }
.field-readout .k { font-family: var(--mono); font-size: 13px; color: var(--cobalt); }
.field-note { font-size: 13px; }

.switch { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 4px; overflow: hidden; width: max-content; max-width: 100%; }
.switch button { padding: 8px 16px; font-family: var(--mono); font-size: 13px; color: var(--graphite); transition: background-color .2s, color .2s; }
.switch button + button { border-left: 1px solid var(--rule-strong); }
.switch button:hover { color: var(--ink); background: var(--paper-deep); }
.switch button[aria-checked="true"] { background: var(--cobalt); color: #fff; }

/* ---------- breaker ---------- */
.breaker { border: 1px solid var(--rule); border-radius: 4px; background: var(--card); padding: clamp(20px, 3vw, 36px); display: grid; gap: 18px; }
.breaker-row { display: flex; flex-wrap: wrap; gap: 10px; }
.breaker .btn:disabled { opacity: .45; cursor: not-allowed; }
.meter { height: 14px; border-radius: 2px; background: var(--paper-deep); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--cobalt); transition: width .25s; }
.meter span.over { background: var(--vermilion); }
.breaker-status { font-weight: 500; }
.breaker-status.bad { color: var(--vermilion-ink); }

/* ---------- bands ---------- */
.band { padding: clamp(80px, 10vw, 150px) var(--gutter); border-top: 1px solid var(--rule); }
.split { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(40px, 5vw, 96px); align-items: start; }
.band-head { position: sticky; top: 48px; }
.band-head p, .band-lead { margin-top: 24px; max-width: 36em; color: var(--graphite); }
.band-wide { max-width: 60rem; margin-bottom: 40px; }

/* ---------- explorer ---------- */
.explorer { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); border: 1px solid var(--rule); border-radius: 4px; background: var(--card); overflow: hidden; }
.list { border-right: 1px solid var(--rule); display: flex; flex-direction: column; max-height: 860px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-bottom: 1px solid var(--rule); background: var(--paper-deep); }
.chip { border: 1px solid var(--rule-strong); background: var(--card); border-radius: 999px; padding: 3px 11px; font-size: 13px; font-weight: 500; color: var(--graphite); }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.rows { list-style: none; overflow-y: auto; }
.rows button { width: 100%; text-align: left; border-bottom: 1px solid var(--rule); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 2px 8px; align-items: center; transition: background .15s; }
.rows button:hover { background: var(--paper); }
.rows button[aria-current="true"] { background: var(--cobalt-tint); }
.rows .key { font-family: var(--mono); font-size: 12px; color: var(--graphite); }
.rows button[aria-current="true"] .key { color: var(--cobalt); font-weight: 500; }
.rows .sum { grid-column: 1 / -1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .lozenge { grid-row: 1; grid-column: 2; }

.lozenge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.lozenge.clear { background: var(--cobalt-tint); color: var(--cobalt); }
.lozenge.link { background: var(--plum-tint); color: var(--plum); }
.lozenge.ask { background: var(--ochre-tint); color: var(--ochre); }
.lozenge.wrong { background: var(--vermilion-ink); color: #fff; }

.issue { padding: 28px 32px 32px; min-width: 0; }
.meta { font-family: var(--mono); font-size: 12px; color: var(--graphite); }
.issue h3 { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.2; letter-spacing: -.01em; margin: 6px 0 12px; text-wrap: balance; }
.desc { margin-bottom: 24px; font-size: 14px; color: var(--graphite); white-space: pre-wrap; max-height: 8.5em; overflow: hidden; position: relative; }
.desc::after { content: ""; position: absolute; inset: auto 0 0 0; height: 3em; background: linear-gradient(transparent, var(--card)); }
.panel { border-top: 1px solid var(--rule); padding-top: 22px; display: grid; gap: 20px; }
.call { border: 1px solid var(--cobalt-pale); background: var(--cobalt-tint); border-radius: 4px; padding: 18px 20px; }
.call.link { border-color: #e0cdea; background: var(--plum-tint); }
.call.ask { border-color: var(--ochre-pale); background: var(--ochre-tint); }
.call .headline { font-family: var(--serif); font-size: 22px; line-height: 1.3; margin-top: 10px; }
.budget { display: flex; gap: 20px; align-items: center; }
.budget strong { font-family: var(--serif); font-weight: 300; font-size: 48px; line-height: 1; color: var(--cobalt); }
.budget p { font-size: 15px; color: var(--graphite); max-width: 32em; }
.next { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 12px 0; font-size: 15px; }
.label { font-size: 13px; font-weight: 600; color: var(--graphite); margin-bottom: 6px; }
.why p:not(.label) { font-size: 15px; }
.cands { list-style: none; border-top: 1px solid var(--rule-strong); }
.cands li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.cands li > span:first-child { display: flex; align-items: center; gap: 10px; }
.cands button { color: var(--cobalt); font-family: var(--mono); font-size: 14px; font-weight: 500; }
.cands button:hover { text-decoration: underline; text-underline-offset: 4px; }
.cands .title { font-size: 14px; }
.cands .score { font-family: var(--mono); font-size: 13px; color: var(--graphite); }
.note { font-size: 13px; color: var(--graphite); margin-top: 6px; }
.truth { border-radius: 4px; padding: 14px 18px; font-size: 15px; background: var(--paper-deep); }
.truth.bad { background: var(--vermilion-tint); color: #5e1a0e; }
.truth.bad b { color: var(--vermilion-ink); }
.verdict { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.verdict b { font-weight: 600; margin-right: 6px; }
.btn { min-height: 40px; border: 1px solid var(--rule-strong); border-radius: 4px; padding: 8px 20px; font-weight: 500; transition: background .2s, color .2s, border-color .2s; }
.btn:hover { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.thanks { color: var(--cobalt); }

/* ---------- figures and bars ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px var(--gutter); margin: 48px 0; max-width: 1100px; }
.facts-tight { margin: 40px 0 8px; }
.facts dt { font-family: var(--serif); font-size: clamp(34px, 3.6vw, 52px); font-weight: 300; line-height: 1.05; color: var(--cobalt-deep); }
.facts dt.bad { color: var(--vermilion-ink); }
.facts dd { margin-top: 8px; color: var(--graphite); font-size: 15px; line-height: 1.5; max-width: 28ch; }
.hbars { margin-top: clamp(40px, 5vw, 64px); max-width: 1100px; }
.hbars figcaption { padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); color: var(--graphite); font-size: 15px; }
.hbars dl > div { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 24px; align-items: center; min-height: 58px; border-bottom: 1px solid var(--rule); }
.hbars dt { font-size: 15px; color: var(--graphite); }
.hbars dl > div.on dt { color: var(--ink); font-weight: 600; }
.hbars dd { display: flex; align-items: center; gap: 14px; min-width: 0; }
.bar { display: block; height: 14px; flex-shrink: 0; background: var(--cobalt-pale); border-radius: 0 4px 4px 0; transform-origin: left; animation: grow .8s var(--ease) both; }
.hbars dl > div.on .bar, .hbars .bar:not(.is-baseline):only-child { background: var(--cobalt); }
#results-bars .bar:not(.is-baseline) { background: var(--cobalt); }
.bar.is-baseline { background: var(--slate); }
.hbars .v { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
@keyframes grow { from { transform: scaleX(0.02); } }
.foot { margin-top: 32px; max-width: 52em; color: var(--graphite); font-size: 15px; }
#dial .switch { margin-top: 4px; }

/* ---------- how and limits ---------- */
.steps, .limits { list-style: none; border-top: 1px solid var(--rule-strong); }
.steps { counter-reset: step; }
.steps li, .limits li { display: grid; grid-template-columns: minmax(180px, 18rem) minmax(0, 1fr); gap: 8px 32px; align-items: baseline; padding: 26px 0; border-bottom: 1px solid var(--rule); }
.steps li { counter-increment: step; grid-template-columns: 44px minmax(120px, 10rem) minmax(0, 1fr); }
.steps li::before { content: counter(step); font-family: var(--serif); font-weight: 300; font-size: 32px; line-height: 1; color: var(--cobalt); }
.steps b, .limits b { font-family: var(--serif); font-weight: 400; font-size: 23px; line-height: 1.2; color: var(--ink); }
.steps p, .limits p { color: var(--graphite); max-width: 40em; }
.limits li::before { content: none; }

/* ---------- footer ---------- */
.site-foot { padding: 40px var(--gutter) 56px; border-top: 1px solid var(--rule); display: grid; gap: 12px; }
.footer-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; color: var(--graphite); }
.attribution { font-size: 12px; color: var(--graphite); max-width: 90ch; }

@media (max-width: 1080px) {
  .explorer { grid-template-columns: 1fr; }
  .list { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 320px; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 56px; }
  .split { grid-template-columns: 1fr; }
  .band-head { position: static; }
}
@media (max-width: 760px) {
  .steps li { grid-template-columns: 40px minmax(0, 1fr); }
  .steps li p { grid-column: 2; }
  .limits li { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --rail: 0px; }
  .rail { display: none; }
  .issue { padding: 22px 18px; }
  .hbars dl > div { grid-template-columns: 1fr; gap: 6px; padding: 10px 0; }
  .switch button { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}
