@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300&family=JetBrains+Mono:wght@300;400&display=swap');

:root {
  --bg: #05060a;
  --ink: #e8e4d8;
  --ink-dim: #8a8578;
  --ink-faint: #4a473e;
  --accent: #d4a574;
  --rule: rgba(232, 228, 216, 0.12);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cormorant Garamond', serif;
  overflow: hidden;
  height: 100%;
  width: 100%;
  cursor: grab;
}
body:active { cursor: grabbing; }

#scene { display: block; position: absolute; inset: 0; }

.vignette {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none; z-index: 2;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  opacity: 0.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.masthead {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 28px 40px 0;
  z-index: 10;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.masthead > * { pointer-events: auto; }

.wordmark {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1.4;
}
.wordmark strong { color: var(--ink); font-weight: 400; }

.plate {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1.6;
}
.plate .coord { color: var(--ink-faint); margin-top: 4px; }

.title-block {
  position: fixed; top: 18%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; z-index: 5;
  pointer-events: none;
  transition: opacity 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.title-block.faded { opacity: 0; }
.title-block h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(36px, 7vw, 100px);
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 0.9;
  color: var(--ink);
  text-shadow: 0 0 60px rgba(212, 165, 116, 0.15);
}
.footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 24px 40px 28px;
  z-index: 10;
  display: flex; justify-content: space-between; align-items: flex-end;
  pointer-events: none;
}
.footer > * { pointer-events: auto; }

.legend {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1.8;
  max-width: 280px;
}
.legend .key {
  display: inline-flex; align-items: center; gap: 8px;
  margin-right: 16px;
}
.legend .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.controls { display: flex; gap: 12px; }
.btn {
  background: rgba(5, 6, 10, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  color: var(--ink-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 14px 20px;
  cursor: pointer;
  transition: color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
  display: inline-flex; align-items: center; gap: 10px;
}
.btn:hover { color: var(--ink); border-color: rgba(232, 228, 216, 0.25); }
.btn.primary {
  color: var(--accent);
  border-color: rgba(212, 165, 116, 0.3);
}
.btn.primary:hover {
  background: rgba(212, 165, 116, 0.1);
  color: var(--accent);
}
.btn .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.35;
  transition: opacity 0.3s ease;
}
.btn.active .dot { opacity: 1; }
.btn.active { color: var(--ink); }

/* Starcard layout:
     .starcard-info = 'a' segment at 475px (existing card scaled 25%).
     .starcard-star = 'b' segment at ~294px, where a/b = φ (golden ratio).
   Total width: 769px. */
.starcard {
  position: fixed;
  bottom: 120px; left: 40px;
  width: 769px;
  max-width: 769px;
  z-index: 9;
  background: rgba(5, 6, 10, 0.82);
  backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  display: flex;
  align-items: stretch;
}
.starcard.visible { opacity: 1; transform: translateY(0); }
.starcard-info {
  flex: 0 0 475px;
  padding: 25px 30px;
  /* Opaque background so a supergiant's glow (which sits at z-index: -1)
     is hidden wherever it bleeds behind the 'a' text column. */
  background: var(--bg);
}
.starcard-star {
  flex: 0 0 294px;
  position: relative;
  padding: 22px;
  border-left: 1px solid var(--rule);
  /* Allow the canvas to overflow in all four directions. The 'a' column
     covers the leftward bleed via its opaque bg and the canvas's negative
     z-index; top/right/bottom bleed out past the card against the scene. */
  overflow: visible;
}
#sc-star-canvas {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: 250px;
  height: 250px;
  z-index: -1;
}
.starcard .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.starcard h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 42px;
  font-weight: 300;
  font-style: italic;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 18px;
}
.starcard .greek {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  color: var(--ink-dim);
  font-style: italic;
  margin-left: 10px;
}
.starcard dl {
  display: grid;
  grid-template-columns: 125px 1fr;
  gap: 5px 15px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.starcard dt { color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.15em; }
.starcard dd { color: var(--ink); }
.starcard p {
  margin-top: 18px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-dim);
  font-style: italic;
}

.sc-story-link {
  display: inline-block;
  margin-top: 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 165, 116, 0.25);
  padding-bottom: 4px;
  transition: color 0.3s ease, border-color 0.3s ease;
  /* Starcard itself has pointer-events: none so it doesn't block the
     raycaster — explicitly re-enable pointer events on the link. */
  pointer-events: auto;
}
.sc-story-link:hover {
  color: var(--ink);
  border-color: rgba(232, 228, 216, 0.45);
}

.hint {
  position: fixed; bottom: 95px; left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  z-index: 6;
  pointer-events: none;
  animation: pulse 3s ease-in-out infinite;
  transition: opacity 0.8s ease;
  text-align: center;
}
.hint.hidden { opacity: 0; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

@media (max-width: 640px) {
  .masthead, .footer { padding-left: 20px; padding-right: 20px; }
  .starcard {
    left: 20px; right: 20px; bottom: 160px;
    width: auto; max-width: none;
    flex-direction: column;
  }
  .starcard-info, .starcard-star { flex: 0 0 auto; }
  .starcard-star { border-left: none; border-top: 1px solid var(--rule); }
  .footer { flex-direction: column; align-items: stretch; gap: 16px; }
  .controls { justify-content: flex-end; }
  .legend { max-width: none; }
}
