/* ==========================================================================
   SAFAR (सफ़र) — Single Page Music Experience Stylesheet
   ========================================================================== */

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-hindi: 'Noto Sans Devanagari', var(--font-main);
  
  --bg-dark: #0d0a12;
  --glass-bg: rgba(18, 14, 24, 0.72);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-blur: 24px;
  
  --accent-gold: #f0be75;
  --accent-gold-glow: rgba(240, 190, 117, 0.35);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.68);
  --text-muted: rgba(255, 255, 255, 0.45);
  
  --radius-full: 9999px;
  --radius-card: 22px;
  --radius-thumb: 10px;
  
  --shadow-player: 0 24px 48px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  --transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Layout Constraints */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-main);
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
}

/* 100vh Hero Viewport */
.hero-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

/* Hero Illustration Container */
.hero-image-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
  background-color: #17101a;
}

.hero-picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.7s var(--transition-smooth), transform 0.7s var(--transition-smooth);
  pointer-events: none;
  z-index: 1;
}

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

.hero-illustration {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}

/* Subtle Vignette & Reader Overlay (Does NOT alter illustration colors) */
.vignette-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: 
    radial-gradient(circle at center, transparent 40%, rgba(10, 7, 14, 0.35) 100%),
    linear-gradient(to bottom, rgba(12, 9, 16, 0.35) 0%, transparent 20%, transparent 75%, rgba(10, 7, 14, 0.6) 100%);
}

/* Top-Left Editorial Live Clock */
.live-clock {
  position: absolute;
  top: 28px;
  left: 32px;
  z-index: 20;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  color: #ffffff;
  font-family: var(--font-main);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  user-select: none;
  pointer-events: none;
}

.clock-digits {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.clock-colon {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1;
  margin: 0 1px;
  animation: colonBlink 1s infinite steps(1);
}

@keyframes colonBlink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

.clock-period {
  font-size: 1.05rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-transform: lowercase;
  line-height: 1;
  margin-left: 5px;
}

/* Top-Right YouTube Music Utility Link */
.yt-music-badge {
  position: absolute;
  top: 24px;
  right: 28px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.88);
  color: #16121b;
  text-decoration: none;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: all 0.25s var(--transition-smooth);
}

.yt-music-badge:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.yt-music-badge:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
}

.yt-icon {
  color: #ff0000;
  flex-shrink: 0;
}

.badge-text {
  white-space: nowrap;
}

.external-arrow {
  opacity: 0.6;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.yt-music-badge:hover .external-arrow {
  opacity: 1;
  transform: translate(1px, -1px);
}

/* Graceful Autoplay Fallback Prompt */
.autoplay-prompt {
  position: absolute;
  bottom: 128px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: rgba(252, 248, 242, 0.94);
  color: #17121d;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-full);
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent-gold-glow);
  transition: opacity 0.4s var(--transition-smooth), transform 0.4s var(--transition-smooth), background-color 0.2s ease;
  animation: promptFloat 3s infinite ease-in-out;
}

.autoplay-prompt:hover {
  background: #ffffff;
  transform: translateX(-50%) scale(1.03);
}

.autoplay-prompt.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

.prompt-icon-ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #17121d;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.prompt-icon-ring svg {
  margin-left: 2px;
}

@keyframes promptFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* Bottom Floating Music Player */
.player-wrapper {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 480px;
  z-index: 25;
  transition: transform 0.4s var(--transition-smooth);
}

.music-player {
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  box-shadow: var(--shadow-player);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Track Row */
.player-main-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Thumbnail */
.artwork-container {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-thumb);
  overflow: hidden;
  background-color: #241d2d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.track-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.music-player:hover .track-artwork {
  transform: scale(1.05);
}

/* Animated Equalizer Overlay */
.playing-indicator {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.playing-indicator.active {
  opacity: 1;
}

.playing-indicator span {
  width: 3px;
  height: 14px;
  background-color: var(--accent-gold);
  border-radius: 2px;
  animation: eqBounce 1.2s ease-in-out infinite alternate;
}

.playing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.playing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes eqBounce {
  0% { height: 4px; }
  100% { height: 16px; }
}

/* Track Info */
.track-details {
  flex: 1;
  min-width: 0; /* Enables text ellipsis truncation */
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-title {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.track-artist {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.82;
  transition: all 0.2s ease;
}

.ctrl-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent-gold);
}

.main-play-btn {
  width: 40px;
  height: 40px;
  background: var(--text-primary);
  color: #120e18;
  opacity: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.main-play-btn:hover {
  background: #ffffff;
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(255, 255, 255, 0.25);
}

/* Playlist Selector & Popover Menu */
.playlist-btn {
  margin-left: 2px;
  position: relative;
}

.playlist-btn.active,
.playlist-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--accent-gold);
}

.playlist-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 210px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(190%);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.35);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transform-origin: bottom right;
  transition: opacity 0.3s var(--transition-smooth), transform 0.3s var(--transition-smooth);
}

.playlist-menu.hidden {
  display: none !important;
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  pointer-events: none;
}

.playlist-menu-header {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 12px 4px 12px;
  font-weight: 600;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.playlist-item.active {
  background: rgba(240, 190, 117, 0.16);
  color: var(--accent-gold);
  font-weight: 600;
}

.playlist-item .active-check {
  opacity: 0;
  color: var(--accent-gold);
  transition: opacity 0.2s ease;
}

.playlist-item.active .active-check {
  opacity: 1;
}

/* Timeline & Progress Bar */
.progress-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 12px; /* Touch target size */
  display: flex;
  align-items: center;
  cursor: pointer;
  outline: none;
}

.progress-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-full);
  transition: height 0.15s ease;
}

.progress-track:hover::before {
  height: 6px;
}

.progress-fill {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, #dfa963, var(--accent-gold));
  border-radius: var(--radius-full);
  pointer-events: none;
  transition: height 0.15s ease;
}

.progress-track:hover .progress-fill {
  height: 6px;
}

.progress-thumb {
  position: absolute;
  left: 0%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.progress-track:hover .progress-thumb,
.progress-track:focus-visible .progress-thumb {
  opacity: 1;
  transform: scale(1);
}

.time-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Background YouTube Player Host (Full Viewport for Tab Persistence) */
#yt-player-host {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.001;
  pointer-events: none;
  overflow: hidden;
}

#yt-player-host iframe,
#yt-player {
  width: 100% !important;
  height: 100% !important;
  border: none;
  pointer-events: none;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

/* Mobile Breakpoint (<768px) */
@media (max-width: 767px) {
  .live-clock {
    top: 18px;
    left: 20px;
    gap: 2px;
  }

  .clock-digits,
  .clock-colon {
    font-size: 1.25rem;
  }

  .clock-period {
    font-size: 0.9rem;
    margin-left: 3px;
  }

  .yt-music-badge {
    top: 16px;
    right: 16px;
    padding: 6px 13px;
    font-size: 0.75rem;
  }
  
  .hero-picture {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  .hero-illustration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transform: none;
  }

  .player-wrapper {
    bottom: 18px;
    width: calc(100% - 28px);
    max-width: 100%;
  }

  .music-player {
    padding: 12px 14px;
    border-radius: 18px;
    gap: 8px;
  }

  .artwork-container {
    width: 42px;
    height: 42px;
  }

  .track-title {
    font-size: 0.88rem;
  }

  .track-artist {
    font-size: 0.74rem;
  }

  .ctrl-btn {
    width: 32px;
    height: 32px;
  }

  .main-play-btn {
    width: 36px;
    height: 36px;
  }

  .autoplay-prompt {
    bottom: 116px;
    padding: 9px 18px;
    font-size: 0.8rem;
  }
}

/* Ultra Small Screens (<380px) */
@media (max-width: 379px) {
  .badge-text {
    display: none;
  }
  
  .yt-music-badge {
    padding: 7px;
  }
  
  .player-main-row {
    gap: 10px;
  }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  .hero-illustration,
  .hero-picture,
  .playlist-menu,
  .yt-music-badge,
  .autoplay-prompt,
  .ctrl-btn,
  .main-play-btn,
  .playing-indicator span {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
