/* ═══════════════════════════════════════════════════════════
   VOID — THE EXPERIENCE
   A music portal born from absolute darkness.
   
   Architecture:
   - Layer 0: Canvas (z:0)     — Lightning, particles, orb
   - Grain:   SVG overlay (z:1) — Analog texture
   - Layer 1: Gate (z:10)      — Entry experience
   - Layer 2: Experience (z:20) — Player HUD, navigation
   ═══════════════════════════════════════════════════════════ */

/* ───────────────────── TOKENS ───────────────────── */
:root {
  --void: #000000;
  --void-surface: #060606;
  --void-elevated: #0c0c0c;

  --accent: #E8E0D5;
  --accent-50: rgba(232, 224, 213, 0.5);
  --accent-20: rgba(232, 224, 213, 0.2);
  --accent-10: rgba(232, 224, 213, 0.1);
  --accent-05: rgba(232, 224, 213, 0.05);
  --accent-glow: rgba(232, 224, 213, 0.08);

  --text-1: #F5F0EB;
  --text-2: #9A9490;
  --text-3: #4A4540;

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Audio-reactive (updated from JS every frame) */
  --intensity: 0;
  --bass: 0;
  --onset: 0; /* 0-1 contínuo: intensidad del transiente actual */
}

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

html, body {
  width: 100%; 
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--void);
  color: var(--text-1);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: default;
  user-select: none;
}

a { text-decoration: none; color: inherit; }
button { background: none; border: none; cursor: pointer; font: inherit; color: inherit; outline: none; }

/* ───────────────────── LAYER 0: CANVAS ───────────────────── */
#void-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  transition: opacity 1.2s var(--ease-out);
}

/* When video mode is active, fade out canvas */
body.video-mode #void-canvas {
  opacity: 0;
}

/* ───────────────────── LAYER 0.3: VIDEO BACKDROP ───────────────────── */
.video-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1; /* Above canvas, below grain/logo */
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s var(--ease-out);
}

body.video-mode .video-backdrop {
  opacity: 1;
  /* Cinematic Enhancement Filter Chain
     Inspired by Instagram/TikTok HDR processing:
     - brightness(1.05): subtle luminosity boost (Instagram HDR effect)
     - contrast(1.15): deeper blacks, punchier highlights (TikTok style)
     - saturate(1.2): richer colors without oversaturation
     - Grain overlay from .grain layer adds film texture on top */
  filter: brightness(1.05) contrast(1.15) saturate(1.2);
}

/* When video is playing, hide the logo + rings */
body.video-mode .core-logo {
  opacity: 0;
  transition: opacity 1s var(--ease-out);
}

/* Cinematic Vignette — darkens edges like IG/TikTok framing */
body.video-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.5) 100%
  );
  opacity: 0;
  transition: opacity 1.5s var(--ease-out);
}

body.video-mode::after {
  opacity: 1;
}

/* ───────────────────── GRAIN ───────────────────── */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.6;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.97 0 0 0 0 0.93 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

@media (max-width: 768px) {
  .grain { opacity: 0.3; } /* lighter on mobile, don't remove completely */
}

@media (prefers-reduced-motion: reduce) {
  .grain { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   LAYER 1: THE GATE
   ═══════════════════════════════════════════════════════════ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  transition: opacity 1.5s var(--ease-out), transform 1.5s var(--ease-out);
}

.gate.is-exiting {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
}

.gate__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  text-align: center;
  padding: 24px;
}

/* ── THE CORE LOGO ── */
.core-logo {
  position: fixed;
  z-index: 5;
  /* Perfect center — same point where lightning originates */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Explicit square */
  width: 220px;
  height: 220px;
  pointer-events: none;
}

.core-logo__img {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  z-index: 2;
  box-shadow:
    0 0 40px rgba(232,224,213,0.08),
    0 0 80px rgba(232,224,213,0.04);
}

.logo-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(232, 224, 213, 0.2);
  border-radius: 50%;
  /* Latido reactivo: escala y brilla según la intensidad del golpe (--onset) */
  transform: scale(calc(1 + (var(--onset) * 0.05)));
  filter: drop-shadow(0 0 calc(var(--onset) * 15px) var(--accent));
  transition: transform 0.1s ease-out, filter 0.1s ease-out;
  z-index: 1;
}

/* Ring 1 — tight around logo */
.core-logo__ring {
  position: absolute;
  top: -14px;
  left: -14px;
  width: calc(100% + 28px);
  height: calc(100% + 28px);
  border: 1px solid var(--accent-20);
  border-radius: 50%;
  z-index: 1;
  animation: ring-pulse 5s ease-in-out infinite;
}

/* Ring 2 — wider orbit */
.core-logo__ring--2 {
  top: -32px;
  left: -32px;
  width: calc(100% + 64px);
  height: calc(100% + 64px);
  border-color: var(--accent-10);
  animation-delay: -2.5s;
  animation-duration: 7s;
}

@keyframes ring-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

@media (max-width: 768px) {
  .core-logo { width: 120px; height: 120px; }
  .core-logo__ring { top: -10px; left: -10px; width: calc(100% + 20px); height: calc(100% + 20px); }
  .core-logo__ring--2 { top: -22px; left: -22px; width: calc(100% + 44px); height: calc(100% + 44px); }
}

/* ── GATE TEXT ── */
.gate__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  letter-spacing: 0.35em;
  color: var(--accent-50);
  display: block;
  margin-bottom: 8px;
  opacity: 0;
  animation: text-up 1s var(--ease-out) 0.6s forwards;
}

.gate__title {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 0.9;
}

.gate__title-line {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: clamp(3rem, 8vw, 7rem);
  letter-spacing: 0.04em;
  display: block;
  opacity: 0;
  transform: translateY(30px);
  animation: text-up 1.2s var(--ease-out) forwards;
}

.gate__title-line:nth-child(1) { animation-delay: 0.8s; }
.gate__title-line:nth-child(2) { animation-delay: 1.0s; font-size: clamp(1.5rem, 3vw, 2.5rem); letter-spacing: 0.3em; color: var(--text-2); }
.gate__title-line--accent { animation-delay: 1.2s; font-style: italic; }

@keyframes text-up {
  to { opacity: 1; transform: translateY(0); }
}

/* ── GATE BUTTON ── */
.gate__btn {
  position: absolute;
  top: calc(50% + min(180px, 22vh));
  left: 0;
  right: 0;
  margin: auto;
  width: max-content;
  padding: 20px 56px;
  border: 1px solid var(--accent-20);
  letter-spacing: 0.25em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--accent);
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px);
  animation: text-up 1s var(--ease-out) 0.5s forwards;
  transition: all 0.6s var(--ease-out);
}

.gate__btn:hover {
  border-color: var(--accent-50);
  background: rgba(232,224,213,0.04);
  box-shadow: 0 0 80px rgba(232,224,213,0.08);
}

.gate__btn-pulse {
  position: absolute;
  inset: 0;
  border: 1px solid var(--accent-20);
  animation: btn-ping 3s ease-out infinite;
  pointer-events: none;
}

@keyframes btn-ping {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}

.gate__hint {
  position: absolute;
  top: calc(50% + min(250px, 30vh));
  left: 0;
  right: 0;
  margin: auto;
  width: max-content;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.4em;
  color: var(--text-3);
  opacity: 0;
  transform: translateY(30px);
  animation: text-up 1s var(--ease-out) 1s forwards;
}

/* ═══════════════════════════════════════════════════════════
   LAYER 2: THE EXPERIENCE
   ═══════════════════════════════════════════════════════════ */
.experience {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s var(--ease-out);
}

.experience.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* ── HEADER ── */
.exp-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 40px;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 1s var(--ease-out) 0.5s, opacity 1s var(--ease-out) 0.5s;
}

.experience.is-active .exp-header {
  transform: translateY(0);
  opacity: 1;
}

.exp-header__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.exp-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exp-header__logo {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: 1.5rem;
  font-style: italic;
  color: var(--accent);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-20);
  border-radius: 50%;
  /* Audio-reactive glow */
  box-shadow: 0 0 calc(var(--intensity) * 30px + 5px) var(--accent-glow);
  transition: box-shadow 0.3s ease;
}

.exp-header__name {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--text-2);
}

.exp-header__nav {
  display: flex;
  gap: 28px;
}

.exp-header__link {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-3);
  transition: color 0.3s ease;
  position: relative;
}

.exp-header__link:hover { color: var(--accent); }

.exp-header__link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-50);
  transition: width 0.3s var(--ease-out);
}

.exp-header__link:hover::after { width: 100%; }

/* ── PLAYER HUD — COMPACT BAR ── */
.player-hud {
  padding: 0 16px 16px;
  transform: translateY(30px);
  opacity: 0;
  transition: transform 1.2s var(--ease-out) 0.8s, opacity 1.2s var(--ease-out) 0.8s;
}

.experience.is-active .player-hud {
  transform: translateY(0);
  opacity: 1;
}

.player-hud__inner {
  max-width: 600px;
  background: rgba(6, 6, 6, 0.1);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 16px 8px;
  box-shadow: 
    0 0 calc(var(--intensity) * 60px) rgba(232,224,213, calc(var(--intensity) * 0.04)),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: box-shadow 0.15s ease;
}

/* ── MAIN ROW: info | controls | actions ── */
.player-hud__row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

/* ── NOW PLAYING HEADER ── */
.exp-header__now-playing {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.exp-header__track-number {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--text-3);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-10);
  border-radius: 5px;
  flex-shrink: 0;
}

.exp-header__track-info {
  min-width: 0;
}

.exp-header__track-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 calc(var(--intensity) * 15px) var(--accent-glow);
}

.exp-header__track-artist {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.25em;
  color: var(--text-3);
  display: block;
  margin-top: 1px;
}

/* ── CONTROLS (center) ── */
.player-hud__controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.player-hud__main-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.btn-tracks-bottom {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  color: var(--text-3);
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.3s var(--ease-out);
  opacity: 0.8;
}

.btn-tracks-bottom:hover {
  color: var(--accent);
  border-color: var(--accent-10);
  background: var(--accent-05);
  opacity: 1;
  box-shadow: 0 0 15px var(--accent-glow);
}

.player-hud__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.player-btn {
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: all 0.3s var(--ease-out);
}

.player-btn svg { width: 14px; height: 14px; }

.player-btn--sm {
  width: 30px; height: 30px;
  color: var(--text-3);
}

.player-btn--sm:hover { color: var(--accent); }

.player-btn--main {
  width: 40px; height: 40px;
  border: 1px solid var(--accent-20);
  color: var(--accent);
  box-shadow: 0 0 calc(var(--bass) * 0.3px + 5px) var(--accent-glow);
}

.player-btn--main svg { width: 16px; height: 16px; }

.player-btn--main:hover {
  background: var(--accent);
  color: var(--void);
  box-shadow: 0 0 40px rgba(232,224,213,0.15);
  transform: scale(1.05);
}

/* ── MOBILE: Compact bar adjustments ── */
@media (max-width: 768px) {
  .player-hud {
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  }
  .player-hud__inner {
    max-width: 100%;
    padding: 10px 12px 6px;
  }
  .player-hud__title {
    font-size: 0.8rem;
  }
}

/* ── PROGRESS ── */
.player-hud__progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-hud__time {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: var(--text-3);
  width: 32px;
  text-align: center;
}

.progress {
  flex: 1;
  height: 3px;
  background: var(--accent-05);
  border-radius: 2px;
  position: relative;
  overflow: visible;
  cursor: pointer;
  /* Bigger touch target for mobile */
  padding: 12px 0;
  margin: -12px 0;
  background-clip: content-box;
}

.progress__fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  background: var(--accent-50);
  border-radius: 2px;
  width: 0%;
  transition: width 0.15s linear;
}

.progress__glow {
  position: absolute;
  top: -4px;
  height: 11px;
  width: 0%;
  background: linear-gradient(90deg, transparent 90%, var(--accent-20) 100%);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(4px);
}

/* ═══════════════════════════════════════════════════════════
   TRACKS PANEL
   ═══════════════════════════════════════════════════════════ */
.tracks-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 85vw);
  height: 100%;
  z-index: 25;
  background: rgba(3, 3, 3, 0.85);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-left: 1px solid var(--accent-10);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.6s var(--ease-out), opacity 0.6s var(--ease-out);
  pointer-events: none;
}

.tracks-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.tracks-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 28px 20px;
  border-bottom: 1px solid var(--accent-05);
}

.tracks-panel__label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.35em;
  color: var(--text-3);
}

.tracks-panel__close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: var(--text-3);
  border: 1px solid var(--accent-10);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.tracks-panel__close:hover {
  color: var(--accent);
  border-color: var(--accent-20);
}

.tracks-panel__list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

/* Minimal scrollbar */
.tracks-panel__list::-webkit-scrollbar { width: 2px; }
.tracks-panel__list::-webkit-scrollbar-track { background: transparent; }
.tracks-panel__list::-webkit-scrollbar-thumb { background: var(--accent-10); border-radius: 1px; }

/* ── TRACK ROW ── */
.track-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  cursor: pointer;
  transition: background 0.3s ease;
  position: relative;
}

.track-row:hover {
  background: var(--accent-05);
}

/* Currently playing indicator */
.track-row.is-active {
  background: var(--accent-05);
}

.track-row.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent-50);
  box-shadow: 0 0 12px var(--accent-glow);
}

.track-row__number {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--text-3);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.track-row.is-active .track-row__number {
  color: var(--accent);
}

.track-row__info {
  flex: 1;
  min-width: 0;
}

.track-row__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 0.85rem;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--text-1);
  margin-bottom: 2px;
}

.track-row.is-active .track-row__title {
  color: var(--accent);
}

.track-row__artist {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  color: var(--text-3);
  margin-top: 2px;
}

.track-row__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.track-row__duration {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 300;
  color: var(--text-3);
}

.track-row__views {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--text-3);
  opacity: 0.7;
  display: block;
  margin-top: 4px;
}

/* Video indicator icon */
.track-row__video-badge {
  width: 16px;
  height: 16px;
  border: 1px solid var(--accent-20);
  border-radius: 3px;
  display: grid;
  place-items: center;
  color: var(--accent-50);
}

.track-row__video-badge svg {
  width: 8px;
  height: 8px;
}

/* ── MOBILE OVERRIDES ── */
@media (max-width: 768px) {
  .exp-header { 
    padding: calc(20px + env(safe-area-inset-top)) 20px 20px; 
  }
  /* Show nav on mobile too — tracks panel is essential */
  .exp-header__nav { display: flex; }
  .tracks-panel { width: 100vw; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
