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

/* ── Custom Properties ── */
:root {
  --bg-deep: #0a0505;
  --bg-panel: rgba(20, 8, 8, 0.85);
  --bg-input: rgba(40, 10, 15, 0.6);
  --accent-burgundy: rgba(128, 20, 40, 0.7);
  --accent-burgundy-solid: #80142a;
  --accent-burgundy-light: rgba(160, 40, 60, 0.4);
  --accent-burgundy-glow: rgba(128, 20, 40, 0.15);
  --accent-gold: #d4a574;
  --accent-gold-dim: rgba(212, 165, 116, 0.5);
  --accent-gold-glow: rgba(212, 165, 116, 0.15);
  --text-warm: #e0d0c0;
  --text-cream: #f0e0d0;
  --text-muted: rgba(200, 170, 140, 0.5);
  --text-muted-strong: rgba(200, 170, 140, 0.6);
  --border-subtle: rgba(160, 40, 60, 0.15);
  --border-hover: rgba(212, 165, 116, 0.3);
  --glow-burgundy: rgba(128, 20, 40, 0.15);
}

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

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-burgundy), rgba(80, 15, 25, 0.6));
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(160, 40, 60, 0.8), var(--accent-burgundy));
}
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 20, 40, 0.6) var(--bg-deep);
}

/* ── Login Screen ── */
body.locked {
  background: linear-gradient(135deg, #0a0505 0%, #1a0a0a 40%, #0d0606 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}
body.locked::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(128, 20, 40, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(100, 15, 30, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(212, 165, 116, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#loginParticles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#loginScreen {
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border: 1px solid rgba(160, 40, 60, 0.2);
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  max-width: 90vw;
  backdrop-filter: blur(20px);
  box-shadow:
    0 0 60px rgba(128, 20, 40, 0.1),
    0 0 120px rgba(80, 15, 25, 0.05);
  animation: loginEntrance 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes loginEntrance {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

#loginScreen h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 34px;
  color: var(--accent-gold);
  text-align: center;
  margin-bottom: 6px;
  font-weight: 300;
  font-style: italic;
  letter-spacing: 3px;
}
#loginScreen .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 36px;
}
#loginScreen .field {
  margin-bottom: 20px;
}
#loginScreen label {
  display: block;
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  color: var(--text-muted-strong);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
#loginScreen input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-warm);
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
#loginScreen input:focus {
  border-color: var(--accent-burgundy-light);
  box-shadow: 0 0 20px rgba(128, 20, 40, 0.1);
}
#loginScreen input::placeholder { color: rgba(180, 145, 130, 0.3); }

#loginScreen button {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, rgba(128, 20, 40, 0.7), rgba(100, 15, 30, 0.7));
  border: 1px solid rgba(160, 40, 60, 0.3);
  border-radius: 8px;
  color: var(--text-cream);
  font-family: 'Quicksand', sans-serif;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 8px;
  position: relative;
  overflow: hidden;
  animation: btnPulse 3s ease-in-out infinite;
}
#loginScreen button:hover {
  background: linear-gradient(135deg, rgba(160, 40, 60, 0.85), rgba(128, 20, 40, 0.85));
  box-shadow: 0 0 30px rgba(128, 20, 40, 0.3), 0 0 60px rgba(212, 165, 116, 0.05);
}
#loginScreen button:active {
  transform: scale(0.96);
  transition: transform 0.1s;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(128, 20, 40, 0.2); }
  50% { box-shadow: 0 0 30px rgba(128, 20, 40, 0.4), 0 0 60px rgba(128, 20, 40, 0.1); }
}

#loginError {
  color: #c04040;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  text-align: center;
  margin-top: 14px;
  min-height: 18px;
}

/* ── Main App (hidden until auth) ── */
#app { display: none; }

body.unlocked {
  background: var(--bg-deep);
}
body.unlocked::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(128, 20, 40, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(212, 165, 116, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(80, 15, 25, 0.05) 0%, transparent 60%);
  background-size: 200% 200%;
  animation: ambientShift 20s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes ambientShift {
  0%, 100% { background-position: 0% 0%; }
  33% { background-position: 100% 50%; }
  66% { background-position: 50% 100%; }
}

body.unlocked #loginScreen { display: none; }
body.unlocked #loginParticles { display: none; }
body.unlocked #app { display: block; }

/* ── Header ── */
.header {
  background: linear-gradient(180deg, rgba(20, 8, 8, 0.95), rgba(12, 5, 5, 0.9));
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}
.header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 300;
  font-style: italic;
  letter-spacing: 1px;
  background: linear-gradient(
    90deg,
    var(--accent-gold) 0%,
    #f0e0c0 40%,
    var(--accent-gold) 60%,
    #c09050 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 100% 50%; }
  50% { background-position: 0% 50%; }
}

.header .count {
  color: var(--text-muted);
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
}

/* Search */
.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-warm);
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.search-box input:focus {
  border-color: var(--accent-burgundy-light);
  box-shadow: 0 0 16px rgba(128, 20, 40, 0.1);
}
.search-box input::placeholder { color: rgba(180, 145, 130, 0.35); }
.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(200, 160, 140, 0.4);
  font-size: 14px;
  pointer-events: none;
}

.mode-toggle {
  display: flex;
  gap: 6px;
}
.mode-toggle button {
  background: var(--bg-input);
  color: var(--text-muted-strong);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.mode-toggle button:active {
  transform: scale(0.96);
  transition: transform 0.1s;
}
.mode-toggle button.active {
  background: linear-gradient(135deg, rgba(128, 20, 40, 0.6), rgba(100, 15, 30, 0.6));
  color: var(--text-cream);
  border-color: rgba(160, 40, 60, 0.3);
}

.logout-btn {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  margin-left: auto;
}
.logout-btn:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold-dim);
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  padding: 24px;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-family: 'Quicksand', sans-serif;
  font-size: 15px;
}

/* ── Grid Loading ── */
.grid-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 80px 20px;
  grid-column: 1 / -1;
}
.grid-loading .orb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-gold);
  margin: 0 6px;
  animation: orbPulse 1.4s ease-in-out infinite;
}
.grid-loading .orb:nth-child(2) { animation-delay: 0.2s; }
.grid-loading .orb:nth-child(3) { animation-delay: 0.4s; }

@keyframes orbPulse {
  0%, 100% { transform: scale(0.5); opacity: 0.3; }
  50% { transform: scale(1); opacity: 1; }
}

/* ── Cards ── */
.card {
  position: relative;
  background: rgba(20, 8, 8, 0.6);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(160, 40, 60, 0.08);
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.6s ease,
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.4s ease,
    border-color 0.3s ease;
}
.card.visible {
  opacity: 1;
  transform: translateY(0);
}
.card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 20px 60px rgba(128, 20, 40, 0.2),
    0 0 30px rgba(212, 165, 116, 0.05);
  border-color: var(--border-hover);
}
.card.visible:hover {
  transform: translateY(-6px);
}

.card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 10px;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(212, 165, 116, 0.1) 0%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 1;
}
.card:hover::after {
  opacity: 1;
}

.card .thumb-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: rgba(12, 5, 5, 0.8);
  overflow: hidden;
}
.card .thumb-container img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s;
}
.card:hover .thumb-container img {
  transform: scale(1.08);
  filter: brightness(1.15) saturate(1.15);
}
.card .thumb-container .play-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 56px; height: 56px;
  background: rgba(128, 20, 40, 0.5);
  border: 2px solid rgba(212, 165, 116, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s, background 0.3s, box-shadow 0.3s;
  backdrop-filter: blur(4px);
  z-index: 2;
}
.card:hover .play-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  box-shadow: 0 0 30px rgba(212, 165, 116, 0.2);
}
.play-icon::after {
  content: '';
  display: block;
  width: 0; height: 0;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent var(--text-cream);
  margin-left: 3px;
}

.card .info {
  padding: 10px 14px 12px;
}
.card .info .title {
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(220, 195, 180, 0.85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .info .vid-id {
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  color: rgba(180, 150, 130, 0.35);
  margin-top: 4px;
}
.card .thumb-container .error-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: 'Quicksand', sans-serif;
  font-size: 13px;
  text-align: center;
  padding: 12px;
  background: rgba(12, 5, 5, 0.6);
}

/* ── Modal / Player ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(5, 2, 2, 0.94);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(5, 2, 2, 0.8) 100%
  );
  pointer-events: none;
}

.modal-close {
  position: absolute;
  top: 16px; right: 24px;
  background: none;
  border: none;
  color: rgba(200, 170, 140, 0.6);
  font-size: 32px;
  cursor: pointer;
  z-index: 1001;
  line-height: 1;
  transition: color 0.2s, text-shadow 0.2s;
}
.modal-close:hover {
  color: var(--accent-gold);
  text-shadow: 0 0 12px var(--accent-gold-glow);
}

.player-wrapper {
  width: 90%;
  max-width: 1100px;
  position: relative;
  z-index: 1;
  transform: scale(0.92);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}
.modal-overlay.active .player-wrapper {
  transform: scale(1);
  opacity: 1;
}

.player-wrapper video {
  width: 100%;
  max-height: 80vh;
  background: #000;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(128, 20, 40, 0.15), 0 0 80px rgba(0, 0, 0, 0.4);
}
.player-wrapper iframe {
  width: 100%;
  height: 70vh;
  border: none;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(128, 20, 40, 0.15), 0 0 80px rgba(0, 0, 0, 0.4);
}

.player-title {
  color: rgba(220, 195, 180, 0.7);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  margin-top: 14px;
  text-align: center;
  position: relative;
  z-index: 1;
}
.player-status {
  color: var(--text-muted);
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  margin-top: 6px;
  text-align: center;
  position: relative;
  z-index: 1;
}
.player-actions {
  margin-top: 12px;
  text-align: center;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.player-actions a, .player-actions button {
  color: var(--accent-gold);
  text-decoration: none;
  font-family: 'Quicksand', sans-serif;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid rgba(160, 40, 60, 0.2);
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.player-actions a:hover, .player-actions button:hover {
  background: rgba(128, 20, 40, 0.4);
  border-color: var(--accent-burgundy-light);
  box-shadow: 0 0 12px var(--glow-burgundy);
}
.player-actions button:active {
  transform: scale(0.96);
  transition: transform 0.1s;
}

.quality-selector {
  margin-top: 8px;
  text-align: center;
  display: flex;
  gap: 6px;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.quality-selector button {
  background: var(--bg-input);
  color: var(--text-muted-strong);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  font-size: 11px;
  transition: all 0.2s;
}
.quality-selector button.active {
  background: rgba(128, 20, 40, 0.5);
  color: var(--text-cream);
  border-color: rgba(160, 40, 60, 0.3);
}

.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(128, 20, 40, 0.3);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Ripple Effect ── */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(212, 165, 116, 0.25);
  transform: scale(0);
  animation: rippleEffect 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
    gap: 10px;
  }
  .header h1 {
    font-size: 18px;
  }
  .search-box {
    order: 10;
    min-width: 100%;
    max-width: 100%;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    padding: 16px;
  }
  .player-wrapper {
    width: 95%;
  }
  .player-wrapper iframe {
    height: 50vh;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 10px 12px;
  }
  .header h1 {
    font-size: 16px;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }
  .mode-toggle {
    margin-left: 0;
  }
  .modal-close {
    top: 8px;
    right: 12px;
    font-size: 28px;
  }
  #loginScreen {
    padding: 32px 24px;
    width: 95vw;
  }
  .player-actions {
    flex-direction: column;
    align-items: center;
  }
}
