/* Scroll of Fire — Theory Interactive Codex
   Shared theory, Canon, and equation page styles
*/

:root {
  --theory-bg: #05070d;
  --theory-bg-soft: #0a0e18;
  --theory-panel: rgba(13, 18, 31, 0.84);
  --theory-panel-strong: rgba(15, 21, 36, 0.96);
  --theory-panel-soft: rgba(255, 255, 255, 0.035);
  --theory-line: rgba(226, 184, 91, 0.24);
  --theory-line-strong: rgba(226, 184, 91, 0.52);
  --theory-gold: #e2b85b;
  --theory-gold-soft: #f3d58a;
  --theory-ember: #d86f3f;
  --theory-blue: #7bb7ff;
  --theory-violet: #b69cff;
  --theory-text: #f4f0e6;
  --theory-muted: #b8b5ad;
  --theory-dim: #858899;
  --theory-danger: #ef8d82;
  --theory-success: #8dd7ac;
  --theory-shadow: 0 28px 72px rgba(0, 0, 0, 0.38);
  --theory-radius: 1.25rem;
  --theory-radius-small: 0.85rem;
  --theory-header-height: 4.8rem;
  --theory-max: 74rem;
  --theory-reading: 46rem;
  --theory-transition: 180ms ease;
  --theory-font-display: "Cormorant Garamond", "Times New Roman", serif;
  --theory-font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--theory-header-height) + 1rem);
}

html.sof.theory-page {
  background: var(--theory-bg);
}

body[data-reading-mode] {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% -10%, rgba(226, 184, 91, 0.1), transparent 30rem),
    radial-gradient(circle at 85% 10%, rgba(123, 183, 255, 0.08), transparent 34rem),
    linear-gradient(180deg, #05070d 0%, #070a12 48%, #05070d 100%);
  color: var(--theory-text);
  font-family: var(--theory-font-body);
  line-height: 1.65;
}

body.nav-open,
body.command-open {
  overscroll-behavior: none;
}

body[data-reading-mode] *,
body[data-reading-mode] *::before,
body[data-reading-mode] *::after {
  box-sizing: border-box;
}

body[data-reading-mode] img,
body[data-reading-mode] svg,
body[data-reading-mode] video,
body[data-reading-mode] canvas {
  max-width: 100%;
}

body[data-reading-mode] a {
  color: inherit;
  text-decoration-color: rgba(226, 184, 91, 0.55);
  text-underline-offset: 0.2em;
}

body[data-reading-mode] a:hover {
  text-decoration-color: var(--theory-gold);
}

body[data-reading-mode] button,
body[data-reading-mode] input,
body[data-reading-mode] select,
body[data-reading-mode] textarea {
  font: inherit;
}

body[data-reading-mode] button,
body[data-reading-mode] a {
  -webkit-tap-highlight-color: transparent;
}

body[data-reading-mode] :focus-visible {
  outline: 3px solid rgba(123, 183, 255, 0.92);
  outline-offset: 3px;
}

body[data-reading-mode] code {
  padding: 0.12em 0.38em;
  border: 1px solid rgba(226, 184, 91, 0.18);
  border-radius: 0.4em;
  background: rgba(255, 255, 255, 0.055);
  color: var(--theory-gold-soft);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

body[data-reading-mode] h1,
body[data-reading-mode] h2,
body[data-reading-mode] h3,
body[data-reading-mode] h4 {
  margin-top: 0;
  color: var(--theory-text);
  font-family: var(--theory-font-display);
  font-weight: 650;
  line-height: 1.08;
  text-wrap: balance;
}

body[data-reading-mode] p {
  text-wrap: pretty;
}
body[data-reading-mode] ::selection {
  background: rgba(226, 184, 91, 0.28);
  color: #fff;
}

/* Decorative field */

.theory-aura,
.theory-stars {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.theory-aura {
  overflow: hidden;
}

.theory-aura::before,
.theory-aura::after {
  content: "";
  position: absolute;
  width: 38rem;
  height: 38rem;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.11;
}

.theory-aura::before {
  top: -18rem;
  left: -12rem;
  background: var(--theory-gold);
}

.theory-aura::after {
  right: -18rem;
  bottom: -20rem;
  background: var(--theory-blue);
}
.theory-stars {
  z-index: -1;
  opacity: 0.35;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.2px),
    radial-gradient(circle, rgba(226, 184, 91, 0.6) 0 1px, transparent 1.2px);
  background-position: 0 0, 37px 53px;
  background-size: 84px 84px, 123px 123px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

/* Accessibility */

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  transform: translateY(-180%);
  padding: 0.7rem 0.95rem;
  border-radius: 0.7rem;
  background: #fff;
  color: #000 !important;
  font-weight: 800;
  text-decoration: none;
  transition: transform var(--theory-transition);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Header and navigation */

.site-header.theory-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--theory-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.85rem clamp(1rem, 3vw, 2.4rem);
  border-bottom: 1px solid rgba(226, 184, 91, 0.16);
  background: rgba(5, 7, 13, 0.88);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.theory-header .brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--theory-text);
  text-decoration: none;
}

.theory-header .brand-mark {
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--theory-line-strong);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.2), transparent 30%),
    linear-gradient(145deg, rgba(226, 184, 91, 0.2), rgba(216, 111, 63, 0.09));
  box-shadow:
    inset 0 0 20px rgba(226, 184, 91, 0.08),
    0 0 24px rgba(226, 184, 91, 0.11);
  color: var(--theory-gold);
  font-size: 1.35rem;
}

.theory-header .brand > span:last-child {
  min-width: 0;
  display: grid;
  line-height: 1.05;
}
.theory-header .brand strong {
  overflow: hidden;
  color: var(--theory-text);
  font-family: var(--theory-font-display);
  font-size: clamp(1.08rem, 1.6vw, 1.35rem);
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theory-header .brand small {
  margin-top: 0.25rem;
  overflow: hidden;
  color: var(--theory-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.theory-header .site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
  flex-wrap: wrap;
}

.theory-header .site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.4rem;
  padding: 0.55rem 0.74rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--theory-muted);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  transition:
    color var(--theory-transition),
    border-color var(--theory-transition),
    background var(--theory-transition),
    transform var(--theory-transition);
}

.theory-header .site-nav a:hover {
  border-color: rgba(226, 184, 91, 0.22);
  background: rgba(226, 184, 91, 0.07);
  color: var(--theory-text);
  transform: translateY(-1px);
}

.theory-header .site-nav a[aria-current="page"] {
  border-color: rgba(226, 184, 91, 0.4);
  background: rgba(226, 184, 91, 0.12);
  color: var(--theory-gold-soft);
}
.theory-header .site-nav a.is-featured {
  border-color: rgba(226, 184, 91, 0.34);
  color: var(--theory-gold-soft);
}

.nav-toggle {
  display: none;
  width: 2.85rem;
  height: 2.85rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.29rem;
  padding: 0;
  border: 1px solid rgba(226, 184, 91, 0.28);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.035);
  color: var(--theory-text);
  cursor: pointer;
  transition:
    border-color var(--theory-transition),
    background var(--theory-transition),
    transform var(--theory-transition);
}

.nav-toggle:hover {
  border-color: var(--theory-line-strong);
  background: rgba(226, 184, 91, 0.09);
}

.nav-toggle span {
  width: 1.18rem;
  height: 2px;
  display: block;
  border-radius: 99px;
  background: currentColor;
  transform-origin: center;
  transition:
    transform var(--theory-transition),
    opacity var(--theory-transition);
}

.nav-toggle.active span:nth-child(1) {
  transform: translateY(0.38rem) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: translateY(-0.38rem) rotate(-45deg);
}

/* Layout */

.section-shell {
  width: min(calc(100% - 3rem), var(--theory-max));
  margin-inline: auto;
  padding-block: clamp(2.6rem, 6vw, 5.8rem);
}
.section-shell[aria-label="Breadcrumb"] {
  padding-top: 1.15rem;
  padding-bottom: 0;
  color: var(--theory-dim);
  font-size: 0.82rem;
}

.section-shell[aria-label="Breadcrumb"] nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.text-link {
  color: var(--theory-muted) !important;
  text-decoration: none;
}

.text-link:hover {
  color: var(--theory-gold-soft) !important;
}

.section-heading {
  max-width: 42rem;
  margin-bottom: clamp(1.4rem, 3vw, 2.4rem);
}

.section-heading h2 {
  margin-bottom: 0.7rem;
  font-size: clamp(2rem, 4vw, 3.45rem);
}

.section-heading > p:last-child {
  color: var(--theory-muted);
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--theory-gold);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* Hero */

.theory-hero {
  padding-top: clamp(2.5rem, 6vw, 5.2rem);
}

.theory-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(20rem, 0.85fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.theory-hero-copy h1 {
  margin-bottom: 1rem;
  font-size: clamp(3.5rem, 9vw, 7.4rem);
  letter-spacing: -0.045em;
}

.hero-line {
  max-width: 48rem;
  margin: 0 0 1rem;
  color: var(--theory-gold-soft);
  font-family: var(--theory-font-display);
  font-size: clamp(1.3rem, 2.7vw, 2rem);
  line-height: 1.3;
}

.hero-copy {
  max-width: 38rem;
  margin: 0;
  color: var(--theory-muted);
  font-size: clamp(1rem, 1.2vw, 1.12rem);
  line-height: 1.78;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  flex-wrap: wrap;
  margin-top: 1.55rem;
}

.theory-orb-card {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  gap: 1.2rem;
  min-height: 24rem;
  padding: 2rem;
  border: 1px solid var(--theory-line);
  border-radius: calc(var(--theory-radius) + 0.35rem);
  background:
    linear-gradient(145deg, rgba(226, 184, 91, 0.08), rgba(123, 183, 255, 0.035)),
    var(--theory-panel);
  box-shadow: var(--theory-shadow);
  text-align: center;
}

.theory-orb-card::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(226, 184, 91, 0.12);
  border-radius: 50%;
  transform: rotate(18deg);
}

.theory-orb-card::after {
  content: "";
  position: absolute;
  width: 22rem;
  height: 22rem;
  border: 1px dashed rgba(123, 183, 255, 0.14);
  border-radius: 50%;
  transform: rotate(-23deg);
}
.theory-orb {
  position: relative;
  z-index: 1;
  width: clamp(9rem, 18vw, 13rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226, 184, 91, 0.48);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 34%, rgba(255, 255, 255, 0.15), transparent 25%),
    radial-gradient(circle, rgba(226, 184, 91, 0.18), rgba(5, 7, 13, 0.94) 68%);
  box-shadow:
    inset 0 0 34px rgba(226, 184, 91, 0.12),
    0 0 52px rgba(226, 184, 91, 0.14);
}

.theory-orb span {
  color: var(--theory-gold-soft);
  font-family: var(--theory-font-display);
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1;
  text-shadow: 0 0 24px rgba(226, 184, 91, 0.32);
}

.theory-orb-card > p {
  position: relative;
  z-index: 1;
  max-width: 22rem;
  margin: 0;
  color: var(--theory-muted);
}

/* ---- Theory hero visual (living system diagram) ---- */

.theory-hero-visual {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--theory-line);
  border-radius: calc(var(--theory-radius) + 0.35rem);
  box-shadow: var(--theory-shadow);
  min-height: 24rem;
}

.theory-hero-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 24rem;
  object-fit: cover;
  object-position: center;
}

/* Buttons and chips */

.btn,
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.65rem;
  padding: 0.68rem 0.95rem;
  border: 1px solid rgba(226, 184, 91, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--theory-text);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-decoration: none !important;
  cursor: pointer;
  transition:
    transform var(--theory-transition),
    border-color var(--theory-transition),
    background var(--theory-transition),
    color var(--theory-transition),
    box-shadow var(--theory-transition);
}

.btn:hover,
.chip:hover {
  border-color: var(--theory-line-strong);
  background: rgba(226, 184, 91, 0.09);
  color: var(--theory-gold-soft);
  transform: translateY(-1px);
}

.btn.primary,
.chip.active,
.chip[aria-pressed="true"] {
  border-color: rgba(226, 184, 91, 0.7);
  background:
    linear-gradient(135deg, rgba(226, 184, 91, 0.28), rgba(216, 111, 63, 0.18));
  color: #fff5d7;
  box-shadow: 0 10px 30px rgba(226, 184, 91, 0.11);
}

.chip {
  min-height: 2.2rem;
  padding: 0.52rem 0.75rem;
  font-size: 0.74rem;
}

/* Cards and grids */

.cards-grid,
.graph-grid,
.theory-symbol-grid {
  display: grid;
  gap: clamp(1rem, 2vw, 1.4rem);
}

.cards-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.graph-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.theory-symbol-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.graph-card,
.canon-card,
.moon-card,
.equation-chapter {
  position: relative;
  min-width: 0;
  padding: clamp(1.1rem, 2vw, 1.45rem);
  border: 1px solid rgba(226, 184, 91, 0.16);
  border-radius: var(--theory-radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    var(--theory-panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
  transition:
    transform var(--theory-transition),
    border-color var(--theory-transition),
    background var(--theory-transition),
    box-shadow var(--theory-transition),
    opacity var(--theory-transition);
}

.card:hover,
.graph-card:hover,
.canon-card:hover,
.moon-card:hover {
  border-color: rgba(226, 184, 91, 0.34);
  background:
    linear-gradient(145deg, rgba(226, 184, 91, 0.055), rgba(123, 183, 255, 0.018)),
    var(--theory-panel);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.24);
  transform: translateY(-2px);
}

.card h3,
.graph-card h3,
.canon-card h3,
.moon-card h3 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.25rem, 2vw, 1.62rem);
}

.card p,
.graph-card p,
.canon-card p,
.moon-card p {
  margin-top: 0;
  margin-bottom: 0;
  color: var(--theory-muted);
}

.card p + p,
.graph-card p + p {
  margin-top: 0.75rem;
}

.graph-card a {
  display: inline-flex;
  margin-top: 1rem;
  color: var(--theory-gold-soft) !important;
  font-weight: 800;
  text-decoration: none;
}

.nav-card {
  min-height: 9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none !important;
}

.nav-card strong {
  color: var(--theory-gold-soft);
  font-family: var(--theory-font-display);
  font-size: 1.35rem;
}

.nav-card span {
  color: var(--theory-muted);
}

/* Seals and equation surfaces */

.codex-seal {
  position: relative;
  overflow: hidden;
  padding: clamp(1.4rem, 3.6vw, 2.7rem);
  border: 1px solid var(--theory-line);
  border-radius: calc(var(--theory-radius) + 0.3rem);
  background:
    radial-gradient(circle at 12% 10%, rgba(226, 184, 91, 0.08), transparent 26rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    rgba(8, 12, 21, 0.92);
  box-shadow: var(--theory-shadow);
}

.codex-seal::before {
  content: "";
  position: absolute;
  inset: 0.7rem;
  z-index: 0;
  border: 1px solid rgba(226, 184, 91, 0.08);
  border-radius: calc(var(--theory-radius) - 0.05rem);
  pointer-events: none;
}

.codex-seal > * {
  position: relative;
  z-index: 1;
}

.codex-seal > p:last-child {
  color: var(--theory-muted);
}

.equation-card h2 {
  margin-bottom: 1.2rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.equation-display {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: clamp(1.15rem, 3vw, 2rem);
  border: 1px solid rgba(226, 184, 91, 0.2);
  border-radius: var(--theory-radius-small);
  background:
    linear-gradient(180deg, rgba(226, 184, 91, 0.045), rgba(255, 255, 255, 0.018)),
    rgba(2, 4, 9, 0.72);
  color: #fff9e9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition:
    max-height 260ms ease,
    opacity 180ms ease,
    padding 260ms ease,
    border-width 260ms ease,
    margin 260ms ease;
}

.equation-display mjx-container {
  min-width: max-content;
  margin-block: 0.3rem !important;
}

.equation-display.collapsed {
  max-height: 0 !important;
  margin-block: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-top-width: 0;
  border-bottom-width: 0;
  opacity: 0;
  pointer-events: none;
}

.equation-caption {
  margin-top: 1rem;
  color: var(--theory-muted);
}

.equation-tools {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

/* Flow, timeline, and theory structures */

.flow-ladder {
  display: grid;
  gap: 0.75rem;
}

.flow-ladder > div {
  display: grid;
  grid-template-columns: 3rem minmax(8rem, 0.32fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(226, 184, 91, 0.15);
  border-radius: var(--theory-radius-small);
  background: rgba(255, 255, 255, 0.025);
}

.flow-ladder span {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226, 184, 91, 0.34);
  border-radius: 50%;
  color: var(--theory-gold-soft);
  font-weight: 850;
}

.flow-ladder strong {
  color: var(--theory-text);
  font-family: var(--theory-font-display);
  font-size: 1.22rem;
}

.flow-ladder p {
  margin: 0;
  color: var(--theory-muted);
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding-left: 1.3rem;
}

.timeline-list::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  bottom: 0.7rem;
  left: 0.35rem;
  width: 1px;
  background: linear-gradient(var(--theory-gold), rgba(226, 184, 91, 0.06));
}
.timeline-list > article {
  position: relative;
}

.timeline-list > article::before {
  content: "";
  position: absolute;
  top: 1.3rem;
  left: -1.42rem;
  width: 0.55rem;
  height: 0.55rem;
  border: 2px solid var(--theory-bg);
  border-radius: 50%;
  background: var(--theory-gold);
  box-shadow: 0 0 0 3px rgba(226, 184, 91, 0.14);
}

.timeline-list strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--theory-gold-soft);
  font-family: var(--theory-font-display);
  font-size: 1.2rem;
}

.timeline-list p {
  margin: 0;
  color: var(--theory-muted);
}

/* Canon chapters and focus */

.equation-chapter {
  overflow: hidden;
}

.equation-chapter.chapter-focused {
  grid-column: 1 / -1;
  border-color: var(--theory-line-strong);
  background:
    radial-gradient(circle at top left, rgba(226, 184, 91, 0.1), transparent 28rem),
    var(--theory-panel-strong);
  box-shadow: var(--theory-shadow);
}

.equation-chapter .chapter-toggle {
  margin-top: 1rem;
}

[data-term] {
  transition:
    opacity var(--theory-transition),
    filter var(--theory-transition),
    transform var(--theory-transition),
    border-color var(--theory-transition);
}

[data-term].term-active {
  border-color: var(--theory-line-strong);
  transform: translateY(-2px);
}

[data-term].term-dim {
  opacity: 0.34;
  filter: saturate(0.4);
}

/* Canon search */

.canon-search {
  display: grid;
  gap: 0.5rem;
  max-width: 46rem;
  margin-bottom: 1.5rem;
}

.canon-search label {
  color: var(--theory-gold-soft);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.canon-search input {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(226, 184, 91, 0.25);
  border-radius: 999px;
  background: rgba(5, 7, 13, 0.74);
  color: var(--theory-text);
  outline: none;
  transition:
    border-color var(--theory-transition),
    box-shadow var(--theory-transition),
    background var(--theory-transition);
}

.canon-search input::placeholder {
  color: var(--theory-dim);
}

.canon-search input:focus {
  border-color: var(--theory-line-strong);
  background: rgba(9, 13, 23, 0.95);
  box-shadow: 0 0 0 4px rgba(226, 184, 91, 0.08);
}

.canon-search-status {
  min-height: 1.25rem;
  margin: 0;
  color: var(--theory-dim);
  font-size: 0.8rem;
}

/* Command palette */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: start center;
  padding: min(12vh, 7rem) 1rem 1rem;
  background: rgba(2, 4, 9, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.command-palette[hidden] {
  display: none;
}

.command-panel {
  width: min(42rem, 100%);
  overflow: hidden;
  border: 1px solid rgba(226, 184, 91, 0.35);
  border-radius: 1.2rem;
  background: rgba(9, 13, 23, 0.98);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.52);
}

.command-panel > input {
  width: 100%;
  min-height: 3.7rem;
  padding: 0.9rem 1.1rem;
  border: 0;
  border-bottom: 1px solid rgba(226, 184, 91, 0.17);
  background: transparent;
  color: var(--theory-text);
  font-size: 1rem;
  outline: none;
}

.command-panel > input::placeholder {
  color: var(--theory-dim);
}

.command-results {
  max-height: min(62vh, 31rem);
  overflow-y: auto;
  padding: 0.6rem;
}

.command-results a {
  display: block;
  padding: 0.8rem 0.9rem;
  border-radius: 0.7rem;
  color: var(--theory-muted);
  font-weight: 700;
  text-decoration: none;
}

.command-results a:hover,
.command-results a:focus-visible {
  background: rgba(226, 184, 91, 0.1);
  color: var(--theory-gold-soft);
}

.command-empty {
  margin: 0;
  padding: 1rem;
  color: var(--theory-dim);
  text-align: center;
}

/* Reveal */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 520ms ease,
    transform 520ms ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Back to top */

.to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.8rem);
}

.to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Reading modes */

body[data-reading-mode="equation"] .section-shell {
  width: min(calc(100% - 2rem), 74rem);
}

body[data-reading-mode="focus"] .site-header,
body[data-reading-mode="focus"] .theory-stars,
body[data-reading-mode="focus"] .theory-aura {
  opacity: 0.45;
}

body[data-reading-mode="focus"] .section-shell:not(.theory-hero) {
  width: min(calc(100% - 2rem), var(--theory-reading));
}

body[data-reading-mode="focus"] .cards-grid,
body[data-reading-mode="focus"] .graph-grid,
body[data-reading-mode="focus"] .theory-symbol-grid {
  grid-template-columns: 1fr;
}

body[data-reading-mode="study"] .card,
body[data-reading-mode="study"] .graph-card {
  border-style: dashed;
}

/* Footer */

.site-footer {
  margin-top: clamp(3rem, 7vw, 7rem);
  border-top: 1px solid rgba(226, 184, 91, 0.15);
  background: rgba(3, 5, 10, 0.72);
}

.footer-inner {
  width: min(calc(100% - 2rem), var(--theory-max));
  margin-inline: auto;
  padding: 2.7rem 0;
  text-align: center;
}

.footer-inner h3 {
  margin-bottom: 0.45rem;
  color: var(--theory-gold-soft);
  font-size: 1.5rem;
}

.footer-inner p {
  margin: 0.3rem 0;
  color: var(--theory-dim);
  font-size: 0.84rem;
}

/* Responsive */

@media (max-width: 1100px) {
  .cards-grid,
  .graph-grid,
  .theory-symbol-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theory-header .site-nav a {
    padding-inline: 0.56rem;
    font-size: 0.76rem;
  }
}

@media (max-width: 900px) {
  :root {
    --theory-header-height: 4.3rem;
  }

  .site-header.theory-header {
    min-height: var(--theory-header-height);
    padding-block: 0.7rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .theory-header .site-nav {
    position: fixed;
    top: var(--theory-header-height);
    right: 0;
    bottom: 0;
    width: min(24rem, 88vw);
    z-index: 105;
    display: flex;
    align-content: flex-start;
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
    border-left: 1px solid rgba(226, 184, 91, 0.2);
    background:
      radial-gradient(circle at top right, rgba(226, 184, 91, 0.09), transparent 18rem),
      rgba(7, 10, 18, 0.985);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.48);
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
    opacity: 0;
    transform: translateX(105%);
    transition:
      transform 240ms ease,
      opacity 180ms ease,
      visibility 0s linear 240ms;
  }

  .theory-header .site-nav::before {
    content: "Theory Navigation";
    display: block;
    margin: 0.2rem 0 0.55rem;
    color: var(--theory-gold);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.16em;
    text-transform: uppercase;
  }

  .theory-header .site-nav.open {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    transition:
      transform 240ms ease,
      opacity 180ms ease,
      visibility 0s;
  }

  body.nav-open::before {
    content: "";
    position: fixed;
    inset: var(--theory-header-height) 0 0;
    z-index: 99;
    background: rgba(1, 3, 8, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .theory-header .site-nav a {
    width: 100%;
    min-height: 3rem;
    justify-content: flex-start;
    padding: 0.8rem 0.9rem;
    border-radius: 0.75rem;
    font-size: 0.92rem;
  }
  .theory-hero-grid {
    grid-template-columns: 1fr;
  }

  .theory-orb-card {
    min-height: 20rem;
  }

  .theory-hero-visual {
    min-height: 18rem;
  }

  .flow-ladder > div {
    grid-template-columns: 2.7rem minmax(0, 1fr);
  }

  .flow-ladder > div p {
    grid-column: 2;
  }
}

@media (max-width: 720px) {
  .section-shell {
    width: min(calc(100% - 1.25rem), var(--theory-max));
    padding-block: 3.25rem;
  }

  .section-shell[aria-label="Breadcrumb"] {
    padding-top: 0.9rem;
    padding-bottom: 0;
  }

  .theory-header .brand small {
    display: none;
  }

  .theory-header .brand-mark {
    width: 2.25rem;
    height: 2.25rem;
  }

  .theory-hero-copy h1 {
    font-size: clamp(3rem, 17vw, 5.2rem);
  }

  .cards-grid,
  .graph-grid,
  .theory-symbol-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .graph-card,
  .canon-card,
  .moon-card,
  .equation-chapter {
    padding: 1rem;
  }

  .codex-seal {
    padding: 1.15rem;
  }

  .equation-display {
    margin-inline: -0.15rem;
    padding: 1rem 0.8rem;
    font-size: 0.9rem;
  }

  .equation-tools {
    justify-content: flex-start;
  }

  .hero-actions {
    align-items: stretch;
  }

  .hero-actions .btn {
    flex: 1 1 12rem;
  }

  .timeline-list {
    padding-left: 1rem;
  }

  .timeline-list > article::before {
    left: -1.12rem;
  }

  .to-top {
    right: 0.7rem;
    bottom: max(0.7rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  .site-header.theory-header {
    gap: 0.65rem;
    padding-inline: 0.75rem;
  }

  .theory-header .brand strong {
    font-size: 1rem;
  }

  .theory-header .brand-mark {
    width: 2rem;
    height: 2rem;
    font-size: 1.05rem;
  }

  .nav-toggle {
    width: 2.55rem;
    height: 2.55rem;
  }

  .theory-header .site-nav {
    width: 100%;
    border-left: 0;
  }

  .theory-orb-card {
    min-height: 17rem;
    padding: 1.25rem;
  }

  .flow-ladder > div {
    grid-template-columns: 2.4rem minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.9rem;
  }

  .flow-ladder span {
    width: 2rem;
    height: 2rem;
  }

  .command-palette {
    padding: 0.7rem;
    place-items: center;
  }

  .command-panel {
    max-height: calc(100vh - 1.4rem);
  }
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

/* Print */

@media print {
  :root {
    color-scheme: light;
  }

  body[data-reading-mode] {
    background: #fff !important;
    color: #111 !important;
  }

  .theory-aura,
  .theory-stars,
  .site-header,
  .hero-actions,
  .equation-tools,
  .chapter-toggle,
  .command-palette,
  .to-top,
  .site-footer {
    display: none !important;
  }
  .section-shell {
    width: 100%;
    padding: 1rem 0;
  }

  .theory-hero-grid,
  .cards-grid,
  .graph-grid,
  .theory-symbol-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .graph-card,
  .canon-card,
  .codex-seal,
  .equation-display,
  .theory-orb-card {
    break-inside: avoid;
    border-color: #bbb !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #111 !important;
  }

  body[data-reading-mode] h1,
  body[data-reading-mode] h2,
  body[data-reading-mode] h3,
  body[data-reading-mode] p,
  body[data-reading-mode] a,
  .eyebrow {
    color: #111 !important;
  }

  body[data-reading-mode] a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    font-weight: 400;
  }

  .theory-orb-card {
    min-height: 0;
  }

  .theory-orb {
    width: 7rem;
  }
}
