/* Categories discovery page (/categories/) */

.categories-page {
    background: #f8fafc;
    overflow-x: hidden;
}

.cat-page {
    width: 100%;
    max-width: 100%;
    min-height: 60vh;
    overflow-x: hidden;
}

/* —— Hero —— */
.cat-hero {
    background: #fff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    padding: 1.75rem 1rem 1.5rem;
}

@media (min-width: 768px) {
    .cat-hero {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.92) 100%),
            radial-gradient(ellipse 80% 60% at 50% -20%, rgba(14, 143, 102, 0.1), transparent 55%);
        padding: 3.5rem 2rem 2.75rem;
    }
}

.cat-hero-inner {
    max-width: 42rem;
    margin: 0 auto;
    text-align: center;
    min-width: 0;
}

.cat-kicker {
    display: inline-block;
    margin: 0 0 0.75rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    background: rgba(14, 143, 102, 0.1);
    color: #056947;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.cat-hero h1 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.5rem, 5vw, 2.65rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.12;
}

.cat-lead {
    margin: 0.75rem auto 0;
    max-width: 36rem;
    color: #64748b;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.cat-hero-cta {
    display: inline-flex;
    margin-top: 1rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.cat-hero-cta:hover {
    border-color: rgba(14, 143, 102, 0.35);
    background: rgba(14, 143, 102, 0.08);
    color: #166534;
}

/* —— Toolbar sticky (debajo del navbar; relativo en móvil — ver mobile-safe.css) —— */
.cat-toolbar-wrap {
    position: sticky;
    top: 4rem;
    z-index: 30;
    background: #f8fafc;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

@media (max-width: 768px) {
    .cat-toolbar-wrap {
        position: relative;
        top: auto;
    }
}

@media (min-width: 1024px) {
    .cat-toolbar-wrap {
        top: 3.75rem;
    }
}

.cat-toolbar {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.875rem 1rem 1rem;
    min-width: 0;
    overflow: visible;
}

@media (min-width: 768px) {
    .cat-toolbar {
        padding: 1rem 2rem 1.1rem;
    }
}

.cat-search-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

@media (min-width: 768px) {
    .cat-search-row {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
}

.cat-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding: 0 1rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 4px 14px -10px rgba(15, 23, 42, 0.2);
    color: #64748b;
}

.cat-search:focus-within {
    border-color: rgba(14, 143, 102, 0.45);
    box-shadow: 0 0 0 3px rgba(14, 143, 102, 0.12);
}

.cat-search input {
    flex: 1;
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #0f172a;
    font-size: 0.95rem;
    outline: none;
}

.cat-search input::placeholder {
    color: #94a3b8;
}

.cat-sort {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
    min-width: 0;
}

@media (max-width: 480px) {
    .cat-sort {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .cat-sort select {
        width: 100%;
        min-width: 0;
    }
}

.cat-sort label {
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.cat-sort select {
    min-width: 0;
    min-height: 3rem;
    padding: 0 2rem 0 0.85rem;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    color: #0f172a;
    font-size: 0.875rem;
    appearance: none;
    cursor: pointer;
}

@media (min-width: 481px) {
    .cat-sort select {
        min-width: 10.5rem;
    }
}

/* —— Chips / filtros (scroll: category-chip-scroll.css) —— */
.cat-chips.category-chip-scroll {
    margin-top: 0;
}

.cat-chip {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: #fff;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.cat-chip:hover {
    border-color: rgba(14, 143, 102, 0.35);
    color: #166534;
}

.cat-chip.is-active {
    border-color: rgba(14, 143, 102, 0.45);
    background: rgba(14, 143, 102, 0.12);
    color: #166534;
}

/* —— Results grid —— */
.cat-results-wrap {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
    min-width: 0;
    overflow-x: hidden;
}

@media (min-width: 768px) {
    .cat-results-wrap {
        padding: 1.5rem 2rem 3.5rem;
    }
}

.cat-results-count {
    margin: 0 0 1rem;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    width: 100%;
    min-width: 0;
}

@media (min-width: 769px) {
    .cat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.15rem;
    }
}

@media (min-width: 1024px) {
    .cat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .cat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.cat-grid--groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

@media (min-width: 768px) {
    .cat-grid--groups {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1rem;
    }
}

@media (min-width: 1100px) {
    .cat-grid--groups {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.cat-breadcrumb {
    margin: 0 0 0.85rem;
    font-size: 0.875rem;
}

.cat-breadcrumb a {
    color: #056947;
    font-weight: 600;
    text-decoration: none;
}

.cat-breadcrumb a:hover {
    text-decoration: underline;
}

/* —— Category cards —— */
.cat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

@media (min-width: 769px) {
    .cat-card {
        isolation: isolate;
    }
}

.cat-card.is-hidden {
    display: none;
}

.cat-card-link {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    min-height: 210px;
    padding: 1.1rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    text-decoration: none;
    overflow: hidden;
    transform: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

@media (max-width: 767px) {
    .cat-card-link {
        min-height: 0;
    }
}

@media (hover: hover) and (pointer: fine) {
    .cat-card-link:hover {
        transform: translateY(-2px);
        border-color: rgba(14, 143, 102, 0.28);
        box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
    }
}

.cat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    min-width: 0;
}

.cat-card-count {
    flex-shrink: 0;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: #edf7f2;
    color: #0e8f66;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.cat-card-title {
    margin: 0;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

.cat-card-desc {
    margin: 0.4rem 0 0;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.5;
    flex: 1;
    word-break: normal;
    overflow-wrap: break-word;
}

.cat-card-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.875rem;
    color: #068C61;
    font-size: 0.82rem;
    font-weight: 700;
}

.cat-card-link:hover .cat-card-action {
    color: #056947;
}

/* —— Category icons (sin landing.css) —— */
.cat-page .landing-category-icon {
    width: 3.5rem;
    height: 3.5rem;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    margin-bottom: 0;
    color: #0f172a;
    background: #f8fafc;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.cat-page .landing-category-icon svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* One icon treatment across every category keeps the catalog visually coherent. */
.cat-page .landing-category-icon {
    color: #0e8f66;
    background: #edf7f2;
}

@media (max-width: 767px) {
    .cat-hero {
        padding: 1.15rem 0.85rem 1rem;
    }

    .cat-hero h1 {
        font-size: 1.55rem;
        letter-spacing: -0.015em;
    }

    .cat-lead {
        font-size: 0.875rem;
        line-height: 1.45;
    }

    .cat-toolbar {
        padding: 0.75rem 0.75rem 0.65rem;
    }

    .cat-search {
        min-height: 2.65rem;
        border-radius: 12px;
        padding: 0 0.75rem;
    }

    .cat-sort {
        display: none;
    }

    .cat-chip {
        padding: 0.42rem 0.72rem;
        font-size: 0.78rem;
    }

    .category-chip-scroll-wrap {
        margin-top: 0.55rem;
    }

    .category-chip-scroll {
        gap: 0.45rem;
        padding: 0.2rem 0 0.45rem;
        scroll-padding-inline: 0.75rem;
    }

    .cat-results-wrap {
        padding: 0.85rem 0.75rem calc(6.5rem + env(safe-area-inset-bottom));
    }

    .cat-results-count {
        margin-bottom: 0.7rem;
        font-size: 0.8rem;
    }

    .cat-grid,
    .cat-grid--groups {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .cat-card-link {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-height: 0;
        height: 100%;
        padding: 0.75rem 0.7rem 0.7rem;
        border-radius: 14px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
    }

    .cat-card-top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        width: 100%;
        margin: 0 0 0.55rem;
    }

    .cat-card-count {
        display: none;
    }

    .cat-card-title {
        margin: 0;
        font-size: 0.84rem;
        line-height: 1.25;
        letter-spacing: -0.01em;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .cat-card-desc {
        margin: 0.28rem 0 0;
        font-size: 0.7rem;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        flex: 1;
    }

    .cat-card-action {
        margin-top: 0.45rem;
        font-size: 0.7rem;
    }

    .cat-card-action svg {
        width: 12px;
        height: 12px;
    }

    .cat-page .landing-category-icon {
        width: 2.35rem;
        height: 2.35rem;
        border-radius: 11px;
    }

    .cat-page .landing-category-icon svg {
        width: 1.05rem;
        height: 1.05rem;
    }
}

@media (max-width: 390px) {
    .cat-hero {
        padding-top: 0.95rem;
    }

    .cat-grid,
    .cat-grid--groups {
        gap: 0.45rem;
    }

    .cat-card-link {
        padding: 0.65rem 0.58rem 0.6rem;
        border-radius: 12px;
    }

    .cat-card-title {
        font-size: 0.8rem;
    }

    .cat-card-desc {
        font-size: 0.66rem;
        -webkit-line-clamp: 2;
    }

    .cat-card-action {
        font-size: 0.66rem;
    }

    .cat-page .landing-category-icon {
        width: 2.1rem;
        height: 2.1rem;
        border-radius: 10px;
    }
}

/* —— Empty state —— */
.cat-empty {
    display: none;
    padding: 2rem 0 1rem;
}

.cat-empty:not(.is-hidden) {
    display: block;
}

.cat-empty-card {
    max-width: 32rem;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    text-align: center;
    border-radius: 20px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.cat-empty-card h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.2rem;
    font-weight: 700;
}

.cat-empty-card p {
    margin: 0.65rem 0 0;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.55;
}

.cat-empty-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1.25rem;
}

@media (min-width: 480px) {
    .cat-empty-actions {
        flex-direction: row;
        justify-content: center;
    }
}

.cat-btn-primary,
.cat-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 1.1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
}

.cat-btn-primary {
    background: #068C61;
    color: #fff;
}

.cat-btn-primary:hover {
    background: #056947;
    color: #fff;
}

.cat-btn-secondary {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    color: #0f172a;
}

.cat-btn-secondary:hover {
    border-color: rgba(14, 143, 102, 0.35);
    color: #166534;
}


/* Grid integrity: padded links must size inside their grid tracks. */
.cat-grid,
.cat-grid > .cat-card,
.cat-card-link {
    min-width: 0;
    box-sizing: border-box;
}

.cat-card-link {
    max-width: 100%;
}

.cat-card-title,
.cat-card-desc {
    min-width: 0;
}
