/* ----------- CSS RESET & THEME VARIABLES ----------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Theme variables (default: dark) */
:root {
    --bg: #020617;
    --bg-elevated: #020617;
    --bg-soft: #0b1120;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --border: #1f2937;
    --card-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}

/* Light theme override */
body[data-theme="light"] {
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-soft: #e5e7eb;
    --text: #0f172a;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --border: #d1d5db;
    --card-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
}

body {
    background: radial-gradient(circle at top, #020617 0, var(--bg) 55%, #000 100%);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ----------- BACKGROUND BLOBS & BIG TEXT ----------- */

.bg-blobs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -2;
}

.blob {
    position: absolute;
    border-radius: 999px;
    filter: blur(100px);
    opacity: 0.55;
}

.blob1 {
    width: 380px;
    height: 380px;
    top: -80px;
    left: -60px;
    background: radial-gradient(circle, #3b82f6, #0ea5e9);
}

.blob2 {
    width: 420px;
    height: 420px;
    bottom: -120px;
    right: -120px;
    background: radial-gradient(circle, #ec4899, #f97316);
}

body[data-theme="light"] .blob {
    opacity: 0.3;
}

.logo-bg-text {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(72px, 15vw, 120px);
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.04);
    pointer-events: none;
    z-index: -1;
}

body[data-theme="light"] .logo-bg-text {
    color: rgba(15, 23, 42, 0.03);
}

/* ----------- LAYOUT ----------- */

.header {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px 20px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.container {
    max-width: 1000px;
    margin: 0 auto 40px;
    padding: 0 20px 40px;
}

/* ----------- BRAND / LOGO ----------- */

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-mark {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: conic-gradient(from 140deg, #3b82f6, #ec4899, #f97316, #22c55e, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 0 3px rgba(15, 23, 42, 0.9),
        0 10px 25px rgba(15, 23, 42, 0.9);
}

body[data-theme="light"] .logo-mark {
    box-shadow:
        0 0 0 3px #f8fafc,
        0 12px 30px rgba(15, 23, 42, 0.25);
}

.logo-mark span {
    color: #ffffff;
    font-weight: 800;
    font-size: 16px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
}

.brand-tagline {
    font-size: 12px;
    color: var(--muted);
}

/* ----------- THEME TOGGLE ----------- */

.theme-toggle {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}

body[data-theme="light"] .theme-toggle {
    background: rgba(248, 250, 252, 0.7);
}

/* ----------- FILTER BOX ----------- */

.filter-box {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 18px 18px 14px;
    margin-top: 6px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

body[data-theme="light"] .filter-box {
    background: linear-gradient(145deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.98));
}

.section-title {
    font-size: 16px;
    margin-bottom: 10px;
}

.filter-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-group.small {
    flex: 1 1 220px;
}

.field-group.tiny {
    flex: 0 0 120px;
}

.field-group.button-wrapper {
    flex: 0 0 auto;
}

.field-group label {
    font-size: 12px;
    color: var(--muted);
}

.field-group input,
.field-group select {
    font-size: 13px;
    padding: 7px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
    outline: none;
}

body[data-theme="light"] .field-group input,
body[data-theme="light"] .field-group select {
    background: rgba(248, 250, 252, 0.9);
}

.field-group input::placeholder {
    color: var(--muted);
    font-size: 12px;
}

#filterBtn {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.45);
}

#filterBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 35px rgba(37, 99, 235, 0.6);
}

.hint-text {
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
}

/* ----------- RESULTS SECTION ----------- */

.results-section {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 16px 18px 20px;
    backdrop-filter: blur(16px);
    box-shadow: var(--card-shadow);
}

body[data-theme="light"] .results-section {
    background: rgba(255, 255, 255, 0.9);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.results-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-info {
    font-size: 12px;
    color: var(--muted);
}
.error-info {
    font-size: 12px;
    color: #f97373;
}

/* ----------- VIDEO GRID ----------- */

.video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.video-card {
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), rgba(15, 23, 42, 0.96));
    border-radius: 14px;
    border: 1px solid rgba(51, 65, 85, 0.7);
    overflow: hidden;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

body[data-theme="light"] .video-card {
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.05), #ffffff);
    border: 1px solid rgba(148, 163, 184, 0.7);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.2);
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.95);
    border-color: rgba(96, 165, 250, 0.9);
}

body[data-theme="light"] .video-card:hover {
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.25);
}

.video-card img {
    width: 100%;
    display: block;
}

.video-body {
    padding: 10px 11px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.video-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
}

.video-title:hover {
    text-decoration: underline;
}

.video-meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.badge {
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: var(--accent-soft);
}

/* Loader */
.loader {
    margin-top: 16px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}
.hidden {
    display: none;
}

/* ----------- FOOTER ----------- */

.footer {
    
    text-align: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px 20px 18px;
    font-size: 12px;
    color: var(--muted);
}

/* ----------- RESPONSIVE ----------- */

/* ----------- RESPONSIVE ----------- */
@media (max-width: 640px) {
    .header {
        flex-direction: row;
        align-items: center;
    }

    .brand-text .brand-tagline {
        display: none;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .field-group.small,
    .field-group.tiny,
    .field-group.button-wrapper {
        flex: 1 1 auto;
    }

    /* Bigger inputs & selects on mobile */
    .field-group input,
    .field-group select {
        font-size: 18px;
        padding: 10px 14px;
    }

    /* Bigger, full-width button on mobile */
    #filterBtn {
        width: 100%;
        font-size: 18px;
        padding: 12px 18px;
    }

    /* Bigger section titles */
    .section-title {
        font-size: 20px;
    }

    /* Slightly bigger hint & meta text */
    .hint-text {
        font-size: 14px;
    }

    .result-info,
    .error-info {
        font-size: 14px;
    }

    /* Bigger card titles on mobile */
    .video-title {
        font-size: 16px;
    }

    .video-meta {
        font-size: 13px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-meta {
        text-align: left;
    }
}

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

.brand-image {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    transition: 0.15s ease;
}

body[data-theme="light"] .icon-btn {
    background: rgba(0, 0, 0, 0.06);
}

.icon-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.15);
}

.social-icon {
    width: 20px;
    height: 20px;
    filter: invert(1); /* white icons in dark mode */
}

body[data-theme="light"] .social-icon {
    filter: invert(0); /* black icons in light mode */
}

/* ----------- PLAYER MODAL (POPUP) ----------- */

.player-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
}

.player-modal-content {
    position: relative;
    width: min(1000px, 95vw);
    /* let height be flexible, only cap it */
    max-height: 90vh;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), var(--bg-elevated));
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.85);
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;

}

body[data-theme="light"] .player-modal-content {
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.05), #ffffff);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.player-modal-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 6px;
}

.modal-close-btn {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

body[data-theme="light"] .modal-close-btn {
    background: rgba(248, 250, 252, 0.9);
}

.modal-close-btn {
    font-size: 14px;
}

.player-modal-main {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
   overflow: unset;

}

.player-modal-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-frame-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    border-radius: 12px;
    overflow: hidden;
    background: #020617;
}

.player-frame-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.player-modal-info h2 {
    font-size: 15px;
    margin-bottom: 2px;
}

.player-modal-info p {
    font-size: 12px;
    color: var(--muted);
}

/* --- Player next/prev controls (popup) --- */
.player-nav {
    margin-top: 6px;
    display: flex;
    gap: 8px;
}

.player-nav-btn {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.player-nav-btn:hover {
    opacity: 0.9;
}

body[data-theme="light"] .player-nav-btn {
    background: rgba(248, 250, 252, 0.95);
}

/* description header + toggle */
.description-header {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.description-toggle {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    cursor: pointer;
}

body[data-theme="light"] .description-toggle {
    background: rgba(248, 250, 252, 0.9);
}

.modal-description {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
    max-height: 72px;        /* ~3–4 lines when collapsed */
    overflow: hidden;
    white-space: pre-line;
    position: relative;
}

/* Expanded description */
.modal-description.expanded {
    max-height: 260px;
    overflow-y: auto;        /* now scrollable when long */
}

/* Fade effect when collapsed */
.modal-description:not(.expanded)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(to bottom, transparent, var(--bg-elevated));
}

.player-modal-right {
    border-left: 1px solid rgba(148, 163, 184, 0.4);
    padding-left: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.player-modal-right h3 {
    font-size: 13px;
    color: var(--muted);
}

.modal-rec-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-rec-card {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.8);
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease;
}

body[data-theme="light"] .modal-rec-card {
    background: rgba(241, 245, 249, 0.9);
}

.modal-rec-card:hover {
    background: rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.modal-rec-thumb {
    width: 70px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
}

.modal-rec-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-rec-title {
    font-size: 12px;
    font-weight: 500;
}

.modal-rec-channel {
    font-size: 11px;
    color: var(--muted);
}

.modal-empty {
    font-size: 12px;
    color: var(--muted);
}

/* Mobile tweaks for modal */
@media (max-width: 768px) {
    .player-modal-content {
        width: 96vw;
        height: 92vh;
        padding: 8px;
    }

    .player-modal-main {
        grid-template-columns: 1fr;
    }

    .player-modal-right {
        border-left: none;
        border-top: 1px solid rgba(148, 163, 184, 0.4);
        padding-left: 0;
        padding-top: 6px;
    }
}

/* Ensure hidden overrides modal display */
.player-modal.hidden {
    display: none;
}

/* ----------- MINI PLAYER ----------- */

.mini-player {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.7);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.8);
    max-width: 340px;
}

body[data-theme="light"] .mini-player {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.25);
}

.mini-player-left {
    flex-shrink: 0;
}

.mini-frame-wrapper {
    position: relative;
    width: 140px;
    padding-top: 56.25%; /* 16:9 */
    border-radius: 8px;
    overflow: hidden;
    background: #020617;
}

.mini-frame-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.mini-player-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
}

.mini-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    max-height: 3em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-controls {
    display: flex;
    gap: 6px;
}

.mini-btn {
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    cursor: pointer;
}

body[data-theme="light"] .mini-btn {
    background: rgba(248, 250, 252, 0.9);
}

.mini-btn:hover {
    opacity: 0.9;
}

/* Ensure hidden overrides mini display */
.mini-player.hidden {
    display: none;
}

/* --- FIX: popup vs mini mode display --- */
.player-active #ytPlayerContainer {
    display: block;
}
.mini-active #ytPlayerContainer {
    display: none;
}
.mini-active #ytMiniContainer {
    display: block;
}

/* Disable scroll in background when popup open */
body.modal-open {
    overflow: hidden;
}

/* Ensure expandable description scrolls properly */
.modal-description.expanded {
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-line;
}
/* ---------- 3D INTRO ANIMATION ---------- */

#intro {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #020617, #000);
  z-index: 9999;
  overflow: hidden;
  pointer-events: none; /* allows clicks to pass once faded */
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-3d {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Big background text */
.intro-bg-text {
  position: absolute;
  font-size: clamp(100px, 22vw, 260px);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.035);
  transform: translateZ(-300px);
  animation: bgFloat 6s ease-in-out infinite;
  pointer-events: none;
}

/* Center text */
.intro-center {
  text-align: center;
  transform-style: preserve-3d;
  animation: popIn 1.4s ease forwards;
}

.intro-logo {
  font-size: 48px;
  letter-spacing: 4px;
  color: white;
}

.intro-tagline {
  margin-top: 10px;
  font-size: 14px;
  color: #9ca3af;
}

/* Floating 3D shape */
.shape-wrapper {
  position: absolute;
  width: 180px;
  height: 180px;
  transform-style: preserve-3d;
  animation: shapeFloat 5s ease-in-out infinite;
}

.floating-shape {
  width: 100%;
  height: 100%;
  border-radius: 32px;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.6),
    rgba(236, 72, 153, 0.6)
  );
  box-shadow:
    0 0 40px rgba(59, 130, 246, 0.4),
    inset 0 0 40px rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  transform: rotateX(25deg) rotateY(35deg);
}

/* Animations */
@keyframes popIn {
  from {
    opacity: 0;
    transform: translateZ(120px) scale(0.85);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateZ(0) scale(1);
    filter: blur(0);
  }
}

@keyframes shapeFloat {
  0% { transform: translateY(0) rotateX(20deg) rotateY(30deg); }
  50% { transform: translateY(-20px) rotateX(30deg) rotateY(50deg); }
  100% { transform: translateY(0) rotateX(20deg) rotateY(30deg); }
}

@keyframes bgFloat {
  0% { transform: translateZ(-300px) translateY(0); }
  50% { transform: translateZ(-300px) translateY(-10px); }
  100% { transform: translateZ(-300px) translateY(0); }
}

@keyframes floatSlow {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-18px) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
}
