/* =====================================================================
   VALLI A — Dual-Mode Portfolio
   Magical (Arcane Archive) + Professional (Cyber-Terminal)
   All theming flows from CSS variables on [data-theme="..."].
   ===================================================================== */

:root {
  --transition-theme: 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------- MAGICAL THEME TOKENS --------------------- */
[data-theme="magical"] {
  --surface: #fff8f3;
  --surface-dim: #e7d8c2;
  --surface-bright: #fff8f3;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #fff2e0;
  --surface-container: #fbecd5;
  --surface-container-high: #f6e6d0;
  --surface-container-highest: #f0e0ca;
  --on-surface: #221b0d;
  --on-surface-variant: #4e4639;
  --inverse-surface: #382f20;
  --inverse-on-surface: #feefd8;
  --outline: #7f7667;
  --outline-variant: #d1c5b4;
  --primary: #775a19;
  --on-primary: #ffffff;
  --primary-container: #c5a059;
  --on-primary-container: #4e3700;
  --inverse-primary: #e9c176;
  --secondary: #82533c;
  --on-secondary: #ffffff;
  --secondary-container: #ffc1a4;
  --on-secondary-container: #7a4d36;
  --tertiary: #5d5e61;
  --on-tertiary: #ffffff;
  --error: #ba1a1a;
  --primary-fixed: #ffdea5;
  --primary-fixed-dim: #e9c176;
  --background: #fff8f3;

  --font-display: 'Libre Caslon Text', 'Times New Roman', serif;
  --font-body: 'EB Garamond', 'Georgia', serif;
  --font-label: 'Courier Prime', 'Courier New', monospace;

  --radius-sm: 0.125rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
}

/* --------------------- PROFESSIONAL THEME TOKENS --------------------- */
[data-theme="professional"] {
  --surface: #131314;
  --surface-dim: #131314;
  --surface-bright: #3a393a;
  --surface-container-lowest: #0a0a0b;
  --surface-container-low: #1c1b1c;
  --surface-container: #201f20;
  --surface-container-high: #2a2a2b;
  --surface-container-highest: #353436;
  --on-surface: #e5e2e3;
  --on-surface-variant: #b9ccb2;
  --inverse-surface: #e5e2e3;
  --inverse-on-surface: #313031;
  --outline: #84967e;
  --outline-variant: #3b4b37;
  --primary: #00ff41;
  --on-primary: #003907;
  --primary-container: #00e639;
  --on-primary-container: #ebffe2;
  --inverse-primary: #006e16;
  --secondary: #00e3fd;
  --on-secondary: #00363d;
  --secondary-container: #bdf4ff;
  --on-secondary-container: #00616d;
  --tertiary: #ffd3c8;
  --on-tertiary: #621100;
  --error: #ffb4ab;
  --primary-fixed: #72ff70;
  --primary-fixed-dim: #00e639;
  --background: #0a0a0b;

  --font-display: 'Space Mono', 'Consolas', monospace;
  --font-body: 'JetBrains Mono', 'Consolas', monospace;
  --font-label: 'JetBrains Mono', 'Consolas', monospace;

  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-xl: 0;
}

/* --------------------- BASE --------------------- */
html { scroll-behavior: smooth; }

body {
  background-color: var(--background);
  color: var(--on-surface);
  font-family: var(--font-body);
  transition:
    background-color var(--transition-theme),
    color var(--transition-theme);
  min-height: 100dvh;
}

/* Smooth re-theming for any element that uses theme tokens */
.themed,
section, header, footer, nav, article, aside,
.surface, .container-themed, button, a, h1, h2, h3, h4, h5 {
  transition:
    background-color var(--transition-theme),
    color var(--transition-theme),
    border-color var(--transition-theme),
    box-shadow var(--transition-theme);
}

/* --------------------- TEXTURES --------------------- */
.parchment-texture {
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.09'/%3E%3C/svg%3E");
}
[data-theme="professional"] .parchment-texture {
  background-image: none;
  background-color: var(--background);
}

.leather-texture {
  background-color: #382f20;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.18'/%3E%3C/svg%3E");
}

.brass-gradient {
  background: linear-gradient(135deg, #e9c176 0%, #c5a059 50%, #775a19 100%);
}

.inner-shadow-parchment {
  box-shadow: inset 0 2px 10px rgba(56, 47, 32, 0.10);
}

/* --------------------- CYBER FX --------------------- */
.glass-panel {
  background: rgba(28, 27, 28, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--outline-variant);
}
[data-theme="magical"] .glass-panel {
  background: var(--surface-container-lowest);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--outline-variant);
  box-shadow: inset 0 2px 10px rgba(56, 47, 32, 0.08);
}

.glow-text {
  text-shadow:
    0 0 4px rgba(0, 255, 65, 0.65),
    0 0 12px rgba(0, 255, 65, 0.35);
}
[data-theme="magical"] .glow-text { text-shadow: none; }

.active-border-glow {
  border: 1px solid var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 12px rgba(0, 255, 65, 0.35);
}
[data-theme="magical"] .active-border-glow {
  border: 1px solid var(--primary-container);
  box-shadow: 0 4px 14px rgba(119, 90, 25, 0.18);
}

.scanline {
  position: relative;
}
.scanline::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.7;
}
[data-theme="magical"] .scanline::after { display: none; }

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
.blinking-cursor::after {
  content: "_";
  display: inline-block;
  margin-left: 2px;
  color: var(--primary);
  animation: blink 1s steps(1) infinite;
  font-weight: 700;
}
[data-theme="magical"] .blinking-cursor::after { display: none; }

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 0.97; }
  94% { opacity: 1; }
  96% { opacity: 0.94; }
}
[data-theme="professional"] .crt-flicker { animation: crt-flicker 7s infinite; }

/* Terminal prompt prefix on professional headlines */
[data-theme="professional"] .terminal-prompt::before {
  content: "> ";
  color: var(--primary);
}

/* --------------------- MAGICAL FLOURISHES --------------------- */
.wax-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: radial-gradient(circle at 30% 30%, #c93030, #8b1818 60%, #5a0e0e 100%);
  color: #fff8f3;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    inset 0 -3px 6px rgba(0, 0, 0, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.3);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brass-latch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, #f0d28a 0%, #c5a059 50%, #775a19 100%);
  color: #261900;
  border: 1px solid #5d4201;
  padding: 0.65rem 1.4rem;
  border-radius: 0.25rem;
  font-family: var(--font-label);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2);
  transition: filter 200ms, transform 200ms;
}
.brass-latch:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.photo-corners > .corner {
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  border-color: var(--primary);
}
.photo-corners > .corner.tl { top: 0.5rem; left: 0.5rem; border-top: 2px solid; border-left: 2px solid; }
.photo-corners > .corner.tr { top: 0.5rem; right: 0.5rem; border-top: 2px solid; border-right: 2px solid; }
.photo-corners > .corner.bl { bottom: 0.5rem; left: 0.5rem; border-bottom: 2px solid; border-left: 2px solid; }
.photo-corners > .corner.br { bottom: 0.5rem; right: 0.5rem; border-bottom: 2px solid; border-right: 2px solid; }

.field-note-card {
  background: var(--surface-container-lowest);
  border: 1px dashed var(--outline);
  border-radius: var(--radius-md);
  position: relative;
}

.stitched-border {
  border: 2px dashed var(--outline);
  outline: 1px solid var(--outline-variant);
  outline-offset: -6px;
}

/* Deco divider for magical sections */
.fleuron-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 3rem 0 2rem;
  color: var(--primary);
  opacity: 0.7;
}
.fleuron-divider .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--outline) 50%, transparent);
}
[data-theme="professional"] .fleuron-divider { display: none; }

/* Cyber divider replaces magical one in professional mode */
.cyber-divider {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin: 2.5rem 0 1.5rem;
  font-family: var(--font-label);
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.cyber-divider .line {
  flex: 1;
  height: 1px;
  background: var(--outline-variant);
}
[data-theme="professional"] .cyber-divider { display: flex; }

/* --------------------- HEADINGS --------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--on-surface);
}
[data-theme="professional"] h1,
[data-theme="professional"] h2,
[data-theme="professional"] h3,
[data-theme="professional"] h4 {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
[data-theme="professional"] h1 {
  color: var(--primary-container);
  text-shadow:
    0 0 6px rgba(0, 255, 65, 0.55),
    0 0 14px rgba(0, 255, 65, 0.25);
}

.label-mono {
  font-family: var(--font-label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.875rem;
  color: var(--on-surface-variant);
}

/* --------------------- BUTTONS / TOGGLE --------------------- */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-xl);
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--on-surface);
  transition:
    background-color var(--transition-theme),
    border-color var(--transition-theme);
}
.mode-toggle .switch {
  position: relative;
  width: 2.5rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: var(--primary-container);
  transition: background-color var(--transition-theme);
}
.mode-toggle .switch .knob {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 9999px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1),
              background-color var(--transition-theme);
}
[data-theme="professional"] .mode-toggle .switch .knob {
  transform: translateX(1.25rem);
  background: var(--primary);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.65);
}
.mode-toggle .label-magical { font-weight: 700; color: var(--primary); }
.mode-toggle .label-pro { color: var(--on-surface-variant); }
[data-theme="professional"] .mode-toggle .label-magical { font-weight: 400; color: var(--on-surface-variant); }
[data-theme="professional"] .mode-toggle .label-pro { font-weight: 700; color: var(--primary); }

/* --------------------- SECTION REVEAL --------------------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms ease, transform 700ms cubic-bezier(0.4, 0, 0.2, 1);
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------- NAV --------------------- */
.nav-link {
  font-family: var(--font-label);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  position: relative;
  padding-bottom: 0.4rem;
}
.nav-link:hover { color: var(--primary); }
.nav-link.active {
  color: var(--primary);
  font-weight: 700;
}
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--primary);
}
[data-theme="professional"] .nav-link.active {
  color: var(--primary);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.6);
}

/* --------------------- THEME-SCOPED VISIBILITY ---------------------
   Use display:none only as the negative — never set display on the
   "shown" state, so each element keeps its own natural/styled display
   (inline, block, inline-flex, etc.). */
[data-theme="professional"] .magical-only { display: none !important; }
[data-theme="magical"] .professional-only { display: none !important; }

/* --------------------- TIMELINE --------------------- */
.timeline { position: relative; padding-left: 2.4rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 1px;
  background: var(--outline-variant);
}
.timeline-node {
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
[data-theme="professional"] .timeline-node {
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--primary);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}
.timeline-item.archived .timeline-node {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  border-color: var(--outline-variant);
  box-shadow: none;
}
[data-theme="professional"] .timeline-item.archived .timeline-node {
  border-color: var(--outline-variant);
  background: transparent;
  box-shadow: none;
}

/* --------------------- CHIPS --------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  border: 1px solid var(--outline-variant);
}
.chip.primary {
  background: rgba(199, 160, 89, 0.15);
  color: var(--primary);
  border-color: var(--primary-container);
}
[data-theme="professional"] .chip.primary {
  background: rgba(0, 255, 65, 0.08);
  color: var(--primary);
  border-color: var(--primary);
  text-transform: uppercase;
}
.chip.status-active {
  background: rgba(0, 255, 65, 0.10);
  color: var(--primary);
  border-color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
[data-theme="magical"] .chip.status-active {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-color: var(--secondary);
  text-transform: none;
  letter-spacing: 0.05em;
}

/* --------------------- LISTS --------------------- */
.paw-list { list-style: none; padding: 0; margin: 0; }
.paw-list li {
  position: relative;
  padding-left: 1.6rem;
  margin-bottom: 0.65rem;
  line-height: 1.5;
}
.paw-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4em;
  width: 0.85rem;
  height: 0.85rem;
  background-color: var(--primary);
  -webkit-mask: url("../svg/pawprint.svg") center / contain no-repeat;
  mask: url("../svg/pawprint.svg") center / contain no-repeat;
}
[data-theme="professional"] .paw-list li::before {
  -webkit-mask: none;
  mask: none;
  width: 0.6rem;
  height: 0.6rem;
  top: 0.55em;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
  border-radius: 0;
}

/* --------------------- HERO BACKGROUND IMAGE --------------------- */
.hero-bg-image {
  position: absolute;
  inset: 0;
  background-image: url("../images/hero-case.jpg");
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  filter: sepia(0.4);
  pointer-events: none;
}
[data-theme="professional"] .hero-bg-image { display: none; }

.circuit-bg {
  display: none;
  position: absolute;
  inset: 0;
  background-image: url("../svg/circuit.svg");
  background-size: 600px 600px;
  background-repeat: repeat;
  background-position: center;
  opacity: 0.6;
  color: var(--primary);
  pointer-events: none;
}
[data-theme="professional"] .circuit-bg { display: block; }

/* --------------------- PROFILE FRAME --------------------- */
.profile-photo {
  background-image: url("../images/INT002.png");
  background-size: cover;
  background-position: center;
  background-color: var(--surface-container);
}
[data-theme="magical"] .profile-photo {
  filter: sepia(0.3) contrast(1.05) brightness(0.98);
}
[data-theme="professional"] .profile-photo {
  filter: grayscale(0.3) contrast(1.1);
}

/* --------------------- FOCUS / ACCESSIBILITY --------------------- */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* =====================================================================
   IMMERSIVE LAYER — Magical mode only
   Loader · Wand cursor · Side rail · Hero stage · Parchment-v2 ·
   Beast Affinities · Pensieve terminal · Case Diagram · Easter eggs
   ===================================================================== */

/* Magical-only display class (parallel to magical-only/professional-only).
   Used for elements that should only render in magical mode AND should
   keep whatever display they were originally given. */
[data-theme="professional"] .magical-immersive { display: none !important; }

/* Magical-mode display tokens (Cinzel for ornamental Roman caps) */
[data-theme="magical"] {
  --font-ornate: 'Cinzel', 'Libre Caslon Text', serif;
  --font-script: 'Cormorant Garamond', 'EB Garamond', serif;
  --gold: #e9c176;
  --gold-deep: #c5a059;
  --mahogany: #5d4201;
  --ember: #c93030;
  --moss: #6f7d5b;
  --twilight: #6e5f88;
}

/* ---------------- LOADER ---------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: radial-gradient(circle at center, #1d160a 0%, #0a0805 80%);
  display: grid;
  place-items: center;
  transition: opacity 1.1s ease;
}
[data-theme="professional"] #loader { display: none; }
#loader.gone { opacity: 0; pointer-events: none; }
#loader[aria-hidden="true"] { display: none; }

.case-clasp-stage {
  position: relative;
  width: 320px;
  height: 320px;
}
.case-clasp {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 1px solid rgba(233, 193, 118, 0.28);
}
.case-clasp.r1 { animation: clasp-spin 16s linear infinite; }
.case-clasp.r2 {
  inset: 32px;
  border-style: dashed;
  border-color: rgba(233, 193, 118, 0.45);
  animation: clasp-spin 22s linear infinite reverse;
}
.case-clasp.r3 {
  inset: 72px;
  border-color: rgba(233, 193, 118, 0.6);
  animation: clasp-spin 11s linear infinite;
}
.case-clasp-core {
  position: absolute;
  inset: 116px;
  border-radius: 9999px;
  background: radial-gradient(circle, rgba(233, 193, 118, 0.55), rgba(233, 193, 118, 0) 70%);
  animation: clasp-pulse 2.4s ease-in-out infinite;
}
.case-clasp-glyph {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 38px !important;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(233, 193, 118, 0.8);
}
.loader-caption {
  position: absolute;
  bottom: -56px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(233, 193, 118, 0.6);
  white-space: nowrap;
}
.loader-bar {
  position: absolute;
  bottom: -84px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 1px;
  background: rgba(233, 193, 118, 0.18);
}
.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: loader-fill 1.5s ease-out forwards;
}
@keyframes clasp-spin { to { transform: rotate(360deg); } }
@keyframes clasp-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.05); opacity: 1; }
}
@keyframes loader-fill { to { width: 100%; } }

/* ---------------- WAND CURSOR (Magical only, fine pointer only) ---------------- */
.wand-spark, .wand-trail {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  border-radius: 9999px;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
  display: none;
}
@media (pointer: fine) {
  [data-theme="magical"] .wand-spark,
  [data-theme="magical"] .wand-trail {
    display: block;
  }
}
.wand-spark {
  width: 8px; height: 8px;
  background: radial-gradient(circle, rgba(255, 220, 140, 0.95) 0%, rgba(233, 193, 118, 0) 70%);
  box-shadow: 0 0 10px 1px rgba(233, 193, 118, 0.55);
  transition: width .14s, height .14s;
}
.wand-spark.click { width: 22px; height: 22px; }
.wand-trail {
  width: 32px; height: 32px;
  border: 1px solid rgba(233, 193, 118, 0.35);
  background: radial-gradient(circle, rgba(233, 193, 118, 0.10) 0%, transparent 70%);
  transition: transform 80ms ease-out;
}

/* ---------------- SIDE RAIL (Magical desktop only) ---------------- */
.case-rail {
  position: fixed;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border: 1px solid rgba(125, 92, 38, 0.4);
  background: rgba(255, 248, 243, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  box-shadow: 0 6px 20px rgba(56, 47, 32, 0.18);
}
@media (min-width: 1024px) {
  [data-theme="magical"] .case-rail { display: flex; }
}
.case-rail .rail-seal {
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  color: var(--mahogany);
}
.case-rail .rail-link {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--on-surface-variant);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  border-radius: 9999px;
  text-decoration: none;
  transition: color 250ms, background-color 250ms;
}
.case-rail .rail-link::after {
  content: attr(data-folio);
}
.case-rail .rail-link .material-symbols-outlined {
  font-size: 14px !important;
  position: absolute;
  opacity: 0;
  transition: opacity 250ms;
}
.case-rail .rail-link:hover {
  color: var(--primary);
  background: rgba(233, 193, 118, 0.18);
}
.case-rail .rail-link:hover::before {
  content: attr(data-name);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  padding: 4px 10px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
  pointer-events: none;
}
.case-rail .rail-link.active {
  color: var(--mahogany);
  background: var(--gold);
  box-shadow: 0 0 12px rgba(233, 193, 118, 0.6);
  font-weight: 700;
}

/* ---------------- HERO STAGE ---------------- */
.hero-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
[data-theme="professional"] .hero-stage { display: none; }

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
}

.case-silhouette {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 130%;
  height: 65%;
  color: rgba(60, 42, 16, 0.85);
  pointer-events: none;
  opacity: 0.85;
}

.case-mist {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 55%;
  background: linear-gradient(to top,
    rgba(40, 30, 14, 0.55) 0%,
    rgba(40, 30, 14, 0.25) 35%,
    transparent 100%);
  pointer-events: none;
}
.case-mist-layer {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 25% 80%, rgba(233, 193, 118, 0.12), transparent 55%),
    radial-gradient(ellipse at 75% 88%, rgba(110, 95, 136, 0.10), transparent 55%);
  animation: mist-drift 24s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes mist-drift {
  0% { transform: translateX(-2%); }
  100% { transform: translateX(2%); }
}

.firefly {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: radial-gradient(circle, rgba(255, 220, 140, 0.95) 0%, rgba(233, 193, 118, 0) 70%);
  filter: drop-shadow(0 0 6px rgba(233, 193, 118, 0.7));
  animation: firefly-float 8s ease-in-out infinite, firefly-flicker 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes firefly-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-22px); }
}
@keyframes firefly-flicker {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---------------- GLOW ORBS ---------------- */
.glow-orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.7;
  animation: orb-pulse 10s ease-in-out infinite;
}
.glow-orb.gold { background: rgba(240, 192, 64, 0.40); }
.glow-orb.amber { background: rgba(255, 168, 96, 0.35); }
.glow-orb.moss { background: rgba(120, 160, 110, 0.32); }
.glow-orb.twilight { background: rgba(140, 110, 180, 0.32); }
[data-theme="professional"] .glow-orb { display: none; }
@keyframes orb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.08); opacity: 0.75; }
}

/* ---------------- CONTAINMENT WARDS PANEL ---------------- */
.wards-card {
  position: relative;
  padding: 18px 20px;
  background: rgba(34, 25, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(233, 193, 118, 0.3);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color: #f6e6d0;
}
.wards-card .wards-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.wards-card .wards-head .pulse-dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  background: #5fe07a;
  box-shadow: 0 0 8px rgba(95, 224, 122, 0.8);
  animation: ward-pulse 1.6s ease-in-out infinite;
  margin-left: auto;
}
@keyframes ward-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}
.ward-row {
  display: grid;
  grid-template-columns: 110px 1fr 56px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(246, 230, 208, 0.85);
}
.ward-bar {
  height: 4px;
  background: rgba(233, 193, 118, 0.15);
  border-radius: 2px;
  overflow: hidden;
}
.ward-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  box-shadow: 0 0 6px rgba(233, 193, 118, 0.6);
  transition: width 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.ward-val {
  text-align: right;
  color: var(--gold);
}
.wards-foot {
  margin-top: 10px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(246, 230, 208, 0.5);
  text-align: center;
}

/* ---------------- PARCHMENT CARD V2 ---------------- */
.parchment-card-v2 {
  position: relative;
  padding: 22px 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(155, 110, 50, 0.10), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(120, 80, 30, 0.18), transparent 60%),
    repeating-linear-gradient(45deg, rgba(155, 110, 50, 0.04) 0 6px, transparent 6px 14px),
    #f6e6d0;
  border: 2px solid #7a4d36;
  outline: 1px solid rgba(233, 193, 118, 0.45);
  outline-offset: -6px;
  border-radius: 4px;
  color: #2a2014;
  font-family: var(--font-script, 'EB Garamond', serif);
}
.parchment-card-v2::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px;
  width: 64px; height: 64px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.18), transparent 60%);
  pointer-events: none;
}
.parchment-card-v2::after {
  content: "";
  position: absolute;
  top: 12px; right: 12px;
  width: 22px; height: 22px;
  border-radius: 9999px;
  background: radial-gradient(circle at 30% 30%, #c93030, #5a0e0e);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3),
              inset 0 -2px 4px rgba(0, 0, 0, 0.4),
              0 2px 4px rgba(0, 0, 0, 0.25);
}
.parchment-card-v2 h3,
.parchment-card-v2 h4 {
  color: #2a2014;
  font-family: 'Cinzel', serif;
}
.parchment-card-v2 p,
.parchment-card-v2 li { color: #4a3a26; }
.parchment-card-v2 .seal {
  display: inline-block;
  padding: 4px 10px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6b0b10;
  border: 1px solid rgba(122, 77, 54, 0.5);
  margin-bottom: 10px;
}
.parchment-card-v2 .where {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: #5b4632;
  margin-bottom: 8px;
}

/* ---------------- FOLIO DIVIDER ---------------- */
.folio-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 64px auto 24px;
  max-width: 760px;
  color: var(--mahogany);
}
.folio-divider .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--mahogany) 50%, transparent);
  opacity: 0.6;
}
.folio-divider .roman {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  letter-spacing: 0.4em;
  padding: 4px 20px;
  border: 1px solid rgba(125, 92, 38, 0.5);
  border-radius: 4px;
  background: rgba(255, 248, 243, 0.6);
}
[data-theme="professional"] .folio-divider { display: none; }

/* ---------------- BEAST AFFINITIES ---------------- */
.beast-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin: 24px 0 32px;
}
.beast-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  transition: color 300ms;
}
.beast-tab .medallion {
  width: 64px;
  height: 64px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, #f0d28a, #c5a059 60%, #7a5a1a 100%);
  border: 2px solid var(--mahogany);
  color: var(--mahogany);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.18);
  transition: transform 300ms, box-shadow 300ms;
}
.beast-tab .medallion svg {
  width: 38px;
  height: 38px;
}
.beast-tab .virtue { font-size: 9px; opacity: 0.7; }
.beast-tab:hover .medallion {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    0 8px 18px rgba(122, 90, 26, 0.4);
}
.beast-tab.active { color: var(--mahogany); }
.beast-tab.active .medallion {
  border-color: var(--ember);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    0 0 18px rgba(233, 193, 118, 0.7),
    0 6px 14px rgba(0, 0, 0, 0.3);
}

.beast-stage {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: center;
  padding: 28px;
  background: rgba(255, 248, 243, 0.55);
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  position: relative;
}
@media (max-width: 768px) {
  .beast-stage { grid-template-columns: 1fr; text-align: center; }
}
.beast-rings {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.beast-rings .ring {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 1px solid rgba(125, 92, 38, 0.35);
}
.beast-rings .ring.r1 { animation: clasp-spin 22s linear infinite; }
.beast-rings .ring.r2 { inset: 24px; border-style: dashed; animation: clasp-spin 30s linear infinite reverse; }
.beast-rings .ring.r3 { inset: 56px; border-color: rgba(125, 92, 38, 0.55); animation: clasp-spin 14s linear infinite; }
.beast-rings .beast-art {
  width: 110px;
  height: 110px;
  color: var(--mahogany);
  z-index: 1;
}
.beast-meta .virtue-line {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}
.beast-meta h3 {
  font-family: 'Cinzel', serif;
  font-size: 24px;
  color: var(--on-surface);
  margin-bottom: 10px;
}
.beast-meta p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  color: var(--on-surface);
  margin-bottom: 14px;
}
.beast-meta .beast-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
}
.beast-meta .beast-tags li {
  padding: 4px 10px;
  background: rgba(199, 160, 89, 0.18);
  border: 1px solid var(--primary-container);
  border-radius: 999px;
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  color: var(--primary);
  letter-spacing: 0.05em;
}

/* ---------------- PENSIEVE TERMINAL ---------------- */
.pensieve {
  background: #0d0a08;
  border: 1px solid rgba(233, 193, 118, 0.25);
  border-radius: 6px;
  overflow: hidden;
  font-family: 'JetBrains Mono', monospace;
  color: #e9c176;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.pensieve-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #1a130d;
  border-bottom: 1px solid rgba(233, 193, 118, 0.2);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(233, 193, 118, 0.6);
}
.pensieve-bar .tdot {
  width: 9px; height: 9px;
  border-radius: 9999px;
  background: rgba(80, 200, 180, 0.4);
}
.pensieve-bar .tdot:nth-child(2) { background: rgba(220, 180, 90, 0.5); }
.pensieve-bar .tdot:nth-child(3) { background: rgba(220, 120, 110, 0.5); }
.pensieve-bar .filename { margin-left: auto; }
.pensieve-body {
  position: relative;
  padding: 14px 16px;
  min-height: 220px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.pensieve-body::after {
  content: "_";
  display: inline-block;
  margin-left: 2px;
  color: var(--gold);
  animation: blink 1s steps(1) infinite;
}
.pensieve-line { display: block; min-height: 18px; }
.pensieve-line .ok { color: #5fe07a; }
.pensieve-line .warn { color: #f5c674; }
.pensieve-line .dim { color: rgba(233, 193, 118, 0.4); }
.pensieve-line .arg { color: #e9c176; }
.pensieve-line.prompt::before {
  content: "› ";
  color: var(--gold);
}

/* ---------------- THREAT SIGHTINGS ---------------- */
.sightings {
  padding: 18px 20px;
}
.sightings-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
}
.sightings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sightings-list li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--outline-variant);
  font-family: 'EB Garamond', serif;
  color: var(--on-surface);
}
.sightings-list li:last-child { border-bottom: none; }
.sightings-list .live-dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  background: var(--ember);
  box-shadow: 0 0 8px rgba(201, 48, 48, 0.7);
  animation: ward-pulse 1.6s ease-in-out infinite;
}
.sightings-list .live-dot.ok {
  background: #5fe07a;
  box-shadow: 0 0 8px rgba(95, 224, 122, 0.7);
}
.sightings-list .threat-name {
  font-weight: 600;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--on-surface);
}
.sightings-list .threat-sub {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  color: var(--on-surface-variant);
}
.sightings-list .threat-time {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  color: var(--primary);
}

/* ---------------- MARGIN NOTES ---------------- */
.margin-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--ember);
  background: rgba(199, 48, 48, 0.06);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: #4a3a26;
}
.notes-code {
  background: rgba(46, 30, 16, 0.92);
  color: #f6e6d0;
  padding: 12px 14px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow-x: auto;
}
.notes-code .cmt { color: #8a7a5a; }
.notes-code .kw { color: #f5c674; }
.notes-code .str { color: #b3d995; }

/* ---------------- BENTO PROJECT GRID ---------------- */
.case-bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 18px;
  margin-top: 20px;
}
.case-bento > * { min-width: 0; }
.case-bento .pensieve { grid-column: span 4; }
.case-bento .sightings { grid-column: span 2; background: rgba(255, 248, 243, 0.6); border: 1px solid var(--outline-variant); border-radius: 6px; }
.case-bento .margin-card { grid-column: span 3; }
.case-bento .felix-card { grid-column: span 3; padding: 18px 20px; background: rgba(255, 248, 243, 0.6); border: 1px solid var(--outline-variant); border-radius: 6px; }
.case-bento .project-card { grid-column: span 3; }
@media (max-width: 768px) {
  .case-bento { grid-template-columns: 1fr; }
  .case-bento > * { grid-column: span 1 !important; }
}

.felix-card .felix-head {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 14px;
}
.felix-card .felix-head .pulse-dot {
  margin-left: auto;
  width: 8px; height: 8px;
  border-radius: 9999px;
  background: #5fe07a;
  box-shadow: 0 0 8px rgba(95, 224, 122, 0.7);
  animation: ward-pulse 1.6s ease-in-out infinite;
}
.felix-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--outline-variant);
}
.felix-row:last-child { border-bottom: none; }
.felix-row .felix-lbl { font-family: 'EB Garamond', serif; color: var(--on-surface); }
.felix-row .felix-vals {
  display: inline-flex; gap: 8px; align-items: center;
  font-family: 'Courier Prime', monospace;
  font-size: 13px;
}
.felix-row .before { color: var(--on-surface-variant); text-decoration: line-through; }
.felix-row .arrow { color: var(--primary); }
.felix-row .after { color: var(--ember); font-weight: 700; }

/* ---------------- CASE DIAGRAM (Folio VIII) ---------------- */
.case-diagram-stage {
  position: relative;
  border: 2px solid rgba(125, 92, 38, 0.5);
  border-radius: 6px;
  background: #fff8f3;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
[data-theme="professional"] .case-diagram-stage { display: none; }
.case-diagram-stage svg.case-diagram {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--mahogany);
}
.case-pin {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.case-pin::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 9999px;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
}
.case-pin::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 2px solid var(--ember);
  animation: pin-ping 2.4s ease-out infinite;
}
@keyframes pin-ping {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}
.case-pin .label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  padding: 3px 8px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 200ms;
  pointer-events: none;
}
.case-pin:hover .label { opacity: 1; }

.diagram-legend {
  position: absolute;
  bottom: 14px; right: 14px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--mahogany);
  background: rgba(255, 248, 243, 0.85);
  padding: 6px 12px;
  border: 1px solid rgba(125, 92, 38, 0.4);
  border-radius: 3px;
}

/* ---------------- ANIMATED OWL ---------------- */
.owl-stage {
  display: grid;
  place-items: center;
  padding: 18px 0;
}
.owl-svg { width: 90px; height: 90px; color: var(--mahogany); }
[data-theme="professional"] .owl-stage { display: none; }

/* ---------------- SEALED PARCHMENT FORM (Magical) ---------------- */
.scroll-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.scroll-form .field {
  position: relative;
}
.scroll-form .field label {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: 4px;
}
.scroll-form .field input,
.scroll-form .field textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(125, 92, 38, 0.5);
  padding: 6px 0;
  font-family: 'EB Garamond', serif;
  font-size: 16px;
  color: #2a2014;
  outline: none;
  transition: border-color 250ms;
}
.scroll-form .field input::placeholder,
.scroll-form .field textarea::placeholder {
  color: rgba(125, 92, 38, 0.45);
  font-style: italic;
}
.scroll-form .field input:focus,
.scroll-form .field textarea:focus {
  border-color: var(--ember);
}
.scroll-form .field textarea {
  resize: vertical;
  min-height: 110px;
}
.scroll-form .send-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #f0d28a 0%, #c5a059 50%, #775a19 100%);
  color: #261900;
  border: 1px solid #5d4201;
  padding: 10px 22px;
  border-radius: 4px;
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2);
  transition: filter 200ms, transform 200ms;
}
.scroll-form .send-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ---------------- EASTER-EGG TOAST + KBD HINT ---------------- */
.spell-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(34, 25, 12, 0.92);
  color: var(--gold);
  padding: 12px 24px;
  border: 1px solid rgba(233, 193, 118, 0.5);
  border-radius: 4px;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 24px rgba(233, 193, 118, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms, transform 300ms;
  z-index: 9000;
}
.spell-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.kbd-hint {
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--on-surface-variant);
  background: rgba(255, 248, 243, 0.65);
  border: 1px solid var(--outline-variant);
  padding: 6px 12px;
  border-radius: 3px;
  z-index: 50;
  pointer-events: none;
  text-transform: uppercase;
  opacity: 0.7;
}
.kbd-hint b { color: var(--primary); font-weight: 700; }
[data-theme="professional"] .kbd-hint { display: none; }
@media (max-width: 768px) { .kbd-hint { display: none; } }

/* ---------------- LUMOS GLOW (page-wide brightness boost) ---------------- */
body.lumos {
  filter: brightness(1.15) saturate(1.05);
  transition: filter 1.2s ease;
}
body.lumos .glow-orb { opacity: 0.95; }

/* ---------------- HIDDEN CABINET (Alohomora) ---------------- */
#cabinet[hidden] { display: none; }
#cabinet {
  margin-top: 64px;
  padding: 32px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(155, 110, 50, 0.15), transparent 60%),
    repeating-linear-gradient(45deg, rgba(155, 110, 50, 0.04) 0 6px, transparent 6px 14px),
    #f6e6d0;
  border: 2px solid #7a4d36;
  border-radius: 4px;
  text-align: center;
  position: relative;
}
[data-theme="professional"] #cabinet { display: none !important; }
#cabinet::before {
  content: "VIII";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 0.4em;
  background: var(--background);
  padding: 0 16px;
  color: var(--ember);
}
#cabinet h3 {
  font-family: 'Cinzel', serif;
  color: var(--ember);
  margin-bottom: 12px;
}
#cabinet p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-style: italic;
  color: #4a3a26;
  max-width: 56ch;
  margin: 0 auto 8px;
}

/* ---------------- IMMERSIVE — hide all in pro mode ---------------- */
[data-theme="professional"] #loader,
[data-theme="professional"] .case-rail,
[data-theme="professional"] .hero-stage,
[data-theme="professional"] .glow-orb,
[data-theme="professional"] .firefly,
[data-theme="professional"] .case-mist,
[data-theme="professional"] .case-mist-layer,
[data-theme="professional"] .case-silhouette,
[data-theme="professional"] .wards-card,
[data-theme="professional"] .beast-tabs,
[data-theme="professional"] .beast-stage,
[data-theme="professional"] .pensieve,
[data-theme="professional"] .sightings,
[data-theme="professional"] .felix-card,
[data-theme="professional"] .margin-card,
[data-theme="professional"] .case-diagram-stage,
[data-theme="professional"] .owl-stage,
[data-theme="professional"] .scroll-form,
[data-theme="professional"] .kbd-hint,
[data-theme="professional"] .spell-toast,
[data-theme="professional"] .folio-divider,
[data-theme="professional"] #cabinet { display: none !important; }

/* ---------------- MIC FAB (both modes) ---------------- */
#mic-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--mahogany, #5d4201);
  background: linear-gradient(180deg, #f0d28a 0%, #c5a059 50%, #775a19 100%);
  border: 2px solid var(--mahogany, #5d4201);
  border-radius: 9999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 200ms, box-shadow 250ms, background 400ms, border-color 400ms, color 400ms;
}
#mic-fab .mic-icon {
  font-size: 26px !important;
  position: relative;
  z-index: 2;
}
#mic-fab .mic-ring {
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  border: 2px solid currentColor;
  opacity: 0;
  pointer-events: none;
}
#mic-fab.listening .mic-ring {
  animation: mic-ping 1.6s ease-out infinite;
}
#mic-fab.listening .mic-ring.r2 {
  animation-delay: 0.6s;
}
#mic-fab:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}
#mic-fab.listening {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.25),
    0 0 0 3px rgba(233, 193, 118, 0.5),
    0 0 22px rgba(233, 193, 118, 0.85);
}
#mic-fab.unsupported {
  cursor: not-allowed;
  filter: grayscale(0.7) brightness(0.85);
  opacity: 0.6;
}
#mic-fab .mic-tip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--inverse-surface, #382f20);
  color: var(--inverse-on-surface, #feefd8);
  padding: 4px 10px;
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
#mic-fab:hover .mic-tip { opacity: 1; }

/* Professional mode — sharp neon mic */
[data-theme="professional"] #mic-fab {
  background: rgba(0, 255, 65, 0.08);
  border: 1px solid var(--primary);
  border-radius: 0;
  color: var(--primary);
  box-shadow:
    inset 0 0 0 1px rgba(0, 255, 65, 0.18),
    0 0 12px rgba(0, 255, 65, 0.35);
}
[data-theme="professional"] #mic-fab.listening {
  box-shadow:
    inset 0 0 0 1px rgba(0, 255, 65, 0.6),
    0 0 0 2px var(--primary),
    0 0 28px rgba(0, 255, 65, 0.85);
}
[data-theme="professional"] #mic-fab .mic-ring {
  border-radius: 0;
  border-color: var(--primary);
}

@keyframes mic-ping {
  0%   { opacity: 0.85; transform: scale(0.85); }
  80%  { opacity: 0;    transform: scale(1.7);  }
  100% { opacity: 0;    transform: scale(1.7);  }
}

/* Hide kbd-hint on small screens; mic FAB stays */
@media (max-width: 768px) {
  #mic-fab { bottom: 80px; }   /* lift above mobile bottom-nav */
}

/* ---------------- REDUCED MOTION ---------------- */
@media (prefers-reduced-motion: reduce) {
  .case-clasp.r1, .case-clasp.r2, .case-clasp.r3,
  .case-clasp-core, .firefly, .case-mist-layer,
  .glow-orb, .ward-bar > span, .ward-pulse, .pulse-dot,
  .beast-rings .ring, .case-pin::after, #mic-fab .mic-ring,
  body.lumos { animation: none !important; transition: none !important; }
  #hero-canvas { display: none; }
}

/* --------------------- PRINT --------------------- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .parchment-texture, .leather-texture, .glass-panel,
  .circuit-bg, .hero-bg-image, .scanline::after {
    background: none !important;
    box-shadow: none !important;
  }
  header, nav, .mode-toggle, .fleuron-divider, .cyber-divider,
  .mobile-bottom-nav, .no-print,
  #loader, .case-rail, .hero-stage, .glow-orb, .firefly,
  .case-mist, .case-mist-layer, .case-silhouette,
  .wards-card, .beast-tabs, .pensieve, .sightings,
  .case-diagram-stage, .owl-stage, .kbd-hint, .spell-toast,
  .folio-divider, #cabinet, .wand-spark, .wand-trail, #mic-fab { display: none !important; }
  section { page-break-inside: avoid; margin: 1rem 0 !important; padding: 0 !important; }
  h1, h2, h3 { color: #000 !important; }
  main { padding-top: 0 !important; }
}
