/* ─── Clips Page ──────────────────────────────────────────────── */

.clips-page {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

.clips-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ─── Top Bar ─────────────────────────────────────────────────── */
.clips-topbar {
    height: 44px;
    min-height: 44px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 14px;
    z-index: 100;
}

.clips-back {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 3px 8px 3px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.clips-back:hover {
    background: rgba(145, 71, 255, 0.1);
}
.clips-back svg {
    opacity: 0.7;
}

.clips-page-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
.clips-page-title svg {
    color: var(--primary);
}

/* ─── Toolbar / Filters ──────────────────────────────────────── */
.clips-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

.clips-filter {
    display: flex;
    align-items: center;
    gap: 5px;
}
.clips-filter-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.clips-select {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}
.clips-select:hover,
.clips-select:focus {
    border-color: var(--primary);
}

.clips-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.clips-search-icon {
    position: absolute;
    left: 8px;
    color: var(--muted);
    pointer-events: none;
}
.clips-search {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 8px 4px 28px;
    font-size: 11px;
    font-family: inherit;
    width: 160px;
    outline: none;
    transition: border-color 0.15s, width 0.2s;
}
.clips-search:focus {
    border-color: var(--primary);
    width: 220px;
}
.clips-search::placeholder {
    color: var(--muted);
}

/* Toolbar separator & nav */
.clips-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}
.clips-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s;
    flex-shrink: 0;
}
.clips-nav-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(145, 71, 255, 0.08);
}

/* ─── Content ─────────────────────────────────────────────────── */
.clips-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.clips-count {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 600;
}

.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

/* ─── Clip Card ───────────────────────────────────────────────── */
.clip-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.clip-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

.clip-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #111;
    overflow: hidden;
}
.clip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.clip-card:hover .clip-thumb img {
    transform: scale(1.05);
}
.clip-thumb-empty {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.clip-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;
}

.clip-views {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.85);
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
}

.clip-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.clip-card:hover .clip-play-icon {
    opacity: 1;
}
.clip-play-icon svg {
    width: 48px;
    height: 48px;
    color: #fff;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
    background: rgba(145, 71, 255, 0.85);
    border-radius: 50%;
    padding: 10px;
}

/* ─── Clip Body ───────────────────────────────────────────────── */
.clip-body {
    padding: 10px 12px;
}

.clip-title-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.clip-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}

.clip-meta {
    min-width: 0;
    flex: 1;
}

.clip-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 3px;
}

.clip-subtitle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--muted);
    flex-wrap: wrap;
}

.clip-channel {
    color: var(--primary);
    font-weight: 600;
}

.clip-dot {
    opacity: 0.4;
}

.clip-curator {
    font-style: italic;
}

.clip-game {
    color: var(--primary);
    font-weight: 500;
}

/* ─── Clip Viewer Modal ───────────────────────────────────────── */
.clip-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.clip-viewer.hidden {
    display: none;
}

.clip-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    cursor: pointer;
}

.clip-viewer-content {
    position: relative;
    width: 90vw;
    max-width: 960px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.clip-viewer-x {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 10;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    font-size: 24px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.clip-viewer-x:hover {
    background: rgba(145, 71, 255, 0.6);
}

.clip-viewer-embed {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}
.clip-viewer-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.clip-viewer-info {
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.clip-viewer-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.clip-viewer-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}

.clip-viewer-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.clip-viewer-channel {
    color: var(--primary);
    font-weight: 600;
}

.clip-viewer-sep {
    opacity: 0.3;
}

.clip-viewer-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 4px;
}
.clip-viewer-link:hover {
    text-decoration: underline;
}

/* ─── Loading / Empty ─────────────────────────────────────────── */
.clips-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 13px;
    grid-column: 1 / -1;
}

.clips-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.clips-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 13px;
}
.clips-empty a {
    color: var(--primary);
    text-decoration: none;
}

/* ─── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .clips-topbar {
        height: auto;
        min-height: 40px;
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 6px;
    }

    .clips-toolbar {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .clips-filter-label {
        display: none;
    }

    .clips-search {
        width: 100%;
        flex: 1;
    }
    .clips-search:focus {
        width: 100%;
    }

    .clips-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 10px;
    }

    .clips-content {
        padding: 10px;
    }

    .clip-viewer-content {
        width: 96vw;
    }

    /* Nav button sits next to search on wrapped row */
    .clips-toolbar-sep {
        display: none;
    }
    .clips-nav-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 420px) {
    .clips-page-title {
        display: none;
    }

    .clips-grid {
        grid-template-columns: 1fr;
    }

    .clips-back span {
        display: none;
    }
}

/* ─── Clip Markers Section ────────────────────────────────────── */
.clip-markers-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.clip-markers-section.hidden { display: none; }

.clip-markers-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
}
.clip-markers-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.clip-markers-hint {
    font-size: 11px;
    color: var(--muted);
}

.clip-markers-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clip-marker-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s;
}
.clip-marker-card:hover {
    border-color: var(--primary);
}

.clip-marker-info {
    flex: 1;
    min-width: 0;
}
.clip-marker-streamer {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}
.clip-marker-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.clip-marker-meta {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.clip-marker-meta span::before {
    content: '• ';
}
.clip-marker-meta span:first-child::before {
    content: '';
}

.clip-marker-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.clip-marker-btn {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.clip-marker-btn-twitch {
    background: #9147ff;
    color: #fff;
}
.clip-marker-btn-twitch:hover {
    background: #7c3ddb;
}
.clip-marker-btn-delete {
    background: var(--border);
    color: var(--muted);
}
.clip-marker-btn-delete:hover {
    background: #ef4444;
    color: #fff;
}

@media (max-width: 600px) {
    .clip-marker-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .clip-marker-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
