/* Paper and Night. The same printed sheet, read by candlelight: soot ground, ivory ink, a warmer vermilion.
   Each page keeps its own light tokens; this file only overrides them for the night sheet.
   The head script sets data-theme before paint; the media query covers readers without JavaScript. */
:root[data-theme="dark"] {
  --paper: #141210;
  --ink: #e8dfd0;
  --ink-soft: #b3a898;
  --soft: #b3a898;
  --rule: #3c352d;
  --vermilion: #d9583b;
  --vermilion-fill: #b8432a;
  --surface: #1c1916;
  --surface-strong: #221e1a;
  --field: rgba(232, 223, 208, .045);
  --well: rgba(0, 0, 0, .22);
  --night: #1c1916;
  --on-night: #e8dfd0;
  --night-soft: #b3a898;
  --frame: #5a5045;
  --grain-blend: multiply;
  --img-dim: brightness(.9);
  --black-sun: drop-shadow(0 0 .5px rgba(232, 223, 208, .9)) drop-shadow(0 0 3px rgba(232, 223, 208, .18));
  --black-mark: #0b0908;
  --black-mark-ring: 0 0 0 1px #b3a898;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141210;
    --ink: #e8dfd0;
    --ink-soft: #b3a898;
    --soft: #b3a898;
    --rule: #3c352d;
    --vermilion: #d9583b;
    --vermilion-fill: #b8432a;
    --surface: #1c1916;
    --surface-strong: #221e1a;
    --field: rgba(232, 223, 208, .045);
    --well: rgba(0, 0, 0, .22);
    --night: #1c1916;
    --on-night: #e8dfd0;
    --night-soft: #b3a898;
    --frame: #5a5045;
    --grain-blend: multiply;
    --img-dim: brightness(.9);
    --black-sun: drop-shadow(0 0 .5px rgba(232, 223, 208, .9)) drop-shadow(0 0 3px rgba(232, 223, 208, .18));
    --black-mark: #0b0908;
    --black-mark-ring: 0 0 0 1px #b3a898;
    color-scheme: dark;
  }
}

/* The paper grain stays; at night it is multiplied into the soot so the sheet keeps its tooth. */
html body { background-blend-mode: var(--grain-blend, normal); }
/* The black sun and the black dot keep their black disc and gain a thin ivory edge. */
html .sun.black { filter: var(--black-sun, none); }
html .footer-brand .mark-black { background: var(--black-mark, var(--ink)); box-shadow: var(--black-mark-ring, none); }

.theme-toggle {
  position: absolute; z-index: 60;
  top: max(.55rem, env(safe-area-inset-top)); right: max(.7rem, env(safe-area-inset-right));
  display: inline-flex; align-items: center; gap: .42em;
  min-height: 2.25rem; padding: .3rem .4rem;
  background: transparent; border: 0; cursor: pointer;
  font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: .98rem; letter-spacing: .02em;
  color: var(--ink-soft, #4a433b); touch-action: manipulation;
}
/* A half-lit disc: the same mark in both states, a moon on paper and a sun at night. */
.theme-toggle::before {
  content: ""; width: .62em; height: .62em; border-radius: 50%; flex: none;
  border: 1px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.theme-toggle:hover { color: var(--vermilion, #a7351e); }
.theme-toggle:focus-visible { outline: 2px solid var(--vermilion, #a7351e); outline-offset: 2px; }
/* Narrower sheets have no free corner beside the masthead, so the toggle takes its own short line above it. */
@media (max-width: 880px) {
  .theme-toggle {
    position: relative; top: auto; right: auto;
    display: flex; width: fit-content;
    margin: max(.2rem, env(safe-area-inset-top)) -.4rem -.55rem auto;
  }
}
@media print { .theme-toggle { display: none; } }
