/* Interconnecting Intelligence
   Cool paper, graphite ink. Four layer colors carry meaning, not decoration:
   each fact wears its layer's color as a thin rule, and the home page stacks
   the layers as connected strata. */

:root {
  --paper: #eef1ee;
  --surface: #f7f9f7;
  --ink: #1f2a30;
  --ink-2: #4d5a60;
  --rule: #c9d0cb;
  --focus: #1f6e8c;

  /* Layer colors: validated as a categorical set (all checks pass on --paper; the
     closest color-blind pair is in the 6-8 band, allowed because a layer name always
     appears as text beside its color). The -ink steps are for text (>= 5.7:1). */
  --demand: #b0418a;  --demand-ink: #8c2f6c;
  --compute: #2a6fc9; --compute-ink: #1f56a3;
  --energy: #c25e00;  --energy-ink: #934600;
  --chips: #198a5c;   --chips-ink: #126b46;

  --serif: "Literata", Georgia, serif;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --measure: 46rem;
}

.l-demand  { --layer: var(--demand);  --layer-ink: var(--demand-ink); }
.l-compute { --layer: var(--compute); --layer-ink: var(--compute-ink); }
.l-energy  { --layer: var(--energy);  --layer-ink: var(--energy-ink); }
.l-chips   { --layer: var(--chips);   --layer-ink: var(--chips-ink); }
.l-none    { --layer: var(--rule);    --layer-ink: var(--ink-2); }

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-stretch: 87.5%;
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.wrap { width: min(100% - 2rem, 62rem); margin-inline: auto; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- masthead ---------- */

.masthead { border-bottom: 1px solid var(--rule); background: var(--surface); }
.masthead-inner {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between;
  gap: 0.75rem 2rem; padding-block: 1.25rem 1rem;
}
.brand { text-decoration: none; display: grid; gap: 0.1rem; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.005em; }
.brand-tag { font-size: 0.875rem; color: var(--ink-2); }
.masthead nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; font-size: 0.9375rem; font-weight: 500; }
.masthead nav a { text-decoration: none; padding-block: 0.2rem; border-bottom: 2px solid transparent; }
.masthead nav a:hover { border-bottom-color: var(--rule); }
.masthead nav a.nav-layer:hover, .masthead nav a.nav-layer[aria-current="page"] { border-bottom-color: var(--layer); }
.masthead nav a[aria-current="page"] { border-bottom-color: var(--ink); }

main { padding-block: 2.5rem 4rem; }

/* ---------- home: intro and the stack ---------- */

.intro { max-width: var(--measure); }
.intro-title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.625rem); line-height: 1.15; letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}
.intro-lead { margin: 0; color: var(--ink-2); font-size: 1.125rem; max-width: 40rem; }

.stack { margin-block: 2.25rem 3rem; display: grid; --node-x: 1.3rem; --node-y: 1.95rem; }
.stratum {
  position: relative; display: grid; grid-template-columns: 2.6rem 8rem 1fr auto; align-items: baseline;
  gap: 0 1rem; padding: 1rem 1rem 1rem 0; text-decoration: none;
  border-top: 1px solid var(--rule);
  background: linear-gradient(to right, color-mix(in srgb, var(--layer) 9%, transparent), transparent 70%);
}
.stratum:last-child { border-bottom: 1px solid var(--rule); }
.stratum::before {
  /* the node where this layer meets the line, centered at (--node-x, --node-y) */
  content: ""; grid-column: 1; justify-self: center; align-self: start;
  margin-top: calc(var(--node-y) - 1rem - 0.425rem);
  width: 0.85rem; height: 0.85rem; border-radius: 50%; background: var(--layer);
  box-shadow: 0 0 0 3px var(--paper); position: relative; z-index: 1;
}
.stratum::after {
  /* the interconnect: a segment per layer, joined into one line through every node */
  content: ""; position: absolute; left: calc(var(--node-x) - 1px); width: 2px; top: 0; bottom: 0; background: var(--ink);
}
.stratum:first-child::after { top: var(--node-y); }
.stratum:last-child::after { bottom: auto; height: var(--node-y); }
.stratum:hover { background: linear-gradient(to right, color-mix(in srgb, var(--layer) 18%, transparent), transparent 80%); }
.stratum-name { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; color: var(--layer-ink); }
.stratum-about { color: var(--ink-2); font-size: 0.9375rem; }
.stratum-count { font-size: 0.875rem; font-weight: 500; white-space: nowrap; }

/* ---------- section and page heads ---------- */

.section-title { font-family: var(--serif); font-weight: 600; font-size: 1.375rem; margin: 0 0 0.25rem; }
.page-head { max-width: var(--measure); margin-bottom: 1.5rem; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.375rem); line-height: 1.15; margin: 0 0 0.5rem; }
.page-lead { color: var(--ink-2); margin: 0; font-size: 1.0625rem; }
.page-count { margin: 0.5rem 0 0; font-weight: 500; font-size: 0.9375rem; }
.layer-head { border-left: 6px solid var(--layer); padding-left: 1rem; }
.layer-head h1 { color: var(--layer-ink); }

/* ---------- items ---------- */

.items { display: grid; max-width: var(--measure); }
.item {
  border-left: 3px solid var(--layer); padding: 1.1rem 0 1.15rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.item-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; font-size: 0.8125rem; color: var(--ink-2); margin-bottom: 0.3rem; }
.layer-tag { color: var(--layer-ink); font-weight: 600; text-decoration: none; }
.layer-tag:hover { text-decoration: underline; }
.item-body { display: flex; align-items: baseline; justify-content: space-between; gap: 1.25rem; }
.item-headline { font-family: var(--serif); font-weight: 600; font-size: 1.1875rem; line-height: 1.3; margin: 0; }
.item-headline a { text-decoration: none; }
.item-headline a:hover { text-decoration: underline; }
.item-size { margin: 0; flex: none; font-weight: 500; font-stretch: 100%; font-size: 1.0625rem; color: var(--layer-ink); }
.item-summary { margin: 0.35rem 0 0; color: var(--ink-2); font-size: 0.9688rem; max-width: 40rem; }
.item-source { margin: 0.55rem 0 0; display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; font-size: 0.8125rem; }
.company { font-weight: 500; text-decoration-style: dotted; }
.source { color: var(--ink-2); }

.empty { color: var(--ink-2); padding: 1.25rem 0; border-top: 1px solid var(--rule); max-width: var(--measure); }
.more { margin-top: 1.25rem; font-weight: 500; }
.latest .items, .latest .empty { margin-top: 0.5rem; }

/* ---------- feed filters ---------- */

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
  max-width: var(--measure); padding-block: 0.75rem; margin-bottom: 0.5rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.filter-layers { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.9375rem; font-weight: 500; }
.filter-layers a { text-decoration: none; border-bottom: 2px solid transparent; }
.filter-layers a[aria-current="true"] { border-bottom-color: var(--layer, var(--ink)); }
.filter-type { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; }
select, button {
  font: inherit; font-size: 0.9375rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.3rem 0.6rem;
}
button { font-weight: 500; cursor: pointer; }
button:hover { border-color: var(--ink-2); }

.pager { display: flex; justify-content: space-between; max-width: var(--measure); margin-top: 1.5rem; font-weight: 500; }

/* ---------- a single fact ---------- */

.fact { max-width: var(--measure); border-left: 6px solid var(--layer); padding-left: 1.25rem; }
.fact-layer { display: flex; gap: 0.9rem; font-size: 0.9375rem; color: var(--ink-2); margin: 0 0 0.5rem; }
.fact-headline { font-family: var(--serif); font-weight: 600; font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem); line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.75rem; }
.fact-summary { font-size: 1.125rem; margin: 0 0 1.5rem; max-width: 40rem; }
.fact-details { margin: 0; display: grid; border-top: 1px solid var(--rule); }
.fact-details > div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.fact-details dt { color: var(--ink-2); font-size: 0.9375rem; }
.fact-details dd { margin: 0; }
.fact-details .num { font-weight: 600; font-stretch: 100%; color: var(--layer-ink); }
.fact-note { font-size: 0.875rem; color: var(--ink-2); margin: 1rem 0 0; max-width: 40rem; }
.related { margin-top: 3rem; }

/* ---------- layer reference page ---------- */

.layer-nav {
  display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; max-width: var(--measure);
  padding-block: 0.7rem; margin-bottom: 0.5rem; font-size: 0.9375rem; font-weight: 500;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.layer-nav a { text-decoration: none; }
.layer-nav a:hover { text-decoration: underline; }

.layer-section { max-width: var(--measure); padding-top: 2.25rem; scroll-margin-top: 1rem; }
.section-note { color: var(--ink-2); font-size: 0.9375rem; margin: 0 0 1rem; max-width: 40rem; }
.sub-title { font-family: var(--serif); font-weight: 600; font-size: 1.0625rem; margin: 1.75rem 0 0.6rem; }
.prose-block p { max-width: 40rem; margin: 0 0 0.9rem; }
.cite { font-size: 0.7rem; line-height: 0; margin-left: 0.1em; }
.cite a { text-decoration: none; color: var(--layer-ink); font-weight: 600; padding: 0 0.1em; }
.cite a:hover { text-decoration: underline; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.steps li {
  counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; max-width: 42rem;
}
.steps li::before {
  content: counter(step); font-family: var(--serif); font-weight: 600; color: var(--layer-ink);
  border-top: 2px solid var(--layer); padding-top: 0.15rem; width: 1.25rem; text-align: left;
}
.steps li p { margin: 0; }
.steps li strong { font-weight: 600; }

.terms, .connections { margin: 0; display: grid; border-top: 1px solid var(--rule); }
.terms > div, .connections > div {
  display: grid; grid-template-columns: 13rem 1fr; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--rule);
}
.terms dt, .connections dt { font-weight: 600; }
.terms dd, .connections dd { margin: 0; color: var(--ink-2); }
.conn-layer { color: var(--layer-ink); text-decoration-color: var(--layer); }

table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
caption { text-align: left; font-weight: 600; padding: 0 0 0.4rem; }
th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 0.875rem; padding: 0.4rem 1rem 0.4rem 0; border-bottom: 1px solid var(--ink-2); }
td { padding: 0.55rem 1rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
td:last-child, th:last-child { padding-right: 0; }
.figures { margin-bottom: 1.75rem; }
.figures td.num { font-weight: 600; font-stretch: 100%; color: var(--layer-ink); white-space: nowrap; width: 7.5rem; }
.figures td.date { color: var(--ink-2); white-space: nowrap; width: 7rem; }
.figures td a { text-decoration: none; }
.figures td a:hover { text-decoration: underline; }
.signals td:first-child { font-weight: 500; width: 30%; }
.signals td:last-child { color: var(--ink-2); width: 28%; }

.counted { list-style: none; margin: 0; padding: 0; columns: 2 16rem; column-gap: 2.5rem; }
.counted li {
  display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule); break-inside: avoid;
}
.counted li span:last-child { color: var(--ink-2); font-weight: 500; }

.sources ol { margin: 0 0 0.75rem; padding-left: 1.4rem; font-size: 0.9375rem; display: grid; gap: 0.35rem; }
.sources li:target { background: color-mix(in srgb, var(--layer) 14%, transparent); }

/* ---------- charts ---------- */

.chart { margin: 1.5rem 0 1.75rem; max-width: var(--measure); }
.chart img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline; margin-top: 0.5rem; font-size: 0.875rem; color: var(--ink-2); }
.chart-download { font-weight: 600; color: var(--ink); }
.chart-data { margin-top: 0.4rem; font-size: 0.875rem; }
.chart-data summary { cursor: pointer; color: var(--ink-2); }
.chart-data table { margin-top: 0.5rem; font-size: 0.875rem; }
.fact-share { margin: 1rem 0 0; font-size: 0.9375rem; font-weight: 600; }

/* ---------- about ---------- */

.prose { max-width: 40rem; }
.prose h1 { font-family: var(--serif); font-weight: 600; font-size: 2.25rem; margin: 0 0 0.5rem; }
.prose h2 { font-family: var(--serif); font-weight: 600; font-size: 1.3125rem; margin: 2rem 0 0.5rem; }
.prose p, .prose li { max-width: 38rem; }
.prose .page-lead { font-size: 1.1875rem; }

/* ---------- footer ---------- */

.footer { border-top: 1px solid var(--rule); background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; padding-block: 1.5rem; font-size: 0.875rem; color: var(--ink-2); }
.footer p { margin: 0; }
.footer a { margin-left: 1rem; }

/* ---------- small screens ---------- */

@media (max-width: 40rem) {
  .stratum { grid-template-columns: 2.6rem 1fr; padding-right: 0.5rem; }
  .stratum-about, .stratum-count { grid-column: 2; }
  .item-body { flex-direction: column; gap: 0.2rem; }
  .fact-details > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .terms > div, .connections > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .signals thead { display: none; }
  .signals tr { display: grid; padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
  .signals td { border: 0; padding: 0.05rem 0; width: auto !important; }
  .figures td.date, .figures th:last-child { display: none; }
  .footer a { margin: 0 1rem 0 0; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
