/* ===== Variables ===== */
:root {
  --bg-primary: #0d0d12;
  --bg-secondary: #1a1520;
  --bg-card: #1e1828;
  --text-primary: #ede6d6;
  --text-secondary: #9a8f80;
  --accent: #e8a87c;
  --accent-soft: rgba(232, 168, 124, 0.15);
  --accent-glow: rgba(232, 168, 124, 0.25);
  --channel-active: #f0c27f;
  --border-radius: 12px;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-channel: 'JetBrains Mono', monospace;
}

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

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

button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

/* ===== Player ===== */
#player-container {
  position: fixed;
  inset: 0;
  background: #000;
}

#youtube-player {
  width: 100%;
  height: 100%;
}

#youtube-player iframe {
  width: 100%;
  height: 100%;
  border: none;
}

#click-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  cursor: pointer;
}

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  z-index: 10;
}

.overlay[hidden] {
  display: none;
}

/* ===== Unmute Overlay ===== */
#unmute-overlay {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 18, 0.6);
  z-index: 50;
  animation: fadeIn 0.3s ease;
}

#unmute-overlay[hidden] {
  display: none;
}

#unmute-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 48px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
  font-weight: 500;
  transition: transform 0.2s ease, background 0.2s ease;
}

#unmute-btn:hover {
  transform: scale(1.05);
  background: var(--bg-secondary);
}

#unmute-btn svg {
  opacity: 0.9;
}

/* ===== Channel Info Banner ===== */
#channel-info {
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(30, 24, 40, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius);
  border: 1px solid rgba(232, 168, 124, 0.1);
  animation: slideInLeft 0.3s ease;
  pointer-events: none;
}

#channel-info[hidden] {
  display: none;
}

#channel-number {
  font-family: var(--font-channel);
  font-size: 28px;
  font-weight: 500;
  color: var(--channel-active);
  min-width: 48px;
  text-align: center;
}

#channel-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#channel-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

#video-title {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Controls ===== */
#controls {
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

#controls[hidden] {
  display: none;
}

#controls button {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 24, 40, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius);
  border: 1px solid rgba(232, 168, 124, 0.1);
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

#controls button:hover {
  background: rgba(30, 24, 40, 0.95);
  color: var(--accent);
  transform: scale(1.08);
}

#controls button:active {
  transform: scale(0.95);
}

/* Volume control */
#volume-control {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-left: 120px;
  margin-left: -120px;
}

#btn-mute svg[hidden] {
  display: none;
}

#volume-slider {
  position: absolute;
  right: 56px;
  top: 50%;
  transform: translateY(-50%);
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(154, 143, 128, 0.3);
  border-radius: 2px;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#volume-control:hover #volume-slider,
#volume-slider:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

#volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* ===== Channel Guide ===== */
#guide {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 18, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  animation: fadeIn 0.2s ease;
}

#guide[hidden] {
  display: none;
}

#guide-panel {
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid rgba(232, 168, 124, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.25s ease;
}

#guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(232, 168, 124, 0.08);
}

#guide-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

#guide-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease;
}

#guide-close:hover {
  background: var(--accent-soft);
}

#guide-list {
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

#guide-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#guide-list li:hover {
  background: var(--accent-soft);
}

#guide-list li.active {
  background: var(--accent-soft);
  border: 1px solid rgba(232, 168, 124, 0.2);
}

.guide-ch-num {
  font-family: var(--font-channel);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
}

.guide-ch-num.active {
  color: var(--channel-active);
}

.guide-ch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.guide-ch-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.guide-ch-desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Loading Spinner ===== */
#loading {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 60;
  transition: opacity 0.4s ease;
}

#loading[hidden] {
  display: none;
}

#loading.fade-out {
  opacity: 0;
}

#spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Scrollbar ===== */
#guide-list::-webkit-scrollbar {
  width: 6px;
}

#guide-list::-webkit-scrollbar-track {
  background: transparent;
}

#guide-list::-webkit-scrollbar-thumb {
  background: rgba(154, 143, 128, 0.3);
  border-radius: 3px;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  #channel-info {
    top: 16px;
    left: 16px;
    right: 16px;
    gap: 12px;
    padding: 10px 16px;
  }

  #channel-number {
    font-size: 22px;
    min-width: 36px;
  }

  #channel-name {
    font-size: 14px;
  }

  #video-title {
    font-size: 12px;
    max-width: 200px;
  }

  #controls {
    bottom: 16px;
    right: 16px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  #controls button {
    width: 44px;
    height: 44px;
  }

  #volume-control {
    padding-left: 0;
    margin-left: 0;
  }

  #volume-slider {
    display: none;
  }

  #guide-panel {
    width: 95%;
    max-height: 70vh;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    animation: slideUp 0.25s ease;
  }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Focus styles ===== */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Channel switch transition ===== */
.channel-transition {
  animation: channelSwitch 0.3s ease;
}

@keyframes channelSwitch {
  0% { opacity: 1; }
  40% { opacity: 0; }
  100% { opacity: 1; }
}
