/* ======================================================
   AS ABOVE — COSMIC DESIGN SYSTEM
   Deep navy-black background, gold accent, crimson affliction
   Typography: Cormorant Garamond (headings) + DM Sans (body) + Space Mono (technical)
   ====================================================== */

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

/* ── Custom Properties ────────────────────────────── */
:root {
  --bg:           #0a0a12;
  --bg-mid:       #0e0d18;
  --bg-card:      #12111a;
  --paper:        #e8e4d9;
  --paper-dim:    #b8b4a8;
  --stone:        #7a7065;
  --gold:         #c9a84c;
  --gold-dim:     #8a7340;
  --crimson:      #8b1a1a;
  --crimson-glow: #c44040;
  --teal:         #4a7c7c;
  --border:       #1e1d28;
  --border-lit:   #3a3848;

  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'Space Mono', monospace;
}

/* ── Global Reset ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
}

/* ── Body — Cosmic Observatory ───────────────────── */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--paper);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  /* Radial purple vignette */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(40, 20, 80, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(20, 10, 50, 0.15) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ── Star Field ──────────────────────────────────── */
/* CSS-only star field: box-shadow stars + pseudo-element gradient */
.star-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star-field::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    /* Tiny stars via box-shadow */
    radial-gradient(1px 1px at 12% 14%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 28% 9%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 44% 67%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 61% 23%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 78% 44%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 93% 8%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 7% 88%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 19% 51%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 76%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 52% 31%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 68% 91%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 56%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 4% 33%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 17% 77%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 31% 4%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 56% 88%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 73% 19%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 89% 71%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 48% 22%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(2px 2px at 82% 38%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(2px 2px at 23% 63%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(2px 2px at 67% 82%, rgba(255,255,255,0.2) 0%, transparent 100%);
  background-size: 100% 100%;
  animation: starParallax 60s linear infinite;
}

@keyframes starParallax {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

/* ── Grain Texture Overlay ────────────────────────── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ── Custom Scrollbar ────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  background: #0a0a12;
}
::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* ── Constellation Lines Overlay ──────────────────── */
#constellation-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* ── Shooting Stars ──────────────────────────────── */
.shooting-star {
  position: fixed;
  width: 120px;
  height: 1px;
  pointer-events: none;
  z-index: 3;
  transform-origin: left center;
  animation: shootAcross linear forwards;
}

.shooting-star::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.9), white);
  border-radius: 50%;
  box-shadow: 0 0 6px 2px rgba(255,255,255,0.4);
}

@keyframes shootAcross {
  0%   { opacity: 0; transform: translateX(0) scaleX(0); }
  5%   { opacity: 1; transform: translateX(0) scaleX(1); }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(800px) scaleX(0.3); }
}

/* ── Loading State ────────────────────────────────── */
.loading-state {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  animation: loadingFadeOut 0.5s ease 1.5s forwards;
}

.loading-constellation {
  width: 60px;
  height: 60px;
}

.loading-constellation svg {
  animation: drawLine 1.2s ease forwards;
}

@keyframes drawLine {
  from { stroke-dashoffset: 100; opacity: 0; }
  to   { stroke-dashoffset: 0; opacity: 1; }
}

.loading-text {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--stone);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

@keyframes loadingFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* ── Staggered Page Load ──────────────────────────── */
.fade-in-item {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp var(--dur, 0.4s) ease var(--delay, 0s) forwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Angel Numbers ────────────────────────────────── */
.angel-number {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  font-family: var(--font-mono);
  font-size: 11px;
  font-style: italic;
  color: var(--paper);
  opacity: 0;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.8s ease;
  letter-spacing: 0.05em;
}

.angel-number.visible {
  opacity: 0.4;
  animation: angelFadeOut 6s ease forwards;
}

@keyframes angelFadeOut {
  0%, 70% { opacity: 0.4; }
  100%     { opacity: 0; }
}

/* ── Store Modal Flash ────────────────────────────── */
#store-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 18, 0.92);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#store-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.store-modal-text {
  font-family: var(--font-heading);
  font-size: 5rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--paper);
  animation: storeModalZoom 1.5s ease forwards;
}

@keyframes storeModalZoom {
  0%   { transform: scale(0.6); opacity: 0; }
  30%  { transform: scale(1.1); opacity: 1; }
  60%  { transform: scale(1); }
  90%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Affliction Count Panel ───────────────────────── */
.affliction-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
}

.affliction-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--stone);
  transition: color 0.5s ease;
}

.affliction-count.has-afflictions { color: var(--crimson-glow); }
.affliction-count.zero { color: var(--teal); }

.affliction-bar {
  display: flex;
  gap: 4px;
}

.affliction-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.5s ease;
}

.affliction-dot.active { background: var(--crimson); animation: dotPulse 2s ease-in-out infinite; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; box-shadow: 0 0 6px var(--crimson-glow); }
}

/* ── Tooltip ──────────────────────────────────────── */
.affliction-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-lit);
  padding: 0.8rem 1rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--paper-dim);
  max-width: 220px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 20;
  border-radius: 2px;
}

.affliction-tooltip.visible { opacity: 1; }

/* ── Common Button Styles ─────────────────────────── */
.btn-primary {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--gold);
  padding: 0.9rem 2.4rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-outline {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper);
  background: transparent;
  padding: 0.9rem 2.4rem;
  text-decoration: none;
  border: 1px solid var(--border-lit);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.btn-outline:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.08);
  transform: translateY(-2px);
}

.btn-outline:active {
  transform: scale(0.97);
}

/* ── Breadcrumb / Label styles ────────────────────── */
.page-label {
  font-family: var(--font-body);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--stone);
}

.page-title {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.1;
  color: var(--paper);
}

.section-rule {
  width: 40px;
  height: 1px;
  background: var(--border-lit);
  margin: 2rem auto;
}

/* ── Card base ────────────────────────────────────── */
.cosmic-card {
  border: 1px solid var(--border);
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.cosmic-card:hover {
  border-color: var(--gold-dim);
  background: var(--bg-card);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ── Reading Progress Bar ─────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--gold);
  z-index: 50;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.4);
}

/* ── Cursor Trail ─────────────────────────────────── */
#cursor-trail {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.2s ease;
}

/* ── Wheel specific ──────────────────────────────── */
.wheel-center-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.3s ease, border-color 0.3s ease;
  animation: breathingPulse 3s ease-in-out infinite;
  z-index: 10;
}

.wheel-center-btn:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold);
}

@keyframes breathingPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%       { transform: translate(-50%, -50%) scale(1.03); }
}

/* ── Reduced motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .star-field::before { animation: none; }
  .shooting-star { display: none; }
  .grain { display: none; }
  .wheel-center-btn { animation: none; }
}