/* ═══════════════════════════════════════════════════════════════════════════
   category.css — the browse page (category.html). Shared theme is in site.css.
   ═══════════════════════════════════════════════════════════════════════════ */

html.native-dark #cp {
    --cat: var(--c-anime);
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 32px 80px;
}

html.native-dark #cp[data-cat="anime"]  { --cat: var(--c-anime); }
html.native-dark #cp[data-cat="game"]   { --cat: var(--c-game); }
html.native-dark #cp[data-cat="movie"]  { --cat: var(--c-movie); }
html.native-dark #cp[data-cat="tvshow"] { --cat: var(--c-tvshow); }

/* ── Hero ───────────────────────────────────────────────────────────────── */
html.native-dark .cp-hero {
    position: relative;
    overflow: hidden;
    margin-top: 24px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background:
        radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--cat) 28%, transparent) 0%, transparent 60%),
        var(--surface);
    isolation: isolate;
}

/* Tilted wall of covers from this category, faded out toward the text */
html.native-dark .cp-hero-mosaic {
    position: absolute;
    top: -40px;
    right: -60px;
    width: 64%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    transform: rotate(-8deg);
    opacity: 0.55;
    z-index: -1;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 45%);
            mask-image: linear-gradient(90deg, transparent 0%, #000 45%);
}

html.native-dark .cp-hero-mosaic span {
    aspect-ratio: 1;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

html.native-dark .cp-hero-content {
    position: relative;
    padding: 44px 44px 40px;
    max-width: 560px;
}

html.native-dark .cp-crumbs {
    display: flex;
    gap: 8px;
    padding: 0;
    border: 0;
    justify-content: flex-start;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-3);
    margin-bottom: 14px;
}

html.native-dark .cp-crumbs a { color: var(--text-2); text-decoration: none; }
html.native-dark .cp-crumbs a:hover { color: var(--text); }

html.native-dark .cp-title {
    font-size: clamp(2.2rem, 4.5vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--text);
    margin-bottom: 12px;
}

html.native-dark .cp-desc {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-2);
    margin-bottom: 18px;
}

html.native-dark .cp-total {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    min-height: 1.2em;
}

html.native-dark .cp-total:not(:empty)::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cat);
    box-shadow: 0 0 12px var(--cat);
}

/* ── Category switcher ──────────────────────────────────────────────────── */
html.native-dark .cp-cats {
    display: flex;
    gap: 8px;
    padding: 20px 0 0;
    border: 0;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
}

html.native-dark .cp-cats::-webkit-scrollbar { display: none; }

html.native-dark .cp-cat {
    --dot: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

html.native-dark .cp-cat[data-cat="anime"]  { --dot: var(--c-anime); }
html.native-dark .cp-cat[data-cat="game"]   { --dot: var(--c-game); }
html.native-dark .cp-cat[data-cat="movie"]  { --dot: var(--c-movie); }
html.native-dark .cp-cat[data-cat="tvshow"] { --dot: var(--c-tvshow); }

html.native-dark .cp-cat:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-2); }

html.native-dark .cp-cat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dot);
}

html.native-dark .cp-cat-n {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

html.native-dark .cp-cat.active {
    background: #fff;
    border-color: #fff;
    color: #0a0a0c;
}

html.native-dark .cp-cat.active .cp-cat-n { color: #52525b; }

/* ── Toolbar (sticks under the header) ──────────────────────────────────── */
html.native-dark .cp-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 40;
    margin: 16px -32px 0;
    padding: 14px 32px 12px;
    background: rgba(10, 10, 12, 0.86);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

html.native-dark .cp-toolbar.is-stuck {
    border-bottom-color: var(--line);
    box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.6);
}

html.native-dark .cp-toolbar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

html.native-dark .cp-search {
    position: relative;
    flex: 1;
    min-width: 0;
}

html.native-dark .cp-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

html.native-dark #cp-search {
    width: 100%;
    height: 46px;
    padding: 0 76px 0 44px;
    border-radius: 12px;
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

html.native-dark #cp-search::-webkit-search-cancel-button { -webkit-appearance: none; }
html.native-dark #cp-search::placeholder { color: var(--text-3); }

html.native-dark #cp-search:focus {
    border-color: color-mix(in srgb, var(--cat) 70%, white 10%);
    background: var(--surface-2);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cat) 18%, transparent);
}

html.native-dark #cp-search:focus-visible { outline: none; }

html.native-dark .cp-search-clear {
    position: absolute;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
}

html.native-dark .cp-search-clear[hidden] { display: none; }
html.native-dark .cp-search-clear:hover { color: var(--text); background: #33333b; }

html.native-dark .cp-search-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    border: 1px solid var(--line-2);
    font: 600 0.72rem/1 var(--font);
    color: var(--text-3);
}

html.native-dark #cp-search:focus ~ .cp-search-kbd { opacity: 0; }

html.native-dark .cp-select {
    position: relative;
    display: flex;
    align-items: center;
    height: 46px;
    border-radius: 12px;
    border: 1px solid var(--line-2);
    background: var(--surface);
    padding-left: 14px;
    flex-shrink: 0;
    transition: border-color 0.15s;
}

html.native-dark .cp-select:hover { border-color: rgba(255, 255, 255, 0.22); }
html.native-dark .cp-select:focus-within { border-color: rgba(255, 255, 255, 0.4); }

html.native-dark .cp-select::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 7px;
    height: 7px;
    margin-top: -5px;
    border-right: 2px solid var(--text-3);
    border-bottom: 2px solid var(--text-3);
    transform: rotate(45deg);
    pointer-events: none;
}

html.native-dark .cp-select-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-3);
    margin-right: 2px;
}

html.native-dark .cp-select select {
    appearance: none;
    -webkit-appearance: none;
    height: 100%;
    max-width: 220px;
    padding: 0 36px 0 6px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: 600 0.875rem var(--font);
    cursor: pointer;
    outline: none;
    text-overflow: ellipsis;
}

html.native-dark .cp-select select:focus-visible { outline: none; }
html.native-dark .cp-select option { background: var(--surface-2); color: var(--text); }

/* Decade chips */
html.native-dark .cp-decades {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

html.native-dark .cp-decades::-webkit-scrollbar { display: none; }

html.native-dark .cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

html.native-dark .cp-chip span {
    font-size: 0.72rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

html.native-dark .cp-chip:hover { color: var(--text); border-color: var(--line-2); background: var(--surface); }

html.native-dark .cp-chip[aria-pressed="true"] {
    color: var(--text);
    border-color: color-mix(in srgb, var(--cat) 55%, transparent);
    background: color-mix(in srgb, var(--cat) 16%, transparent);
}

html.native-dark .cp-chip[aria-pressed="true"] span { color: var(--text-2); }

/* ── Results ────────────────────────────────────────────────────────────── */
html.native-dark .cp-results { padding-top: 18px; }

html.native-dark .cp-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 28px;
    margin-bottom: 18px;
}

html.native-dark #cp-count {
    font-size: 0.875rem;
    color: var(--text-2);
}

html.native-dark .cp-clear {
    border: 0;
    background: none;
    padding: 4px 0;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--text-3);
    cursor: pointer;
}

html.native-dark .cp-clear:hover { text-decoration-color: var(--text); }
html.native-dark .cp-clear[hidden] { display: none; }

html.native-dark .cp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 28px 20px;
}

html.native-dark .cp-card {
    display: block;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
    outline-offset: 4px;
}

html.native-dark .cp-card-art {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2) center / cover no-repeat;
    box-shadow: 0 0 0 1px var(--line);
    margin-bottom: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Initial letter shown until (or unless) artwork arrives */
html.native-dark .cp-card-art::before {
    content: attr(data-initial);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--surface-3);
}

html.native-dark .cp-card-art.has-art::before { content: none; }

html.native-dark .cp-card-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

html.native-dark .cp-card:hover .cp-card-art {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line-2);
}

html.native-dark .cp-card-rating {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fcd34d;
    font-size: 0.72rem;
    font-weight: 700;
}

html.native-dark .cp-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

html.native-dark .cp-card-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-3);
    min-width: 0;
}

html.native-dark .cp-card-composer {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html.native-dark .cp-card-year {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

html.native-dark .cp-card-year::before {
    content: '·';
    margin-right: 6px;
}

/* Loading skeleton */
html.native-dark .cp-card.is-skeleton .cp-card-art,
html.native-dark .cp-skel-line {
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
    background-size: 200% 100%;
    animation: cpShimmer 1.3s ease-in-out infinite;
}

html.native-dark .cp-card.is-skeleton .cp-card-art::before { content: none; }

html.native-dark .cp-skel-line {
    height: 11px;
    border-radius: 6px;
    margin-bottom: 8px;
}

html.native-dark .cp-skel-line.short { width: 60%; }

@keyframes cpShimmer {
    from { background-position: 100% 0; }
    to   { background-position: -100% 0; }
}

/* Empty / error */
html.native-dark .cp-empty {
    text-align: center;
    padding: 72px 20px;
    border: 1px dashed var(--line-2);
    border-radius: 16px;
}

html.native-dark .cp-empty[hidden] { display: none; }
html.native-dark .cp-empty-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
html.native-dark .cp-empty-sub { font-size: 0.9rem; color: var(--text-3); margin-bottom: 20px; }

html.native-dark .cp-empty-btn {
    padding: 10px 20px;
    border-radius: 999px;
    border: 0;
    background: #fff;
    color: #0a0a0c;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

html.native-dark .cp-empty-btn:hover { background: #e4e4e7; }

html.native-dark .cp-error {
    grid-column: 1 / -1;
    padding: 48px 0;
    text-align: center;
    color: #fca5a5;
}

html.native-dark .cp-sentinel { height: 1px; }

/* Back to top */
html.native-dark .cp-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line-2);
    background: var(--surface-2);
    color: var(--text);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

html.native-dark .cp-top:hover { background: var(--surface-3); transform: translateY(-2px); }
html.native-dark .cp-top[hidden] { display: none; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    html.native-dark .cp-toolbar-inner { flex-wrap: wrap; }
    html.native-dark .cp-search { flex-basis: 100%; }
    html.native-dark .cp-select { flex: 1; min-width: 0; }
    html.native-dark .cp-select select { max-width: none; width: 100%; }
    html.native-dark .cp-hero-mosaic { width: 80%; opacity: 0.35; }
}

@media (max-width: 768px) {
    html.native-dark #cp { padding: 0 16px 64px; }

    html.native-dark .cp-hero { margin-top: 16px; border-radius: 16px; }
    html.native-dark .cp-hero-content { padding: 28px 22px 26px; }
    html.native-dark .cp-hero-mosaic { width: 110%; right: -45%; opacity: 0.3; }
    html.native-dark .cp-desc { font-size: 0.92rem; }

    /* The header isn't sticky on phones, so the toolbar sticks to the very top */
    html.native-dark .cp-toolbar { top: 0; margin: 12px -16px 0; padding: 12px 16px 10px; }
    html.native-dark .cp-search-kbd { display: none; }
    html.native-dark .cp-select-label { display: none; }
    html.native-dark .cp-select select { padding-left: 0; }
    html.native-dark #cp-search { padding-right: 44px; }
    html.native-dark .cp-search-clear { right: 10px; }

    html.native-dark .cp-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 22px 14px;
    }

    html.native-dark .cp-top { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    html.native-dark .cp-card.is-skeleton .cp-card-art,
    html.native-dark .cp-skel-line { animation: none; }
}
