/* =====================================================================
   The Learning Machine
   Palette sampled from the colour ramp used for attention and loss
   heatmaps: deep purple, magenta, warm orange, pale yellow on lilac paper.
   ================================================================== */

:root {
  --ink:        #17102b;
  --ink-soft:   #4c4363;
  --ink-faint:  #7b7292;
  --paper:      #f3f1f7;
  --card:       #ffffff;
  --line:       #ddd7e8;
  --line-firm:  #c6bcd9;

  --deep:       #57106e;
  --hot:        #bc3754;
  --warm:       #f98e09;
  --yellow:     #f6d746;

  --measure:    66ch;
  --shell:      72rem;
  --radius:     3px;

  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --sans:  "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::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-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "kern" 1;
}

/* ------------------------------------------------------------ basics */

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2.1rem); }
h3 { font-size: 1.24rem; }
h4 { font-size: 1.05rem; font-family: var(--sans); font-weight: 600; }

p { margin: 0 0 1.1em; }

a { color: var(--deep); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--hot); }

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

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 50;
}
.skip:focus { left: 0; }

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

.measure { max-width: var(--measure); }

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

.masthead {
  background: var(--ink);
  color: #efeaf6;
  border-bottom: 3px solid var(--hot);
}

.masthead-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 0;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  margin-right: auto;
}

.wordmark-cells {
  display: grid;
  grid-template-columns: repeat(2, 11px);
  grid-auto-rows: 11px;
  gap: 2px;
}
.wordmark-cells i { display: block; border-radius: 1px; }

.wordmark-text strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.wordmark-text small {
  display: block;
  font-size: 0.78rem;
  color: #b1a6c6;
  line-height: 1.3;
}

.nav-toggle {
  display: none;
  background: transparent;
  color: inherit;
  border: 1px solid #554a6e;
  border-radius: var(--radius);
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.sitenav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.navgroup {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-left: 0.6rem;
  margin-left: 0.4rem;
  border-left: 1px solid #3b3155;
}

.navgroup-label { display: none; }

.navlink {
  color: #cdc3de;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius);
  white-space: nowrap;
}
.navlink:hover { color: #fff; background: #2a2044; }

.navlink.is-current {
  color: var(--ink);
  background: var(--yellow);
  font-weight: 500;
}

/* ----------------------------------------------------------- page top */

.pagehead {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 3rem 0 2.4rem;
}

.pagehead h1 { max-width: 20ch; }

.lede {
  font-size: 1.18rem;
  color: var(--ink-soft);
  max-width: 58ch;
  margin: 0;
}

/* --------------------------------------------------------------- hero */

.hero {
  background: var(--ink);
  color: #ece6f5;
  padding: clamp(2.5rem, 5vw, 4.5rem) 0;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero h1 {
  color: #fff;
  max-width: 15ch;
  margin-bottom: 0.6rem;
}

.hero p {
  color: #b9aecd;
  font-size: 1.13rem;
  max-width: 44ch;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.8rem;
}

.button {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.98rem;
  text-decoration: none;
  border: 1px solid transparent;
}

.button-solid { background: var(--yellow); color: var(--ink); }
.button-solid:hover { background: #fff; color: var(--ink); }

.button-ghost { border-color: #5a4f76; color: #ded4ee; }
.button-ghost:hover { border-color: var(--yellow); color: var(--yellow); }

/* --------------------------------------------------- attention figure */

.figure-heat {
  background: #110b20;
  border: 1px solid #2e2446;
  border-radius: var(--radius);
  padding: 1.1rem;
}

.heat {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.68rem;
  color: #b9aecd;
  table-layout: fixed;
}

.heat th {
  font-weight: 400;
  font-family: var(--sans);
  padding: 0.25rem 0.3rem;
  text-align: left;
  white-space: nowrap;
}

.heat thead th {
  text-align: center;
  vertical-align: bottom;
  height: 5.5rem;
}

.heat thead th span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.heat tbody th { text-align: right; padding-right: 0.5rem; }

.heat td {
  padding: 0;
  height: 1.85rem;
  border: 1px solid #110b20;
}

.heat td.is-empty { background: #17102b; }

.figure-caption {
  font-size: 0.85rem;
  color: #9d92b4;
  margin: 0.9rem 0 0;
  line-height: 1.5;
  max-width: 46ch;
}

.figure-caption b { color: #ded4ee; font-weight: 500; }

/* -------------------------------------------------------------- bands */

.band { padding: clamp(2.6rem, 5vw, 4.2rem) 0; }
.band-paper { background: var(--paper); }
.band-white { background: var(--card); border-block: 1px solid var(--line); }
.band-deep { background: var(--deep); color: #f2e7f6; }
.band-deep h2, .band-deep h3 { color: #fff; }
.band-deep a { color: var(--yellow); }

.band-head { max-width: 54ch; margin-bottom: 2.2rem; }
.band-head p { color: var(--ink-soft); margin: 0; }
.band-deep .band-head p { color: #d8c7e2; }

.prose { max-width: var(--measure); }
.prose h2 { margin-top: 2.4rem; }
.prose h3 { margin-top: 1.8rem; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 1.2em; }
.prose li { margin-bottom: 0.5em; }
.prose strong { font-weight: 600; }

/* -------------------------------------------------------------- cards */

.cardset {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.4rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--deep);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card h3 { margin-bottom: 0.4rem; }
.card p { margin-bottom: 0; color: var(--ink-soft); }
.card p + p { margin-top: 0.8rem; }

.band-white .card { background: var(--paper); }

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.card-link:hover { border-top-color: var(--hot); }
.card-link h3 { color: var(--deep); }
.card-link:hover h3 { color: var(--hot); }

/* Sector panels — wider, with a limits note set apart. */
.sector {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  display: grid;
  gap: 1rem;
}

.sector-head {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.7rem;
}

.sector-head h3 { margin: 0; }
.sector-head span { color: var(--ink-faint); font-size: 0.95rem; }

.sector p { margin: 0; max-width: 62ch; }

.sector-limit {
  background: #fdf4e6;
  border-left: 3px solid var(--warm);
  padding: 0.85rem 1rem;
  font-size: 0.96rem;
  color: #5d4415;
}
.sector-limit b { font-weight: 600; }

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

.taglist li {
  font-size: 0.82rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  color: var(--ink-soft);
}

/* ----------------------------------------------------------- timeline */

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

.timeline > li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 2rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
}
.timeline > li:last-child { border-bottom: 1px solid var(--line); }

.timeline-year {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--hot);
  line-height: 1.1;
}

.timeline-era {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.3rem;
}

.timeline h3 { margin-bottom: 0.35rem; }
.timeline p { margin: 0; color: var(--ink-soft); max-width: 62ch; }

/* -------------------------------------------------------------- steps */

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 1.5rem 0 1.5rem 4.2rem;
  border-top: 1px solid var(--line);
}
.steps > li:last-child { border-bottom: 1px solid var(--line); }

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1.45rem;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  background: var(--deep);
  color: #fff;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}

.step-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.step-head h3 { margin: 0; }
.step-time { font-size: 0.88rem; color: var(--hot); }

.steps p { margin: 0.5rem 0 0.8rem; color: var(--ink-soft); max-width: 60ch; }

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

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

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

table.data thead th {
  font-family: var(--sans);
  font-weight: 600;
  border-bottom: 2px solid var(--line-firm);
  white-space: nowrap;
}

table.data tbody tr:hover { background: #faf8fd; }

/* ------------------------------------------------------------- claims */

.claims { display: grid; gap: 1.2rem; }

.claim {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}

.claim h3 {
  margin-bottom: 0.5rem;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--hot);
}

.claim h3::before {
  content: "“";
  font-family: var(--serif);
  font-size: 1.5em;
  line-height: 0;
  vertical-align: -0.2em;
  margin-right: 0.1em;
}
.claim h3::after {
  content: "”";
  font-family: var(--serif);
  font-size: 1.5em;
  line-height: 0;
  vertical-align: -0.2em;
}

.claim p { margin: 0; color: var(--ink-soft); max-width: 64ch; }

/* -------------------------------------------------------------- risks */

.risk {
  border-top: 1px solid var(--line);
  padding: 1.6rem 0;
}
.risk:last-of-type { border-bottom: 1px solid var(--line); }
.risk h3 { margin-bottom: 0.4rem; }
.risk p { color: var(--ink-soft); max-width: 64ch; margin-bottom: 0.8rem; }

.risk-do {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: var(--paper);
  border-left: 3px solid var(--deep);
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  max-width: 64ch;
}
.band-white .risk-do { background: #f7f4fb; }
.risk-do b { font-weight: 600; white-space: nowrap; }

/* ----------------------------------------------------------- glossary */

.glossary-tools {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.8rem;
}

.glossary-tools input {
  font: inherit;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  background: var(--card);
  min-width: min(22rem, 100%);
  color: inherit;
}

.glossary-count { color: var(--ink-faint); font-size: 0.92rem; }

.glossary { margin: 0; }

.glossary-entry {
  border-top: 1px solid var(--line);
  padding: 1.05rem 0;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 1.2rem;
}

.glossary-entry:last-child { border-bottom: 1px solid var(--line); }

.glossary-letter {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--line-firm);
  line-height: 1.4;
}

.glossary-entry dt {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.glossary-entry dd {
  margin: 0;
  color: var(--ink-soft);
  max-width: 64ch;
}

.glossary-empty {
  padding: 2.5rem 0;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------- form */

.form {
  display: grid;
  gap: 1.15rem;
  max-width: 34rem;
}

.field { display: grid; gap: 0.35rem; }

.field label { font-weight: 500; font-size: 0.96rem; }

.field input,
.field select,
.field textarea {
  font: inherit;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  width: 100%;
}

.field textarea { min-height: 9rem; resize: vertical; }

.field .hint { font-size: 0.87rem; color: var(--ink-faint); }

.field.has-error input,
.field.has-error textarea,
.field.has-error select { border-color: var(--hot); }

.field .error { font-size: 0.88rem; color: var(--hot); }

.form button {
  justify-self: start;
  font: inherit;
  font-weight: 500;
  padding: 0.75rem 1.6rem;
  background: var(--deep);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.form button:hover { background: var(--hot); }

.notice {
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.8rem;
  max-width: 44rem;
}

.notice-good { background: #eef7f0; border-left: 3px solid #2f7d4f; color: #1f4d31; }
.notice-bad  { background: #fdeef0; border-left: 3px solid var(--hot); color: #7a1f2f; }
.notice p:last-child { margin-bottom: 0; }

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.contact-aside {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
}
.contact-aside h3 { margin-top: 1.4rem; }
.contact-aside h3:first-of-type { margin-top: 0; }
.contact-aside p { color: var(--ink-soft); font-size: 0.97rem; }
.contact-aside p:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------- callouts */

.callout {
  border-left: 3px solid var(--hot);
  background: var(--card);
  padding: 1.2rem 1.4rem;
  margin: 2rem 0;
  max-width: var(--measure);
}
.band-white .callout { background: var(--paper); }
.callout p:last-child { margin-bottom: 0; }
.callout h3 { margin-bottom: 0.4rem; }

/* A row of cells showing a value scale, used to explain the figures. */
.scale {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin-top: 1rem;
}
.scale-bar { display: flex; flex: 0 1 12rem; height: 0.7rem; }
.scale-bar i { flex: 1; }

/* Next/previous page links */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 1.6rem;
  margin-top: 3rem;
}

.pager a {
  text-decoration: none;
  max-width: 20rem;
}
.pager span {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-faint);
}
.pager strong { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.pager .next { text-align: right; margin-left: auto; }

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

.footer {
  background: var(--ink);
  color: #b7acca;
  padding: 3.2rem 0 1.6rem;
  margin-top: 0;
  font-size: 0.95rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem;
  padding-bottom: 2.4rem;
  border-bottom: 1px solid #2e2446;
}

.footer h2 {
  font-size: 1rem;
  font-family: var(--sans);
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.7rem;
}

.footer p { max-width: 46ch; }
.footer a { color: #e0d5f0; }
.footer a:hover { color: var(--yellow); }

.footer-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 1.5rem;
}
.footer-nav li { margin-bottom: 0.35rem; break-inside: avoid; }
.footer-nav a { text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; }

.footer-base {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.4rem;
  font-size: 0.85rem;
  color: #8b81a3;
}
.footer-base p { margin: 0; }


/* ------------------------------------------------------- odds and ends */

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

code {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: #ece6f4;
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
.band-deep code, .footer code { background: #2c2247; color: #e6dcf5; }

/* Pagers and cards sitting on the purple band need their own contrast. */
.band-deep .pager { border-top-color: #7c5093; }
.band-deep .pager span { color: #cbb2d9; }
.band-deep .pager a { text-decoration: none; }
.band-deep .callout { background: #4a0d5e; border-left-color: var(--yellow); }
.band-deep .prose a { color: var(--yellow); }

.pager a:hover strong { text-decoration: underline; }

/* The heat figure caption sits inside a dark panel on light pages too. */
.figure-heat caption { text-align: left; }

/* --------------------------------------------------------- responsive */

@media (max-width: 60rem) {
  .hero-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}

@media (max-width: 48rem) {
  body { font-size: 1rem; }

  .nav-toggle { display: block; }

  .sitenav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0 0.8rem;
    border-top: 1px solid #2e2446;
    margin-top: 0.8rem;
  }
  .sitenav.is-open { display: flex; }

  .navgroup {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
    margin-top: 0.9rem;
  }

  .navgroup-label {
    display: block;
    font-size: 0.78rem;
    color: #7d7398;
    padding: 0 0.55rem 0.35rem;
  }

  .navlink { padding: 0.6rem 0.55rem; font-size: 0.98rem; }

  .timeline > li { grid-template-columns: 1fr; gap: 0.5rem; }
  .timeline-era { display: inline; margin-left: 0.6rem; }

  .steps > li { padding-left: 3.4rem; }
  .steps > li::before { width: 2.2rem; height: 2.2rem; font-size: 0.95rem; }

  .footer-inner { grid-template-columns: 1fr; gap: 2rem; }
  .heat { font-size: 0.6rem; }
  .heat thead th { height: 4.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .masthead, .footer, .pager, .nav-toggle, .glossary-tools { display: none; }
  body { background: #fff; font-size: 11pt; }
  .band, .pagehead { padding: 1rem 0; }
}
