@import url('/assets/css/fonts.css');
@import url('/assets/css/tokens.css');

/* =========================================================================
   Reset
   ========================================================================= */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--ink-700);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img,
picture,
svg,
video { display: block; max-width: 100%; height: auto; }

input,
button,
textarea,
select { font: inherit; color: inherit; }

/* =========================================================================
   Type
   ========================================================================= */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink-900);
  line-height: var(--leading-snug);
  font-weight: 700;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  font-variation-settings: 'wdth' var(--wdth-wide);
  letter-spacing: -0.015em;
}

h2 { font-size: var(--text-xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); font-weight: 600; }
h4 { font-size: var(--text-md); font-weight: 600; }

p { text-wrap: pretty; }

a { color: var(--signal); text-underline-offset: 0.18em; text-decoration-thickness: from-font; }
a:hover { color: var(--signal-deep); }

strong { font-weight: 600; color: var(--ink-900); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip link — visible the moment it takes focus. */
.skip {
  position: absolute;
  left: var(--s-4);
  top: -4rem;
  z-index: 100;
  background: var(--ink-900);
  color: var(--paper);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: top var(--dur) var(--ease-out);
}
.skip:focus { top: var(--s-4); color: var(--paper); }

/* =========================================================================
   Layout
   ========================================================================= */

.wrap {
  width: min(100% - 2.5rem, var(--width-page));
  margin-inline: auto;
}
.wrap--wide { width: min(100% - 2.5rem, var(--width-wide)); }

.section { padding-block: var(--s-8); }
.section--tight { padding-block: var(--s-7); }
.section--sunk { background: var(--surface-sunk); }

@media (min-width: 48rem) {
  .section { padding-block: var(--s-9); }
  .section--tight { padding-block: var(--s-8); }
}

/* An eyebrow states what a section is. Mono, so it reads as a label rather
   than as more prose. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: var(--s-3);
}
.eyebrow--hv { color: var(--hv); }

.section-head { margin-bottom: var(--s-6); max-width: 46rem; }
.section-head p { color: var(--ink-500); margin-top: var(--s-3); }

/* =========================================================================
   The data plate — this site's signature

   Every article and card wears a strip of machine-readable facts, set in mono
   and letterspaced like the plate riveted to a machine. It carries only things
   that are true and checkable: what it covers, how long it takes to read, and
   when it was written.
   ========================================================================= */

.plate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-500);
  line-height: 1.5;
}

.plate--framed {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-block: var(--s-3);
}

.plate__key { color: var(--hv); font-weight: 600; }
.plate__sep { color: var(--rule-strong); }
.plate a { color: inherit; text-decoration: none; }
.plate a:hover { color: var(--hv); text-decoration: underline; }

/* A revision is stated, not hidden. */
.plate__flag {
  color: var(--warn);
  font-weight: 600;
}

/* =========================================================================
   Charge bar — reading progress, drawn as state of charge

   State of charge is the one instrument every electric vehicle has. Using it
   for reading progress means the device does a real job (where am I in this
   article) in the subject's own vernacular.
   ========================================================================= */

.charge {
  position: fixed;
  inset-inline: 0;
  top: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

.charge__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--hv-deep), var(--hv-bright));
  transform-origin: left center;
  transition: width 90ms linear;
}

/* =========================================================================
   Header
   ========================================================================= */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-3);
}

.wordmark {
  font-family: var(--font-display);
  font-variation-settings: 'wdth' var(--wdth-wide);
  font-weight: 800;
  font-size: var(--text-md);
  letter-spacing: 0.01em;
  color: var(--ink-900);
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.wordmark:hover { color: var(--ink-900); }
.wordmark b { color: var(--hv); font-weight: inherit; }

.nav { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; }

.nav a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-500);
  text-decoration: none;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.nav a:hover { color: var(--ink-900); background: var(--surface-sunk); }
.nav a[aria-current='page'] { color: var(--hv); }

@media (max-width: 47.99rem) {
  .masthead__inner { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
  .nav { gap: 0; margin-inline: calc(var(--s-2) * -1); }
  .nav a { padding: var(--s-2); }
}

/* =========================================================================
   Home hero — the thesis is breadth
   ========================================================================= */

.hero { padding-block: var(--s-8) var(--s-7); }

@media (min-width: 48rem) {
  .hero { padding-block: var(--s-9) var(--s-8); }
}

.hero__title {
  font-size: var(--text-hero);
  font-variation-settings: 'wdth' var(--wdth-wide);
  font-weight: 800;
  line-height: 0.94;
  letter-spacing: -0.03em;
  color: var(--ink-900);
  max-width: 14ch;
}
.hero__title em {
  font-style: normal;
  color: var(--hv);
}

.hero__lede {
  margin-top: var(--s-5);
  font-size: var(--text-md);
  color: var(--ink-500);
  max-width: 46ch;
}

/* The index of subjects. This is the argument: the site is not an EV-car blog,
   and the fastest way to prove it is to show the range. */
.index-rail {
  margin-top: var(--s-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.index-rail li { list-style: none; }

.index-rail a {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-700);
  text-decoration: none;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  transition:
    transform var(--dur) var(--ease-spring),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.index-rail a:hover {
  color: var(--hv);
  border-color: var(--hv);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   Cards
   ========================================================================= */

.grid {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition:
    transform var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-strong);
}

.card__media {
  aspect-ratio: 16 / 9;
  background: var(--surface-sunk);
  overflow: hidden;
}
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out);
}
.card:hover .card__media img { transform: scale(1.035); }

.card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); flex: 1; }

.card__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  line-height: var(--leading-snug);
  color: var(--ink-900);
  letter-spacing: -0.005em;
}

/* The whole card is the target, but only the title is the link — so the
   accessible name stays the headline rather than the whole block of text. */
.card__title a { color: inherit; text-decoration: none; }
.card__title a::after { content: ''; position: absolute; inset: 0; }
.card:hover .card__title { color: var(--hv); }

.card__summary {
  font-size: var(--text-sm);
  color: var(--ink-500);
  line-height: 1.6;
  flex: 1;
}

.card .plate { margin-top: auto; }

/* =========================================================================
   Category hubs
   ========================================================================= */

.hub-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.hub-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-5) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  overflow: hidden;
  transition:
    transform var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}

/* A charge-level tick along the tile edge: how much of the site sits here. */
.hub-tile::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--fill, 20%);
  background: var(--hv-bright);
  transition: width var(--dur-slow) var(--ease-out);
}

.hub-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-strong);
}

.hub-tile__name {
  font-family: var(--font-display);
  font-variation-settings: 'wdth' var(--wdth-wide);
  font-weight: 800;
  font-size: var(--text-lg);
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.hub-tile:hover .hub-tile__name { color: var(--hv); }

.hub-tile__blurb { font-size: var(--text-sm); color: var(--ink-500); line-height: 1.55; }

.hub-tile__count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-top: var(--s-1);
}

/* =========================================================================
   Article
   ========================================================================= */

.article { padding-block: var(--s-7) var(--s-8); }

.article__head { max-width: var(--measure); margin-inline: auto; margin-bottom: var(--s-5); }
.article__head .plate { margin-top: var(--s-4); }

.article__hero {
  max-width: var(--width-page);
  margin: var(--s-6) auto var(--s-7);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-sunk);
}
.article__hero img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; }

/* An editor's note, shown where the reader will see it, because a rewrite that
   isn't disclosed is just a silent edit. */
.note {
  max-width: var(--measure);
  margin: 0 auto var(--s-6);
  padding: var(--s-4);
  background: var(--hv-wash);
  border-left: 3px solid var(--hv);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--ink-700);
}
.note strong {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--hv);
  margin-bottom: var(--s-2);
}

/* The 2026 addendum on a guide written years earlier. Distinct enough that a
   reader knows they are reading newer material, quiet enough not to shout over
   the article it belongs to. */
.prose .update {
  background: var(--surface-sunk);
  border-left: 3px solid var(--hv);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--s-5) var(--s-5) var(--s-4);
  margin-block: var(--s-6);
}

.prose .update > h2 {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
  font-size: var(--text-lg);
  color: var(--hv);
}

.prose .update > * + * { margin-top: var(--s-4); }
.prose .update > :last-child { margin-bottom: 0; }

.prose { max-width: var(--measure); margin-inline: auto; }

.prose > * + * { margin-top: var(--s-4); }
.prose > h2 { margin-top: var(--s-7); }
.prose > h3 { margin-top: var(--s-6); }
.prose > figure { margin-top: var(--s-6); }
.prose > figure + * { margin-top: var(--s-6); }

.prose h2 {
  font-size: var(--text-xl);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
}

.prose p { color: var(--ink-700); }

.prose a { color: var(--signal); }
.prose a:hover { color: var(--signal-deep); }

.prose ul,
.prose ol { padding-left: 1.25rem; display: flex; flex-direction: column; gap: var(--s-2); }
.prose li { color: var(--ink-700); }
.prose li::marker { color: var(--hv); }

.prose figure {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-sunk);
}
.prose figure img { width: 100%; }
.prose figcaption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-500);
  padding: var(--s-3);
  line-height: 1.5;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}
.prose th,
.prose td { text-align: left; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--rule); }
.prose th { color: var(--ink-900); font-weight: 600; }

/* Wide content must scroll inside itself, never push the page sideways. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.btn--primary { background: var(--hv); color: var(--on-hv); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--hv-deep); color: var(--on-hv); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0); box-shadow: none; background: var(--hv-deep); }

.btn--ghost { background: transparent; color: var(--ink-900); border-color: var(--rule-strong); }
.btn--ghost:hover { background: var(--surface); border-color: var(--ink-900); color: var(--ink-900); }

/* =========================================================================
   Footer
   ========================================================================= */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding-block: var(--s-7) var(--s-6);
  margin-top: var(--s-8);
}

.footer__grid {
  display: grid;
  gap: var(--s-6);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

.footer h2 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-bottom: var(--s-3);
}

.footer ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.footer a { color: var(--ink-700); text-decoration: none; font-size: var(--text-sm); }
.footer a:hover { color: var(--hv); text-decoration: underline; }

.footer__base {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-400);
  letter-spacing: 0.05em;
}

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }

.field label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-700);
}

.field input,
.field textarea {
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink-900);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--hv);
  box-shadow: 0 0 0 3px var(--hv-wash);
}
.field .hint { font-size: var(--text-sm); color: var(--ink-500); }

.hp { position: absolute; left: -9999px; }

/* =========================================================================
   Motion

   Reveals are staggered rather than simultaneous, and only run once the
   element is on screen. Anyone who has asked for less movement gets none.
   ========================================================================= */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --- Above the fold: CSS only ---------------------------------------------
   The hero animates on load through a keyframe, not through script. A CSS
   animation always runs to completion, so the headline cannot be left at
   opacity 0 by a blocked script, a hidden document, or an observer that never
   fires. Nothing a visitor sees first is allowed to depend on JavaScript. */

@media (prefers-reduced-motion: no-preference) {
  .stagger > * {
    animation: rise var(--dur-slow) var(--ease-out) both;
  }
  .stagger > *:nth-child(1) { animation-delay: 40ms; }
  .stagger > *:nth-child(2) { animation-delay: 130ms; }
  .stagger > *:nth-child(3) { animation-delay: 220ms; }
  .stagger > *:nth-child(4) { animation-delay: 310ms; }
  .stagger > *:nth-child(5) { animation-delay: 400ms; }

  /* The subject index cascades inside the hero's own sequence. Capped so a
     seventeen-item list still feels brisk rather than making anyone wait. */
  .index-rail li { animation: rise var(--dur) var(--ease-out) both; }
  .index-rail li:nth-child(1)  { animation-delay: 420ms; }
  .index-rail li:nth-child(2)  { animation-delay: 455ms; }
  .index-rail li:nth-child(3)  { animation-delay: 490ms; }
  .index-rail li:nth-child(4)  { animation-delay: 525ms; }
  .index-rail li:nth-child(5)  { animation-delay: 560ms; }
  .index-rail li:nth-child(6)  { animation-delay: 595ms; }
  .index-rail li:nth-child(7)  { animation-delay: 630ms; }
  .index-rail li:nth-child(8)  { animation-delay: 665ms; }
  .index-rail li:nth-child(n+9) { animation-delay: 700ms; }
}

/* --- Below the fold: observed ---------------------------------------------
   Scoped to .js (see the inline script in base.njk), so without scripting the
   rule never applies and every card is visible from the start. */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(14px);
  }
  .js .reveal.is-in {
    opacity: 1;
    transform: none;
    transition:
      opacity var(--dur-slow) var(--ease-out),
      transform var(--dur-slow) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .charge { display: none; }
}

/* Print: no animation state, no chrome, and every reveal target visible. */
@media print {
  .masthead,
  .charge,
  .footer,
  .index-rail { display: none; }

  .stagger > *,
  .index-rail li,
  .js .reveal {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  body { background: #fff; color: #000; }
  .prose { max-width: none; }
  a { text-decoration: underline; }
}

/* =========================================================================
   Utilities
   ========================================================================= */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stack-6 { display: flex; flex-direction: column; gap: var(--s-6); }
.lede { font-size: var(--text-md); color: var(--ink-500); }
.center-cta { display: flex; justify-content: center; margin-top: var(--s-7); }
