/* Shared theme. Plain colors remain a complete fallback; no script or storage. */
:root {
  color-scheme: light dark;
  --paper: #ece7e1;
  --surface: #ffffff;
  --ink: #24252a;
  --muted: #686762;
  --line: #dcdad4;
  --accent: #3949c8;
  --wash: #efeee8;
  --on-accent: #ffffff;
  --header-name: rgba(236,231,225,.94);
  --header-fill: rgba(236,231,225,.96);
  --nav-bg: rgba(235,234,229,.94);
  --nav-hover: rgba(222,220,215,.98);
  --selection-bg: #dce0ff;
  --selection-ink: #181c59;
  --panel-shadow: rgba(36,37,42,.14);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #18191c;
    --surface: #22242a;
    --ink: #ecebe6;
    --muted: #b3b1a9;
    --line: #44464e;
    --accent: #adb7ff;
    --wash: #282b34;
    --on-accent: #18191c;
    --header-name: rgba(24,25,28,.94);
    --header-fill: rgba(24,25,28,.96);
    --nav-bg: rgba(46,49,57,.94);
    --nav-hover: rgba(59,62,71,.98);
    --selection-bg: #424d86;
    --selection-ink: #ffffff;
    --panel-shadow: rgba(0,0,0,.4);
  }
}
/* This query tests a real color property: unknown functions must not overwrite
   usable custom properties at computed-value time. */
@supports (color: light-dark(white, black)) {
  :root {
    --paper: light-dark(#ece7e1, #18191c);
    --surface: light-dark(#ffffff, #22242a);
    --ink: light-dark(#24252a, #ecebe6);
    --muted: light-dark(#686762, #b3b1a9);
    --line: light-dark(#dcdad4, #44464e);
    --accent: light-dark(#3949c8, #adb7ff);
    --wash: light-dark(#efeee8, #282b34);
    --on-accent: light-dark(#ffffff, #18191c);
    --header-name: light-dark(rgba(236,231,225,.94), rgba(24,25,28,.94));
    --header-fill: light-dark(rgba(236,231,225,.96), rgba(24,25,28,.96));
    --nav-bg: light-dark(rgba(235,234,229,.94), rgba(46,49,57,.94));
    --nav-hover: light-dark(rgba(222,220,215,.98), rgba(59,62,71,.98));
    --selection-bg: light-dark(#dce0ff, #424d86);
    --selection-ink: light-dark(#181c59, #ffffff);
    --panel-shadow: light-dark(rgba(36,37,42,.14), rgba(0,0,0,.4));
  }
}
/* Palette changes must not animate text through low-contrast middle colors. */
.site-nav a, .post-link { transition: none; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* Explicit colors preserve the manual choice without light-dark(). */
@supports not (color: light-dark(white, black)) {
    :root[data-theme="light"] {
      --paper: #ece7e1;
      --surface: #ffffff;
      --ink: #24252a;
      --muted: #686762;
      --line: #dcdad4;
      --accent: #3949c8;
      --wash: #efeee8;
      --on-accent: #ffffff;
      --header-name: rgba(236,231,225,.94);
      --header-fill: rgba(236,231,225,.96);
      --nav-bg: rgba(235,234,229,.94);
      --nav-hover: rgba(222,220,215,.98);
      --selection-bg: #dce0ff;
      --selection-ink: #181c59;
      --panel-shadow: rgba(36,37,42,.14);
    }
    :root[data-theme="dark"] {
      --paper: #18191c;
      --surface: #22242a;
      --ink: #ecebe6;
      --muted: #b3b1a9;
      --line: #44464e;
      --accent: #adb7ff;
      --wash: #282b34;
      --on-accent: #18191c;
      --header-name: rgba(24,25,28,.94);
      --header-fill: rgba(24,25,28,.96);
      --nav-bg: rgba(46,49,57,.94);
      --nav-hover: rgba(59,62,71,.98);
      --selection-bg: #424d86;
      --selection-ink: #ffffff;
      --panel-shadow: rgba(0,0,0,.4);
    }
}
@supports (color: contrast-color(red)) {
  :root { --on-accent: contrast-color(var(--accent)); }
}
/* Text links are identifiable before hover, including notes beside forms.
   Only links already presented as navigation controls/cards opt out. */
a {
  text-decoration: underline;
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
  text-decoration-skip-ink: auto;
}
a:hover { text-decoration-thickness: .12em; }
.site-name, .site-nav a, .post-link, .archive-years a, .archive-tags a,
.inline-tags a, .tag-index a, .tabs a, .freebsd-badge { text-decoration: none; }

/* A single native action button; only its next-action icon is visible. */
.header-tools { display: flex; align-items: flex-start; gap: 12px; min-width: 0; max-width: 100%; pointer-events: auto; }
.header-tools > .site-nav { flex: 1; min-width: 0; }
.theme-toggle { display: inline-flex; flex: 0 0 44px; align-items: center; justify-content: center; box-sizing: border-box; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; margin: 0; border: 0; border-radius: 2px; background: var(--nav-bg); color: var(--ink); font: inherit; cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.theme-toggle[hidden] { display: none !important; }
.theme-toggle svg { display: block; flex: 0 0 auto; }
.theme-toggle .theme-sun, .theme-toggle[data-next-theme="light"] .theme-moon { display: none; }
.theme-toggle[data-next-theme="light"] .theme-sun { display: block; }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { background: var(--nav-hover); }
}
.utility-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 16px; }
.utility-header > a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); }
.footer-tools a:focus-visible, .utility-header a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
@media (max-width: 47.5em) {
  .site-header > .header-tools { width: auto; }
  .theme-toggle { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.footer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; min-width: 0; max-width: 100%; }
.footer-tools > a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; }
.feed-link { text-decoration: underline; text-underline-offset: .2em; }
@media (forced-colors: active) {
  :root { --paper: Canvas !important; --surface: Canvas !important; --ink: CanvasText !important; --muted: CanvasText !important; --line: CanvasText !important; --accent: LinkText !important; --wash: Canvas !important; --on-accent: HighlightText !important; --header-name: Canvas !important; --header-fill: Canvas !important; --nav-bg: Canvas !important; --nav-hover: Canvas !important; --selection-bg: Highlight !important; --selection-ink: HighlightText !important; }
  .site-nav a[aria-current="page"] { border: 1px solid CanvasText; }
  .poster-squares { visibility: hidden; }
  .poster-field { display: none; }
  .note-toggle[aria-expanded="true"] .note-icon { color: HighlightText; background: Highlight; }
  .theme-toggle { border: 1px solid ButtonText; }
  .site-name, .site-nav a, .site-header, .theme-toggle { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media print {
  :root { color-scheme: light !important; --paper: #fff !important; --surface: #fff !important; --ink: #000 !important; --muted: #444 !important; --line: #777 !important; --accent: #152b7d !important; --wash: #eee !important; --on-accent: #fff !important; --header-name: #fff !important; --header-fill: #fff !important; --nav-bg: #eee !important; --nav-hover: #eee !important; }
  .theme-toggle, .feed-link { display: none !important; }
}
