/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a12;
  --bg2: #10101e;
  --surface: #16162a;
  --surface2: #1e1e36;
  --accent: #7c3aed;
  --accent2: #06b6d4;
  --accent3: #f59e0b;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --radius: 16px;
  --font: 'Outfit', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

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

/* ── HERO ── */
#hero {
  position: relative;
  height: 100vh;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
#hero-canvas {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.6;
}
.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
  max-width: 750px;
}
.badge {
  display: inline-block;
  background: rgba(124,58,237,0.25);
  border: 1px solid rgba(124,58,237,0.5);
  color: #a78bfa;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 1rem;
  border-radius: 100px;
  margin-bottom: 1.2rem;
}
#hero h1 {
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  line-height: 1.05;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}
.gradient-text {
  background: linear-gradient(135deg, #7c3aed, #06b6d4, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-weight: 300;
}
.btn-hero {
  display: inline-block;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  text-decoration: none;
  padding: 0.9rem 2.5rem;
  border-radius: 100px;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 0 30px rgba(124,58,237,0.4);
}
.btn-hero:hover { transform: translateY(-3px); box-shadow: 0 0 50px rgba(124,58,237,0.6); }

/* ── SECTIONS ── */
.section { padding: 6rem 2rem; }
.section-dark { background: var(--bg2); }
.container { max-width: 1100px; margin: 0 auto; }

.step-number {
  font-size: 6rem;
  font-weight: 900;
  color: rgba(124,58,237,0.12);
  line-height: 1;
  margin-bottom: -1.5rem;
  font-variant-numeric: tabular-nums;
}
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 0.5rem;
}
h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  margin-bottom: 2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h2 em { color: var(--accent); font-style: normal; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.two-col.reverse { direction: rtl; }
.two-col.reverse > * { direction: ltr; }

@media (max-width: 768px) {
  .two-col, .two-col.reverse { grid-template-columns: 1fr; direction: ltr; }
}

/* ── FORMULAS ── */
.formula-box {
  background: var(--surface);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  font-family: var(--mono);
  font-size: 1.1rem;
  color: #a78bfa;
  margin: 1.2rem 0;
  text-align: center;
  letter-spacing: 0.05em;
}
.formula-box.large { font-size: 1.4rem; }
.formula-box.xlarge { font-size: 1.8rem; padding: 1.5rem; }

/* ── INFO CARD ── */
.info-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: rgba(6,182,212,0.08);
  border: 1px solid rgba(6,182,212,0.25);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #a5f3fc;
}
.info-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }

/* ── MATH LIST ── */
.math-list { list-style: none; margin: 1rem 0; }
.math-list li {
  padding: 0.5rem 0 0.5rem 1.5rem;
  position: relative;
  color: var(--text-muted);
}
.math-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
}
.math-list li strong { color: var(--text); }

/* ── CANVAS WRAP ── */
.canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.canvas-wrap.big canvas { width: 100%; max-width: 500px; height: auto; }
canvas {
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(124,58,237,0.25);
  background: #0d0d1a;
}
.canvas-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--mono);
}
.droste-demo-small { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }

/* ── FORMULA HERO ── */
.formula-hero-wrap { text-align: center; margin-bottom: 3rem; }
.formula-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.fh-part {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 14px;
  padding: 1rem 1.5rem;
}
.fh-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.fh-sym { font-size: 2rem; font-family: var(--mono); color: #a78bfa; }
.fh-arrow { text-align: center; color: var(--accent2); font-size: 1.2rem; line-height: 1.4; }
.fh-arrow span { font-size: 0.7rem; display: block; color: var(--text-muted); font-family: var(--mono); }
.formula-desc { color: var(--text-muted); max-width: 600px; margin: 1rem auto; }

/* ── PARAMS GRID ── */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.param-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.3s, transform 0.3s;
}
.param-card:hover { border-color: var(--accent); transform: translateY(-4px); }
.param-name {
  font-family: var(--mono);
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.param-desc { font-size: 0.88rem; color: var(--text-muted); }

/* ── PLAYGROUND ── */
.playground-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 768px) { .playground-layout { grid-template-columns: 1fr; } }

.controls-panel {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.ctrl-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.ctrl-group label strong { color: var(--accent2); }
input[type=range] {
  width: 100%;
  appearance: none;
  height: 4px;
  background: var(--surface2);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  box-shadow: 0 0 10px rgba(124,58,237,0.5);
  cursor: pointer;
}
.palette-row { display: flex; gap: 0.5rem; }
.pal-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.pal-btn.active { border-color: white; transform: scale(1.2); }
.pal-btn[data-pal="cosmic"] { background: linear-gradient(135deg, #7c3aed, #06b6d4); }
.pal-btn[data-pal="fire"]   { background: linear-gradient(135deg, #ef4444, #f59e0b); }
.pal-btn[data-pal="ocean"]  { background: linear-gradient(135deg, #0ea5e9, #10b981); }
.pal-btn[data-pal="forest"] { background: linear-gradient(135deg, #16a34a, #84cc16); }

.btn-animate {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.btn-animate:hover { opacity: 0.85; transform: translateY(-2px); }
.formula-live {
  background: var(--bg);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 10px;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.8;
}
#alpha-display { color: #a78bfa; }

/* ── ESCHER VIZ ── */
.escher-viz { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }

/* ── SUMMARY GRID ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.sum-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.sum-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 10px 40px rgba(124,58,237,0.2);
}
.sum-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sum-card h3 { font-size: 1rem; margin-bottom: 0.6rem; color: var(--text); }
.sum-card p { font-size: 0.85rem; color: var(--text-muted); }

/* ── FOOTER ── */
footer {
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.footer-sub { margin-top: 0.5rem; font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 4px; }
