/* ===========================================================
   site.css — shared layout + typography
   Three text sizes: heading (h1 only), body, chrome — plus a
   mini for footnote superscripts (see CLAUDE.md). Hierarchy below
   h1 comes from face, weight, italic, case, color, and white
   space — never from font-size.
   =========================================================== */

/* -- Reset & base ------------------------------------------------ */
* { box-sizing: border-box; }

::selection {
  background: var(--accent);
  color: var(--bg);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--size-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 200ms ease, color 200ms ease;
}

main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 4rem;
}

/* -- Shared caps treatment --------------------------------------- */
/* Valkyrie Caps, body-sized, bold. In the Caps fonts a lowercase letter
   is drawn as a small cap and a capital as a full cap, so text is NOT
   lowercased here: "ThetaSigma" keeps its tall T and S (Daniel, 2026-10-05).
   Shared by every element on the site that uses the heading-caps treatment.
   Hierarchy is signalled per-element by the margin above. */
h1, h2, h3,
dt, th,
.footnotes-label,
.index li > a {
  font-family: var(--font-serif-caps);
  font-weight: 700;
  letter-spacing: var(--track-caps);
}

/* -- Headings ---------------------------------------------------- */
/* h2/h3 at 1em so they inherit body size instead of the user-agent
   defaults (h1=2em etc). Only h1 gets the heading size. */
h1, h2, h3 {
  font-size: 1em;
  text-align: left;
}
h1 { margin: 0 0 0.4rem; font-size: var(--size-heading); }
h2 { margin: 2rem 0 0.4rem; }
h3 { margin: 1.5rem 0 0.3rem; font-style: italic; }

/* -- Body text --------------------------------------------------- */
p {
  margin: 0 0 1.1em;
  text-align: left;
}

/* -- Top bar (masthead + toggles) -------------------------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 2rem;
}

.masthead,
.toggles {
  font-family: var(--font-sans-caps);
  font-size: var(--size-chrome);
  letter-spacing: var(--track-chrome);
}

.masthead {
  font-weight: 400;
  color: var(--ink);
  margin: 0;
}
.masthead a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  margin: -0.5rem -0.75rem;
  color: inherit;
  text-decoration: none;
  border: 0;
  transition: color 150ms ease;
}
.masthead a:hover,
.masthead a:focus-visible { color: var(--accent); }

.toggles {
  display: flex;
  gap: 1rem;
  color: var(--ink-soft);
}
.toggles button,
.toggles a {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.toggles .opt {
  opacity: 0.45;
  transition: opacity 120ms ease, color 120ms ease;
}
.toggles .opt:hover { opacity: 0.8; }
.toggles .opt.active { opacity: 1; color: var(--ink); }
.toggles .sep {
  opacity: 0.3;
  margin: 0 0.15rem;
}

/* -- Theme menu (dropdown in the topbar) -------------------------- */
.theme-menu {
  position: relative;
  display: inline-block;
}
.theme-menu summary {
  cursor: pointer;
  list-style: none;           /* hide the default disclosure marker */
  opacity: 0.45;
  transition: opacity 120ms ease;
}
.theme-menu summary::-webkit-details-marker { display: none; }
.theme-menu summary:hover,
.theme-menu[open] summary { opacity: 1; color: var(--ink); }
.theme-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  display: flex;
  flex-direction: column;
  min-width: 7.5rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.3rem 0;
  z-index: 50;
}
.theme-menu-list button {
  text-align: left;
  padding: 0.25rem 0.9rem;
  opacity: 0.7;
}
.theme-menu-list button:hover { opacity: 1; background: var(--bg-soft); }
.theme-menu-list button.active { opacity: 1; color: var(--ink); }
.theme-menu-list button.active::after { content: " ·"; color: var(--accent); }

/* -- Custom theme dialog ------------------------------------------ */
.theme-dialog {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  max-width: 26rem;
  width: calc(100vw - 3rem);
  padding: 1.4rem 1.6rem;
  font-family: var(--font-serif);
  font-size: var(--size-body);
  line-height: 1.6;
}
.theme-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.theme-dialog .kicker { margin-top: 0; }
.theme-dialog dl {
  font-family: var(--font-sans);
  font-size: var(--size-chrome);
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.15em;
  margin: 0.8em 0;
}
.theme-dialog dl dt {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.theme-dialog dl dd { margin: 0; color: var(--ink-soft); }
.theme-dialog textarea {
  width: 100%;
  min-height: 10.5em;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 0.6rem 0.7rem;
  font-family: var(--font-mono);
  font-size: var(--size-chrome);
  line-height: 1.45;
  resize: vertical;
}
.theme-dialog .dialog-error {
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: var(--size-chrome);
  min-height: 1.4em;
  margin: 0.3em 0 0;
}
.theme-dialog .dialog-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 0.8rem;
  font-family: var(--font-sans-caps);
  font-size: var(--size-chrome);
  letter-spacing: var(--track-chrome);
}
.theme-dialog .dialog-actions button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}
.theme-dialog .dialog-actions button:hover { color: var(--accent); }
.theme-dialog .dialog-actions button[value="apply"] { color: var(--accent); }
.theme-dialog .dialog-actions button[value="apply"]:hover { color: var(--accent-hover); }

/* -- Meta line, standfirst --------------------------------------- */
.meta {
  font-family: var(--font-sans);
  color: var(--ink-soft);
  margin: 0 0 2rem;
  letter-spacing: 0.02em;
}

.standfirst {
  font-style: italic;
  margin: 0 0 2rem;
}

/* -- Pull quote -------------------------------------------------- */
.pullquote {
  margin: 2.5rem auto;
  max-width: 22rem;
  text-align: center;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.2rem 0;
}
.pullquote p {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}

/* -- Figure ------------------------------------------------------ */
figure { margin: 2.5rem 0; }
figure img {
  display: block;
  width: 100%;
  height: auto;
}
figcaption {
  font-family: var(--font-sans);
  line-height: 1.4;
  margin: 0.7rem 0 0;
}

/* -- Section break (fleuron) ------------------------------------- */
hr {
  border: 0;
  text-align: center;
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  overflow: visible;
  line-height: 1;
}
hr::before {
  content: "❦";
  font-size: 1em; /* fleuron rides the body size */
  letter-spacing: 0.5em;
}

/* -- Blockquote (external quotation) ----------------------------- */
blockquote {
  margin: 2rem 0 2rem 1.5rem;
  padding: 0;
}
blockquote p { margin: 0 0 0.6em; }
blockquote cite {
  display: block;
  font-family: var(--font-serif-caps);
  font-style: normal;
  letter-spacing: var(--track-caps);
  color: var(--ink-soft);
  margin-top: 0.4rem;
}
blockquote cite::before { content: "— "; }

/* -- Table of contents (in-essay nav) ---------------------------- */
.toc {
  font-family: var(--font-sans);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0;
  margin: 0 0 2.5rem;
}
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}
.toc li {
  counter-increment: toc;
  display: flex;
  gap: 0.6rem;
  padding: 0.15rem 0;
}
.toc li::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* -- Links ------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: color 120ms ease;
}
a:hover, a:focus { color: var(--accent-hover); }

/* -- Focus & skip link (a11y) ------------------------------------ */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}
a:focus-visible { outline-offset: 4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  font-family: var(--font-sans);
  font-size: var(--size-chrome);
  border: 0;
  z-index: 100;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 0.5rem;
  top: 0.5rem;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* -- Code -------------------------------------------------------- */
code, pre, kbd, samp {
  font-family: var(--font-mono);
  font-size: 1em;
}

p code, li code {
  background: var(--bg-soft);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}

pre {
  background: var(--bg-soft);
  padding: 1rem 1.1rem;
  margin: 1.4em 0;
  overflow-x: auto;
  line-height: 1.45;
  border-left: 2px solid var(--rule);
}
pre code {
  background: none;
  padding: 0;
}

/* Shell / terminal blocks. The $ prompt is decorative (not selectable).
   Wrap commands in <span class="cmd"> and output in <span class="out">. */
pre.shell { border-left-color: var(--accent); }
pre.shell .cmd,
pre.shell .out { display: block; }
pre.shell .cmd::before {
  content: '$ ';
  color: var(--accent);
  user-select: none;
  -webkit-user-select: none;
}
pre.shell .out {
  color: var(--ink-soft);
  font-style: italic;
}
pre.shell .out::before {
  content: '  ';
  user-select: none;
  -webkit-user-select: none;
}

/* -- Lists ------------------------------------------------------- */
ul, ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}
li { margin: 0 0 0.4em; }

/* -- Definition lists -------------------------------------------- */
dl { margin: 0 0 1.1em; }
dt { margin: 0.6em 0 0.1em; }
dt:first-child { margin-top: 0; }
dd { margin: 0 0 0.4em 1.4em; }

/* Two-column factsheet variant — used on reference pages. */
dl.factsheet {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.5rem;
  row-gap: 0.4em;
  margin: 1.4em 0;
}
dl.factsheet dt,
dl.factsheet dd { margin: 0; }

/* -- Tables ------------------------------------------------------ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-variant-numeric: tabular-nums;
}
caption {
  font-family: var(--font-sans);
  text-align: left;
  color: var(--ink-soft);
  padding: 0 0 0.5rem;
  caption-side: top;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.8rem 0.5rem 0;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
th { border-bottom: 1px solid var(--ink); }
tbody tr:last-child td { border-bottom: 1px solid var(--ink); }

/* -- Footnotes --------------------------------------------------- */
sup {
  font-size: var(--size-mini);
  line-height: 0;
  vertical-align: super;
}
sup a, .footnote-ref {
  border-bottom: 0;
  padding: 0 0.05em;
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}
.footnotes-label {
  color: var(--ink);
  margin: 0 0 0.4rem;
}
.footnotes ol {
  padding-left: 1.4em;
  margin: 0;
}
.footnotes li {
  line-height: 1.6;
  margin: 0 0 0.7em;
  color: var(--ink);
}
.footnotes li::marker { color: var(--ink); }
.footnote-back {
  margin-left: 0.4em;
  font-size: var(--size-mini);
  border-bottom: 0;
}

/* -- Article index (listing on index.html) ----------------------- */
.index ol {
  list-style: none;
  padding: 0;
  margin: 1.4rem 0 0;
}
.index li {
  padding: 1.2rem 0;
  border-top: 1px solid var(--rule);
}
.index li:last-child { border-bottom: 1px solid var(--rule); }
.index-blurb {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0.3rem 0 0;
}
.index-date {
  font-family: var(--font-sans);
  color: var(--ink-soft);
  margin: 0.3rem 0 0;
  letter-spacing: 0.02em;
}

/* -- Not-found page (404.html) ------------------------------------ */
.notfound {
  text-align: center;
  margin: 3.5rem 0 2rem;
}
.notfound-number {
  font-family: var(--font-serif);
  font-style: italic;
  line-height: 1;
  color: var(--ink-soft);
  margin: 0 0 1.4rem;
  letter-spacing: 0.02em;
  /* the global `p` rule sets text-align: left, so centring here has to be
     said out loud — inheriting .notfound's centre is not enough */
  text-align: center;
}
.notfound-verse {
  font-style: italic;
  color: var(--ink);
  line-height: 1.7;
  margin: 0 0 0.4rem;
  text-align: center;
}

/* -- Poem (used on root index and the standalone poem page) ------ */
.poem p { margin: 0 0 1.4em; }
.poem p:last-child { margin-bottom: 0; }
h1 + .poem { margin-top: 0; }
.poem + h1 { margin-top: 2.5rem; }
.poem-tail { margin: 0; }
.poem-tail + h1 { margin-top: 3.3rem; }

/* -- Colophon (page footer) -------------------------------------- */
.colophon {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: var(--size-chrome);
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;               /* on a narrow phone the button takes its own row */
  justify-content: space-between;
  align-items: flex-end;         /* button level with the second line */
  gap: 0.6rem 1.5rem;
}
.colophon-line { display: block; }
.colophon-line + .colophon-line { margin-top: 0.3rem; }

/* The footer's right-hand control (back to top; "inicio / home" on the 404).
   An <a> drawn as a button (Daniel, 2026-10-05): filled with the theme's
   accent (OS1 red, ThetaSigma pink, gray green), rounded, with the page
   background as its text; on hover it fills with --accent-hover (the blues;
   gray's slate). Text contrast, measured from the token values:
   OS1 5.4 / 6.2, ThetaSigma 11.0 / 10.5, gray 7.5 / 11.5 (rest / hover),
   all above 4.5:1. `border: 0` also removes the global link underline,
   a bottom border that wrapped badly. Keyboard focus keeps the site's
   :focus-visible ring. */
.colophon-button {
  margin-left: auto;             /* stays right when it wraps onto its own row */
  display: inline-block;
  white-space: nowrap;
  padding: 0.45rem 0.85rem;
  line-height: 1;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 0.4rem;
  transition: background 120ms ease;
}
.colophon-button:hover,
.colophon-button:focus-visible { color: var(--bg); background: var(--accent-hover); }
.colophon-button:focus { color: var(--bg); }  /* beats the global a:focus colour after a click */

/* ===========================================================
   Reusable patterns
   Building blocks usable inside any essay. Each is documented
   with a rendered example in style-guide.html.
   =========================================================== */

/* Callout — boxed aside on warm paper-soft, with a hairline left rule.
   First/last child margins are reset so any element drops in cleanly. */
.callout {
  background: var(--bg-soft);
  border-left: 2px solid var(--rule);
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child  { margin-bottom: 0; }

/* Kicker — small caps eyebrow / sub-label. Body-sized; hierarchy
   comes from the small caps, letterspacing, and soft ink — not size.
   .toc-label shares the same treatment with a tighter margin. */
.kicker,
.toc-label {
  font-family: var(--font-sans-caps);
  letter-spacing: var(--track-kicker);
  color: var(--ink-soft);
}
.kicker    { margin: 1.4rem 0 0.4rem; }
.toc-label { margin: 0 0 0.5rem; }

/* Note — quieter, soft-ink paragraph for editorial asides. */
.note {
  color: var(--ink-soft);
  margin: 0 0 1rem;
}

/* Chapter — a major top-ruled section block. The first .chapter on
   a page omits its top rule. The h2 inside inherits the shared caps
   treatment; the rule + spacing do the work of marking the break. */
.chapter {
  margin: 3rem 0;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.chapter:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.chapter > h2 { margin: 0 0 1.4rem; }
