/* Top 10 custom blocks: Category Grid + List Browser
   Card language mirrors top10.us.com: rounded image frame with a solid idle
   border that fades on hover to reveal a spinning conic-gradient ring while the
   image zooms. */

/* Custom angle property so the conic gradient can be animated. */
@property --top10-border-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

.top10-cat-grid-block,
.top10-list-browser-block {
    --top10-cols: 4;
    --top10-card-radius: 28px;
    --top10-ink: #1f2733;
    --top10-muted: #6b7480;
    --top10-frame-bg: #f4f6f8;
    --top10-frame-border: #e6e9ee;
    --top10-border-width: 5px;
    /* Idle border colour — prefers the theme's neutral if present. */
    --top10-border-idle: var(--global-palette7, #e6e9ee);
    /* Brand spin colours — prefer existing theme vars, else fall back to the
       rank-colour palette used elsewhere in the plugin. */
    --top10-spin-green: var(--green-dark, #4b7f4f);
    --top10-spin-blue: var(--blue-dark, #2e6385);
    --top10-spin-yellow: var(--yellow-dark, #d9ac45);
    --top10-spin-orange: var(--orange-dark, #e06e38);
    --top10-spin-red: var(--red-dark, #c03933);
    font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    color: var(--top10-ink);
    box-sizing: border-box;
}

.top10-cat-grid-block *,
.top10-list-browser-block * {
    box-sizing: border-box;
}

/* Archive page: contain and centre the browser at 1440px. */
.top10-archive-wrapper {
    max-width: 1440px;
    margin-inline: auto;
    padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px);
    font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    color: #1f2733;
}

.top10-archive-header {
    margin: 0 0 clamp(20px, 3vw, 34px);
}

.top10-archive-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    margin: 0 0 .5rem;
    color: #1f2733;
}

.top10-archive-description {
    width: 100%;
    max-width: none;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #4a5563;
}

.top10-archive-description p {
    margin: 0 0 .75em;
}

.top10-archive-description :last-child {
    margin-bottom: 0;
}

.top10-blocks-heading {
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 800;
    margin: 0 0 1.5rem;
    color: var(--top10-ink);
}

/* ---- Grids ---- */
/* Scoped under the block wrapper so the reset beats the theme's
   `.entry-content ul { padding-inline-start }` rule (which otherwise indents
   the grid to the left of its container). */
.top10-cat-grid-block .top10-cat-grid,
.top10-list-browser-block .top10-lb-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-inline-start: 0;
    display: grid;
    grid-template-columns: repeat(var(--top10-cols), minmax(0, 1fr));
    gap: clamp(16px, 2.2vw, 30px);
}

.top10-cat-grid-block .top10-cat-grid > li,
.top10-list-browser-block .top10-lb-grid > li {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---- Card ---- */
.top10-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    gap: 12px;
}

.top10-card-thumb {
    --top10-border-angle: 0deg;
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--top10-card-radius);
    /* Solid idle border sits over a hidden conic gradient in the border-box. */
    border: var(--top10-border-width) solid var(--top10-border-idle);
    background:
        linear-gradient(var(--top10-frame-bg), var(--top10-frame-bg)) padding-box,
        conic-gradient(
            from var(--top10-border-angle),
            var(--top10-spin-green),
            var(--top10-spin-blue),
            var(--top10-spin-yellow),
            var(--top10-spin-orange),
            var(--top10-spin-red),
            var(--top10-spin-green)
        ) border-box;
    /* Constrain the zooming image so it can't spill past the rounded frame. */
    overflow: hidden;
    box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .35);
    transition: border-color .4s ease, box-shadow .35s ease;
}

.top10-card-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border: none;
    border-radius: 0;
    transition: transform .4s ease-in-out;
}

/* "10" placeholder */
.top10-card-ph {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    letter-spacing: -.03em;
    color: #b9c0ca;
    background: var(--top10-frame-bg);
}

.top10-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--top10-ink);
}

.top10-card-meta {
    font-size: .85rem;
    font-weight: 500;
    color: var(--top10-muted);
}

/* ---- Hover: fade the solid border to reveal + spin the gradient, zoom img ---- */
.top10-card:hover .top10-card-thumb,
.top10-card:focus-visible .top10-card-thumb {
    border-color: transparent;
    animation: top10-border-spin 4s linear infinite;
    box-shadow: 0 18px 38px -20px rgba(0, 0, 0, .45);
}

.top10-card:hover .top10-card-thumb img,
.top10-card:focus-visible .top10-card-thumb img {
    transform: scale(1.1);
}

.top10-card:focus-visible {
    outline: none;
}

.top10-card:focus-visible .top10-card-thumb {
    outline: 3px solid var(--top10-spin-blue);
    outline-offset: 4px;
}

.top10-card:hover .top10-card-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

@keyframes top10-border-spin {
    to {
        --top10-border-angle: 360deg;
    }
}

/* ---- List Browser controls ---- */
.top10-lb-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0 0 1.75rem;
}

.top10-lb-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.top10-lb-search-wrap {
    flex: 1 1 240px;
    min-width: 200px;
}

.top10-lb-search,
.top10-lb-filter {
    width: 100%;
    font: inherit;
    color: var(--top10-ink);
    background: #fff;
    border: 1px solid var(--top10-frame-border);
    border-radius: 12px;
    padding: 10px 14px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.top10-lb-filter {
    width: auto;
    min-width: 160px;
    cursor: pointer;
}

.top10-lb-search:focus,
.top10-lb-filter:focus {
    outline: none;
    border-color: var(--top10-spin-blue);
    box-shadow: 0 0 0 3px rgba(43, 106, 168, .15);
}

.top10-lb-status {
    margin: 0 0 0 auto;
    font-size: .9rem;
    color: var(--top10-muted);
    white-space: nowrap;
}

.top10-lb-status [data-role="visible-count"] {
    font-weight: 700;
    color: var(--top10-ink);
}

/* Category chips — multi-select, combinable (union). */
.top10-lb-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.top10-lb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1;
    padding: 8px 14px;
    border: 1px solid var(--top10-frame-border);
    border-radius: 999px;
    background: #fff;
    color: var(--top10-ink);
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.top10-chip-icon {
    font-size: 18px;
    line-height: 1;
}

/* Material Symbols base (shared by chips + archive header). */
.top10-list-browser-block .material-symbols-outlined,
.top10-archive-header .material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    display: inline-flex;
    vertical-align: middle;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
}

.top10-archive-icon {
    font-size: 1.5em;
    margin-right: .4em;
    color: var(--top10-spin-blue, #2e6385);
}

/* Beat the display:inline-flex above so [hidden] icons/desc stay hidden. */
.top10-archive-header .material-symbols-outlined[hidden],
.top10-archive-description[hidden] {
    display: none !important;
}

.top10-lb-chip:hover {
    border-color: var(--top10-spin-blue);
    color: var(--top10-spin-blue);
}

.top10-lb-chip.is-active {
    background: var(--top10-spin-blue);
    border-color: var(--top10-spin-blue);
    color: #fff;
}

/* ---- Empty states ---- */
.top10-blocks-empty,
.top10-lb-empty {
    text-align: center;
    color: var(--top10-muted);
    padding: 2.5rem 1rem;
    font-weight: 500;
}

.top10-lb-item.is-hidden {
    display: none;
}

/* ---- Smooth fades ---- */
@keyframes top10-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Visible cards fade/slide in — replays whenever an item goes from hidden to
   shown (filter change, pagination) or on first render. */
.top10-lb-item {
    animation: top10-fade-in .35s ease both;
}

/* Header title + description crossfade (opacity toggled from JS on switch). */
.top10-archive-title,
.top10-archive-description {
    transition: opacity .18s ease;
}

@media (prefers-reduced-motion: reduce) {
    .top10-lb-item {
        animation: none;
    }
    .top10-archive-title,
    .top10-archive-description {
        transition: none;
    }
}

/* ---- Pagination ---- */
.top10-lb-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: clamp(24px, 4vw, 44px);
}

.top10-lb-page {
    font: inherit;
    font-weight: 600;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--top10-frame-border);
    border-radius: 10px;
    background: #fff;
    color: var(--top10-ink);
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.top10-lb-page:hover:not(:disabled):not(.is-current) {
    border-color: var(--top10-spin-blue);
    color: var(--top10-spin-blue);
}

.top10-lb-page.is-current {
    background: var(--top10-spin-blue);
    border-color: var(--top10-spin-blue);
    color: #fff;
    cursor: default;
}

.top10-lb-page:disabled {
    opacity: .45;
    cursor: default;
}

.top10-lb-page-gap {
    padding: 0 4px;
    color: var(--top10-muted);
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
    .top10-cat-grid-block .top10-cat-grid,
    .top10-list-browser-block .top10-lb-grid {
        grid-template-columns: repeat(min(var(--top10-cols), 3), minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .top10-cat-grid-block .top10-cat-grid,
    .top10-list-browser-block .top10-lb-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .top10-lb-status {
        margin: 4px 0 0;
        width: 100%;
    }
}

@media (max-width: 420px) {
    .top10-cat-grid-block .top10-cat-grid,
    .top10-list-browser-block .top10-lb-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .top10-card-thumb,
    .top10-card-thumb img {
        transition: none;
    }
    .top10-card:hover .top10-card-thumb,
    .top10-card:focus-visible .top10-card-thumb {
        animation: none;
        border-color: var(--top10-spin-blue);
    }
    .top10-card:hover .top10-card-thumb img,
    .top10-card:focus-visible .top10-card-thumb img {
        transform: none;
    }
}
