/* AI economics: site stylesheet.
   Dense and quiet. Numbers sit in tabular figures under thin rules, labels are small and muted,
   and there is one accent. Green and red mark the sign of a change and nothing else.
   Phone-first, no framework, no build step. Dark mode follows the OS. */

:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #1b1b1a;
  --muted: #62615c;
  --line: #dedbd2;
  --rule: #8e8c85;
  --grid: #ebe8df;
  --accent: #2c5d8a;
  --accent-soft: rgba(44, 93, 138, 0.28);
  --ok: #2f6b4f;
  --warn: #8a5a12;
  --bad: #9b3b31;
  --code-bg: #f1efe8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --surface: #1c1d1b;
    --ink: #e7e5de;
    --muted: #a29f97;
    --line: #33342f;
    --rule: #6d6b64;
    --grid: #2a2b27;
    --accent: #8fb5dd;
    --accent-soft: rgba(143, 181, 221, 0.32);
    --ok: #7fc39f;
    --warn: #d9a850;
    --bad: #e08a80;
    --code-bg: #23241f;
  }
}

/* ---- base ------------------------------------------------------------------------------ */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border-radius: 2px;
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  margin: 1em 0;
  padding: 0.25em 0 0.25em 1em;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.wrap {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 40rem) {
  .wrap {
    padding: 0 1.5rem;
  }
}

/* ---- type ------------------------------------------------------------------------------ */

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.25rem;
  margin-top: 1.5em;
}

h3 {
  font-size: 1.05rem;
}

@media (min-width: 40rem) {
  h1 {
    font-size: 1.75rem;
  }
}

p,
ul,
ol {
  margin: 0 0 1em;
}

/* Writeups are read, not scanned, so they get a larger size and a text measure. A bare URL or a
   file path in inline code has no break point; without the wrap rule it pushes a phone page
   sideways. */
.prose {
  max-width: 72ch;
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.prose h2 {
  margin-top: 2em;
}

.prose li {
  margin-bottom: 0.35em;
}

.lede {
  font-size: 1.15rem;
}

.eyebrow,
.section > h2,
thead th,
caption {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.25rem;
}

.muted,
.source,
.note {
  color: var(--muted);
}

.source,
.note {
  font-size: 0.8rem;
  margin: 0 0 0.75rem;
}

.nowrap {
  white-space: nowrap;
}

.more {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

/* ---- header / nav ---------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

/* One line at every width: on a 375px phone the links do not always fit, so the row scrolls
   sideways inside the header instead of wrapping to a second line. */
.site-header nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.site-header nav::-webkit-scrollbar {
  display: none;
}

/* 44px tall targets: comfortable to tap with a thumb. */
.site-header a {
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.7rem 0.5rem;
  min-height: 44px;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--muted);
}

/* The scrolling nav clips anything drawn outside it, so the focus ring goes inside the link. */
.site-header a:focus-visible {
  outline-offset: -2px;
}

.site-header a:hover {
  color: var(--ink);
}

.site-header .brand {
  color: var(--ink);
  font-weight: 600;
  margin-right: auto;
  padding-left: 0;
}

main {
  padding: 1.5rem 0 2.5rem;
  min-width: 0;
}

.section {
  margin: 2rem 0;
}

.section > h2 {
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

/* ---- page header ----------------------------------------------------------------------- */

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin-bottom: 0.35rem;
}

.question {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
}

.page-header .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.page-header .meta a {
  padding: 0.25rem 0;
}

.ticker {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.7em;
}

.layer {
  text-transform: capitalize;
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-built {
  color: var(--accent);
}

.badge-pending {
  border-style: dashed;
}

/* Tracked for reported figures only: the quietest of the three. */
.badge-no-model {
  border-color: var(--line);
}

/* ---- key figures ----------------------------------------------------------------------- */

/* Two columns on a phone, so six tiles are three short rows and not one long column. */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.25rem;
  margin: 0;
}

@media (min-width: 40rem) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.kpi {
  min-width: 0;
  padding: 0.55rem 0 0.75rem;
  border-bottom: 1px solid var(--line);
}

.kpi dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.kpi dd {
  margin: 0;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.kpi-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* The sign of a change on a year earlier. Direction only: more debt is green too. */
.pos {
  color: var(--ok);
}

.neg {
  color: var(--bad);
}

.flat {
  color: var(--muted);
}

/* ---- writeup lists --------------------------------------------------------------------- */

.writeup-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.writeup-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.writeup-title {
  font-weight: 600;
  display: inline-block;
  padding: 0.15rem 0;
}

.writeup-list .meta {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.writeup-list .summary {
  margin: 0.25rem 0 0;
  max-width: 72ch;
  font-size: 0.95rem;
}

.tags {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.05rem 0.45rem;
}

.page-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- tables ---------------------------------------------------------------------------- */

/* Wide tables scroll inside this box; the page itself never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 0.5rem 0 1.5rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

caption {
  text-align: left;
  padding: 0.5rem 0 0.3rem;
}

th,
td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

/* The first and last cells line up with the section rule above instead of sitting inset. */
th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

thead th {
  border-bottom: 1px solid var(--rule);
  vertical-align: bottom;
  white-space: nowrap;
}

tbody th {
  font-weight: 500;
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--surface);
}

.num {
  text-align: right;
  white-space: nowrap;
}

.unit {
  color: var(--muted);
  white-space: nowrap;
}

/* Index table: ticker over name on a phone keeps the first column narrow, so the period and
   the first figure are on screen before any sideways scroll. */
.companies td,
.companies th {
  vertical-align: middle;
}

.co-ticker {
  font-weight: 600;
  text-decoration: none;
}

.co-ticker:hover {
  text-decoration: underline;
}

.co-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}

@media (min-width: 64rem) {
  .co-name {
    display: inline;
    margin-left: 0.4rem;
    font-size: 0.85rem;
  }
}

.calls td {
  min-width: 8rem;
}

/* Three short columns: at full width the value would sit a screen away from its label. */
.outputs {
  width: auto;
  min-width: min(100%, 22rem);
}

.basis {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 7rem;
}

/* The note is a sentence or two; without a floor the other columns squeeze it into a ribbon. */
.inputs td:last-child {
  min-width: 18rem;
}

.prose table {
  font-size: 0.9rem;
}

.outcome {
  font-weight: 600;
}

.outcome-open {
  color: var(--muted);
  font-weight: 400;
}

.outcome-right {
  color: var(--ok);
}

.outcome-wrong {
  color: var(--bad);
}

.outcome-partial {
  color: var(--warn);
}

.sources {
  font-size: 0.8rem;
  color: var(--muted);
}

.sources summary {
  cursor: pointer;
  padding: 0.25rem 0;
}

.sources ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  overflow-wrap: anywhere;
}

/* ---- stack ----------------------------------------------------------------------------- */

/* Stage names are phrases, not tickers, so unlike other row headers they wrap; the chain table
   then shows the unit and the lead time on a phone before it scrolls. */
.stages th[scope="row"],
.conversions th[scope="row"] {
  white-space: normal;
  min-width: 9rem;
}

.stages .order {
  color: var(--muted);
}

/* Free text ("sells", tier examples, notes) needs a floor or the numeric columns squeeze it into
   a one-word-per-line ribbon. */
.stages .sells,
.tiers .examples,
.figures td:last-child,
.conversions td:last-child,
.players td:last-child {
  min-width: 14rem;
}

/* A key figure in the chain table: the number on its own line, the metric under it in small
   type, so two figures stack instead of running together. */
.figure {
  display: block;
  white-space: nowrap;
}

.figure-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

/* The facts under a stage heading: label and value in two columns, the value free to wrap. */
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 1rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Work status of a stage: a deep dive is highlighted, a skeleton outlined. */
.badge-deep {
  color: var(--accent);
}

.badge-skeleton {
  border-style: dashed;
}

/* Two vocabularies, one scale: the stack rates figures high / medium / low, the ledger rates
   signals confirmed / reported / speculated. The firm end is ink, the middle muted, the soft end
   the warning colour, so a reader learns the scale once. */
.confidence {
  color: var(--muted);
}

.confidence-high,
.confidence-confirmed {
  color: var(--ink);
}

.confidence-low,
.confidence-speculated {
  color: var(--warn);
}

/* ---- campuses -------------------------------------------------------------------------- */

/* Campus names are phrases (a sponsor, a project, a town), so like stage names they wrap; the
   power source is free text and needs a floor; the two source links stay on one line. */
.campuses th[scope="row"] {
  white-space: normal;
  min-width: 11rem;
}

.campuses .power-source {
  min-width: 12rem;
}

.campuses .sources {
  white-space: nowrap;
}

/* The totals under the campuses table sit close to it, in the table's type size. */
.campus-totals {
  margin: -1rem 0 1.5rem;
  font-size: 0.875rem;
}

/* ---- US supply (EIA-860M) -------------------------------------------------------------- */

/* The source line (workbook, month, "preliminary") sits under the heading in the table's type
   size; the two tables that follow carry their own captions. */
.us-supply-source {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
}

/* The planned table's long last two headers wrap instead of pushing nine columns off a phone. */
.planned thead th {
  white-space: normal;
  min-width: 5rem;
}

/* ---- signals --------------------------------------------------------------------------- */

/* A claim is a sentence with its number in it; without a floor the eight short columns beside
   it squeeze it into a one-word-per-line ribbon. */
.signals .claim {
  min-width: 18rem;
}

.signals .kind {
  white-space: nowrap;
}

/* Previous stage on the left, next on the right, whichever of them exist. */
.stage-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.stage-nav .next {
  margin-left: auto;
}

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

.charts {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  margin: 0.75rem 0 1rem;
}

.charts:empty {
  display: none;
}

.chart {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.6rem 0.6rem 0.4rem;
  min-width: 0;
}

.chart figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

/* Chart.js needs a positioned, fixed-height box to size a responsive canvas. */
.chart-box {
  position: relative;
  height: 220px;
  width: 100%;
}

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1rem 0 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0 auto;
  overflow-wrap: anywhere;
}
