/* ============================================
   AI Tools Presentation — wabbazzar.com/blog
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
/* Light-mode "lab notebook" vibe (borrowed from 2pizzaclub) */
@import url('https://fonts.googleapis.com/css2?family=Caveat+Brush&family=Quicksand:wght@400;500;600;700&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #000;
  --text: #fff;
  --accent: #00D4FF;
  --muted: #666;
  --code-bg: #111;
  --diagram-bg: #0a0a0a;
  --dot-inactive: #333;
  --section-pad: 4rem 2rem;
  --max-w: 900px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --transition: 0.3s ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  overflow-x: hidden;
}

body.present-mode {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover { opacity: 0.8; }

/* --- Mode Toggle --- */
.mode-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  background: #111;
  border: 1px solid #222;
  border-radius: 999px;
  overflow: hidden;
  font-size: 0.8rem;
  font-family: var(--font);
  letter-spacing: 0.04em;
}

.mode-toggle button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  transition: all var(--transition);
}

.mode-toggle button.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.mode-toggle button:hover:not(.active) {
  color: var(--text);
}

/* --- Progress Dots --- */
.progress-dots {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 101;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

body.present-mode .progress-dots {
  opacity: 1;
  pointer-events: auto;
}

.progress-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-inactive);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  padding: 0;
}

.progress-dots .dot:hover {
  background: rgba(0, 212, 255, 0.5);
}

.progress-dots .dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.6);
  transform: scale(1.3);
}

/* --- Main Container --- */
main {
  width: 100%;
}

body.present-mode main {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
}

body.present-mode main::-webkit-scrollbar {
  display: none;                  /* Chrome/Safari */
}

body.present-mode .section-divider {
  height: 0;
  padding: 0;
  overflow: hidden;
}

.snap-spacer {
  display: none;
}

body.present-mode .snap-spacer {
  display: block;
  height: 1px;
  scroll-snap-align: end;
}

/* --- Sections --- */
section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--section-pad);
  min-height: auto;
}

body.present-mode section {
  max-width: 100%;
  height: 100vh;
  min-height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem 2rem;
  overflow: hidden;
}

body.present-mode section > .slide-inner {
  max-width: var(--max-w);
  width: 100%;
}

/* --- Typography --- */
h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

h2 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

p {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: rgba(255, 255, 255, 0.85);
}

.subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 300;
  margin-bottom: 2rem;
}

.author {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 2rem;
}

/* --- Accent line (matches wabbazzar h1 underline) --- */
h2::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
  margin-top: 0.75rem;
}

/* --- Lists --- */
ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.85);
}

li strong {
  color: var(--text);
}

/* --- Code --- */
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* --- Callout Boxes --- */
.callout {
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout.result {
  border-left-color: #00FF88;
}

.callout.result .callout-label {
  color: #00FF88;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

/* --- Stat Grid --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.stat-card {
  background: var(--code-bg);
  border: 1px solid #222;
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  line-height: 1.2;
}

.stat-card .label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
  display: block;
}

/* --- Mermaid Diagrams --- */
.mermaid {
  margin: 1.5rem 0;
  text-align: center;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* --- Two-Column Layout --- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 1.5rem 0;
}

/* --- Tier Stack (DocHound) --- */
.tier-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.tier {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  border-left: 4px solid;
}

.tier-1 { border-left-color: #00FF88; }
.tier-2 { border-left-color: #FFD700; }
.tier-3 { border-left-color: #FF6B6B; }

.tier-label {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.tier-1 .tier-label { color: #00FF88; }
.tier-2 .tier-label { color: #FFD700; }
.tier-3 .tier-label { color: #FF6B6B; }

.tier-desc {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 0.4rem;
}

.tier-examples {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* --- Closing Image --- */
.closing-visual {
  width: 100%;
  max-width: 600px;
  margin: 2rem auto;
  border-radius: 12px;
  overflow: hidden;
}

.closing-visual img {
  width: 100%;
  height: auto;
  display: block;
}

/* --- Takeaways --- */
.takeaway-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

.takeaway-list li {
  font-size: 1.2rem;
  padding: 1rem 0;
  border-bottom: 1px solid #181818;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.takeaway-list li:last-child {
  border-bottom: none;
}

.takeaway-num {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.5rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* --- Section Divider (read mode) --- */
.section-divider {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
}

.section-divider hr {
  border: none;
  height: 1px;
  background: #222;
  margin: 0;
}

body.present-mode .section-divider {
  display: none;
}

/* --- Detail Panel (present mode sidebar) --- */
.detail-panel {
  display: none;
  position: fixed;
  top: 0;
  left: -400px;
  width: 380px;
  height: 100vh;
  background: #0a0a0a;
  border-right: 1px solid #222;
  z-index: 90;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  transition: left 0.25s ease;
  scrollbar-width: none;
}

.detail-panel::-webkit-scrollbar { display: none; }

.detail-panel.open {
  left: 0;
}

.detail-panel-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: none;
  border: 1px solid #333;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.detail-panel-close:hover {
  border-color: var(--accent);
  color: var(--text);
}

.detail-panel h3 {
  color: var(--accent);
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.detail-panel p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

.detail-panel code {
  font-size: 0.85em;
}

.detail-panel pre {
  background: #111;
  border: 1px solid #222;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.detail-panel pre code {
  background: none;
  padding: 0;
  font-size: 0.8em;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  white-space: pre;
}

.detail-panel ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.detail-panel li {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.35rem;
}

body.present-mode .detail-panel {
  display: block;
}

/* Detail blocks: inline in read mode, hidden in present mode */
.detail-blocks {
  margin-top: 1.5rem;
}

body.present-mode .detail-blocks {
  display: none;
}

/* Make mermaid nodes clickable in present mode */
body.present-mode .mermaid .node { cursor: pointer; }
body.present-mode .mermaid .node:hover rect,
body.present-mode .mermaid .node:hover polygon {
  filter: brightness(1.3);
}

/* Overlay when panel is open */
.detail-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 85;
}

.detail-overlay.open {
  display: block;
}

/* --- Notes Panel (right sidebar) --- */
.notes-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: #0a0a0a;
  border-left: 1px solid #222;
  z-index: 80;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  transform: translateX(0);
}

.notes-panel.hidden {
  transform: translateX(100%);
}

.notes-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.notes-panel-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.notes-mode-toggle {
  display: none; /* hidden on production, shown on localhost via JS */
  background: #111;
  border: 1px solid #222;
  border-radius: 999px;
  overflow: hidden;
  font-size: 0.7rem;
}

.notes-mode-toggle.visible {
  display: flex;
}

.notes-mode-toggle button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  transition: all var(--transition);
}

.notes-mode-toggle button.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.notes-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 2.5rem 1.25rem 1.25rem;
  scrollbar-width: none;
  font-size: 0.95rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.8);
}

.notes-panel-body::-webkit-scrollbar { display: none; }

.notes-panel-body p {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

/* Present mode: center notes, auto-size via JS class */
body.present-mode .notes-panel-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-right: 3.5rem; /* clear progress dots */
}

body.present-mode .notes-panel-body p {
  text-align: center;
}

/* Auto-size tiers applied by JS based on word count */
.notes-panel-body.size-xl p { font-size: 1.6rem; line-height: 1.4; font-weight: 300; }
.notes-panel-body.size-lg p { font-size: 1.3rem; line-height: 1.45; }
.notes-panel-body.size-md p { font-size: 1.05rem; line-height: 1.55; }
.notes-panel-body.size-sm p { font-size: 0.9rem; line-height: 1.6; }

/* Published button flash feedback on save */
.notes-mode-toggle button.flash-saved {
  background: #00FF88;
  color: #000;
}

.notes-panel-body.editing {
  background: #080808;
  border: 1px solid #1a1a1a;
  border-radius: 4px;
  margin: 0.5rem;
  padding: 0.75rem;
  outline: none;
  white-space: pre-wrap;
  font-family: var(--font);
  caret-color: var(--accent);
}

.notes-panel-body .notes-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Notes tab (chevron toggle, visible in present mode when panel is hidden) */
.notes-panel-tab {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 0;
  z-index: 81;
  background: #1a1a1a;
  border: 1px solid var(--accent);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--accent);
  font-size: 1.75rem;
  padding: 1.5rem 0.6rem;
  cursor: pointer;
  transition: right 0.3s ease, background 0.2s ease, box-shadow 0.2s ease;
  line-height: 1;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.15);
}

.notes-panel-tab:hover {
  background: #222;
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.35);
}

.notes-panel-tab.open {
  right: 340px;
}

/* Animate the chevron character rotation */
.notes-panel-tab .chevron {
  display: inline-block;
  transition: transform 0.3s ease;
}

.notes-panel-tab.open .chevron {
  transform: rotate(180deg);
}

/* Present mode: hide panel by default, show tab */
body.present-mode .notes-panel {
  transform: translateX(100%);
}

body.present-mode .notes-panel.visible {
  transform: translateX(0);
}

body.present-mode .notes-panel-tab {
  display: block;
}

/* Keep progress dots above the notes panel */
body.present-mode .progress-dots {
  z-index: 101;
}

/* Keep mode toggle above notes panel in present mode */
body.present-mode .mode-toggle {
  z-index: 101;
}

/* Hide edit toggle in present mode — edit in read mode only */
body.present-mode .notes-mode-toggle {
  display: none !important;
}

/* In read mode, reserve space for notes panel and center content */
body:not(.present-mode) main {
  margin-right: 340px;
}

body:not(.present-mode) section {
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
}

body:not(.present-mode) .section-divider {
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
}

/* Mode toggle stays visible above the notes panel */
body:not(.present-mode) .mode-toggle {
  right: calc(340px + 1.5rem);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  p, li { font-size: 1rem; }
  .subtitle { font-size: 1.1rem; }
  .two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  section { padding: 2.5rem 1.25rem; }
  body.present-mode section { padding: 2rem 1.25rem; }
  .mode-toggle { top: 1rem; right: 1rem; }
  .progress-dots { right: 0.75rem; }

  .stat-card .number { font-size: 1.5rem; }

  .notes-panel { display: none; }
  .notes-panel-tab { display: none !important; }
  body:not(.present-mode) main { margin-right: 0; }
  body:not(.present-mode) .mode-toggle { right: 1rem; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.75rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Print --- */
@media print {
  .mode-toggle, .progress-dots { display: none; }
  body { background: #fff; color: #000; }
  section { page-break-inside: avoid; }
  h2 { color: #005f73; }
  h2::after { background: #005f73; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   THEME TOGGLE  +  LIGHT MODE
   Light mode reskins the deck as a lab notebook on engineering
   graph paper, using the 2pizzaclub palette (royal-blue ink on
   cream, bus-yellow + planet-red accents, hand-drawn headings).
   Everything is scoped under html.light so dark mode is untouched.
   ============================================================ */

/* --- Theme toggle button (visible in both modes) --- */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #111;
  border: 1px solid #222;
  border-radius: 999px;
  color: var(--muted);
  padding: 0.45rem 0.95rem;
  font-family: var(--font);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.theme-toggle:hover { color: var(--text); }

/* --- Light-mode palette + engineering graph paper --- */
html.light body {
  --bg: #FBF6E9;            /* cream paper */
  --text: #16213E;          /* dark ink */
  --accent: #1B3FB5;        /* royal blue */
  --muted: #6F6650;         /* sepia graphite */
  --code-bg: #FDF3D8;       /* warm code tint */
  --diagram-bg: #FBF6E9;
  --dot-inactive: rgba(27, 63, 181, 0.28);
  /* light-mode-only helpers */
  --ink-soft: #3A3A52;
  --rule: rgba(27, 63, 181, 0.22);
  --card: #FFFDF5;
  --planet-red: #E63946;

  color: var(--text);
  font-family: 'Quicksand', var(--font);
  background-color: var(--bg);
  /* fine 22px quad-rule grid + heavier 110px major grid */
  background-image:
    linear-gradient(rgba(27, 63, 181, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 63, 181, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(27, 63, 181, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 63, 181, 0.09) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px, 110px 110px, 110px 110px;
}

/* Hand-drawn headings */
html.light h1,
html.light h2 { font-family: 'Caveat Brush', 'Quicksand', cursive; letter-spacing: 0; }
html.light h2::after { background: var(--planet-red); opacity: 0.85; }

/* Body copy → ink */
html.light p,
html.light li,
html.light .tier-desc { color: var(--ink-soft); }
html.light li strong,
html.light h3 { color: var(--text); }

/* Code / cards / panels → paper surfaces with blueprint hairlines */
html.light code { border: 1px solid var(--rule); }
html.light .stat-card { background: var(--code-bg); border-color: var(--rule); box-shadow: 0 1px 0 rgba(27, 63, 181, 0.08); }
html.light .section-divider hr { background: var(--rule); }
html.light .takeaway-list li { border-bottom-color: var(--rule); }

/* Chrome: mode toggle, theme toggle, back link */
html.light .mode-toggle { background: var(--card); border-color: var(--rule); }
html.light .mode-toggle button.active,
html.light .notes-mode-toggle button.active { color: #FFF8E7; }
html.light .theme-toggle { background: var(--card); border-color: var(--rule); color: var(--accent); font-family: 'Quicksand', sans-serif; }
html.light .theme-toggle:hover { background: #FFF; }
html.light .back-to-writing { background: var(--card); border-color: var(--rule); color: var(--muted); }
html.light .back-to-writing:hover { color: var(--accent); }

/* Progress dots: blue instead of cyan glow */
html.light .progress-dots .dot:hover { background: rgba(27, 63, 181, 0.5); }
html.light .progress-dots .dot.active { box-shadow: 0 0 8px rgba(27, 63, 181, 0.4); }

/* Detail panel (present-mode sidebar) */
html.light .detail-panel { background: var(--card); border-right-color: var(--rule); }
html.light .detail-panel p,
html.light .detail-panel li,
html.light .detail-panel pre code { color: var(--ink-soft); }
html.light .detail-panel pre { background: var(--code-bg); border-color: var(--rule); }
html.light .detail-panel-close { border-color: var(--rule); }
html.light .detail-overlay { background: rgba(27, 63, 181, 0.12); }

/* Notes panel */
html.light .notes-panel { background: var(--card); border-left-color: var(--rule); }
html.light .notes-panel-header { border-bottom-color: var(--rule); }
html.light .notes-panel-body { color: var(--ink-soft); }
html.light .notes-mode-toggle { background: var(--code-bg); border-color: var(--rule); }
html.light .notes-panel-tab { background: var(--card); box-shadow: 0 0 8px rgba(27, 63, 181, 0.15); }
html.light .notes-panel-tab:hover { background: #FFF; box-shadow: 0 0 14px rgba(27, 63, 181, 0.3); }
html.light .notes-panel-body.editing { background: #FFFDF5; border-color: var(--rule); }

/* Result callout + tier colors → darker, readable-on-cream variants.
   Keep the left-border bars bright/decorative; darken only the label text. */
html.light .callout.result { border-left-color: #06A57E; }
html.light .callout.result .callout-label { color: #0A6E54; }
html.light .tier-1 { border-left-color: #06A57E; }
html.light .tier-2 { border-left-color: #B8860B; }
html.light .tier-3 { border-left-color: var(--planet-red); }
html.light .tier-1 .tier-label { color: #0A6E54; }
html.light .tier-2 .tier-label { color: #8A6200; }
html.light .tier-3 .tier-label { color: #C32430; }

/* Mermaid figures keep their own dark-node styling — don't let the light-mode
   <p>/<li> ink overrides bleed into diagram labels (they'd go dark-on-dark).
   The node's <span class="nodeLabel"> carries the real color; let <p> inherit it. */
html.light .mermaid p,
html.light .mermaid li { color: inherit; }

/* ============================================================
   SIMULATE-A-CRISIS section + death-blink overlay
   ============================================================ */
/* Simulate pill — top-left, mirrors the Read/Present pill. Tap = on/off, hold = modal. */
.sim-pill {
  position: fixed; top: 1.5rem; left: 1.5rem; z-index: 100;
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: #111; border: 1px solid #222; border-radius: 999px;
  padding: 0.45rem 1rem; color: var(--muted);
  font-family: var(--font); font-size: 0.8rem; letter-spacing: 0.04em;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  transition: color var(--transition), border-color var(--transition);
}
.sim-pill:hover { color: var(--text); }
.sim-pill .sim-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background var(--transition); }
.sim-pill.running { color: var(--text); border-color: #E63946; }
.sim-pill.running .sim-dot { background: #E63946; box-shadow: 0 0 8px rgba(230,57,70,0.9); animation: simpulse 1.1s ease-in-out infinite; }
@keyframes simpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
/* Push the back-link below the pill so they don't collide at top-left. */
body .back-to-writing { top: 4.2rem; }

/* Settings / explanation modal (opened by holding the pill) */
.sim-modal[hidden] { display: none; }
.sim-modal { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.sim-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sim-modal-card {
  position: relative; z-index: 1; width: min(680px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--diagram-bg); border: 1px solid #222; border-radius: 14px;
  padding: 1.75rem 1.75rem 1.5rem; box-shadow: 0 30px 80px -20px rgba(0,0,0,0.8);
}
.sim-modal-close { position: absolute; top: 0.8rem; right: 1rem; background: none; border: none; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.sim-modal-close:hover { color: var(--text); }
.sim-modal h2 { margin-bottom: 0.6rem; }
.sim-modal-intro { font-size: 0.95rem; }
.crisis-enable-wrap { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.crisis-enable { accent-color: var(--accent); cursor: pointer; }
.sim-speed { font-size: 0.85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.45rem; margin: 0.5rem 0 1.25rem; }
.sim-speed select {
  background: var(--code-bg); color: var(--text); border: 1px solid #333;
  border-radius: 6px; padding: 0.3rem 0.55rem; font-family: var(--font); font-size: 0.85rem;
}

.crisis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin: 1.25rem 0 0.75rem; }
.crisis-counter {
  background: var(--code-bg); border: 1px solid #222; border-radius: 10px;
  padding: 1.25rem 1.4rem; cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.crisis-counter:hover { border-color: var(--accent); transform: translateY(-2px); }
.crisis-counter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.crisis-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.5rem; }
.crisis-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.crisis-tag {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
  border: 1px solid #333; border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.crisis-rate { font-size: 1.05rem; color: var(--text); }
.crisis-rate strong { color: #E63946; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.crisis-live { font-size: 0.85rem; color: var(--muted); margin-top: 0.55rem; font-variant-numeric: tabular-nums; }
.crisis-since { color: var(--accent); font-weight: 700; }
.crisis-more { display: inline-block; margin-top: 0.85rem; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }
.crisis-counter[aria-expanded="true"] .crisis-more { display: none; }
.crisis-detail { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #222; }
.crisis-detail p { font-size: 0.92rem; margin-bottom: 0.75rem; }
.crisis-src { font-size: 0.82rem; }
.crisis-foot { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-top: 0.75rem; }

/* Death-blink overlay: one vignette flash per modeled death */
.death-blink {
  position: fixed; inset: 0; z-index: 200; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, var(--flash, rgba(230,57,70,0.55)) 125%);
}
.death-blink.flash { animation: deathflash 0.7s ease-out; }
@keyframes deathflash { 0% { opacity: 0; } 9% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 768px) { .crisis-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .death-blink.flash { animation-duration: 0.25s; } }

/* Light-mode tweaks for the simulator */
html.light .sim-pill { background: var(--card); border-color: var(--rule); }
html.light .sim-pill.running { border-color: #C32430; }
html.light .sim-pill.running .sim-dot { background: #C32430; box-shadow: 0 0 8px rgba(195,36,48,0.7); }
html.light .sim-modal-backdrop { background: rgba(27,63,181,0.18); }
html.light .sim-modal-card { background: #FFFDF5; border-color: var(--rule); }
html.light .sim-speed select { border-color: var(--rule); }
html.light .crisis-counter { border-color: var(--rule); box-shadow: 0 1px 0 rgba(27, 63, 181, 0.08); }
html.light .crisis-tag { border-color: var(--rule); }
html.light .crisis-detail { border-top-color: var(--rule); }
html.light .crisis-rate strong { color: #C32430; }
