:root {
  /* Witchy storm palette — bruised indigo, storm-purple, lightning */
  --bg: #0a0612;
  --bg-gradient-top: #1f1133;       /* deep storm violet */
  --bg-gradient-mid: #140a24;
  --bg-gradient-bottom: #06040d;    /* near-black */
  --bg-elevated: #160d28;
  --border: #3a2456;
  --border-glow: #5b3a8a;
  --text: #ece4f5;
  --text-muted: #9d8bb8;
  --accent: #b794f6;        /* witchy lavender */
  --accent-bright: #d6bcff; /* lightning highlight */
  --accent-lightning: #e8d5ff;
  --accent-eerie: #6ee7b7;  /* eerie witch-fire green */
  --accent-dim: #6b4d99;
  --sidebar-width: 240px;
  --max-content: 1200px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  background:
    radial-gradient(ellipse at 70% 0%, rgba(91, 58, 138, 0.35) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-mid) 35%, var(--bg-gradient-bottom) 75%) fixed;
  min-height: 100%;
}

body {
  background: var(--bg-gradient-bottom);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 2rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 3rem 0;
  background: rgba(10, 6, 18, 0.5);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

/* layered storm clouds + a faint lightning fork in the header */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse 120% 80% at 20% 130%, rgba(58, 36, 86, 0.55) 0%, transparent 60%),
    radial-gradient(ellipse 100% 70% at 85% 120%, rgba(91, 58, 138, 0.4) 0%, transparent 55%);
  pointer-events: none;
}

/* Storm decoration overlay — scattered bolts that flash individually */
.storm-deco {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.storm-deco svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Each bolt is dark most of the time, then briefly strikes. All share ONE
   period and are evenly phase-shifted (16s / 5 bolts = one strike every 3.2s),
   so only one fires at a time and there's a clear gap between firings. */
.storm-deco .bolt { opacity: 0; }
.storm-deco .b1 { animation: strike 16s linear infinite; animation-delay: 0s;     }
.storm-deco .b2 { animation: strike 16s linear infinite; animation-delay: -3.2s;  }
.storm-deco .b3 { animation: strike 16s linear infinite; animation-delay: -6.4s;  }
.storm-deco .b4 { animation: strike 16s linear infinite; animation-delay: -9.6s;  }
.storm-deco .b5 { animation: strike 16s linear infinite; animation-delay: -12.8s; }

/* The flash occupies ~9% of the period (~1.4s); the rest is dark. Since the
   flash is shorter than the 20% slot between phases, strikes never overlap. */
@keyframes strike {
  0%, 100% { opacity: 0; }
  1.5% { opacity: 1; }
  4%   { opacity: 0.2; }
  6.5% { opacity: 0.8; }
  9%   { opacity: 0; }
}

/* Respect users who prefer no motion: show bolts faintly, no flashing. */
@media (prefers-reduced-motion: reduce) {
  .storm-deco .bolt { opacity: 0.45; animation: none; }
}

.site-header h1 {
  font-family: var(--font-display);
  font-size: 2.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  position: relative;
  text-shadow: 0 0 24px rgba(183, 148, 246, 0.45);
}

.subtitle {
  color: var(--accent);
  margin-top: 0.4rem;
  font-size: 1.05rem;
  font-style: italic;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  position: relative;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  border-right: 1px solid var(--border);
  background: rgba(10, 6, 18, 0.7);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding-top: 2rem;
}

.sidebar-inner {
  padding: 0 1.5rem;
}

.nav-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 1rem;
  font-weight: 600;
}

#nav-list {
  list-style: none;
}

#nav-list li {
  margin-bottom: 0.25rem;
}

#nav-list a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-size: 0.92rem;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

#nav-list a:hover {
  color: var(--accent-bright);
  background: rgba(183, 148, 246, 0.1);
  text-shadow: 0 0 10px rgba(214, 188, 255, 0.5);
}

#nav-list a.active {
  color: var(--accent-bright);
  border-left-color: var(--accent);
  background: rgba(183, 148, 246, 0.08);
  box-shadow: -1px 0 12px -2px rgba(183, 148, 246, 0.5);
}

/* Main content */
.content {
  margin-left: var(--sidebar-width);
  padding: 3rem 0;
  min-height: 100vh;
}

.site-header,
.site-footer {
  margin-left: var(--sidebar-width);
}

.page-description {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 70ch;
  margin-bottom: 3rem;
}

/* Figure cards */
.figure {
  margin-bottom: 4rem;
  scroll-margin-top: 2rem;
}

.figure h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
  text-shadow: 0 0 16px rgba(183, 148, 246, 0.3);
}

.figure .caption {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 0.98rem;
  max-width: 70ch;
}

.figure-media {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #05030a;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.6),
    0 0 24px -6px rgba(91, 58, 138, 0.5);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.figure-media:hover {
  border-color: var(--border-glow);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.6),
    0 0 32px -2px rgba(183, 148, 246, 0.55);
}

.figure-media img,
.figure-media video {
  display: block;
  max-width: 100%;
  height: auto;
}

.figure-meta {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--accent-eerie);
  letter-spacing: 0.03em;
  font-family: var(--font-display);
  font-style: italic;
  text-shadow: 0 0 10px rgba(110, 231, 183, 0.35);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  background: rgba(10, 6, 18, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  .content,
  .site-header,
  .site-footer {
    margin-left: 0;
  }
  #nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  #nav-list li {
    margin-bottom: 0;
  }
}
