/* Battery Life Cycle — site stylesheet.
   One accent (blue from the logo), one neutral ramp, dark theme by the same roles. */

:root {
  --bg:          #f7f8fa;
  --surface:     #ffffff;
  --surface-alt: #f1f3f6;
  --ink:         #11151c;
  --ink-2:       #5b6573;
  --ink-3:       #66707d;
  --line:        #e5e8ee;
  --line-soft:   #eef1f5;
  --accent:      #1c6ce0;
  --accent-dark: #0f4fa8;
  --accent-wash: #e9f1fc;
  --crit:        #c2334d;
  --logo-bg:     #26384e;

  --measure: 36rem;
  --s--1: 0.8125rem;
  --s-0:  1.0625rem;
  --s-1:  1.25rem;
  --s-2:  1.625rem;
  --s-3:  2.25rem;
  --s-4:  3rem;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0d1117;
    --surface:     #151b23;
    --surface-alt: #1b222b;
    --ink:         #e8ecf1;
    --ink-2:       #9aa4b2;
    --ink-3:       #808b99;
    --line:        #252d38;
    --line-soft:   #1c232c;
    --accent:      #5c9df0;
    --accent-dark: #8bbaf5;
    --accent-wash: #132235;
    --crit:        #e4708a;
  }
}

:root[data-theme="dark"] {
  --bg:          #0d1117;
  --surface:     #151b23;
  --surface-alt: #1b222b;
  --ink:         #e8ecf1;
  --ink-2:       #9aa4b2;
  --ink-3:       #808b99;
  --line:        #252d38;
  --line-soft:   #1c232c;
  --accent:      #5c9df0;
  --accent-dark: #8bbaf5;
  --accent-wash: #132235;
  --crit:        #e4708a;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--s-0);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ——— top bar: logo and page menu ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.625rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
  flex-shrink: 0;
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: block;
}
.brand-name {
  font-weight: 600;
  font-size: var(--s--1);
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-name em {
  display: block;
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.topnav { display: flex; flex-wrap: wrap; gap: 0.125rem 0.25rem; justify-content: flex-end; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  font-size: var(--s--1);
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.topnav a:hover, .topnav a:focus-visible { background: var(--surface-alt); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-wash); font-weight: 500; }

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding-inline: 1.25rem;
  padding-block: 3rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: var(--s-4); line-height: 1.05; }
h2 { font-size: var(--s-2); line-height: 1.2; }
h3 { font-size: var(--s-0); letter-spacing: 0; }
p { margin: 0; max-width: var(--measure); }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--s--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.lede { font-size: var(--s-1); line-height: 1.5; color: var(--ink-2); max-width: 40rem; }
.ident {
  font-family: var(--mono);
  font-size: var(--s--1);
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1.5rem;
}

header { display: flex; flex-direction: column; gap: 1.5rem; }
section { display: flex; flex-direction: column; gap: 1.5rem; }
.prose { display: flex; flex-direction: column; gap: 1rem; }

/* ——— impedance chart ——— */
.plot-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0; }
.plot-head {
  padding: 1.25rem 1.375rem 0;
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem;
  align-items: baseline; justify-content: space-between;
}
.plot-title { font-weight: 600; font-size: var(--s-0); }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: var(--s--1); font-family: var(--mono); }
.legend > * { white-space: nowrap; }
.legend b { display: inline-flex; align-items: center; gap: 0.4375rem; font-weight: 400; }
.swatch { width: 14px; height: 3px; border-radius: 2px; }
.sw-new { background: var(--accent); }
.sw-aged { background: var(--crit); }

.plot-body { padding: 0.5rem 0.75rem 0; }
svg.plot { display: block; width: 100%; height: auto; touch-action: pan-y; }
.grid line { stroke: var(--line-soft); stroke-width: 1; }
.axis text { fill: var(--ink-3); font-family: var(--mono); font-size: 10px; }
.axis-label { fill: var(--ink-2); font-size: 11px; font-family: var(--sans); }
.curve { fill: none; stroke-width: 2; stroke-linejoin: round; }
.curve-new { stroke: var(--accent); }
.curve-aged { stroke: var(--crit); }
.dot-new { fill: var(--accent); }
.dot-aged { fill: var(--crit); }
.marker { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.halo { fill: none; stroke-width: 2; }
.halo-new { stroke: var(--accent); }
.halo-aged { stroke: var(--crit); }

.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); border-top: 1px solid var(--line); background: var(--surface-alt); margin: 0; }
.ro { padding: 0.875rem 1.375rem; display: flex; flex-direction: column; gap: 0.125rem; border-right: 1px solid var(--line); }
.ro:last-child { border-right: 0; }
.ro dt { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.ro dd { margin: 0; font-family: var(--mono); font-size: var(--s-1); font-variant-numeric: tabular-nums; }
.ro.is-new dd { color: var(--accent); }
.ro.is-aged dd { color: var(--crit); }

.slider-row { padding: 1.125rem 1.375rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.5rem; }
.slider-row label { font-family: var(--mono); font-size: var(--s--1); color: var(--ink-2); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); background: transparent; }

figcaption.credit { padding: 0.875rem 1.375rem 1.125rem; border-top: 1px solid var(--line); font-size: 0.8125rem; line-height: 1.55; color: var(--ink-2); margin: 0; }

/* ——— figures ——— */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { background: var(--surface); padding: 1.125rem 1.25rem; display: flex; flex-direction: column; gap: 0.25rem; }
.stat b { font-family: var(--mono); font-size: var(--s-2); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: var(--s--1); color: var(--ink-2); line-height: 1.45; }

/* ——— cards ——— */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.875rem; }
.card { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.125rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; }
.card:hover, .card:focus-visible { border-color: var(--accent); }
.card .kind { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.card p { font-size: var(--s--1); color: var(--ink-2); max-width: none; }
.card .state { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); }

/* ——— lists and findings ——— */
.gaps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 2rem; }
.gaps li { font-size: var(--s--1); line-height: 1.5; padding: 0.5rem 0; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }

.finding { display: flex; flex-direction: column; gap: 0.5rem; padding-left: 1rem; border-left: 2px solid var(--line); }
.finding.lead { border-left-color: var(--accent); }

table { border-collapse: collapse; font-family: var(--mono); font-size: var(--s--1); font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.tnote { font-size: var(--s--1); color: var(--ink-2); margin-top: 0.75rem; }
.nowrap { white-space: nowrap; }

/* ——— one record, shown in full: label above, value below ——— */
.record {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) 1fr;
  gap: 0.75rem 2rem;
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.record dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding-top: 0.15rem;
}
.record dd { margin: 0; font-size: var(--s-0); color: var(--ink); }
.record dd em { font-style: italic; }
.record .nostate { color: var(--ink-2); font-family: var(--mono); font-size: 0.9em; }
.record q { quotes: "\201C" "\201D"; font-style: italic; color: var(--ink-2); }
@media (max-width: 40rem) {
  .record { grid-template-columns: 1fr; gap: 0.25rem 0; }
  .record dt { padding-top: 0.875rem; }
  .record dd { padding-bottom: 0.25rem; }
}
th, td { text-align: left; padding: 0.4375rem 1.5rem 0.4375rem 0; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
td:first-child { white-space: normal; min-width: 11rem; }
th { font-weight: 500; color: var(--ink-3); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; }

.terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.75rem 2.5rem; }
.term { display: flex; flex-direction: column; gap: 0.375rem; }
.term h3 { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.term p { font-size: var(--s--1); line-height: 1.55; max-width: none; }

/* ——— page footer ——— */
.pagefoot { border-top: 1px solid var(--line); padding-top: 1.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.contact-rows { font-family: var(--mono); font-size: var(--s--1); color: var(--ink-2); display: flex; flex-direction: column; gap: 0.375rem; }
.contact-rows a, .half .who-rows a { min-height: 44px; display: inline-flex; align-items: center; }
.updated { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }

.next-page { display: inline-flex; align-items: center; gap: 0.4375rem; font-size: var(--s--1); min-height: 44px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ——— head of the page: person and subject as equal halves ——— */
.pair-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 2rem 3rem;
  align-items: start;
}
.half { display: flex; flex-direction: column; gap: 0.875rem; }
.half > h1, .half > .who-name { font-size: var(--s-3); line-height: 1.08; font-weight: 700; }
.half .role { font-size: var(--s-1); line-height: 1.4; color: var(--ink-2); max-width: 26rem; }
.half .who-rows {
  font-family: var(--mono);
  font-size: var(--s--1);
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 0.3125rem;
}
.half .who-rows a { color: var(--accent); }
.half-topic { border-left: 2px solid var(--accent); padding-left: 1.5rem; }
@media (max-width: 40rem) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 0.625rem; }
  .topnav { justify-content: flex-start; }
  .embed-frame { height: auto; aspect-ratio: 420 / 1100; max-height: none; }

  .half-topic { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 1.5rem; }
}
.half-topic p { font-size: var(--s-0); color: var(--ink-2); }

/* ——— embedded animation: opens in place, not behind a link ——— */
.embed-frame {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  height: min(78vh, 46rem);
}
.embed-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.embed-note { font-size: var(--s--1); color: var(--ink-3); }

/* ——— long explainers: a row with a read link ——— */
.reads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.reads li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.125rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.reads li:first-child { border-top: 1px solid var(--line-soft); }
.reads li > div { display: flex; flex-direction: column; gap: 0.25rem; flex: 1 1 22rem; }
.reads p { font-size: var(--s--1); color: var(--ink-2); max-width: 34rem; }
.read-link {
  font-family: var(--mono);
  font-size: var(--s--1);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
}
.read-link:hover, .read-link:focus-visible { border-color: var(--accent); background: var(--accent-wash); }
