/* thinking analog. Tokens first; no color literal may appear below them (tests/test_tokens.py).
   The two dark blocks must stay identical: CSS can't share one between a media query and an
   attribute selector. */

:root {
  color-scheme: light;
  --ta-surface: #FAF8F4;
  --ta-raised: #FFFFFF;
  --ta-sunken: #F1EDE6;
  --ta-ink: #161210;
  --ta-text: #332F2B;
  --ta-muted: #67625B;
  --ta-accent: #266488;
  --ta-line: #161210;
  --ta-hairline: #D9D1C4;
  --ta-highlight: #C6E0EF;
  --ta-button: #161210;
  --ta-button-text: #FAF8F4;
  --ta-code: #181716;
  --ta-code-text: #E5E1DA;
  --ta-code-label: #E5E1DA;
  --ta-code-label-text: #161210;
  --ta-code-keyword: #6FB3DC;
  --ta-code-string: #E6C27A;
  --ta-code-comment: #918E88;
  --ta-band-text: #FFFFFF;
  --ta-band-note: #266488;
  --ta-band-tip: #2F6B3A;
  --ta-band-info: #4A4540;
  --ta-band-warning: #8A4B00;
  --ta-overlay: #161210;
  --ta-overlay-text: #FAF8F4;
  --ta-logo-ink: #161210;
  --ta-logo-accent: #880000;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ta-surface: #181716;
    --ta-raised: #211F1D;
    --ta-sunken: #121210;
    --ta-ink: #E5E1DA;
    --ta-text: #CBC8C2;
    --ta-muted: #918E88;
    --ta-accent: #6FB3DC;
    --ta-line: #75716C;
    --ta-hairline: #33312E;
    --ta-highlight: #2B5670;
    --ta-button: #E5E1DA;
    --ta-button-text: #181716;
    --ta-code: #121210;
    --ta-logo-ink: #E5E1DA;
    --ta-logo-accent: #A80000;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ta-surface: #181716;
  --ta-raised: #211F1D;
  --ta-sunken: #121210;
  --ta-ink: #E5E1DA;
  --ta-text: #CBC8C2;
  --ta-muted: #918E88;
  --ta-accent: #6FB3DC;
  --ta-line: #75716C;
  --ta-hairline: #33312E;
  --ta-highlight: #2B5670;
  --ta-button: #E5E1DA;
  --ta-button-text: #181716;
  --ta-code: #121210;
  --ta-logo-ink: #E5E1DA;
  --ta-logo-accent: #A80000;
}

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

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ta-surface);
  color: var(--ta-ink);
  font: 18px/1.6 var(--ta-font-text);
  overflow-wrap: break-word;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ta-accent); }
:focus-visible { outline: 3px solid var(--ta-accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--ta-font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.mono { font-family: var(--ta-font-mono); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.muted { color: var(--ta-muted); }
.accent { color: var(--ta-accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
main:focus { outline: none; }
.skip { position: absolute; left: -9999px; padding: 12px 20px; background: var(--ta-button); color: var(--ta-button-text); }
.skip:focus { left: 16px; top: 16px; z-index: 10; }
.underlined { display: inline-block; padding: 12px 0; border-bottom: 2px solid var(--ta-accent); }
.dots { background-color: var(--ta-surface); background-image: radial-gradient(var(--ta-hairline) 1.2px, transparent 1.2px); background-size: 24px 24px; }
.numeral { margin: 12px 0 0; font-family: var(--ta-font-display); font-weight: 800; font-size: 120px; line-height: 0.85; letter-spacing: -0.05em; }
.mark { background: var(--ta-highlight); color: var(--ta-ink); padding: 0 4px; }

/* -- header and footer ------------------------------------------------------------- */

.site-header { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; justify-content: space-between; padding-top: 20px; padding-bottom: 20px; }
.site-header__logo { display: block; padding: 4px 0; }
.site-header__logo svg { display: block; width: 210px; height: 40px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 28px; align-items: center; }
.site-nav a { padding: 12px 0; border-bottom: 2px solid transparent; }
.site-nav a[aria-current] { border-bottom-color: var(--ta-line); }
.site-header__logo { margin-right: auto; }
.theme-toggle { width: 44px; height: 44px; margin-right: -10px; padding: 10px; border: 0; background: none; color: inherit; cursor: pointer; }
.theme-toggle svg { display: block; width: 24px; height: 24px; }
.site-footer { margin-top: 88px; border-top: 1px solid var(--ta-line); font-family: var(--ta-font-mono); font-size: 13px; color: var(--ta-muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 32px; justify-content: space-between; align-items: center; padding-top: 28px; padding-bottom: 28px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.site-footer nav a { padding: 12px 0; }

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

.masthead { border-top: 1px solid var(--ta-line); border-bottom: 1px solid var(--ta-line); }
.masthead .wrap { padding-top: 56px; padding-bottom: 48px; }
.masthead p { margin: 0; }
.masthead p a { text-decoration: underline; }
.masthead h1 { margin-top: 12px; font-size: clamp(40px, 6.4vw, 88px); line-height: 0.98; letter-spacing: -0.035em; }
.masthead__lead { color: var(--ta-text); font-size: 22px; font-style: italic; }
.masthead .masthead__lead { margin-top: 20px; }
.masthead--home .wrap { padding-top: 72px; padding-bottom: 64px; }
.masthead--home h1 { margin-top: 20px; max-width: 14ch; }
.masthead--home .masthead__lead { margin-top: 28px; max-width: 36ch; }

/* -- home -------------------------------------------------------------------------- */

.page { padding-top: 56px; }
.page--home { padding-top: 64px; }
.hero { display: flex; flex-wrap: wrap; gap: 40px; align-items: center; }
.hero__image { flex: 3 1 480px; min-width: 0; }
.hero__image img { width: 100%; border: 1px solid var(--ta-line); }
.hero__text { flex: 2 1 320px; min-width: 0; }
.hero__text > p { margin: 0; }
.hero__text h2 { margin-top: 12px; font-size: 36px; }
.hero__text > .numeral { margin-top: 12px; }
.hero__text > .hero__date { margin-top: 8px; font-family: var(--ta-font-mono); font-size: 14px; }
.hero__text > .hero__description { margin-top: 16px; color: var(--ta-text); }
.hero__text .underlined { margin-top: 16px; }
.section-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--ta-line); }
.section-head h2 { font-size: 28px; line-height: 1.6; }
.section-head a { padding: 12px 0; }
.recent { margin-top: 80px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 48px 64px; margin-top: 88px; }
.about { display: flex; flex-wrap: wrap; gap: 40px; align-items: center; margin-top: 88px; padding: 40px; border: 1px solid var(--ta-line); background-color: var(--ta-raised); }
.about > * { flex: 1 1 360px; min-width: 0; }
.about img { width: 100%; border: 1px solid var(--ta-line); }
.about h2 { font-size: 36px; }
.about p { margin: 12px 0 0; font-size: 20px; }
.about .about__links { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 20px; font-size: 14px; }
.home-categories { margin-top: 72px; }
.home-categories h2 { margin-bottom: 20px; font-weight: 400; }

/* -- cards, rows, chips ------------------------------------------------------------ */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 56px 32px; }
.recent .cards { gap: 48px 32px; margin-top: 32px; }
.card__slot { display: flex; align-items: flex-end; aspect-ratio: 3 / 2; background-image: radial-gradient(var(--ta-hairline) 1.2px, transparent 1.2px); background-size: 12px 12px; }
.card__slot img { width: 100%; border: 1px solid var(--ta-line); }
.card__meta { display: flex; justify-content: space-between; gap: 12px; margin: 16px 0 0; font-family: var(--ta-font-mono); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.card__meta time { white-space: nowrap; }
.card__title { margin-top: 8px; font-size: 24px; line-height: 1.15; }
.card__description { display: -webkit-box; margin: 8px 0 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; color: var(--ta-text); font-size: 17px; line-height: 1.55; }
.rows { margin: 0; padding: 0; list-style: none; }
.rows a { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--ta-hairline); }
.rows__title { font-family: var(--ta-font-display); font-weight: 600; font-size: 20px; }
.rows time { align-self: center; white-space: nowrap; font-family: var(--ta-font-mono); font-size: 13px; color: var(--ta-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip { display: inline-flex; gap: 6px; align-items: center; min-height: 26px; padding: 0 6px; border: 1px solid var(--ta-line); font-family: var(--ta-font-mono); font-size: 13px; line-height: 1.5; color: var(--ta-ink); }
.pager { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin-top: 72px; padding-top: 16px; border-top: 1px solid var(--ta-line); }

/* -- search ------------------------------------------------------------------------ */

.masthead .search-form { padding-top: 56px; padding-bottom: 56px; }
.search-form label { display: block; }
.search-form__row { display: flex; flex-wrap: wrap; gap: 12px; max-width: 760px; margin-top: 12px; }
.search-form input { flex: 1 1 280px; min-width: 0; height: 64px; padding: 0 20px; border: 1px solid var(--ta-line); border-radius: 0; background: var(--ta-raised); color: var(--ta-ink); font-family: var(--ta-font-display); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; }
.search-form button { height: 64px; border-radius: 0; cursor: pointer; }
.search-page { padding-top: 40px; }
.search-summary { margin: 0; padding-bottom: 12px; border-bottom: 1px solid var(--ta-line); font-family: var(--ta-font-mono); font-size: 14px; letter-spacing: 0.06em; color: var(--ta-muted); }
.result { display: flex; flex-wrap: wrap; gap: 16px 32px; padding: 28px 0; border-bottom: 1px solid var(--ta-hairline); }
.result__image { flex: 0 1 270px; min-width: 0; }
.result__image img { width: 100%; border: 1px solid var(--ta-line); }
.result__text { flex: 999 1 320px; min-width: 0; max-width: 680px; }
.result__text p { margin: 8px 0 0; color: var(--ta-text); }
.result__text .card__meta { flex-wrap: wrap; gap: 4px 20px; justify-content: flex-start; margin: 0; }
.result h2 { margin-top: 8px; font-size: 28px; line-height: 1.15; }
.no-results { padding: 48px 0; }
.no-results h2 { font-size: 36px; }
.no-results p { margin: 12px 0 20px; color: var(--ta-text); }

/* -- article ----------------------------------------------------------------------- */

.article-head { border-top: 1px solid var(--ta-line); }
.article-head .wrap { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-end; padding-top: 56px; padding-bottom: 48px; }
.article-head .numeral { margin: 0; font-size: clamp(96px, 14vw, 200px); line-height: 0.8; }
.article-head__text { flex: 1 1 360px; min-width: 0; }
.article-head__text p { margin: 0; }
.article-head h1 { margin-top: 12px; font-size: clamp(36px, 4.4vw, 60px); line-height: 1.02; letter-spacing: -0.03em; }
.article-cover { margin: 0 auto; }
.page-cover { margin-top: 56px; }
.article-cover img { width: 100%; border: 1px solid var(--ta-line); }
figcaption { display: flex; flex-wrap: wrap; gap: 4px 24px; justify-content: space-between; margin-top: 12px; font-family: var(--ta-font-mono); font-size: 13px; color: var(--ta-muted); }
figcaption a { text-decoration: underline; }
.article-body { display: flex; flex-wrap: wrap; gap: 32px 64px; padding-top: 56px; }
.article-aside { flex: 1 1 200px; min-width: 0; font-family: var(--ta-font-mono); font-size: 13px; line-height: 1.5; color: var(--ta-muted); }
.article-aside h2 { margin: 28px 0 8px; font: inherit; letter-spacing: 0.08em; text-transform: uppercase; }
.article-aside h2:first-child { margin-top: 0; }
.earlier { padding-top: 88px; }
.earlier__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 32px; }
.earlier__grid a { display: block; padding: 20px 0; border-bottom: 1px solid var(--ta-hairline); }
.earlier__grid time { display: block; font-family: var(--ta-font-mono); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ta-muted); }
.earlier__grid .numeral { display: block; margin-top: 4px; font-size: 56px; line-height: 1; letter-spacing: -0.04em; }
.earlier__title { display: block; margin-top: 4px; font-family: var(--ta-font-display); font-weight: 600; font-size: 18px; }
.prev-next { display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; padding-top: 56px; }
.prev-next a { flex: 0 1 auto; padding: 12px 0; }
.prev-next a[rel="next"] { text-align: right; margin-left: auto; }
.prev-next span { display: block; }
.prev-next__title { font-family: var(--ta-font-display); font-weight: 600; font-size: 20px; }

/* -- prose and body blocks --------------------------------------------------------- */

.prose { flex: 999 1 560px; min-width: 0; max-width: 700px; font-size: 20px; line-height: 1.65; }
.prose::after { content: ""; display: block; clear: both; }
.prose a { color: var(--ta-accent); text-decoration: underline; }
.prose a:hover { color: var(--ta-ink); }
.prose p, .prose ul, .prose ol, .prose table, .prose hr { margin: 24px 0 0; }
.prose li > ul, .prose li > ol, .prose li > p { margin-top: 4px; }
.prose > :first-child, .prose > :first-child > :first-child { margin-top: 0; }
.prose h2 { margin: 48px 0 0; font-size: 34px; line-height: 1.2; }
.prose h3 { margin: 36px 0 0; font-size: 26px; line-height: 1.2; }
.prose h4, .prose h5, .prose h6 { margin: 28px 0 0; font-family: var(--ta-font-display); font-size: 20px; }
.prose hr { border: 0; border-top: 1px solid var(--ta-hairline); }
.prose blockquote { display: flow-root; margin: 24px 0 0; padding-left: 20px; border-left: 3px solid var(--ta-accent); color: var(--ta-text); font-style: italic; }
.prose code { padding: 2px 6px; background: var(--ta-sunken); font-family: var(--ta-font-mono); font-size: 0.85em; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 17px; }
.prose th, .prose td { padding: 8px 12px; border: 1px solid var(--ta-hairline); text-align: left; }
.prose th { background: var(--ta-sunken); }
.prose .highlight { margin: 24px 0 0; padding: 16px 20px 22px; overflow-x: auto; background: var(--ta-code); color: var(--ta-code-text); font: 15px/1.6 var(--ta-font-mono); }
.prose .highlight code { padding: 0; background: none; font-size: 1em; }
.highlight .k, .highlight .kn, .highlight .kd, .highlight .kc, .highlight .ow, .highlight .nt, .highlight .nb { color: var(--ta-code-keyword); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sd, .highlight .se, .highlight .si { color: var(--ta-code-string); }
.highlight .c, .highlight .c1, .highlight .cm, .highlight .ch, .highlight .cp { color: var(--ta-code-comment); }
.code { margin: 24px 0 0; border: 1px solid var(--ta-line); background: var(--ta-code); }
.prose .code .highlight { margin: 0; }
.prose .code__label { display: block; width: fit-content; margin: 0; padding: 4px 12px; background: var(--ta-code-label); color: var(--ta-code-label-text); font: 13px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.notice { margin: 24px 0 0; border: 1px solid var(--ta-line); background: var(--ta-raised); }
.prose .notice__label { display: block; width: fit-content; margin: 0; padding: 4px 12px; color: var(--ta-band-text); font: 13px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.notice--note .notice__label { background: var(--ta-band-note); }
.notice--tip .notice__label { background: var(--ta-band-tip); }
.notice--info .notice__label { background: var(--ta-band-info); }
.notice--warning .notice__label { background: var(--ta-band-warning); }
.notice__body { padding: 12px 20px 18px; }
.notice__body > :first-child, .postscript > :first-child, .prose blockquote > :first-child { margin-top: 0; }
.postscript { margin: 48px 0 0; padding-top: 20px; border-top: 1px solid var(--ta-hairline); color: var(--ta-text); font-size: 18px; }
.quote, .figure { margin: 24px 0 0; }
.quote blockquote { margin: 0; }
.figure img { border: 1px solid var(--ta-line); }
.figure--left, .figure--right { max-width: 320px; }
.figure--left { float: left; margin-right: 32px; }
.figure--right { float: right; margin-left: 32px; }
.figure__zoom { display: block; cursor: zoom-in; }
.collapse { margin: 24px 0 0; border: 1px solid var(--ta-line); background: var(--ta-raised); padding: 0 20px 4px; }
.collapse summary { padding: 12px 0; font-family: var(--ta-font-display); font-weight: 600; cursor: pointer; }
.collapse > p:first-of-type { margin-top: 0; }
.collapse[open] { padding-bottom: 18px; }
.tabs { margin: 24px 0 0; border: 1px solid var(--ta-line); background: var(--ta-raised); }
.tabs__list { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--ta-line); background: var(--ta-surface); }
.tabs__list button { min-height: 48px; padding: 0 20px; border: 0; border-left: 1px solid transparent; border-right: 1px solid transparent; background: none; color: var(--ta-muted); font: 14px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.tabs__list button[aria-selected="true"] { border-left-color: var(--ta-line); border-right-color: var(--ta-line); margin-bottom: -1px; background: var(--ta-raised); color: var(--ta-ink); }
.tabs__list button:first-child { border-left: 0; }
.tabs__panel { padding: 24px; }
.tabs__panel > p:first-of-type { margin-top: 0; }
.tabs__panel + .tabs__panel:not([role]) { border-top: 1px solid var(--ta-hairline); }
.lightbox { width: 100vw; max-width: none; height: 100dvh; max-height: none; padding: 24px; border: 0; background: transparent; }
.lightbox[open] { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; }
.lightbox::backdrop { background: color-mix(in srgb, var(--ta-overlay) 92%, transparent); }
.lightbox form { align-self: flex-end; }
.lightbox button { min-width: 44px; height: 44px; padding: 0 16px; border: 1px solid var(--ta-overlay-text); background: var(--ta-overlay); color: var(--ta-overlay-text); font: 14px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.lightbox img { max-height: 80%; width: auto; object-fit: contain; border: 0; }
.prose .lightbox p { margin: 0; color: var(--ta-overlay-text); font: 13px/1.6 var(--ta-font-mono); }
.prose .tabs__label { margin: 0 0 12px; font: 14px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.embed { margin: 24px 0 0; border: 1px solid var(--ta-line); aspect-ratio: 16 / 9; }
.embed iframe { display: block; width: 100%; height: 100%; border: 0; }
.prose a.button, .button { display: inline-block; padding: 12px 28px; border: 1px solid var(--ta-line); background: var(--ta-button); color: var(--ta-button-text); font: 14px/1.6 var(--ta-font-mono); letter-spacing: 0.08em; text-decoration: none; text-transform: uppercase; }
.prose a.button:hover { background: var(--ta-accent); color: var(--ta-surface); }
.toc { margin: 24px 0 0; padding: 16px 20px; border: 1px solid var(--ta-line); background: var(--ta-raised); font-size: 17px; }
.prose .toc ul { margin: 0; padding: 0; list-style: none; }
.toc__3 { padding-left: 20px; }
.readout { margin: 24px 0 0; padding: 16px 20px; border: 1px solid var(--ta-line); background: var(--ta-raised); font-family: var(--ta-font-mono); font-size: 15px; }
.readout p, .readout dl { margin: 8px 0 0; }
.readout dl { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.readout dt { font-size: 13px; color: var(--ta-muted); }
.readout dd { margin: 0; font-size: 22px; }

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

@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .site-nav { order: 1; flex-basis: 100%; gap: 0 20px; }
  .about { padding: 24px; }
  .numeral { font-size: 96px; }
  .prose { font-size: 18px; }
  .figure--left, .figure--right { float: none; max-width: none; margin-left: 0; margin-right: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
