/* Sphere Packing Breakthrough — Visual Guide Styles */
/* Design system: deep navy background, gold (construction) + cyan (barrier) accents */

:root {
  --bg-primary: #0d1b2a;
  --bg-secondary: #1b263b;
  --bg-card: #162436;
  --accent-gold: #e6b800;
  --accent-cyan: #00d4ff;
  --accent-red: #c43d3d;
  --accent-green: #5cb85c;
  --text-primary: #e0e1dd;
  --text-secondary: #a0a0a0;
  --text-muted: #6c7a8c;
  --subtle: #415a77;
  --max-width: 1200px;
  --text-col: 680px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.125rem;
  line-height: 1.65;
  overflow-x: hidden;
}

/* --- Layout --- */

.guide-header {
  text-align: center;
  padding: 6rem 2rem 4rem;
  background: linear-gradient(180deg, #0a1520 0%, var(--bg-primary) 100%);
}

.guide-header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.2;
  max-width: 900px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.guide-header .subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

.guide-header .source-link {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--subtle);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: border-color 0.3s, color 0.3s;
}

.guide-header .source-link:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 4rem 2rem;
  position: relative;
  border-bottom: 1px solid rgba(65, 90, 119, 0.2);
}

section:nth-child(even) {
  background: var(--bg-secondary);
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 3rem;
  align-items: center;
}

.section-number {
  position: absolute;
  top: 2rem;
  left: 2rem;
  font-size: 5rem;
  font-weight: 800;
  color: rgba(65, 90, 119, 0.12);
  line-height: 1;
  pointer-events: none;
}

.section-text h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  line-height: 1.25;
}

.section-text h2 .accent-cyan { color: var(--accent-cyan); }
.section-text h2 .accent-gold { color: var(--accent-gold); }

.section-text p {
  margin-bottom: 1.2rem;
  color: var(--text-primary);
}

.section-text p.caption {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

.section-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.section-text .key-takeaway {
  margin-top: 2rem;
  padding: 1rem 1.5rem;
  background: rgba(0, 212, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
  border-radius: 0 4px 4px 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.section-text .key-takeaway.gold {
  background: rgba(230, 184, 0, 0.08);
  border-left-color: var(--accent-gold);
}

.section-text .caveat {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--subtle);
}

.section-text .formula-display {
  font-family: 'STIX Two Math', 'Cambria Math', serif;
  font-size: 1.5rem;
  text-align: center;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--subtle);
}

.section-text .formula-display .label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* --- Visual Area --- */

.visual-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

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

/* --- Visual Elements --- */

.barrier-line {
  stroke: var(--accent-cyan);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
}

.barrier-label {
  fill: var(--accent-cyan);
  font-size: 1.5rem;
  font-weight: 700;
  text-anchor: middle;
}

.approach-cyan {
  stroke: var(--accent-cyan);
  stroke-width: 2.5;
  fill: none;
}

.approach-gold {
  stroke: var(--accent-gold);
  stroke-width: 2.5;
  fill: none;
}

.heat-map-cell {
  transition: opacity 0.6s ease;
}

/* --- Two Halves Meet --- */

.two-halves {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.two-halves .arrow-label {
  font-size: 0.9rem;
  text-align: center;
  max-width: 250px;
}

.two-halves .arrow-label.cyan { color: var(--accent-cyan); }
.two-halves .arrow-label.gold { color: var(--accent-gold); }

.two-halves .barrier-bar {
  width: 300px;
  height: 4px;
  background: var(--accent-cyan);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.6);
  position: relative;
}

.two-halves .barrier-bar::after {
  content: '1/π';
  position: absolute;
  left: 50%;
  top: -2rem;
  transform: translateX(-50%);
  color: var(--accent-cyan);
  font-size: 1.75rem;
  font-weight: 800;
}

/* --- Heat Maps --- */

.heat-maps {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.heat-map {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--subtle);
}

.heat-map .map-label {
  position: absolute;
  bottom: -1.8rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.heat-map .ink-counter {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(13, 27, 42, 0.8);
  padding: 2px 6px;
  border-radius: 3px;
}
/* --- Screen Reader Only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- Coordinate Ladder --- */
#coordinate-ladder {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: #111a26;
  border: 1px solid #1b263b;
  border-radius: 12px;
  padding: 1.5rem;
}


#coordinate-equation {
  margin: 0;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'STIX Two Math', 'Cambria Math', serif;
  font-size: 1.5rem;
  text-align: center;
}

#coordinate-inequality {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}
.ladder-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0b131e;
  border-radius: 8px;
  padding: 0.5rem;
  position: relative;
}

.ladder-controls::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 1rem;
  right: 1rem;
  height: 2px;
  background: #1b263b;
  z-index: 0;
  transform: translateY(-50%);
}

.dimension-step {
  position: relative;
  z-index: 1;
  background: #162436;
  color: #a0a0a0;
  border: 2px solid #1b263b;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dimension-step:hover {
  background: #1b263b;
  border-color: var(--accent-cyan);
  color: #e0e1dd;
}

.dimension-step[aria-pressed="true"] {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #0b131e;
  transform: scale(1.1);
}

.dimension-step:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
}

.ladder-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 380px;
}

.dimension-visual {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 1rem;
  background: #0b131e;
  border: 1px solid #1b263b;
  border-radius: 8px;
}

.dimension-visual[hidden] {
  display: none;
}

.dimension-visual > svg {
  width: 100%;
  max-width: 300px;
  height: auto;
}

#coordinate-description {
  color: #a0a0a0;
  font-size: 0.95rem;
  text-align: center;
}

/* Keep this a class, not an id: .dimension-visual[hidden] has to outrank it so
   the panel stays hidden until 4D is selected. An id would win instead and
   leave the slice on screen under every dimension. */
.slice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #0b131e;
  border-radius: 8px;
  border: 1px solid #1b263b;
}

.slice-intro {
  max-width: 30rem;
  margin: 0;
  color: #e0e1dd;
  font-size: 0.95rem;
  text-align: center;
}

.slice-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 280px;
  gap: 0.5rem;
}

.slice-controls label {
  color: #e0e1dd;
  font-size: 0.9rem;
  font-weight: 500;
}

.slice-radius-text {
  color: #a0a0a0;
  font-size: 0.85rem;
  margin: 0;
}

.slice-controls input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

.slice-controls input[type="range"]:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
  border-radius: 2px;
}

.slice-controls input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: #1b263b;
  border-radius: 3px;
}

.slice-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  margin-top: -7px;
  cursor: pointer;
  border: none;
}

.slice-controls input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: #1b263b;
  border-radius: 3px;
}

.slice-controls input[type="range"]::-moz-range-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: none;
}

#four-d-slice-graphic {
  width: 100%;
  max-width: 260px;
  height: auto;
}


.beyond-four-panel {
  border-top: 1px dashed #415a77;
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.beyond-four-panel h3 {
  color: #e0e1dd;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.beyond-four-panel p {
  color: #a0a0a0;
  font-size: 0.95rem;
}
/* --- Gaussian / Curve --- */

.gaussian-curve {
  stroke: var(--accent-gold);
  stroke-width: 2.5;
  fill: none;
}

.target-marker {
  stroke: var(--accent-cyan);
  stroke-width: 2;
  stroke-dasharray: 4 4;
}

.current-marker {
  stroke: var(--text-secondary);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

/* --- Failure Visual --- */

.failure-crack {
  stroke: var(--accent-red);
  stroke-width: 2;
  fill: none;
}

.blowup-spike {
  fill: var(--accent-red);
  opacity: 0.8;
}

/* --- Remote Shell --- */

.remote-shell-bracket {
  stroke: var(--accent-green);
  stroke-width: 3;
  fill: none;
}

.wobble {
  stroke: var(--accent-red);
  stroke-width: 2;
  fill: none;
  opacity: 0.7;
}

/* --- Chart (0.6044) --- */

.exponent-chart {
  width: 100%;
  max-width: 500px;
}

.chart-axis {
  stroke: var(--text-muted);
  stroke-width: 1;
}

.chart-line-old {
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 5 5;
}

.chart-line-new {
  stroke: var(--accent-gold);
  stroke-width: 2.5;
  fill: none;
}

.chart-label {
  fill: var(--text-secondary);
  font-size: 0.75rem;
}

/* --- Lean Verification Flow --- */

.lean-flow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.lean-box {
  padding: 0.8rem 1rem;
  border-radius: 6px;
  text-align: center;
  font-size: 0.85rem;
  min-width: 120px;
  border: 1px solid var(--subtle);
  background: var(--bg-card);
}

.lean-box.verified {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.lean-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* --- Three Columns (Epilogue) --- */

.three-columns {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.epilogue-column {
  flex: 1;
  min-width: 200px;
  max-width: 280px;
  padding: 1.5rem;
  border-radius: 8px;
  background: var(--bg-card);
}

.epilogue-column.known { border-top: 3px solid var(--accent-green); }
.epilogue-column.observable { border-top: 3px solid var(--accent-gold); }
.epilogue-column.unknown { border-top: 3px solid var(--accent-red); }

.epilogue-column h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.epilogue-column.known h3 { color: var(--accent-green); }
.epilogue-column.observable h3 { color: var(--accent-gold); }
.epilogue-column.unknown h3 { color: var(--accent-red); }

.epilogue-column ul {
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.8;
}

.epilogue-column ul li::before {
  content: '• ';
  color: var(--text-muted);
}

.epilogue-column.unknown ul li::before {
  content: '? ';
  color: var(--accent-red);
}

/* --- Progressive Disclosure --- */

.disclose-trigger {
  display: inline-block;
  color: var(--accent-cyan);
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px dotted var(--accent-cyan);
  margin: 0.5rem 0;
  user-select: none;
}

.disclose-content {
  display: none;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 6px;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--subtle);
}

.disclose-content.visible { display: block; }

/* --- Transition Cues --- */

.transition-cue {
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Scroll Animations --- */

.fade-in {
  opacity: 1;
}

.barrier-emerge {
  opacity: 1;
}

/* --- Footer --- */

.guide-footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--subtle);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.guide-footer a {
  color: var(--accent-cyan);
  text-decoration: none;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .section-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .visual-area { order: -1; min-height: 300px; }

  .heat-maps { flex-direction: column; gap: 2.5rem; }

  .three-columns { flex-direction: column; align-items: center; }

  .epilogue-column { max-width: 100%; }

  .lean-flow { flex-direction: column; }

  .lean-arrow { transform: rotate(90deg); }

  section { padding: 3rem 1rem; }

  .section-number { font-size: 3rem; }
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  .fade-in, .barrier-emerge {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .dimension-step,
  #four-d-slice-ball,
  #four-d-w-marker {
    transition: none;
  }

  html { scroll-behavior: auto; }
}