/* ============================================================
   Cluster Expansion Tutorial — Custom Reveal.js Theme
   ============================================================ */

:root {
  --primary: #2c3e50;
  --accent: #e74c3c;
  --accent2: #3498db;
  --accent3: #27ae60;
  --bg-light: #f8f9fa;
  --text-dark: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- Slide number (centered at bottom) --- */

.reveal .slide-number {
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 4px;
  padding: 0.15em 0.6em;
  font-size: 0.7em;
}

/* --- Global --- */

.reveal {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-dark);
}

.reveal h1, .reveal h2, .reveal h3, .reveal h4 {
  font-weight: 700;
  color: var(--primary);
  text-transform: none;
  letter-spacing: -0.02em;
}

.reveal h1 { font-size: 2.4em; }
.reveal h2 { font-size: 1.2em; padding-bottom: 0; display: block; margin-top: 0; text-align: center; }
.reveal h3 { font-size: 1.2em; }
.reveal h4 { font-size: 1.0em; color: var(--accent2); margin-bottom: 0.4em; }

.reveal ul { list-style: none; padding-left: 0; }
.reveal ul li { position: relative; padding-left: 1.2em; margin-bottom: 0.35em; font-size: 0.78em; }
.reveal ul li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); font-weight: bold; }

.reveal ol { font-size: 0.75em; }
.reveal ol li { margin-bottom: 0.3em; }

/* --- Title Slide --- */

.title-main {
  font-size: 3em !important;
  margin-bottom: 0.1em;
  background: linear-gradient(135deg, var(--primary), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-sub {
  font-weight: 400 !important;
  color: var(--text-muted) !important;
  font-size: 1.3em !important;
}

.title-author {
  font-size: 0.9em;
  color: var(--accent);
  margin-top: 1em;
}

.title-hint {
  font-size: 0.6em;
  color: var(--text-muted);
  margin-top: 2em;
}

.title-hint kbd {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: monospace;
  font-size: 0.9em;
}

/* --- Slide subtitle --- */

.slide-subtitle {
  font-size: 0.8em;
  color: var(--text-muted);
  margin-top: -0.5em;
  margin-bottom: 0.5em;
  text-align: center;
}

/* --- Two Column Layout --- */

.two-col {
  display: flex;
  gap: 2em;
  align-items: flex-start;
  text-align: left;
}

.col {
  flex: 1;
  min-width: 0;
}

/* --- Info Card --- */

.info-card {
  background: #e0e0e0;
  border-left: 4px solid var(--accent2);
  border-radius: 6px;
  padding: 0.8em 1em;
  box-shadow: var(--shadow);
  border: 1px solid #999;
  border-left: 4px solid var(--accent2);
}

.info-card h4 {
  margin-top: 0;
  font-size: 0.9em;
}

.info-card p, .info-card ul {
  font-size: 0.75em;
}

/* --- Math --- */

.math-block {
  background: var(--bg-light);
  border-radius: 6px;
  padding: 0.6em 1em;
  margin: 0.6em 0;
  text-align: center;
}

.math-block .katex { font-size: 1.1em; }
.math-block .katex-display { margin: 0.2em 0; }
.reveal .katex { font-size: 0.85em !important; }
.reveal .katex-display > .katex { font-size: 1.1em; }

/* --- Visualization Containers --- */

.viz-container {
  width: 100%;
  height: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

#cluster-functions {
  height: 420px;
}

#cluster-orbits {
  height: 500px;
}

.viz-container-large {
  height: 390px;
}

.viz-container canvas,
.viz-container svg {
  width: 100%;
  height: 100%;
}

/* --- Controls (pill style, applied to all .viz-controls) --- */

.viz-controls {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 0.5em;
  flex-wrap: wrap;
  font-size: 0.45em;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.viz-controls label,
.viz-controls .ctl-group,
.viz-controls .ctl-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.25em 0.7em;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}

.viz-controls label:hover,
.viz-controls .ctl-group:hover,
.viz-controls .ctl-chip:hover {
  border-color: var(--accent2);
  background: #f4faff;
}

.viz-controls .ctl-key {
  color: var(--text-muted);
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.viz-controls .ctl-val {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  min-width: 2.3em;
  text-align: right;
}

.viz-controls select,
.viz-controls .ctl-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--primary);
  padding: 0 1em 0 0;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 8px) 50%, calc(100% - 4px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
  outline: none;
}

.viz-controls input[type="range"] {
  width: 90px;
  accent-color: var(--accent2);
  height: 3px;
  margin: 0 0.1em;
}

.viz-controls input[type="checkbox"] {
  accent-color: var(--accent2);
  margin: 0;
  width: 0.9em;
  height: 0.9em;
}

.viz-controls .btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25em 0.9em;
  font-size: 1em;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.viz-controls .btn:hover {
  border-color: var(--accent2);
  color: var(--accent2);
  background: #f4faff;
}

.viz-controls .btn.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

.viz-controls .info-label,
.info-label {
  color: var(--text-muted);
  font-style: normal;
  margin-left: auto;
  font-size: 0.95em;
  background: var(--bg-light);
  padding: 0.25em 0.7em;
  border-radius: 999px;
}

/* --- Workflow Diagram --- */

.workflow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  margin-top: 1.5em;
}

.workflow-step {
  background: var(--bg-light);
  border: 2px solid var(--accent2);
  border-radius: 10px;
  padding: 0.8em 1em;
  text-align: center;
  min-width: 100px;
  box-shadow: var(--shadow);
}

.step-num {
  background: var(--accent2);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.4em;
  font-weight: bold;
  font-size: 0.8em;
}

.step-label {
  font-size: 0.7em;
  font-weight: 600;
  color: var(--primary);
}

.workflow-arrow {
  font-size: 1.5em;
  color: var(--accent2);
  font-weight: bold;
}

/* --- Summary Grid --- */

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
  margin-top: 1em;
}

.summary-item {
  background: #e0e0e0;
  border-radius: 8px;
  padding: 0.8em;
  border-left: 4px solid var(--accent);
  border: 1px solid #999;
  border-left: 4px solid var(--accent);
  text-align: left;
}

.summary-item h4 {
  margin: 0 0 0.3em;
  font-size: 0.85em;
  color: var(--accent);
}

.summary-item p {
  font-size: 0.7em;
  margin: 0;
}

/* --- Lists with icons --- */

.list-do li::before { content: "✓"; color: var(--accent3); }
.list-dont li::before { content: "✗"; color: var(--accent); }

/* --- References --- */

.references {
  text-align: left;
  font-size: 0.65em !important;
  column-count: 1;
}

.references li {
  margin-bottom: 0.3em;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .two-col { flex-direction: column; gap: 1em; }
  .workflow-diagram { flex-wrap: wrap; }
  .viz-container { height: 280px; }
  .summary-grid { grid-template-columns: 1fr; }
}

/* --- Tooltip --- */

.d3-tooltip {
  position: absolute;
  background: rgba(44, 62, 80, 0.92);
  color: #fff;
  padding: 0.4em 0.7em;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* --- D3 chart styling --- */

.axis text {
  font-size: 11px;
  fill: var(--text-muted);
}

.axis line, .axis path {
  stroke: var(--border);
}

.grid line {
  stroke: #eee;
}
