/* ============================================================
   AppCard — reusable mini-app card
   ============================================================ */

.app-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8ecf0;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    height: 100%;
}

.app-card:hover,
.app-card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--app-color, #149ddd);
    outline: none;
}

/* Colored top accent bar */
.app-card__accent {
    height: 4px;
    background: var(--app-color, #149ddd);
    flex-shrink: 0;
}

/* Header: icon + badges */
.app-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 16px 8px;
    gap: 8px;
}

.app-card__icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.app-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}

.app-card__badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.app-card__badge--featured {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.app-card__badge--trending {
    background: #fde8f0;
    color: #c0392b;
    border: 1px solid #f5a0b5;
}

.app-card__badge--type {
    background: #e8f8f2;
    color: #0d7a5f;
    border: 1px solid #a3e4cc;
}

/* Body: title + description */
.app-card__body {
    padding: 0 16px 12px;
    flex: 1;
}

.app-card__title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
    line-height: 1.3;
}

.app-card__description {
    font-size: 0.85rem;
    color: #555;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer: meta + tags */
.app-card__footer {
    padding: 10px 16px 14px;
    border-top: 1px solid #f0f2f5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.app-card__category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-color, #149ddd);
    background: color-mix(in srgb, var(--app-color, #149ddd) 10%, transparent);
    padding: 2px 8px;
    border-radius: 20px;
}

.app-card__meta {
    font-size: 0.75rem;
    color: #777;
    display: flex;
    align-items: center;
    gap: 3px;
}

.app-card__meta--time {
    margin-left: auto;
}

.app-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
    margin-top: 4px;
}

.app-card__tag {
    font-size: 0.7rem;
    background: #f0f4f8;
    color: #555;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

/* Size variants */

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .app-card {
        background: #1e2433;
        border-color: #2d3748;
        color: #e2e8f0;
    }

    .app-card__title {
        color: #f0f4f8;
    }

    .app-card__description {
        color: #a0aec0;
    }

    .app-card__footer {
        border-top-color: #2d3748;
    }

    .app-card__tag {
        background: #2d3748;
        color: #a0aec0;
        border-color: #3d4a5c;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .app-card__header {
        padding: 12px 12px 6px;
    }

    .app-card__body {
        padding: 0 12px 10px;
    }

    .app-card__footer {
        padding: 8px 12px 12px;
    }
}/* ============================================================
   CategoryLayout — reusable category landing page
   ============================================================ */

.category-layout {
    min-height: 60vh;
    padding-bottom: 60px;
}

/* Small gap to separate sticky site header from category hero
   Ensures pages that reuse the exams-style header (for example /tools)
   align visually with other pages like /courses. */
.category-layout>.container>.exams-hub-header,
.category-layout>.container>.category-hero {
    margin-top: 1.2rem;
}

/* ── Hero ── */
.category-hero {
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--category-color, #149ddd) 8%, #fff) 0%,
            #fff 100%);
    border-bottom: 1px solid #e8ecf0;
    padding: 48px 0 40px;
    margin-bottom: 40px;
}

.category-hero__inner {
    display: flex;
    align-items: center;
    gap: 24px;
}

.category-hero__icon {
    font-size: 3.5rem;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.12));
}

.category-hero__title {
    font-size: 2rem;
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 8px;
    line-height: 1.2;
}

.category-hero__description {
    font-size: 1rem;
    color: #555;
    margin: 0 0 12px;
    max-width: 560px;
    line-height: 1.6;
}

.category-hero__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.category-hero__stats span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--category-color, #149ddd);
    background: color-mix(in srgb, var(--category-color, #149ddd) 10%, transparent);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--category-color, #149ddd) 25%, transparent);
}

/* Note: In-hero category switcher was removed from JSX in favor of header-provided nav.
   These styles were intentionally removed to avoid stale CSS. Reintroduce if enabling
   a hero switcher in future (use `.category-switcher` and `.category-switcher__link`). */

/* Blog-specific: make blog header, search and tags match Exams hub styles */
body.page-blog .category-hero {
    background: transparent;
    border-bottom: none;
    /* nudge down slightly: more gap above, less below to visually slide toward search */
    padding: 22px 0 6px;
    margin-bottom: 1.25rem;
}

body.page-blog .category-hero__inner {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

body.page-blog .category-hero__icon {
    font-size: 3rem;
    color: var(--category-color, #20c997);
    line-height: 1;
    flex-shrink: 0;
    filter: none;
}

body.page-blog .category-hero__title {
    margin: 0 0 0.3rem;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    color: #1a1a2e;
    line-height: 1.1;
}

body.page-blog .category-hero__description {
    margin: 0;
    color: #4b5563;
    font-size: 1rem;
    line-height: 1.6;
}

body.page-blog .category-hero__stats span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--category-color, #20c997);
    background: color-mix(in srgb, var(--category-color, #20c997) 10%, transparent);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid color-mix(in srgb, var(--category-color, #20c997) 25%, transparent);
}

/* hide header stat pill (e.g. "6 items") on blog pages */
body.page-blog .category-hero__stats {
    display: none;
}

/* Search mapped to Exams look */
body.page-blog .category-search {
    margin-bottom: 2rem;
}

body.page-blog .category-search__input {
    width: 100%;
    max-width: 420px;
    padding: 0.65rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.page-blog .category-search__input:focus {
    border-color: var(--category-color, #20c997);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--category-color, #20c997) 12%, transparent);
}

/* hide the search icon on blog pages to avoid placeholder overlap */
body.page-blog .category-search__icon {
    display: none;
}

/* Tags mapped to Exams tag pills */
body.page-blog .category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.75rem;
}

body.page-blog .category-tag {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.3rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    user-select: none;
    line-height: 1.4;
}

body.page-blog .category-tag:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
}

body.page-blog .category-tag--active {
    background: var(--category-color, #20c997);
    color: #fff;
    border-color: var(--category-color, #20c997);
}

/* Category pages that should use Exams-style hero/search/tags (blog, tools, games, playground) */
/* Hero */
body.page-blog .category-hero {
    background: transparent;
    border-bottom: none;
    /* nudge down slightly: more gap above, less below to visually slide toward search */
    padding: 22px 0 6px;
    margin-bottom: 1.25rem;
}

body.page-blog .category-hero__inner {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

body.page-blog .category-hero__icon {
    font-size: 3rem;
    color: var(--category-color, #20c997);
    line-height: 1;
    flex-shrink: 0;
    filter: none;
}

body.page-blog .category-hero__title {
    margin: 0 0 0.3rem;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    color: #1a1a2e;
    line-height: 1.1;
}

body.page-blog .category-hero__description {
    margin: 0;
    color: #4b5563;
    font-size: 1rem;
    line-height: 1.6;
}

/* hide header stat pill (e.g. "6 items") on these category pages */
body.page-blog .category-hero__stats {
    display: none;
}

/* Search mapped to Exams look */
body.page-blog .category-search {
    margin-bottom: 2rem;
}

body.page-blog .category-search__input {
    width: 100%;
    max-width: 420px;
    padding: 0.65rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.page-blog .category-search__input:focus {
    border-color: var(--category-color, #20c997);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--category-color, #20c997) 12%, transparent);
}

/* hide the search icon on these category pages to avoid placeholder overlap */
body.page-blog .category-search__icon {
    display: none;
}

/* Tags mapped to Exams tag pills */
body.page-blog .category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.75rem;
}

body.page-blog .category-tag {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.3rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    user-select: none;
    line-height: 1.4;
}

body.page-blog .category-tag:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
}

body.page-blog .category-tag--active {
    background: var(--category-color, #20c997);
    color: #fff;
    border-color: var(--category-color, #20c997);
}

.category-search {
    position: relative;
    max-width: 480px;
}

.category-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.category-search__input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #333;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.category-search__input:focus {
    border-color: var(--category-color, #149ddd);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--category-color, #149ddd) 15%, transparent);
}

.category-search__clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 0.85rem;
    padding: 2px 4px;
    line-height: 1;
}

.category-search__clear:hover {
    color: #333;
}

/* Tag filter pills */
.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tag {
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid #dde3ea;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: capitalize;
}

.category-tag:hover {
    border-color: var(--category-color, #149ddd);
    color: var(--category-color, #149ddd);
}

.category-tag--active {
    background: var(--tag-color, #149ddd);
    border-color: var(--tag-color, #149ddd);
    color: #fff;
    font-weight: 600;
}

/* ── App Grid ── */
.category-grid-section {
    margin-bottom: 40px;
}

.category-grid__count {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 16px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.category-grid__item {
    display: flex;
}

.category-grid__item .app-card {
    width: 100%;
}

/* ── Empty state ── */
.category-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.category-empty__icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.category-empty p {
    font-size: 1rem;
    margin-bottom: 16px;
}

.category-empty__reset {
    background: none;
    border: 1px solid #dde3ea;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #555;
    transition: all 0.15s;
}

.category-empty__reset:hover {
    border-color: #149ddd;
    color: #149ddd;
}

/* ── Back link ── */
.category-back {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #f0f2f5;
}

.category-back__link {
    font-size: 0.85rem;
    color: #777;
    text-decoration: none;
    transition: color 0.15s;
}

.category-back__link:hover {
    color: #149ddd;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .category-hero {
        padding: 32px 0 28px;
        margin-bottom: 28px;
    }

    .category-hero__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .category-hero__icon {
        font-size: 2.5rem;
    }

    .category-hero__title {
        font-size: 1.6rem;
    }

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

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

    .category-hero__title {
        font-size: 1.4rem;
    }
}

/* ------------------------------------------------------------------
   Enforce light theme for app cards within category pages (/tools etc.)
   This overrides prefers-color-scheme dark rules so tiles remain light.
 ------------------------------------------------------------------ */
.category-layout .app-card {
    background: #fff;
    border-color: #e8ecf0;
    color: inherit;
}

.category-layout .app-card__title {
    color: #1a1a2e;
}

.category-layout .app-card__description {
    color: #555;
}

.category-layout .app-card__footer {
    border-top-color: #f0f2f5;
}

.category-layout .app-card__tag {
    background: #f0f4f8;
    color: #555;
    border-color: #e2e8f0;
}