/* ===========================
   Root theme + base reset
   =========================== */

:root {
  --page-bg: radial-gradient(circle at top left, #050816 0, #020617 40%, #000 100%);
  --page-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='noStitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/%3E%3C/svg%3E");
  --ink: #e5e7eb;
  --ink-soft: #9ca3af;
  --ink-strong: #f9fafb;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --accent-strong: #0ea5e9;
  --gold: #fbbf24;
  --muted: #6b7280;
  --card-bg: rgba(15, 23, 42, 0.78);
  --card-border: rgba(148, 163, 184, 0.35);
  --radius-lg: 24px;
  --radius-md: 18px;
  --shadow-soft: 0 26px 60px rgba(15, 23, 42, 0.75);
  --shadow-subtle: 0 18px 40px rgba(15, 23, 42, 0.55);
  --shadow-tiny: 0 0 0 1px rgba(15, 23, 42, 0.7);
  --blur-glass: 18px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Inter", "Segoe UI", sans-serif;
  --font-serif: "Playfair Display", "Times New Roman", serif;
}

/* Allow background glow */
html,
body {
  background: #020617;
  color: var(--ink);
  font-family: var(--font-sans);
}

/* Main page container (wrap whole notes if possible) */
body {
  min-height: 100vh;
  background:
    var(--page-bg),
    var(--page-noise);
  background-blend-mode: soft-light;
  color: var(--ink);
}

/* ===========================
   Masthead / global chrome
   =========================== */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 1.5rem;
  margin-bottom: 0.25rem;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.94));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.7);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead span {
  color: rgba(148, 163, 184, 0.7);
}

/* ===========================
   Hero image band
   =========================== */

.hero-image-wrap {
  position: relative;
  max-width: 1200px;
  margin: 1.5rem auto 0.5rem;
  border-radius: 28px;
  overflow: hidden;
  isolation: isolate;
  box-shadow: var(--shadow-soft);
}

.hero-img {
  display: block;
  width: 100%;
  height: auto;
  transform: scale(1.02);
  filter: saturate(1.1) contrast(1.1);
  transform-origin: center;
  transition: transform 900ms ease, filter 900ms ease;
}

.hero-image-wrap::before {
  /* science grid overlay */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.hero-img-fade {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 0, rgba(8, 47, 73, 0.5), transparent 55%),
              radial-gradient(circle at 100% 100%, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.98));
}

.hero-image-wrap:hover .hero-img {
  transform: scale(1.05);
  filter: saturate(1.2) contrast(1.15);
}

.img-caption {
  position: absolute;
  left: 2rem;
  bottom: 1.6rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--ink-soft);
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.85);
}

.img-caption span {
  font-size: 1.05rem;
}

/* ===========================
   Main hero heading block
   =========================== */

.hero {
  position: relative;
  max-width: 1200px;
  margin: 1.25rem auto 1.8rem;
  padding-inline: 1.25rem;
}

.hero-inner {
  position: relative;
  padding: 1.8rem 2rem 1.7rem;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18), transparent 45%),
              radial-gradient(circle at 110% 0%, rgba(251, 191, 36, 0.22), transparent 50%),
              rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.hero-inner::before {
  /* thin glowing ring behind heading */
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px dashed rgba(148, 163, 184, 0.18);
  inset: auto auto -300px -160px;
  pointer-events: none;
}

.hero-label {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 4vw, 3.5rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-strong);
  margin-bottom: 0.2rem;
  position: relative;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, #22d3ee, #38bdf8, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin-bottom: 1.3rem;
}

/* badges */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.badge-custom {
  font-size: 0.76rem;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.9);
  color: var(--muted);
}

.badge-red {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fecaca;
  background: linear-gradient(to right, rgba(153, 27, 27, 0.7), rgba(127, 29, 29, 0.9));
}

.badge-gold {
  border-color: rgba(251, 191, 36, 0.9);
  color: #fef9c3;
  background: linear-gradient(to right, rgba(180, 83, 9, 0.8), rgba(161, 98, 7, 0.95));
}

.badge-ghost {
  background: rgba(15, 23, 42, 0.85);
}

/* ===========================
   Preamble + typography
   =========================== */

.preamble-wrap,
.chapter-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1.5rem 0 0.75rem;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.55);
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lead-para {
  margin-top: 0.6rem;
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--ink-soft);
  max-width: 70ch;
}

/* Author block */
.author-block {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 1.25rem 0 1.75rem;
}

.author-block img.rounded {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  padding: 4px;
}

.author-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-strong);
}

.author-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Section labels + titles */
.section-label {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.5rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--ink-strong);
  margin: 0.2rem 0 0.75rem;
}

/* Equation boxes */
.eq-box {
  margin: 1.1rem 0;
  padding: 1.1rem 1.1rem 1.25rem;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-subtle);
}

.eq-label {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

/* Core info card */
.info-card {
  margin-top: 0.75rem;
  padding: 1.15rem 1.1rem;
  border-radius: 18px;
  background: radial-gradient(circle at 0 0, var(--accent-soft), transparent 65%),
              rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: var(--shadow-subtle);
}

/* Links */
a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===========================
   Quick navigation card
   =========================== */

.quick-nav {
  position: sticky;
  top: 72px;
  margin: 2.25rem 0 1.5rem;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-subtle);
}

.quick-nav-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.quick-nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.4), rgba(15, 23, 42, 0.9));
  font-size: 0.95rem;
}

.quick-nav-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.quick-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.quick-nav li + li {
  margin-top: 0.3rem;
}

.quick-nav a {
  display: block;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  border-radius: 999px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.quick-nav a:hover {
  background: rgba(15, 23, 42, 0.98);
  color: var(--accent-strong);
  transform: translateX(2px);
}

/* ===========================
   Chapter cards (Bootstrap .card)
   =========================== */

.ch-card.card {
  border-radius: 22px;
  overflow: hidden;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 1.75rem;
}

.ch-card .card-header {
  border: none;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.85));
  border-bottom: 1px solid rgba(148, 163, 184, 0.4);
}

.ch-card .card-header h4 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-strong);
}

.ch-card .card-body {
  padding: 1.25rem 1.3rem 1.5rem;
  background: var(--card-bg);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border-radius: 0 0 22px 22px;
  border: 1px solid var(--card-border);
  border-top: none;
  box-shadow: var(--shadow-subtle);
}

/* Header accent variants (keep subtle colour hints) */
.ch-hdr-primary {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.95), rgba(8, 47, 73, 0.9));
}

.ch-hdr-secondary {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.85), rgba(15, 23, 42, 0.95));
}

.ch-hdr-success {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.9), rgba(15, 23, 42, 0.95));
}

.ch-hdr-info {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.9), rgba(15, 23, 42, 0.95));
}

.ch-hdr-warning {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.9), rgba(15, 23, 42, 0.96));
}

.ch-hdr-danger {
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.9), rgba(15, 23, 42, 0.96));
}

.ch-hdr-dark {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 1));
}

/* ===========================
   Content typography inside cards
   =========================== */

.card-body p,
.text-secondary {
  font-size: 0.99rem;
  line-height: 1.8;
  color: var(--ink-soft) !important;
}

.card-body h4.neon-title,
.card-body h5.neon-title {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.35rem;
  margin-bottom: 0.65rem;
  color: var(--accent-strong);
}

/* alerts */
.alert {
  border-radius: 14px;
  border-width: 1px;
  border-style: solid;
  font-size: 0.92rem;
  line-height: 1.6;
  box-shadow: var(--shadow-tiny);
  background: rgba(15, 23, 42, 0.94);
}

.alert-info {
  border-color: rgba(56, 189, 248, 0.55);
  color: var(--ink-soft);
}

.alert-success {
  border-color: rgba(34, 197, 94, 0.6);
}

.alert-warning {
  border-color: rgba(234, 179, 8, 0.65);
}

.alert-danger {
  border-color: rgba(239, 68, 68, 0.7);
}

/* Lists */
.list-group-item {
  background: transparent;
  border-color: rgba(55, 65, 81, 0.6);
  color: var(--ink-soft);
  padding: 0.55rem 0.75rem;
}

/* Small chips (scope pills etc.) */
.scope-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.scope-pill {
  font-size: 0.76rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--ink-soft);
}

/* ===========================
   Images and figures
   =========================== */

.figure img {
  border-radius: 18px !important;
  box-shadow: var(--shadow-subtle);
}

.figure-caption {
  color: var(--muted) !important;
}

/* ===========================
   Ornamental rules
   =========================== */

.full-rule {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  margin: 2.2rem 0 1.8rem;
}

.ornamental-rule {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 2.4rem 0 1.8rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.ornamental-rule hr {
  flex: 1;
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.45);
}

/* ===========================
   Responsive tweaks
   =========================== */

@media (max-width: 768px) {
  .hero-inner {
    padding: 1.4rem 1.4rem 1.6rem;
  }

  .hero h1 {
    font-size: 2.3rem;
  }

  .img-caption {
    left: 1.1rem;
    right: 1.1rem;
    bottom: 1.1rem;
    justify-content: center;
    text-align: center;
  }

  .quick-nav {
    position: static;
  }

  .ch-card .card-body {
    padding: 1.1rem 1.1rem 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
