/* ============ The Night Before the Duel — styles ============ */

:root {
  --bg: #0e1020;
  --bg2: #161a30;
  --card: #1c2138;
  --ink: #e9e7df;
  --dim: #9aa0b8;
  --gold: #f2c14e;
  --indigo: #7c8cf8;
  --rose: #f27ea9;
  --green: #6fd6a4;
  --line: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.65;
}

h1, h2, h3, h4 {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  line-height: 1.15;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.08em 0.35em;
  font-size: 0.9em;
  color: var(--gold);
}

.dim { color: var(--dim); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.mt { margin-top: 2.2rem; }

/* ---------- nav ---------- */
#topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 1.1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.55rem 1.2rem;
  background: rgba(14, 16, 32, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
#topnav .brand { color: var(--gold); font-family: Georgia, serif; font-size: 1rem; margin-right: auto; }
#topnav a { color: var(--dim); text-decoration: none; }
#topnav a:hover { color: var(--ink); }

/* ---------- hero ---------- */
.hero {
  max-width: 820px;
  margin: 0 auto;
  padding: 5rem 1.5rem 4rem;
  text-align: center;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0 0 1rem;
}
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); margin: 0 0 1.6rem; color: var(--ink); }
.lede { color: var(--dim); font-size: 1.08rem; max-width: 680px; margin: 0 auto 1.2rem; }
.lede strong, .lede em { color: var(--ink); }
.cta {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.75rem 1.8rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--gold);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.cta:hover { background: var(--gold); color: #111; }

/* ---------- panels ---------- */
.panel {
  max-width: 860px;
  margin: 0 auto 3rem;
  padding: 3rem 1.5rem;
  border-top: 1px solid var(--line);
}
.panel h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0.4rem 0 1.2rem; }
.panel h3 { font-size: 1.3rem; }
.panel p { color: #c9c7bd; }
.panel p strong, .panel blockquote strong { color: var(--ink); }

blockquote {
  margin: 1.6rem 0;
  padding: 1rem 1.4rem;
  border-left: 3px solid var(--gold);
  background: var(--bg2);
  border-radius: 0 12px 12px 0;
  font-family: Georgia, serif;
  font-size: 1.12rem;
  color: var(--ink);
}

.callout {
  margin-top: 1.8rem;
  padding: 1.2rem 1.4rem;
  background: linear-gradient(135deg, rgba(242, 193, 78, 0.09), rgba(124, 140, 248, 0.09));
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #c9c7bd;
}
.callout strong { color: var(--ink); }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---------- degree picker & formula card ---------- */
.degree-picker { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1.2rem 0; }
.degree-picker button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  transition: transform 0.15s, border-color 0.15s;
}
.degree-picker button:hover { transform: translateY(-2px); border-color: var(--indigo); }
.degree-picker button.active { border-color: var(--gold); background: rgba(242, 193, 78, 0.12); }

.formula-card, .solv-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.6rem;
  min-height: 190px;
}
.formula-card h3 { margin-top: 0; }
.formula {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  background: #0a0c18;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  color: var(--green);
  margin: 0.6rem 0 0.9rem;
}
.formula .nope { color: var(--rose); }

/* ---------- root swap demo ---------- */
.swap-stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem;
  margin: 1.4rem 0;
}
.roots-row { display: flex; align-items: center; justify-content: center; gap: 1.2rem; flex-wrap: wrap; }
.root-chip {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  background: #0a0c18;
  border: 1px solid var(--indigo);
  border-radius: 14px;
  padding: 0.8rem 1.6rem;
  min-width: 110px;
  transition: transform 0.6s cubic-bezier(0.6, -0.2, 0.3, 1.4);
}
.root-label { font-size: 0.75rem; color: var(--dim); letter-spacing: 0.1em; }
.root-val { font-size: 1.5rem; font-family: Georgia, serif; color: var(--gold); }
.swap-btn {
  cursor: pointer;
  background: var(--indigo);
  color: #0a0c18;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
}
.swap-btn:hover { filter: brightness(1.15); }
.facts { display: grid; gap: 0.5rem; margin-top: 1.4rem; }
.fact {
  background: #0a0c18;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-family: ui-monospace, Menlo, monospace;
  display: flex; gap: 0.8rem; align-items: baseline; flex-wrap: wrap;
}
.check { color: var(--green); font-size: 0.85rem; }
.swap-note { margin: 1rem 0 0; color: var(--dim); font-size: 0.92rem; text-align: center; }

/* ---------- triangle explorer ---------- */
.explorer {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1.6rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem;
  margin: 1.4rem 0;
}
@media (max-width: 720px) { .explorer { grid-template-columns: 1fr; } }

.stage { display: flex; justify-content: center; }
.stage svg { width: 100%; max-width: 320px; height: auto; }

.controls { display: flex; flex-direction: column; gap: 0.7rem; align-items: flex-start; }
.mv {
  cursor: pointer;
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--indigo);
  border-radius: 10px;
  padding: 0.55rem 1.1rem;
  font-size: 1rem;
  transition: background 0.15s, transform 0.1s;
}
.mv:hover { background: rgba(124, 140, 248, 0.18); }
.mv:active { transform: scale(0.96); }
.mv.ghost { border-color: var(--line); color: var(--dim); }
.mv small { color: var(--dim); }
.readout {
  margin-top: 0.6rem;
  background: #0a0c18;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  width: 100%;
}
.readout strong { color: var(--gold); font-family: ui-monospace, Menlo, monospace; }
#moveSeq { font-family: ui-monospace, Menlo, monospace; color: var(--indigo); }

/* triangle svg pieces */
.tri-outline { fill: none; stroke: rgba(255,255,255,0.25); stroke-width: 2; }
.home-ring { fill: none; stroke: rgba(255,255,255,0.18); stroke-width: 1.5; stroke-dasharray: 5 6; }
.dot { transition: transform 0.55s cubic-bezier(0.5, 0, 0.2, 1); }
.dot circle { stroke: rgba(0,0,0,0.5); stroke-width: 2; }
.dot text { font: 700 20px Georgia, serif; fill: #0a0c18; text-anchor: middle; dominant-baseline: central; }

/* ---------- axioms ---------- */
.axioms { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
@media (max-width: 720px) { .axioms { grid-template-columns: 1fr; } }
.axiom {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
}
.axiom h4 { margin: 0 0 0.5rem; color: var(--gold); }
.axiom p { margin: 0.4rem 0; font-size: 0.95rem; }
.chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0; }
.chip-row button {
  cursor: pointer;
  background: #0a0c18;
  color: var(--indigo);
  border: 1px solid var(--indigo);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.95rem;
}
.chip-row button:hover { background: rgba(124, 140, 248, 0.15); }

/* ---------- cayley table ---------- */
.table-layout { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 1.6rem; align-items: start; margin-top: 1.2rem; }
@media (max-width: 720px) { .table-layout { grid-template-columns: 1fr; } }
.cayley-wrap { overflow-x: auto; }
.cayley { border-collapse: collapse; margin: 0 auto; }
.cayley th, .cayley td {
  border: 1px solid var(--line);
  width: 52px; height: 44px;
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.95rem;
}
.cayley th { background: var(--bg2); color: var(--gold); }
.cayley td { cursor: pointer; color: var(--dim); background: var(--card); transition: background 0.15s; }
.cayley td:hover { background: rgba(242, 193, 78, 0.12); }
.cayley td.known { color: var(--ink); }
.cayley td.rot { color: var(--gold); }
.cayley td.ref { color: var(--indigo); }
.table-tools { display: flex; gap: 0.7rem; align-items: center; margin-top: 0.8rem; flex-wrap: wrap; font-size: 0.9rem; }

/* ---------- solvability ---------- */
.solv-card .tower { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.8rem 0; }
.solv-card .piece {
  background: #0a0c18;
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9rem;
}
.solv-card .piece.block { border-color: var(--rose); color: var(--rose); animation: pulse 1.6s infinite; }
.solv-card .arrow { color: var(--dim); }
.solv-card .verdict { font-weight: 700; margin-top: 0.6rem; }
.solv-card .verdict.yes { color: var(--green); }
.solv-card .verdict.no { color: var(--rose); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(242,126,169,0.5);} 50% { box-shadow: 0 0 0 6px rgba(242,126,169,0);} }

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.85rem;
}
