/* Crystal Pass — diiverge-mini */

:root {
  --bg: #07070e;
  --panel: rgba(14, 14, 28, 0.82);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #7dd3fc;
  --hotspot: rgba(125, 211, 252, 0.85);
  --hotspot-glow: rgba(125, 211, 252, 0.35);
  --radius: 14px;
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 1fr 300px;
  height: 100vh;
  height: 100dvh;
}

/* ——— Main stage ——— */
.stage {
  position: relative;
  overflow: hidden;
  background: #05050c;
  min-width: 0;
}

.scene-stack {
  position: absolute;
  inset: 0;
}

.scene-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
  pointer-events: none;
}

.scene-layer.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  z-index: 2;
}

.scene-layer.leaving {
  opacity: 0;
  transform: scale(0.97);
  z-index: 1;
}

.scene-art {
  flex: 1;
  position: relative;
  min-height: 0;
}

.scene-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hotspot {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 40% 35%,
    rgba(255,255,255,0.95) 0%,
    var(--hotspot) 35%,
    transparent 70%);
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.35),
    0 0 24px 6px var(--hotspot-glow);
  animation: pulse 2.4s ease-in-out infinite;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
  z-index: 5;
}

.hotspot::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(8, 8, 18, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.hotspot:hover,
.hotspot:focus-visible {
  transform: scale(1.18);
  outline: none;
  animation: none;
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.5),
    0 0 32px 10px var(--hotspot-glow);
}

.hotspot:hover::after,
.hotspot:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.3), 0 0 18px 4px var(--hotspot-glow); }
  50% { box-shadow: 0 0 0 2px rgba(255,255,255,0.5), 0 0 28px 10px var(--hotspot-glow); }
}

.scene-chrome {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.25rem 1.5rem 1.5rem;
  background: linear-gradient(transparent, rgba(5,5,12,0.92) 40%);
  z-index: 4;
  pointer-events: none;
}

.scene-chrome h1 {
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.scene-chrome p {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 36rem;
  line-height: 1.45;
}

.top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(rgba(5,5,12,0.75), transparent);
  pointer-events: none;
}

.brand {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(226,232,240,0.7);
}

.brand span { color: var(--accent); }

.top-actions {
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: rgba(30, 30, 55, 0.95);
  border-color: rgba(148, 163, 184, 0.35);
}

.btn-danger:hover {
  border-color: rgba(251, 113, 133, 0.5);
  color: #fda4af;
}

/* Generating flash (mock) */
.gen-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,12,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.gen-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.gen-chip {
  font-family: var(--font-display);
  font-size: 0.95rem;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  background: rgba(14,14,28,0.9);
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--accent);
  letter-spacing: 0.03em;
  animation: shimmer 1s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ——— Side panel: branch map ——— */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  min-height: 0;
}

.panel-header {
  padding: 1.15rem 1.15rem 0.75rem;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 550;
  margin-bottom: 0.25rem;
}

.panel-header p {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.branch-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.branch-card {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  background: rgba(8, 8, 18, 0.55);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.branch-card:hover {
  border-color: rgba(125, 211, 252, 0.35);
  background: rgba(12, 20, 36, 0.7);
}

.branch-card.current {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.15);
}

.branch-card .branch-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.branch-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.branch-node {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  white-space: nowrap;
}

.branch-node.terminal {
  background: rgba(125, 211, 252, 0.18);
  color: var(--accent);
}

.branch-arrow {
  color: var(--muted);
  font-size: 0.65rem;
  opacity: 0.6;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.5rem 0.25rem;
}

.panel-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--panel-border);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

/* Mobile */
@media (max-width: 820px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr min(38vh, 280px);
  }
  .panel {
    border-left: none;
    border-top: 1px solid var(--panel-border);
  }
  .hotspot::after {
    font-size: 0.7rem;
    max-width: 10rem;
    white-space: normal;
    text-align: center;
  }
}

.brand a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(125, 211, 252, 0.35);
}
.brand a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.mini-tag {
  margin-left: 0.35rem;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: middle;
}
.panel-header a, .panel-footer a {
  color: var(--accent);
  text-decoration: none;
}
.panel-header a:hover, .panel-footer a:hover { text-decoration: underline; }
.panel-header p + p { margin-top: 0.65rem; }
.panel-header h2 + p { margin-top: 0.35rem; }
.panel-header h2 { margin-top: 0.9rem; }
.panel-header h2:first-child { margin-top: 0; }
