/* ---------------------------------------------------------------- base --- */
:root {
  --ink: #f4f7f2;
  --ink-soft: #f4f7f2cc;
  --ink-faint: #f4f7f299;
  --accent: #cfe7a6;
  --glass: rgba(14, 26, 22, 0.68);
  --glass-edge: rgba(255, 255, 255, 0.14);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
}

#scene { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; }

a { color: inherit; }
.hidden { display: none; }
.sr-only:not(:focus-within) {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------- white fade on load --- */
#fade {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #fff;
  display: grid;
  place-items: center;
  transition: opacity 2.8s cubic-bezier(0.4, 0, 0.2, 1);
}
body.ready #fade { opacity: 0; pointer-events: none; }
#fade .message { color: #3a4a42; font: 15px/1.5 var(--serif); max-width: 32em; text-align: center; padding: 0 1.5em; }
#fade.error { opacity: 1 !important; pointer-events: auto; }

/* The header and intro appear once the scene has mostly faded in. */
.ui { opacity: 0; transition: opacity 1.6s ease 1.4s; }
body.ready .ui { opacity: 1; }

/* -------------------------------------------------------------- header --- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30; /* above the page panel, so you can switch pages directly */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.4rem clamp(1.2rem, 4vw, 3rem);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}
.site-name {
  font: 1.15rem/1 var(--serif);
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: opacity 0.3s, visibility 0.3s;
}
/* On the home view the hero already shows the name, so only show this
   (as a way back home) while a page is open. */
body:not(.panel-open) .site-name { opacity: 0; visibility: hidden; }
.site-header nav { display: flex; gap: clamp(1rem, 3vw, 2.2rem); }
.site-header nav a {
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.site-header nav a:hover,
.site-header nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ---------------------------------------------------------------- hero --- */
.hero {
  position: fixed;
  left: clamp(1.2rem, 4vw, 3rem);
  bottom: clamp(1.5rem, 7vh, 4.5rem);
  z-index: 5;
  max-width: 34rem;
  pointer-events: none; /* presses go through to the landscape (radial menu) */
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.4);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.hero h1 {
  margin: 0 0 0.4rem;
  font: 400 clamp(2.4rem, 6vw, 4.2rem)/1.05 var(--serif);
  letter-spacing: 0.01em;
}
.hero p { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }
.hero code { font-size: 0.85em; }
body.panel-open .hero { opacity: 0; transform: translateY(8px); transition-delay: 0s; }

/* --------------------------------------------------------------- panel --- */
.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 20;
  width: min(36rem, 100vw);
  box-sizing: border-box;
  overflow-y: auto;
  padding: 5.5rem clamp(1.4rem, 4vw, 3rem) 3rem;
  background: var(--glass);
  border-left: 1px solid var(--glass-edge);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  opacity: 0;
  transform: translateX(2.5rem);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.panel.open { opacity: 1; transform: none; pointer-events: auto; }
.panel .close {
  position: absolute;
  top: 5.4rem; right: clamp(1.2rem, 4vw, 3rem);
  width: 2.4rem; height: 2.4rem;
  border: 1px solid var(--glass-edge);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.panel .close:hover { background: rgba(255, 255, 255, 0.08); }
/* Keep the nav readable above the panel on narrow screens. */
@media (max-width: 40rem) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .panel { padding-top: 8rem; }
  .panel .close { top: 7.7rem; }
}

/* ------------------------------------------------------- page content --- */
.panel-body h1 { margin: 0 0 1.2rem; font: 400 2.2rem/1.15 var(--serif); outline: none; }
.panel-body h2 { margin: 2rem 0 0.4rem; font: 400 1.35rem/1.3 var(--serif); }
.panel-body p, .panel-body li { color: var(--ink-soft); }
.panel-body a { color: var(--accent); text-underline-offset: 3px; }
.panel-body .lede { font-size: 1.1rem; color: var(--ink); }
.panel-body .meta { font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

.cards { display: grid; gap: 1rem; margin-top: 1.5rem; }
.card {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--glass-edge);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.card h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.card p { margin: 0.2rem 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; padding: 0; list-style: none; }
.tags li {
  font-size: 0.75rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(207, 231, 166, 0.14);
  color: var(--accent);
}

/* --------------------------------------------------------- radial menu --- */
#scene { cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }

.menu-hint {
  position: fixed;
  left: 50%; bottom: 1.6rem;
  z-index: 5;
  margin: 0;
  transform: translateX(-50%);
  font: 0.78rem/1 var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: hint-breathe 3.2s ease-in-out infinite;
}
body.menu-used .menu-hint, body.panel-open .menu-hint { opacity: 0; transition-delay: 0s; transition-duration: 0.4s; }
@keyframes hint-breathe { 50% { color: var(--ink); } }

.radial {
  position: fixed;
  z-index: 40;
  width: 300px; height: 300px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.14s ease, transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.radial.open { opacity: 1; transform: none; }
/* Frosted ring behind the sectors. */
.radial-glass {
  position: absolute; inset: 0;
  border-radius: 50%;
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  -webkit-mask: radial-gradient(circle, transparent 53px, #000 54px, #000 132px, transparent 133px);
          mask: radial-gradient(circle, transparent 53px, #000 54px, #000 132px, transparent 133px);
}
.radial svg { position: absolute; inset: 0; overflow: visible; }
.radial .sector path {
  fill: rgba(14, 26, 22, 0.52);
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
  transition: fill 0.12s, stroke 0.12s;
}
.radial .sector text {
  fill: var(--ink-soft);
  font: 400 15px var(--serif);
  letter-spacing: 0.06em;
  transition: fill 0.12s;
}
.radial .sector.current path { stroke: rgba(207, 231, 166, 0.55); }
.radial .sector.selected path { fill: rgba(207, 231, 166, 0.30); stroke: var(--accent); stroke-width: 1.5; }
.radial .sector.selected text { fill: #fff; }
.radial .hub { fill: rgba(14, 26, 22, 0.45); stroke: rgba(255, 255, 255, 0.2); }
.radial .hub-label {
  fill: var(--accent);
  font: 600 10px var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.radial .stick { fill: var(--accent); filter: drop-shadow(0 0 4px rgba(207, 231, 166, 0.8)); }
body.menu-open, body.menu-open #scene { cursor: grabbing; }

/* -------------------------------------------------------- sound toggle --- */
.sound-control {
  position: fixed;
  right: clamp(1.2rem, 4vw, 3rem);
  bottom: 1.4rem;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
/* The slider is tucked away until you hover (or focus/tap) the control. */
.volume {
  width: 0;
  opacity: 0;
  margin: 0;
  transition: width 0.3s ease, opacity 0.25s ease;
  accent-color: var(--accent);
  cursor: pointer;
}
.sound-control:hover .volume,
.sound-control:focus-within .volume { width: 7.5rem; opacity: 1; }
.sound-control.off .volume { opacity: 0.5; }
.sound-control:hover .volume:hover,
.sound-control:focus-within .volume:focus { opacity: 1; }
.volume { -webkit-appearance: none; appearance: none; height: 1.6rem; background: transparent; }
.volume::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); }
.volume::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); }
.volume::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 0.9rem; height: 0.9rem; margin-top: calc(-0.45rem + 1.5px);
  border-radius: 50%; background: var(--ink); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
.volume::-moz-range-thumb { width: 0.9rem; height: 0.9rem; border: 0; border-radius: 50%; background: var(--ink); }

.sound-toggle {
  flex: none;
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  border: 1px solid var(--glass-edge);
  border-radius: 50%;
  background: rgba(14, 26, 22, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  cursor: pointer;
}
.sound-toggle:hover { background: rgba(14, 26, 22, 0.55); }
.sound-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .speaker { fill: currentColor; stroke: none; }
.sound-toggle .cross { display: none; }
.sound-toggle.off { color: var(--ink-faint); }
.sound-toggle.off .waves { display: none; }
.sound-toggle.off .cross { display: inline; }

#stats {
  position: fixed; left: 10px; bottom: 10px; z-index: 50;
  padding: 4px 8px; border-radius: 4px;
  background: #0008; color: #fff; font: 12px/1.3 ui-monospace, monospace;
}

@media (prefers-reduced-motion: reduce) {
  #fade, .ui, .panel, .hero { transition-duration: 0.01s; transition-delay: 0s; }
}

/* ---------------------------------------------------- blog: standard view --- */
.blog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.blog-head h1 { margin-bottom: 1rem; }
.view-toggle {
  flex: none;
  display: inline-flex; align-items: center; gap: 0.45rem;
  /* Leaves room for the panel's close button in the top-right corner. */
  margin: 0.4rem 3.4rem 0 0;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  font: 0.8rem/1 var(--sans);
  cursor: pointer;
}
.view-toggle:hover { color: var(--ink); background: rgba(255, 255, 255, 0.1); }
/* On a post, the toggle sits beside the close button area, above the article. */
.view-toggle.floating { float: right; margin: 0 3.4rem 0.5rem 1rem; }

.subject-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.subject-tabs a {
  --subject: var(--accent);
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.subject-tabs a:hover { color: var(--ink); border-color: var(--subject); }
.subject-tabs a[aria-current] {
  color: #10201a;
  background: var(--subject);
  border-color: var(--subject);
}
.subject-tabs .count { font-size: 0.75em; opacity: 0.7; }

.subject-intro { margin: 0 0 0.5rem; font-size: 0.95rem; }
.rss {
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.post-card { border-left: 3px solid var(--subject, var(--accent)); }
.post-card h2 a { color: var(--ink); text-decoration: none; }
.post-card h2 a:hover { text-decoration: underline; text-decoration-color: var(--subject); }
.post-card .meta { margin: 0 0 0.3rem; }
.subject-chip { color: var(--subject, var(--accent)); font-weight: 600; }
.draft {
  padding: 0 0.35rem;
  border-radius: 3px;
  background: #e7c6a6;
  color: #3a2a10;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.book-line { margin: 0.1rem 0 0.4rem; font-size: 0.9rem; }
.stars { color: #e7c96a; letter-spacing: 0.08em; white-space: nowrap; }
.empty, .blog-loading { color: var(--ink-faint); font-style: italic; }
.text-button { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

/* A post. */
.crumbs { margin: 0 0 0.8rem; font-size: 0.9rem; }
.crumbs a { text-decoration: none; color: var(--subject, var(--accent)) !important; }
.post-head h1 { margin: 0.2rem 0 0.8rem; }
.post-head .meta { margin: 0; }
.book-info {
  margin: 0 0 1.2rem;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--subject, var(--accent));
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0 6px 6px 0;
}
.book-info .book-title { font-family: var(--serif); font-size: 1.1rem; font-style: italic; color: var(--ink); }

.post-body { font: 1.02rem/1.75 var(--serif); color: var(--ink-soft); overflow-wrap: break-word; }
.post-body p, .post-body li { font: inherit; }
.post-body h2 { margin: 2rem 0 0.5rem; font-size: 1.45rem; color: var(--ink); }
.post-body h3 { margin: 1.6rem 0 0.4rem; font: 600 1.1rem/1.3 var(--sans); color: var(--ink); }
.post-body blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--subject, var(--accent));
  font-style: italic;
}
.post-body img { max-width: 100%; height: auto; border-radius: 6px; }
.post-body code { font: 0.88em/1.4 ui-monospace, 'Cascadia Code', Consolas, monospace; background: rgba(255, 255, 255, 0.08); padding: 0.1em 0.3em; border-radius: 3px; }
.post-body pre { overflow-x: auto; padding: 0.9rem 1rem; border-radius: 6px; background: rgba(0, 0, 0, 0.35); }
.post-body pre code { background: none; padding: 0; font-size: 0.85rem; }
.post-body table { width: 100%; border-collapse: collapse; font: 0.9rem/1.4 var(--sans); }
.post-body th, .post-body td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--glass-edge); text-align: left; }
.post-body hr { border: 0; border-top: 1px solid var(--glass-edge); margin: 2rem 0; }
.post-body .footnote-definition { font-size: 0.88rem; }

.post-nav { display: flex; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--glass-edge); }
.post-nav a { max-width: 48%; text-decoration: none; color: var(--ink) !important; font-family: var(--serif); }
.post-nav a:last-child { text-align: right; }
.post-nav a span { display: block; font: 0.72rem/1.6 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
