/* mr-cal-guide — shared theme.
   Dark cyberpunk aesthetic borrowed (with attribution) from
   graphlings.net/reports.html. */

:root {
  --bg-dark: #000000;
  --bg-panel: rgba(4, 4, 12, 0.92);
  --bg-elev: rgba(255, 255, 255, 0.03);

  --text-primary: #e8eaf0;
  --text-secondary: #8890a8;
  --text-dim: #505068;

  --accent-cyan:   #00e0ff;
  --accent-purple: #a855f7;
  --accent-green:  #30e868;
  --accent-amber:  #f0b020;
  --accent-red:    #ff4757;
  --accent-pink:   #ff6b9d;

  --border-base: rgba(60, 60, 80, 0.3);
  --border-strong: rgba(120, 120, 160, 0.5);

  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg-dark); }
body {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent-cyan); text-decoration: none; transition: color 120ms; }
a:hover { color: var(--accent-pink); }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-cyan);
  background: rgba(0, 224, 255, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(0, 224, 255, 0.15);
}

/* ─────────── animated background layers ─────────── */

.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(80, 80, 130, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 80, 130, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(40, 40, 70, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 40, 70, 0.025) 1px, transparent 1px);
  background-size: 64px 64px, 64px 64px, 16px 16px, 16px 16px;
}

.bg-nebula {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 25%, rgba(168, 85, 247, 0.10), transparent 60%),
    radial-gradient(ellipse 70% 60% at 80% 70%, rgba(0, 224, 255, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 95%, rgba(48, 232, 104, 0.05), transparent 50%);
  animation: nebulaShift 25s ease-in-out infinite alternate;
}
@keyframes nebulaShift {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  50%  { transform: translate(-10px, 8px) scale(1.02); opacity: 0.85; }
  100% { transform: translate(8px, -5px) scale(0.98); opacity: 0.9; }
}

/* Atmospheric layers all sit BELOW the UI. UI is z-index 10 (.site-header,
   main, footer, etc). Nothing atmospheric paints over text or controls. */

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(0deg,
    transparent, transparent 2px,
    rgba(0, 0, 0, 0.04) 2px, rgba(0, 0, 0, 0.04) 4px);
}

.noise-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.018;
}

.scan-beam {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0, 224, 255, 0.4) 20%,
    rgba(168, 85, 247, 0.4) 80%,
    transparent 100%);
  box-shadow: 0 0 20px rgba(0, 224, 255, 0.3),
              0 0 40px rgba(168, 85, 247, 0.2);
  z-index: 3; pointer-events: none;
  animation: scanBeam 10s ease-in-out infinite;
}
@keyframes scanBeam {
  0%   { top: -2px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 100vh; opacity: 0; }
}

/* ─────────────── shared header ─────────────── */

.site-header {
  position: relative; z-index: 20;
  padding: 1rem 1.75rem;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-base);
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
}

/* Hamburger for the mobile topic-rail drawer.
   Visible only at ≤900px (see rail drawer media query below). */
.rail-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  padding: 0; border-radius: 8px;
  background: rgba(0, 224, 255, 0.06);
  border: 1px solid var(--border-base);
  color: var(--accent-cyan);
  cursor: pointer;
  transition: background 160ms, border-color 160ms, transform 160ms;
}
.rail-toggle:hover { background: rgba(0, 224, 255, 0.12); border-color: rgba(0, 224, 255, 0.4); }
.rail-toggle-bars { display: inline-flex; flex-direction: column; gap: 4px; width: 20px; }
.rail-toggle-bars span {
  display: block; height: 2px; border-radius: 2px;
  background: currentColor;
  transition: transform 180ms, opacity 180ms;
}
body.rail-open .rail-toggle {
  background: rgba(0, 224, 255, 0.14);
  border-color: var(--accent-cyan);
}
body.rail-open .rail-toggle-bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.rail-open .rail-toggle-bars span:nth-child(2) { opacity: 0; }
body.rail-open .rail-toggle-bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.site-header::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent-purple) 15%,
    var(--accent-cyan) 50%,
    var(--accent-green) 85%,
    transparent 100%);
  animation: headerGlow 3s ease-in-out infinite;
}
@keyframes headerGlow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.site-brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-decoration: none;
  text-shadow: 0 0 12px rgba(0, 224, 255, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.site-brand-icon {
  width: 28px; height: 28px;
  filter: drop-shadow(0 0 6px rgba(0, 224, 255, 0.45));
}
.site-brand .accent { color: var(--accent-purple); }

.site-tagline {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.site-nav { display: flex; gap: 0.5rem; margin-left: auto; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: all 160ms;
}
.site-nav a:hover, .site-nav a[aria-current="page"] {
  color: var(--accent-cyan);
  border-color: rgba(0, 224, 255, 0.3);
  background: rgba(0, 224, 255, 0.06);
}

/* ── Mobile header ──────────────────────────────────────────────────
   At ≤720px the header would be ~1180px wide (hamburger + brand +
   319-px tagline + 6 nav links) inside a ≤430-px viewport. Hide the
   tagline + the inline nav at narrow widths and move the nav into the
   rail-drawer (see nav.js `mountSiteNav`). The header becomes a
   single-row compact strip: [hamburger] [brand]. */
@media (max-width: 720px) {
  .site-header { padding: 0.65rem 0.85rem; gap: 0.7rem; flex-wrap: nowrap; }
  .site-tagline { display: none; }
  .site-nav { display: none; }
  .site-brand { font-size: 0.95rem; letter-spacing: 0.06em; }
}

/* Sticky header on narrow viewports so the hamburger is always
   reachable regardless of how far down the user has scrolled. Uses
   `position: sticky` rather than `fixed` so it participates in layout
   and doesn't need a manual top-padding on `main`. `z-index: 30` keeps
   it above atmospheric layers (z 0-3) and the main content (z 10) but
   below the drawer (portaled to body, z 50) and its backdrop (z 40). */
@media (max-width: 900px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 30;
  }
}

footer.site-footer {
  position: relative; z-index: 10;
  padding: 1.25rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-align: center;
  text-transform: uppercase;
  border-top: 1px solid var(--border-base);
  margin-top: 4rem;
}

/* ─────────────── shared headings ─────────────── */

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0.6rem;
  text-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
}

h2 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-cyan);
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-base);
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.2rem 0 0.4rem;
  color: var(--text-primary);
}

p { margin: 0.5rem 0; color: var(--text-primary); }
.muted, p.muted { color: var(--text-secondary); }
.dim { color: var(--text-dim); }
