/**
 * Per-page stylesheet for main_page=index (categories, category product listings).
 * Loaded in <head> by common/html_header.php's per-page sheet lookup.
 *
 * These rules used to sit in <style> blocks inside <body>, emitted by
 * tpl_category_page_content.php, tpl_index_product_list.php and
 * tpl_index_categories.php (#2049). All selectors are scoped, so loading them on
 * every index page (home included) is harmless.
 */

/* ---------------------------------------------------------------------------
 * Category Page Enrichment (tpl_category_page_content.php)
 * ------------------------------------------------------------------------- */
/* Category Page Enrichment — scoped styles */
.cat-page-enrichment {
    --cat-primary: #1e2432;
    --cat-accent: #c7522a;
    --cat-accent-light: #e8734a;
    --cat-muted: #6b7280;
    --cat-light: #f0f1f3;
    --cat-card-border: #dee1e6;
    --cat-radius: 6px;
}
.cat-hero {
    background: linear-gradient(160deg, #1e2432 0%, #2c3448 40%, #3a4258 100%);
    background-size: cover;
    background-position: center;
    color: #fff;
    border-radius: var(--cat-radius);
    position: relative;
    overflow: hidden;
}
.cat-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        rgba(255,255,255,0.015) 0px,
        rgba(255,255,255,0.015) 1px,
        transparent 1px,
        transparent 60px
    );
    pointer-events: none;
}
/* Hero title is an H2 (the page H1 is #indexProductList-pageHeading). It must keep
   the old H1 look and opt out of the section-heading rule further down
   (.cat-page-enrichment h2: dark text, accent underline). */
.cat-hero .cat-hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.35rem;
    line-height: 1.2;
    color: inherit;
    padding-bottom: 0;
}
.cat-hero .cat-hero-title::after {
    content: none;
}
.cat-hero .cat-hero-stats {
    font-size: 0.95rem;
    opacity: 0.88;
    line-height: 1.5;
}
.cat-hero .cat-brand-pills {
    max-height: 2.4rem;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.cat-hero .cat-brand-pills.expanded {
    max-height: 200px;
}
.cat-hero .cat-brand-pill {
    display: inline-block;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 0.25rem 0.65rem;
    border-radius: 3px;
    font-size: 0.8rem;
    margin: 0 0.35rem 0.35rem 0;
    text-decoration: none;
    transition: background 0.15s;
}
.cat-hero .cat-brand-pill:hover {
    background: rgba(255,255,255,0.22);
    color: #fff;
    text-decoration: none;
}
.cat-hero .cat-intro {
    font-size: 0.95rem;
    opacity: 0.92;
    line-height: 1.6;
    max-width: 700px;
}

/* Subcategory cards */
.cat-subcat-card {
    border: 1px solid var(--cat-card-border);
    border-radius: var(--cat-radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cat-subcat-card:hover {
    border-color: var(--cat-accent);
    box-shadow: 0 2px 8px rgba(199,82,42,0.1);
}
.cat-subcat-card .card-title a {
    color: var(--cat-primary);
    text-decoration: none;
    font-weight: 600;
}
.cat-subcat-card .card-title a:hover {
    color: var(--cat-accent);
}
.cat-subcat-count {
    color: var(--cat-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

/* Top brands row */
.cat-brands-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.cat-brand-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: var(--cat-light);
    border: 1px solid var(--cat-card-border);
    border-radius: var(--cat-radius);
    text-decoration: none;
    color: var(--cat-primary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}
.cat-brand-item:hover {
    border-color: var(--cat-accent);
    background: #fff;
    color: var(--cat-primary);
    text-decoration: none;
}
.cat-brand-item .brand-prod-count {
    color: var(--cat-muted);
    font-weight: 400;
    font-size: 0.78rem;
}

/* Best sellers cards */
.cat-seller-card {
    border: 1px solid var(--cat-card-border);
    border-radius: var(--cat-radius);
    transition: border-color 0.15s, transform 0.15s;
}
.cat-seller-card:hover {
    border-color: var(--cat-accent);
    transform: translateY(-2px);
}
.cat-seller-card .card-img-wrap {
    display: block;
    padding: 0.75rem;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cat-seller-card .card-img-wrap img {
    max-height: 120px;
    object-fit: contain;
}
.cat-seller-card .card-title {
    color: var(--cat-primary);
    font-size: 0.82rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cat-seller-card .card-title:hover {
    color: var(--cat-accent);
}
.cat-seller-price {
    color: var(--cat-accent);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Related categories pills */
.cat-related-pill {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--cat-card-border);
    border-radius: 3px;
    color: var(--cat-primary);
    font-size: 0.85rem;
    text-decoration: none;
    margin: 0 0.35rem 0.5rem 0;
    transition: border-color 0.15s, background 0.15s;
}
.cat-related-pill:hover {
    border-color: var(--cat-accent);
    background: var(--cat-light);
    color: var(--cat-primary);
    text-decoration: none;
}

/* Description section */
.cat-description p {
    color: #374151;
    line-height: 1.7;
    font-size: 0.95rem;
}

/* Section headings */
.cat-page-enrichment h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cat-primary);
    letter-spacing: -0.01em;
    position: relative;
    padding-bottom: 0.5rem;
}
.cat-page-enrichment h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 2.5rem;
    height: 2px;
    background: var(--cat-accent);
    border-radius: 1px;
}

/* FAQ accordion */
.cat-faq .card {
    border: 1px solid var(--cat-card-border);
    border-radius: 0;
    margin-bottom: -1px;
}
.cat-faq .card:first-child {
    border-radius: var(--cat-radius) var(--cat-radius) 0 0;
}
.cat-faq .card:last-child {
    border-radius: 0 0 var(--cat-radius) var(--cat-radius);
}
.cat-faq .card-header {
    background: #fff;
    border-bottom: none;
}
.cat-faq .btn-link {
    color: var(--cat-primary);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cat-faq .btn-link::after {
    content: '\2212';
    font-size: 1.1rem;
    color: var(--cat-accent);
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.cat-faq .btn-link.collapsed::after {
    content: '\002B';
}
.cat-faq .card-body {
    color: #4b5563;
    font-size: 0.92rem;
    line-height: 1.6;
    padding-top: 0;
}

/* ---------------------------------------------------------------------------
 * In-Stock Only empty-category note (#714, tpl_index_product_list.php)
 * ------------------------------------------------------------------------- */
.instock-empty-note {
    border: 1px solid #ffd9a6;
    background: #fff7ec;
    color: #7a4b00;
    border-left: 4px solid #ffa520;
    border-radius: 8px;
    padding: .7rem .9rem;
    margin-bottom: 1rem;
    font-size: .9rem;
    line-height: 1.35;
}
.instock-empty-note strong {
    color: #5c3900;
}

/* ---------------------------------------------------------------------------
 * Category intro clamp, product-listing pages (tpl_index_product_list.php)
 * ------------------------------------------------------------------------- */
#indexProductList .intro-text {
    position: relative;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    /* fallback when line-clamp unsupported */
    max-height: 5.4em;
}
#indexProductList .intro-text.clamped::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.2em;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--intro-bg));
}
#indexProductList .intro-text.expanded {
    -webkit-line-clamp: unset;
    max-height: none;
}
#indexProductList .intro-text.expanded::after {
    display: none;
}
#indexProductList #toggleIntro {
    font-weight: 600;
}
#indexProductList .category-intro {
    --intro-bg: #fff;
}

/* ---------------------------------------------------------------------------
 * Category intro clamp, subcategory-grid pages (tpl_index_categories.php)
 * ------------------------------------------------------------------------- */
#indexCategories .intro-text {
    position: relative;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    /* fallback when line-clamp unsupported */
    max-height: 5.4em;
}
#indexCategories .intro-text.clamped::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.8em;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--intro-bg));
    pointer-events: none;
}
#indexCategories .category-intro {
    --intro-bg: #fff;
}
