/* ── Reset & base ─────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Georgia', serif;
  color: #fff;
  cursor: crosshair;
}

/* ── Mandelbrot canvas ────────────────────────────────────────────────────── */
#mandelbrot-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ── Non-interactive UI overlay ───────────────────────────────────────────── */
#ui-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#title-bar {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.8s;
}

#title-bar h1 {
  font-size: 2em;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  font-weight: 400;
}

#title-equation {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,0.28);
}

#hint {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  opacity: 1;
  transition: opacity 1s;
  pointer-events: none;
}

#zoom-hint {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.22);
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
}
#zoom-hint.visible { opacity: 1; }

#crosshair {
  position: fixed;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s;
}
#crosshair.visible { opacity: 1; }

#button-row {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

/* ── Reset button ─────────────────────────────────────────────────────────── */
#reset-btn {
  position: static;
  z-index: 10;
  background: rgba(255,255,255,0.18);
  border: 0.5px solid rgba(255,255,255,0.7);
  color: rgba(255,255,255,0.95);
  padding: 8px 18px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.6s, background 0.2s;
  pointer-events: none;
  font-family: 'Georgia', serif;
}
#reset-btn.visible { opacity: 1; pointer-events: all; }
#reset-btn:hover   { background: rgba(255,255,255,0.28); }

/* ── Back button ─────────────────────────────────────────────────────────── */
#back-btn {
  position: static;
  z-index: 10;
  background: rgba(255,255,255,0.18);
  border: 0.5px solid rgba(255,255,255,0.7);
  color: rgba(255,255,255,0.95);
  padding: 8px 18px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.6s, background 0.2s;
  pointer-events: none;
  font-family: 'Georgia', serif;
}
#back-btn.visible { opacity: 1; pointer-events: all; }
#back-btn:hover   { background: rgba(255,255,255,0.28); }

/* ── Shared panel-icon style ──────────────────────────────────────────────── */
.panel-icon {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  border: 0.5px solid rgba(100,160,255,0.25);
  background: rgba(100,160,255,0.06);
  color: rgba(150,190,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.panel-icon:hover {
  background: rgba(100,160,255,0.18);
  color: rgba(200,220,255,1);
}

/* ── Graph panel ──────────────────────────────────────────────────────────── */
#graph-panel {
  position: fixed;
  width: 440px;
  height: 420px;
  background: rgba(4,6,14,0.93);
  border: 0.5px solid rgba(100,160,255,0.2);
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
  overflow: hidden;
  z-index: 10;
  cursor: default;
}
#graph-panel.bottom-right { bottom: 24px; right: 24px; }
#graph-panel.bottom-left  { bottom: 24px; left: 24px; }

#panel-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px 0;
}

#graph-canvas {
  width: 440px;
  height: 290px;
  display: block;
}

/* ── LaTeX area ───────────────────────────────────────────────────────────── */
#latex-area,
#fs-latex-area {
  padding: 6px 16px 10px;
  font-size: 15px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-top: 0.5px solid rgba(100,160,255,0.12);
  gap: 0;
  transition: opacity 0.15s;
}

#fs-latex-area {
  font-size: 18px;
  text-align: center;
  align-items: center;
  margin-top: 20px;
  border-top: none;
  min-height: 80px;
}

@keyframes latexSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes latexSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}
@keyframes latexFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.latex-slide-out {
  animation: latexSlideOut var(--latex-dur, 120ms) ease-in forwards;
}
.latex-slide-in {
  animation: latexSlideIn var(--latex-dur, 120ms) ease-out forwards;
}
.latex-fade-in {
  animation: latexFadeIn var(--latex-dur, 120ms) ease-out forwards;
}

.latex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

#latex-area .katex-display,
#fs-latex-area .katex-display {
  margin: 0.15em 0;
}

.katex, .katex * { color: inherit !important; }
.katex { font-variant-numeric: tabular-nums; }
#latex-area   .katex-display { margin: 0.15em 0; }
#fs-latex-area .katex-display { margin: 0.15em 0; }
#title-bar     .katex { font-size: 2.5em; }

/* ── Fullscreen overlay ───────────────────────────────────────────────────── */
#fs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,4,12,0.97);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: all;
  cursor: default;
}
#fs-overlay.visible { display: flex; }

#fs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 900px;
  padding: 0 0 8px;
}

#fs-toolbar-right {
  display: flex;
  gap: 6px;
}

#fs-graph-canvas {
  border: 0.5px solid rgba(100,160,255,0.15);
  border-radius: 3px;
}

/* ── Max-depth screen ─────────────────────────────────────────────────────── */
#depth-screen {
  position: fixed;
  inset: 0;
  background: rgba(2,4,12,0.0);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 150;
  transition: background 1.2s;
  cursor: default;
}
#depth-screen.active { display: flex; }
#depth-screen.shown  { background: rgba(2,4,12,0.95); }

#depth-content {
  max-width: 680px;
  text-align: center;
  padding: 40px 32px;
  opacity: 0;
  transition: opacity 1s 0.6s;
}
#depth-screen.shown #depth-content { opacity: 1; }

#depth-content h2 {
  font-size: 14px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(100,160,255,0.6);
  font-weight: 400;
  margin-bottom: 28px;
}

#depth-content p {
  font-size: 14px;
  line-height: 1.9;
  color: rgba(200,215,255,0.62);
  margin-bottom: 20px;
}
#depth-content p em { color: rgba(180,200,255,0.85); font-style: italic; }

#precision-anim {
  margin-top: 28px;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#precision-anim .katex { font-size: 1em; }

.depth-reset {
  margin-top: 36px;
  display: inline-block;
  background: rgba(255,255,255,0.06);
  border: 0.5px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.65);
  padding: 9px 22px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: 'Georgia', serif;
  transition: background 0.2s;
}
.depth-reset:hover { background: rgba(255,255,255,0.12); }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 1.2s;
  pointer-events: none;
  z-index: 300;
}
#loading-overlay.hidden { opacity: 0; }

.load-text {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}

/* ── Mobile layout (≤ 600px wide) ────────────────────────────────────────── */
@media (max-width: 600px) {
  #title-bar h1 {
    font-size: 1.1em;
  }
  #graph-panel {
    width: 100vw !important;
    height: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  #graph-panel.bottom-right,
  #graph-panel.bottom-left {
    bottom: 0;
    left: 0;
    right: 0;
  }
  #graph-canvas {
    width: 100vw !important;
  }
  #latex-area {
    padding: 4px 10px 8px;
    font-size: 13px;
  }
  #fs-graph-canvas {
    width: calc(100vw - 32px) !important;
  }
  #reset-btn {
    padding: 6px 12px;
    font-size: 10px;
  }

  #panel-toolbar-desktop-icons {
    display: none;
  }

  #fs-toolbar-desktop-icons {
    display: none;
  }
  #fs-minimise-btn {
    display: none;
  }
  #fs-toolbar {
    max-width: calc(100vw - 32px);
  }
}

/* ── Show Orbit CTA button ────────────────────────────────────────────────── */
#show-graph-btn {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 10;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s, transform 0.6s;
  display: block;
}

#show-graph-btn.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.show-graph-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 26px 13px 20px;
  background: rgba(6, 10, 24, 0.82);
  border: 0.5px solid rgba(100, 170, 255, 0.55);
  border-radius: 40px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.2s, border-color 0.2s;
}

#show-graph-btn:active .show-graph-inner {
  background: rgba(20, 35, 70, 0.9);
  border-color: rgba(140, 200, 255, 0.8);
}

.show-graph-icon {
  color: rgba(120, 200, 255, 0.9);
  flex-shrink: 0;
}

.show-graph-label {
  font-family: 'Georgia', serif;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(200, 225, 255, 0.92);
  white-space: nowrap;
}

.show-graph-glow {
  position: absolute;
  inset: -1px;
  border-radius: 40px;
  background: transparent;
  border: 1px solid rgba(80, 160, 255, 0.0);
  animation: graphBtnPulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes graphBtnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(80,160,255,0.0); border-color: rgba(80,160,255,0.0); }
  40%  { box-shadow: 0 0 18px 4px rgba(80,160,255,0.18); border-color: rgba(80,160,255,0.3); }
  70%  { box-shadow: 0 0 28px 8px rgba(80,160,255,0.10); border-color: rgba(80,160,255,0.15); }
  100% { box-shadow: 0 0 0 0 rgba(80,160,255,0.0); border-color: rgba(80,160,255,0.0); }
}


