/* ==========================================================================
   michaelkipkorir.com — V9 layer ("night field edition")
   --------------------------------------------------------------------------
   Loaded after styles.css. Adds, without disturbing the V8 field-journal
   foundation:
     A. Night theme ("the field at dusk") — token overrides + component
        adaptations for hard-coded light values.
     B. Theme toggle + iris transition overlay.
     C. The Field Desk — a Ctrl/Cmd+K command palette (pages, publications,
        research areas, actions) with fuzzy search.
     D. Hero sky — layered parallax landscape (sun by day, moon, stars and
        fireflies by night, birds, mist, contour lines).
     E. Research geography — an interactive map of Africa.
     F. Back-to-top, live Eldoret clock, custom 404, view transitions,
        card spotlight and magnetic button micro-interactions.
   All motion respects prefers-reduced-motion. No dependencies.
   ========================================================================== */

/* --------------------------------------------------------------------------
   A. Night theme — the field at dusk
   -------------------------------------------------------------------------- */
html[data-theme="night"] {
  color-scheme: dark;

  --pine-950: #06140F;
  --pine-975: #040F0B;
  --pine-900: #0A1F19;
  --pine-800: #0D2820;
  --pine-700: #133227;
  --moss-600: #2E5546;

  --cream: #0A1E18;
  --cream-deep: #081812;
  --paper: #0E241C;
  --ink: #E7E1CF;
  --ink-soft: #A9B6AD;
  --ink-body: #CBD5CB;

  --gold-600: #B08924;
  --gold-500: #C2911F;
  --gold-400: #D9A836;
  --gold-300: #E9C268;
  --gold-wash: #1A291D;

  --terra-600: #D0825E;
  --terra-500: #B4562E;
  --terra-400: #C9714E;
  --terra-wash: #291711;

  --on-dark: #EFE9D8;
  --on-dark-muted: rgba(239, 233, 216, 0.72);
  --on-dark-faint: rgba(239, 233, 216, 0.55);
  --line: rgba(231, 225, 207, 0.15);
  --line-dark: rgba(239, 233, 216, 0.16);

  --shadow-lg: 0 26px 60px -22px rgba(0, 0, 0, 0.62);
  --shadow-md: 0 18px 38px -18px rgba(0, 0, 0, 0.5);
}

/* Adaptations for values the V8 sheet hard-codes light. */
html[data-theme="night"] .site-header.scrolled {
  background: rgba(6, 20, 15, 0.9);
  border-bottom-color: var(--line-dark);
}
html[data-theme="night"] .site-header.scrolled .brand-text { color: var(--on-dark); }
html[data-theme="night"] .site-header.scrolled .site-nav a { color: rgba(231, 225, 207, 0.8); }
html[data-theme="night"] .site-header.scrolled .site-nav a:hover,
html[data-theme="night"] .site-header.scrolled .site-nav a.active { color: var(--gold-300); }
html[data-theme="night"] .site-header.scrolled .nav-toggle span { background: var(--on-dark); }

html[data-theme="night"] .cite-format,
html[data-theme="night"] .pub-search input,
html[data-theme="night"] .pub-filters select,
html[data-theme="night"] .form-row input,
html[data-theme="night"] .form-row select,
html[data-theme="night"] .form-row textarea {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme="night"] .record-strip dt { color: var(--gold-300); }
html[data-theme="night"] .area-card .area-q,
html[data-theme="night"] .ft-heading,
html[data-theme="night"] .pub-year,
html[data-theme="night"] .pub-geo,
html[data-theme="night"] .contact-card .card-h { color: var(--ink); }
html[data-theme="night"] .form-sent { color: var(--gold-300); }
html[data-theme="night"] .pub h3 a:hover { color: var(--gold-300); }

html[data-theme="night"] .b-published { color: #9fd3b4; border-color: #9fd3b4; background: rgba(62, 107, 87, 0.24); }
html[data-theme="night"] .b-review { color: #E9C268; border-color: #B08924; background: rgba(194, 145, 31, 0.18); }
html[data-theme="night"] .b-ongoing { color: #eba87f; border-color: #B4562E; background: rgba(180, 86, 46, 0.2); }
html[data-theme="night"] .b-concept { color: #A9B6AD; border-color: #4A5B53; background: rgba(74, 91, 83, 0.16); }

/* Smooth cross-fade while a theme switch settles (class set briefly by JS). */
html.theme-switching body,
html.theme-switching .section-alt,
html.theme-switching .card,
html.theme-switching .glance-cell,
html.theme-switching .pub-tools,
html.theme-switching .contact-form,
html.theme-switching .lab-module,
html.theme-switching .note-card,
html.theme-switching .site-header,
html.theme-switching .site-footer {
  transition: background-color 0.45s ease, color 0.45s ease, border-color 0.45s ease;
}

/* --------------------------------------------------------------------------
   B. Theme toggle + iris transition
   -------------------------------------------------------------------------- */
/* Cluster nav + tools + burger to the right edge (v8 used space-between
   with only two children; the tools group now completes the row). */
.header-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
}
.header-inner .site-nav { order: 1; }
.header-inner .header-tools { order: 2; }
.header-inner .nav-toggle { order: 3; }
@media (min-width: 881px) {
  .site-nav { margin-left: auto; }
  .header-tools { margin-left: 1.3rem; }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(244, 238, 220, 0.4);
  border-radius: 999px;
  background: transparent;
  color: var(--on-dark);
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.3s var(--ease-out);
}
.icon-btn:hover {
  background: rgba(217, 168, 54, 0.14);
  border-color: var(--gold-400);
  color: var(--gold-300);
  transform: translateY(-1px);
}
.icon-btn svg { width: 18px; height: 18px; }

.site-header.scrolled .icon-btn { color: rgba(29, 43, 37, 0.8); }
html[data-theme="night"] .site-header.scrolled .icon-btn { color: var(--on-dark); }
.site-header.scrolled .icon-btn:hover { color: var(--gold-600); }

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { transition: opacity 0.4s ease, transform 0.4s var(--ease-out); }
.theme-toggle .icon-sun { display: none; }
html[data-theme="night"] .theme-toggle .icon-sun { display: block; }
html[data-theme="night"] .theme-toggle .icon-moon { display: none; }

/* The search trigger — wider on desktop, icon-only on small screens. */
.desk-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-dark);
  background: transparent;
  border: 1px solid rgba(244, 238, 220, 0.4);
  border-radius: 999px;
  padding: 0.72em 1.1em;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.desk-btn:hover {
  background: rgba(217, 168, 54, 0.14);
  border-color: var(--gold-400);
  color: var(--gold-300);
}
.desk-btn svg { width: 15px; height: 15px; flex: none; }
.desk-btn .desk-kbd {
  font-family: var(--mono);
  font-size: 0.66rem;
  padding: 0.14em 0.42em;
  border: 1px solid rgba(244, 238, 220, 0.35);
  border-radius: 5px;
  color: rgba(244, 238, 220, 0.7);
}
.site-header.scrolled .desk-btn { color: rgba(29, 43, 37, 0.85); }
.site-header.scrolled .desk-btn .desk-kbd { border-color: rgba(29, 43, 37, 0.3); color: rgba(29, 43, 37, 0.6); }
html[data-theme="night"] .site-header.scrolled .desk-btn { color: var(--on-dark); }
@media (max-width: 880px) {
  .desk-btn .desk-label, .desk-btn .desk-kbd { display: none; }
  .desk-btn { padding: 0.72em 0.85em; }
}

/* Iris overlay used for the day/night wipe. */
.iris {
  position: fixed;
  inset: 0;
  z-index: 1140;
  pointer-events: none;
  clip-path: circle(0px at 50% 50%);
}

/* --------------------------------------------------------------------------
   C. The Field Desk — command palette
   -------------------------------------------------------------------------- */
.fd-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(4, 12, 9, 0.58);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0s linear 0.24s;
}
.fd-backdrop.is-open { opacity: 1; visibility: visible; transition: opacity 0.24s ease; }

.fd-panel {
  position: fixed;
  z-index: 1110;
  top: 11vh;
  left: 50%;
  transform: translateX(-50%) translateY(10px) scale(0.985);
  width: min(660px, calc(100vw - 1.8rem));
  max-height: min(62vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid rgba(194, 145, 31, 0.55);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
}
.fd-panel.is-open { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

.fd-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--gold-wash);
}
.fd-head svg { width: 17px; height: 17px; color: var(--gold-500); flex: none; }
.fd-input {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 1.02rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
}
.fd-input::placeholder { color: var(--ink-soft); font-style: italic; }
.fd-head .fd-kbd-hint {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  padding: 0.24em 0.5em;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  flex: none;
}

.fd-results {
  overflow-y: auto;
  padding: 0.5rem;
  overscroll-behavior: contain;
}
.fd-group {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terra-600);
  padding: 0.7rem 0.75rem 0.3rem;
}
.fd-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}
.fd-item .fd-item-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold-600);
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--cream);
}
.fd-item .fd-item-body { flex: 1; min-width: 0; }
.fd-item-title {
  display: block;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fd-item-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fd-item .fd-arrow { color: var(--gold-600); opacity: 0; transform: translateX(-4px); transition: opacity 0.2s, transform 0.2s; }
.fd-item:hover, .fd-item[aria-selected="true"] {
  background: var(--gold-wash);
  outline: none;
}
.fd-item:hover .fd-arrow, .fd-item[aria-selected="true"] .fd-arrow { opacity: 1; transform: none; }
.fd-item mark { background: rgba(217, 168, 54, 0.35); color: inherit; border-radius: 2px; }

.fd-empty {
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}
.fd-foot {
  display: flex;
  gap: 1.1rem;
  padding: 0.7rem 1.2rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--cream);
}
.fd-foot kbd {
  font-family: var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.38em;
  margin-right: 0.35em;
}

/* --------------------------------------------------------------------------
   D. Hero sky — the layered landscape
   -------------------------------------------------------------------------- */
.hero-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.hero-sky svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-inner { position: relative; z-index: 3; }
.hero .scroll-cue { z-index: 4; }

/* Sky groups fade between day and night. */
.sky-sun, .sky-moon, .sky-stars, .sky-fireflies, .sky-birds { transition: opacity 0.9s ease; }
html[data-theme="night"] .sky-sun,
html[data-theme="night"] .sky-birds { opacity: 0; }
.sky-moon, .sky-stars, .sky-fireflies { opacity: 0; }
html[data-theme="night"] .sky-moon,
html[data-theme="night"] .sky-stars,
html[data-theme="night"] .sky-fireflies { opacity: 1; }

/* Day/night sky rects cross-fade. */
.sky-base, .sky-glow-day { transition: opacity 0.9s ease; }
.sky-base-night, .sky-glow-night { opacity: 0; transition: opacity 0.9s ease; }
html[data-theme="night"] .sky-base,
html[data-theme="night"] .sky-glow-day { opacity: 0; }
html[data-theme="night"] .sky-base-night,
html[data-theme="night"] .sky-glow-night { opacity: 1; }

/* Landscape fills. */
.star { fill: #EFE9D8; }
.h-far { fill: rgba(27, 74, 60, 0.55); }
.h-mid { fill: #143B30; }
.h-near { fill: #0B241E; }
html[data-theme="night"] .h-far { fill: rgba(13, 40, 32, 0.8); }
html[data-theme="night"] .h-mid { fill: #0A1F19; }
html[data-theme="night"] .h-near { fill: #040F0B; }
.h-rim { fill: none; stroke: #D9A836; stroke-opacity: 0.32; stroke-width: 1.5; }
.contour-line { fill: none; stroke: #D9A836; stroke-opacity: 0.2; stroke-width: 1.2; }
.mist ellipse { fill: #F4EEDC; opacity: 0.08; }
.bird path { stroke: #D9A836; stroke-width: 2; fill: none; opacity: 0.8; stroke-linecap: round; }

/* Sun + halo breathe slowly. */
.sun-halo { animation: sun-pulse 9s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes sun-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

/* Stars twinkle on a stagger. */
.star { animation: twinkle 5s ease-in-out infinite; }
.star:nth-child(3n) { animation-delay: 1.3s; animation-duration: 6.2s; }
.star:nth-child(3n+1) { animation-delay: 2.6s; animation-duration: 4.4s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* Fireflies wander gently. */
.ff { animation: ff-drift 11s ease-in-out infinite alternate, ff-glow 3.4s ease-in-out infinite; }
.ff:nth-child(2n) { animation-delay: 0.7s, 1.2s; animation-duration: 13s, 4.2s; }
.ff:nth-child(3n) { animation-delay: 2.1s, 0.4s; animation-duration: 9.5s, 2.8s; }
@keyframes ff-drift {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-14px, -9px); }
  100% { transform: translate(10px, 6px); }
}
@keyframes ff-glow {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.95; }
}

/* Birds cross the sky by day. */
.bird { animation: bird-pass 38s linear infinite; }
.bird.b2 { animation-delay: 11s; animation-duration: 46s; }
.bird.b3 { animation-delay: 23s; animation-duration: 52s; }
@keyframes bird-pass {
  0% { transform: translate(-80px, 12px); opacity: 0; }
  6% { opacity: 0.8; }
  88% { opacity: 0.8; }
  100% { transform: translate(1160px, -26px); opacity: 0; }
}

/* Mist drifts across the valley. */
.mist { animation: mist-drift 26s ease-in-out infinite alternate; }
.mist.m2 { animation-duration: 34s; animation-delay: 4s; }
@keyframes mist-drift {
  0% { transform: translateX(-26px); opacity: 0.5; }
  100% { transform: translateX(26px); opacity: 0.75; }
}

/* Hills shade down at night. */
.h-fill { transition: fill 0.9s ease; }

/* Parallax targets move via JS transform (rAF, scroll + pointer). */
.plx { will-change: transform; }

@media (prefers-reduced-motion: reduce) {
  .sun-halo, .star, .ff, .bird, .mist { animation: none !important; }
}

/* --------------------------------------------------------------------------
   E. Research geography — interactive map of Africa
   -------------------------------------------------------------------------- */
.geo-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(1.4rem, 4vw, 3rem);
  align-items: center;
}
.geo-map {
  position: relative;
  border: 1px solid rgba(194, 145, 31, 0.4);
  border-radius: 16px;
  background:
    radial-gradient(420px 300px at 78% 18%, rgba(217, 168, 54, 0.13), transparent 65%),
    var(--paper);
  padding: clamp(0.9rem, 2.5vw, 1.8rem);
  box-shadow: var(--shadow-md);
}
.geo-map svg { display: block; width: 100%; height: auto; }

.geo-land {
  fill: rgba(62, 107, 87, 0.16);
  stroke: var(--moss-600);
  stroke-width: 2;
  stroke-linejoin: round;
  transition: fill 0.35s ease, stroke 0.35s ease;
}
.geo-map:hover .geo-land { fill: rgba(62, 107, 87, 0.22); }
.geo-grid { stroke: var(--line); stroke-width: 1; }

.geo-marker {
  fill: var(--gold-400);
  stroke: var(--gold-600);
  stroke-width: 1.5;
  cursor: pointer;
  transition: r 0.25s var(--ease-out), fill 0.25s ease, stroke 0.25s ease;
}
.geo-marker-ring {
  fill: none;
  stroke: var(--gold-400);
  stroke-width: 1.6;
  opacity: 0.55;
  transform-box: fill-box;
  transform-origin: center;
  animation: marker-pulse 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes marker-pulse {
  0% { transform: scale(0.45); opacity: 0.6; }
  70% { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}
.geo-dot.is-active .geo-marker { fill: var(--terra-500); stroke: var(--terra-600); r: 8; }
.geo-dot.is-active .geo-marker-ring { stroke: var(--terra-400); }

.geo-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  fill: var(--ink-soft);
  text-transform: uppercase;
  pointer-events: none;
}
.geo-dot.is-active .geo-label { fill: var(--ink); font-weight: 600; }

.geo-global {
  cursor: pointer;
}
.geo-global .geo-orbit {
  fill: none;
  stroke: var(--terra-500);
  stroke-width: 1.4;
  stroke-dasharray: 4 5;
  opacity: 0.7;
  transform-box: fill-box;
  transform-origin: center;
  animation: orbit-spin 26s linear infinite;
}
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.geo-global .geo-globe { fill: var(--terra-wash); stroke: var(--terra-500); stroke-width: 1.6; }
.geo-global .geo-globe-meridian { fill: none; stroke: var(--terra-400); stroke-width: 1; opacity: 0.8; }
.geo-global.is-active .geo-globe { fill: rgba(180, 86, 46, 0.25); }
.geo-global-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; fill: var(--ink-soft); text-transform: uppercase; }

.geo-panel { min-height: 220px; }
.geo-panel-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terra-600);
  margin: 0 0 0.4rem;
}
.geo-panel h3 { font-size: clamp(1.5rem, 3vw, 1.9rem); margin: 0 0 0.7rem; color: var(--ink); }
.geo-panel p { color: var(--ink-body); line-height: 1.65; max-width: 40rem; }
.geo-panel-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-600);
  text-decoration: none;
  border-bottom: 1px solid rgba(194, 145, 31, 0.4);
  padding-bottom: 0.2em;
}
.geo-panel-link:hover { color: var(--terra-600); border-color: var(--terra-600); }

.geo-hint {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
@media (prefers-reduced-motion: reduce) {
  .geo-marker-ring, .geo-orbit { animation: none !important; }
}
@media (max-width: 860px) {
  .geo-stage { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   F. Back-to-top, footer clock, 404, view transitions, micro-interactions
   -------------------------------------------------------------------------- */
.to-top {
  position: fixed;
  right: clamp(0.9rem, 2.5vw, 1.6rem);
  bottom: clamp(0.9rem, 2.5vw, 1.6rem);
  z-index: 900;
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(194, 145, 31, 0.6);
  background: var(--pine-900);
  color: var(--gold-300);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-out), visibility 0s linear 0.3s, background 0.3s ease;
  box-shadow: var(--shadow-md);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity 0.3s ease, transform 0.3s var(--ease-out), background 0.3s ease; }
.to-top:hover { background: var(--pine-700); }
.to-top svg { width: 18px; height: 18px; }

/* Live Eldoret clock in the footer. */
.footer-clock {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-300);
  margin: 0.7rem 0 0;
}
.footer-clock .clock-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--gold-400);
  animation: clock-beat 2.4s ease-in-out infinite;
  flex: none;
}
@keyframes clock-beat {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) { .footer-clock .clock-dot { animation: none; } }

/* Card spotlight — a soft gold wash that follows the cursor. */
.card { position: relative; }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(217, 168, 54, 0.13), transparent 65%);
}
.card:hover::after { opacity: 1; }
html[data-theme="night"] .card::after {
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(217, 168, 54, 0.1), transparent 65%);
}

/* View transitions — a quiet page turn between documents. */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.26s; }
}

/* Custom 404 — off the map. */
.err-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 84% -10%, rgba(217, 168, 54, 0.15), transparent 62%),
    radial-gradient(800px 460px at -12% 112%, rgba(62, 107, 87, 0.3), transparent 60%),
    var(--pine-950);
  color: var(--on-dark);
  padding: clamp(7rem, 16vh, 10rem) 0 5rem;
}
.err-inner { max-width: 640px; }
.err-code {
  position: absolute;
  right: -0.5rem;
  top: 1rem;
  font-family: var(--serif);
  font-size: clamp(9rem, 26vw, 17rem);
  font-weight: 300;
  line-height: 1;
  color: rgba(217, 168, 54, 0.07);
  letter-spacing: -0.04em;
  user-select: none;
  pointer-events: none;
}
.err-compass { width: 84px; height: 84px; margin: 0 0 1.4rem; }
.err-needle { transform-box: fill-box; transform-origin: center; animation: needle-wobble 5.5s ease-in-out infinite; }
@keyframes needle-wobble {
  0%, 100% { transform: rotate(-9deg); }
  50% { transform: rotate(13deg); }
}
@media (prefers-reduced-motion: reduce) { .err-needle { animation: none; } }
.err-hero h1 { color: var(--on-dark); font-size: clamp(2.2rem, 5vw, 3.2rem); margin: 0.3rem 0 1rem; }
.err-hero .lede { color: var(--on-dark-muted); }
.err-links { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.8rem; }
.err-note {
  margin-top: 2.2rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-dark-faint);
}
.err-note kbd {
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  padding: 0.12em 0.45em;
  margin: 0 0.2em;
  color: var(--gold-300);
}

/* Print: keep publications printing clean. */
@media print {
  .to-top, .desk-btn, .theme-toggle, .header-tools, .hero-sky, .iris, .fd-backdrop, .fd-panel { display: none !important; }
}
