@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
    --bg: #0d0d0f;
    --surface: #18181b;
    --surface-2: #222226;
    --border: #2b2b30;
    --text: #f2f0ea;
    --text-muted: #8a8a90;
    --accent: #e8a33d;
    --accent-dim: #6b5228;
    --ok: #4fb8a6;
    --error: #e85d5d;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; margin: 0; }

button {
    font-family: 'Inter', system-ui, sans-serif;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.08s ease, background 0.15s ease;
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Auth screen ---------- */
#auth-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 24px;
    text-align: center;
    background:
        radial-gradient(circle at 50% 30%, rgba(232,163,61,0.08), transparent 60%),
        var(--bg);
}

.auth-disc {
    width: 84px; height: 84px;
    border-radius: 50%;
    margin-bottom: 20px;
    background:
        radial-gradient(circle at center, var(--bg) 0 8%, var(--accent) 8% 11%, var(--bg) 11% 100%),
        repeating-radial-gradient(circle at center, #2b2b30 0 2px, #18181b 2px 6px);
    border: 1px solid var(--border);
}

#auth-screen h2 { font-size: 1.6rem; margin-bottom: 6px; }
#auth-screen p { color: var(--text-muted); margin: 4px 0 18px; font-size: 0.95rem; }

#passwordInput {
    padding: 13px 16px;
    width: 100%;
    max-width: 280px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
}

#authSubmit {
    padding: 13px 28px;
    background: var(--accent);
    color: #1a1400;
    font-size: 15px;
}
#authSubmit:hover { background: #f0b458; }

#error-msg { color: var(--error); margin-top: 12px; min-height: 1.2em; font-size: 0.9rem; }

/* ---------- App shell ---------- */
#app-content { display: none; padding-bottom: 110px; }

header {
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

header h2 { font-size: 1.25rem; margin-right: auto; white-space: nowrap; }

.search-row { display: flex; gap: 8px; flex: 1 1 320px; }

#searchQuery {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    min-width: 0;
}

#searchBtn { padding: 10px 18px; background: var(--accent); color: #1a1400; }
#searchBtn:hover { background: #f0b458; }

.mode-toggle { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; border: 1px solid var(--border); }
.mode-toggle button {
    background: transparent;
    color: var(--text-muted);
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 7px;
}
.mode-toggle button.active { background: var(--accent); color: #1a1400; }

#logoutBtn { background: var(--surface-2); color: var(--text-muted); padding: 9px 14px; font-size: 13px; }
#logoutBtn:hover { color: var(--text); }

/* ---------- Chips (categorías tipo YouTube) ---------- */
.chip-row {
    display: flex;
    gap: 8px;
    padding: 14px 20px 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
}
.chip:hover { border-color: var(--accent-dim); }
.chip.active { background: var(--accent); color: #1a1400; border-color: var(--accent); }

.section-title {
    padding: 18px 20px 0;
    font-size: 1.1rem;
}

/* ---------- Status / results ---------- */
#status-msg { padding: 14px 20px 0; color: var(--text-muted); font-size: 0.9rem; min-height: 1.2em; }
#status-msg.error { color: var(--error); }

.retry-btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
    margin-left: 4px;
}
.retry-btn:hover { border-color: var(--accent-dim); }

.error-details {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.error-details summary { cursor: pointer; color: var(--accent); }
.error-details pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 6px;
}

#results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 18px 20px;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, transform 0.1s ease;
}.video-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.video-card.playing { border-color: var(--accent); }

.video-card .thumb-wrap { position: relative; aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
.video-card img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Ícono de nota musical: solo se muestra si las dos miniaturas fallan */
.thumb-note-icon {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--surface-2);
}
.thumb-wrap.no-thumb .thumb-note-icon { display: flex; }

/* Overlay de reproducir al pasar el mouse (o al enfocar con teclado) */
.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13,13,15,0.35);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
.play-overlay svg {
    width: 46px; height: 46px;
    padding: 12px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1400;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.video-card:hover .play-overlay,
.video-card:focus-visible .play-overlay { opacity: 1; }

.video-card .duration {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.75);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}
.video-card .meta { padding: 10px 12px 12px; }
.video-card .title {
    font-size: 0.9rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}
.video-card .author { font-size: 0.78rem; color: var(--text-muted); }

.empty-state, .loading-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}

/* ---------- Player (mini turntable bar) ---------- */
#player-container {
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 1000;
    display: none;
}

#player-container.visible { display: block; }

.player-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.disc {
    width: 46px; height: 46px;
    border-radius: 50%;
    flex-shrink: 0;
    background:
        radial-gradient(circle at center, var(--bg) 0 9%, var(--accent) 9% 13%, var(--bg) 13% 100%),
        repeating-radial-gradient(circle at center, #2b2b30 0 2px, #141416 2px 5px);
    border: 1px solid var(--border);
    animation: spin 3.5s linear infinite;
    animation-play-state: paused;
}
.disc.spinning { animation-play-state: running; }

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

.now-playing { flex: 1; min-width: 0; }
.now-playing .np-title { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing .np-sub { font-size: 0.75rem; color: var(--text-muted); }

.player-controls { display: flex; align-items: center; gap: 6px; }
.player-controls button {
    background: var(--surface-2);
    color: var(--text);
    width: 38px; height: 38px;
    font-size: 15px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.player-controls button.primary { background: var(--accent); color: #1a1400; width: 44px; height: 44px; }
.player-controls button:hover { background: #33333a; }
.player-controls button.primary:hover { background: #f0b458; }

.media-el-wrap { display: none; }
.media-el-wrap.video-visible {
    display: block;
    background: #000;
    padding: 10px 16px 0;
    max-width: 900px;
    margin: 0 auto;
}
.media-el-wrap video { width: 100%; max-height: 45vh; border-radius: 8px; display: block; }

.close-player { background: transparent; color: var(--text-muted); font-size: 18px; width: 32px; height: 32px; }
.close-player:hover { color: var(--error); }

@media (max-width: 480px) {
    header h2 { display: none; }
    .now-playing .np-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .disc { animation: none; }
    button { transition: none; }
}
