/* style.css — YouTube-style UI */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;

    --yt-bg:           #0f0f0f;
    --yt-surface:      #212121;
    --yt-surface-alt:  #272727;
    --yt-border:       #3f3f3f;
    --yt-text:         #f1f1f1;
    --yt-text-sub:     #aaaaaa;
    --yt-red:          #ff0000;
    --yt-red-hover:    #cc0000;
    --yt-radius:       12px;
    --yt-nav-h:        56px;
    --transition:      0.15s ease;
}

/* ─── Base ─────────────────────────────────────── */
body {
    font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--yt-bg);
    color: var(--yt-text);
    line-height: 1.4;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--yt-bg); }
::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #888; }

/* ─── Navbar ────────────────────────────────────── */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--yt-nav-h);
    background: var(--yt-bg);
    z-index: 1000;
    border-bottom: 1px solid var(--yt-border);
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 16px;
}

/* Logo */
.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--yt-text);
    text-decoration: none;
    letter-spacing: -0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.logo span {
    color: var(--yt-red);
}

/* Search bar */
.nav-icons {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.nav-icons input[type="search"] {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    background: var(--yt-bg);
    border: 1px solid var(--yt-border);
    border-right: none;
    border-radius: 40px 0 0 40px;
    color: var(--yt-text);
    font-size: 16px;
    outline: none;
    transition: border-color var(--transition);
}
.nav-icons input[type="search"]:focus {
    border-color: #1c62b9;
}
.nav-icons input[type="search"]::placeholder {
    color: var(--yt-text-sub);
}

/* Fake search button appended visually */
.nav-icons::after {
    content: "🔍";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 40px;
    background: var(--yt-surface);
    border: 1px solid var(--yt-border);
    border-radius: 0 40px 40px 0;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ─── Main layout ───────────────────────────────── */
main {
    padding-top: calc(var(--yt-nav-h) + 24px);
    padding-bottom: 48px;
    min-height: 100vh;
}

/* ─── Video grid ────────────────────────────────── */
.videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px 16px;
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ─── Video card ────────────────────────────────── */
.video-card {
    background: transparent;
    border-radius: var(--yt-radius);
    overflow: hidden;
    cursor: pointer;
    transition: background var(--transition);
    border: none;
    box-shadow: none;
}

.video-card:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

/* ── Thumbnail (16:9) ── */
.thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;          /* ← YouTube's horizontal ratio */
    background: #000;
    border-radius: var(--yt-radius);
    overflow: hidden;
}

.thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s ease;
}

.video-card:hover .thumbnail-img {
    opacity: 0.85;
    transform: none;               /* no zoom — YouTube doesn't zoom */
}

/* Duration badge (optional — works if JS injects it) */
.thumb-duration {
    position: absolute;
    bottom: 6px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 4px;
    pointer-events: none;
}

/* Progress bar hint */
.thumbnail-overlay {
    display: none;                  /* hide the TikTok gradient */
}

/* ── Below-thumbnail meta ── */
.video-meta {
    display: flex;
    gap: 12px;
    padding: 10px 4px 8px 4px;
    align-items: flex-start;
}

/* Channel avatar (left column) */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--yt-surface);
    flex-shrink: 0;
    border: none;                   /* remove TikTok blue ring */
    margin-top: 2px;
}

/* Right column: title + channel name + stats */
.video-info-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.video-desc {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--yt-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.author-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.author-info {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-size: 13px;
    font-weight: 400;
    color: var(--yt-text-sub);
    letter-spacing: 0;
}

.author-handle {
    display: none;                  /* YouTube shows channel name, not @handle below title */
}

/* Stats row (views · time) */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    margin: 0;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    border-radius: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--yt-text-sub);
}

.stat-badge:hover {
    background: transparent;
}

.stat-badge + .stat-badge::before {
    content: "·";
    margin-right: 4px;
    color: var(--yt-text-sub);
}

.stat-badge span:first-child {
    font-size: 13px;               /* no big emoji sizing */
}

/* Hashtags → subtle, smaller */
.hashtag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.hashtag {
    font-size: 12px;
    background: transparent;
    color: #3ea6ff;
    padding: 0;
    border-radius: 0;
    letter-spacing: 0;
}

.hashtag:hover {
    text-decoration: underline;
}

/* ─── Pagination ────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding: 0 24px;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    cursor: pointer;
    transition: background var(--transition);
    border: none;
    outline: none;
    background: var(--yt-surface);
    color: var(--yt-text);
}

button:hover {
    background: var(--yt-surface-alt);
}

/* ─── Video player ──────────────────────────────── */
.videoPlayer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    z-index: 3000;
}

/* ─── Loader ────────────────────────────────────── */
.global-loader {
    position: fixed;
    inset: 0;
    background: var(--yt-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 0, 0, 0.2);
    border-top: 3px solid var(--yt-red);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ─── Empty state ───────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--yt-text-sub);
    font-size: 15px;
}

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 900px) {
    .videos {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
        padding: 0 12px;
    }
}

@media (max-width: 600px) {
    .videos {
        grid-template-columns: 1fr;
        padding: 0 8px;
        gap: 8px;
    }
    .nav-container {
        padding: 0 10px;
    }
    .nav-icons {
        max-width: 100%;
    }
    .video-meta {
        padding: 8px 2px 6px 2px;
    }
}
