/* avbox — minimal lightweight design system */
:root {
    --bg: #0a0a0b;
    --surface: #121214;
    --surface-2: #1a1a1e;
    --border: #2a2a30;
    --text: #f2f2f3;
    --muted: #9a9aa3;
    --accent: #e8e8ea;
    --accent-hot: #c8ff5a;
    --danger: #ff7a8a;
    --radius: 10px;
    --radius-sm: 6px;
    --max: 1120px;
    --header-h: 60px;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(200, 255, 90, 0.45);
    --ease: 0.15s ease;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.container {
    width: min(100% - 32px, var(--max));
    margin-inline: auto;
    padding-block: 20px 48px;
}

/* —— Header —— */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 10, 11, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    margin: 0 0 20px;
}

.header {
    width: min(100% - 32px, var(--max));
    margin-inline: auto;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text);
    flex-shrink: 0;
    line-height: 1;
}

.brand:hover {
    color: var(--accent);
}

.search-bar {
    display: flex;
    align-items: stretch;
    flex: 1;
    max-width: 420px;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    transition: border-color var(--ease);
}

.search-bar:focus-within {
    border-color: #4a4a55;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    padding: 9px 14px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.92rem;
}

.search-bar input::placeholder {
    color: var(--muted);
}

.search-bar input:focus {
    outline: none;
    box-shadow: none;
}

.search-bar button {
    background: var(--surface-2);
    color: var(--text);
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    border-left: 1px solid var(--border);
    transition: background var(--ease), color var(--ease);
    white-space: nowrap;
}

.search-bar button:hover:not(:disabled) {
    background: var(--accent-hot);
    color: #111;
}

.search-bar button:disabled,
.search-bar button.loading {
    opacity: 0.55;
    cursor: not-allowed;
}

/* —— Filters —— */
.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 20px;
}

.filters-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.filters-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.filters-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
}

.filters-head small {
    display: none;
}

.filter-toggle-btn,
.filter-toggle {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    transition: color var(--ease), border-color var(--ease), background var(--ease);
    white-space: nowrap;
}

.filter-toggle-btn:hover,
.filter-toggle:hover {
    color: var(--text);
    border-color: #4a4a55;
    background: var(--surface-2);
}

.filters.collapsed .filter-grid,
.filter-grid.hidden {
    display: none;
}

.filters:not(.collapsed) .filters-head {
    margin-bottom: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.filter-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-control label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.filter-control select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    font-size: 0.9rem;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9aa3' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.filter-control select:focus {
    outline: none;
    border-color: #5a5a66;
    box-shadow: var(--focus);
}

/* —— Results header —— */
.search-section {
    margin-bottom: 16px;
}

.search-section .search-bar {
    max-width: none;
    width: 100%;
}

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

.search-results-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.search-results-count {
    font-size: 0.85rem;
    color: var(--muted);
}

.back-link,
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    margin-bottom: 16px;
    transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.back-link:hover,
.back-btn:hover {
    color: var(--text);
    border-color: #4a4a55;
    background: var(--surface);
}

/* —— Grid & cards —— */
#videos-container {
    min-height: 180px;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--ease), transform var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.video-card:hover {
    border-color: #4a4a55;
    transform: translateY(-2px);
}

.video-card:active,
.video-card.touched {
    transform: translateY(0);
}

.video-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--surface-2);
    overflow: hidden;
}

.video-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-thumb .placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 1.4rem;
    opacity: 0.6;
}

.code-badge,
.duration-chip {
    position: absolute;
    z-index: 2;
    font-size: 0.68rem;
    padding: 3px 7px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.code-badge {
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    text-transform: uppercase;
}

.duration-chip {
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: var(--accent-hot);
}

.video-body {
    padding: 12px 12px 14px;
}

/* Card title (grid). Detail page uses h1.video-title */
.video-card .video-title,
.video-body .video-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-sub {
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-tags {
    color: #6e6e78;
    font-size: 0.75rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-card .video-meta,
.video-body .video-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 0.72rem;
    color: var(--muted);
    align-items: center;
}

/* —— States —— */
.loading,
.loading-state,
.no-results,
.error-state,
.error {
    text-align: center;
    padding: 56px 16px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-hot);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.no-results-icon,
.error-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    color: var(--muted);
    opacity: 0.85;
}

.error-state h3,
.error {
    color: var(--danger);
    font-size: 1rem;
    font-weight: 600;
}

.no-results-hint,
.error-state p {
    font-size: 0.85rem;
    color: var(--muted);
}

.retry-btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background var(--ease), border-color var(--ease);
}

.retry-btn:hover {
    background: var(--accent-hot);
    color: #111;
    border-color: transparent;
}

/* —— Pagination —— */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.pagination button {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    transition: background var(--ease), border-color var(--ease);
}

.pagination button:hover:not(:disabled):not(.loading) {
    border-color: #4a4a55;
    background: var(--surface-2);
}

.pagination button:disabled,
.pagination button.loading {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    color: var(--muted);
    font-size: 0.85rem;
}

/* —— Detail page —— */
.page-detail .container {
    max-width: 960px;
}

.video-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 220px;
    max-height: 70vh;
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.video-player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.player-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    text-align: center;
    padding: 24px;
    font-size: 0.95rem;
}

.video-info {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.video-info > .video-title,
h1.video-title {
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
    color: var(--text);
    display: block;
    -webkit-line-clamp: unset;
}

.video-info > .video-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.meta-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.meta-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
}

.meta-item > div:last-child {
    font-size: 0.9rem;
    color: var(--text);
    word-break: break-word;
}

.search-link {
    color: var(--accent-hot);
    text-decoration: none;
    transition: opacity var(--ease);
}

.search-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.description {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.65;
}

.description strong {
    color: var(--text);
    font-weight: 600;
}

.scroll-top-btn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(18, 18, 20, 0.92);
    color: var(--text);
    font-size: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease), background var(--ease);
    z-index: 40;
}

.scroll-top-btn.show {
    opacity: 1;
    pointer-events: auto;
}

.scroll-top-btn:hover {
    background: var(--surface-2);
}

/* —— Footer —— */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 40px;
    padding: 28px 0 36px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

.site-footer .container {
    padding-block: 0;
}

.footer-title {
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.14em;
    margin-bottom: 8px;
}

.site-footer p {
    max-width: 40rem;
    margin-inline: auto;
}

.site-footer p + p {
    margin-top: 6px;
}

/* —— Responsive —— */
@media (max-width: 720px) {
    .header {
        flex-wrap: wrap;
    }

    .brand {
        font-size: 1.15rem;
    }

    .search-bar {
        max-width: none;
        width: 100%;
        flex-basis: 100%;
        order: 3;
    }

    .videos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .video-body {
        padding: 10px;
    }

    .video-card .video-title,
    .video-body .video-title {
        font-size: 0.82rem;
    }

    .video-sub,
    .video-tags {
        display: none;
    }

    .container {
        width: min(100% - 20px, var(--max));
        padding-block: 14px 36px;
    }
}

@media (max-width: 400px) {
    .videos-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.meta-sep {
    opacity: 0.45;
    margin: 0 2px;
}
.video-thumb img {
    background: var(--surface-2);
}
