/* ==============================
   Variables & Resets
============================== */
:root {
    --ddpl-primary: #582A8A;
    --ddpl-primary-rgb: 88, 42, 138;
    --ddpl-text: #111827;
    --ddpl-muted: #6b7280;
    --ddpl-border: rgba(0, 0, 0, .08);
    --ddpl-bg: #ffffff;
    --ddpl-shadow-sm: 0 10px 24px rgba(0, 0, 0, .04);
    --ddpl-shadow-md: 0 18px 42px rgba(0, 0, 0, .10);
    --ddpl-radius-lg: 18px;
    --ddpl-radius-md: 14px;
    --ddpl-radius-pill: 999px;
}

/* Production-critical reset to prevent layout math bugs */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    color: var(--ddpl-text);
    background: var(--ddpl-bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased; /* Crisp text rendering */
}

/* ==============================
   Animations
============================== */
@keyframes ddplFadeUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes ddplFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ddplHeroZoom {
    0% { transform: scale(1.03); }
    100% { transform: scale(1.09); }
}

@keyframes ddplFloatSoft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ==============================
   Category Hero Banner
============================== */
#category-breadcrumbs {
    position: relative;
    min-height: 460px;
    display: flex;
    align-items: center;
    overflow: hidden;
    isolation: isolate;
}

.category-bg {
    position: absolute;
    inset: 0; /* Replaces width/height 100% */
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    transform: scale(1.03);
    z-index: -2;
    animation: ddplHeroZoom 16s ease-in-out infinite alternate;
    will-change: transform;
}

.category-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.60) 0%, rgba(0,0,0,.38) 100%);
    z-index: -1;
    animation: ddplFadeIn .9s ease both; /* Added 'both' to keep end state consistent */
}

.category-page-title {
    margin: 0 0 .75rem;
    color: #fff;
    font-weight: 800;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.15;
    letter-spacing: .01em;
    text-wrap: balance;
    animation: ddplFadeUp .8s ease both;
}

.category-page-subtitle {
    margin: 0 auto;
    max-width: 760px;
    color: rgba(255,255,255,.88);
    font-size: 1rem;
    line-height: 1.7;
    text-wrap: pretty;
    animation: ddplFadeUp .95s ease both;
}

.category-title-accent {
    display: inline-block;
    width: 78px;
    height: 4px;
    border-radius: var(--ddpl-radius-pill);
    background: var(--ddpl-primary);
    animation: ddplFadeUp 1.1s ease both;
}

/* ==============================
   Horizontal Scroll Category Bar
============================== */
.cat-glass-wrap {
    position: absolute;
    right: 24px;
    left: auto;
    bottom: 24px;
    z-index: 3;
    width: min(760px, calc(100% - 48px));
    max-width: 100%;
    padding: .45rem;
    animation: ddplFadeUp 1.05s ease both;
}

.cat-glass-meta {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: .7rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: .1rem 0 .3rem;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* Cross-browser scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
}

.cat-glass-meta::-webkit-scrollbar {
    height: 6px;
}

.cat-glass-meta::-webkit-scrollbar-track {
    background: transparent;
}

.cat-glass-meta::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.35);
    border-radius: var(--ddpl-radius-pill);
}

.cat-glass-meta::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.50);
}

.cat-category-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: .7rem 1rem;
    border-radius: var(--ddpl-radius-pill);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: .92rem;
    line-height: 1;
    background: linear-gradient(90deg, rgba(0,0,0,.20), rgba(0,0,0,.08));
    border: 1px solid rgba(255,255,255,.10);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    scroll-snap-align: start;
    animation: ddplFadeUp .7s ease both;
    transition: transform .3s ease, background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease;
}

.cat-category-link:hover,
.cat-category-link:focus-visible {
    color: #fff;
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.24);
    transform: translateY(-2px);
    outline: none;
}

.cat-category-link.is-active {
    background: #fff;
    color: var(--ddpl-primary);
    border-color: #fff;
    box-shadow: 0 10px 24px rgba(0,0,0,.16);
    animation: ddplFadeUp .7s ease both, ddplFloatSoft 3.2s ease-in-out infinite;
}

.cat-category-link img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
    flex-shrink: 0;
    transition: transform .35s ease;
}

.cat-category-link:hover img,
.cat-category-link:focus-visible img {
    transform: scale(1.06);
}

/* ==============================
   Ultra Large Devices (1400px+)
============================== */
@media (min-width: 1400px) {
    #category-breadcrumbs { min-height: 540px; }
    .category-page-title { font-size: clamp(2.75rem, 4vw, 4.2rem); max-width: 900px; }
    .category-page-subtitle { max-width: 840px; font-size: 1.08rem; }
    .category-overlay{ width: 102%}
    .cat-category-link { font-size: .96rem; padding: .78rem 1.15rem; }
}

/* ==============================
   Large Desktop (1200px - 1399px)
============================== */
@media (max-width: 1399.98px) {
    #category-breadcrumbs { min-height: 500px; }
    .category-overlay{ width: 104%}
    .cat-glass-wrap { width: min(760px, calc(100% - 48px)); }
}

/* ==============================
   Medium Desktop (992px - 1199px)
============================== */
@media (max-width: 1199.98px) {
    #category-breadcrumbs { min-height: 460px; }
    .category-page-title { font-size: clamp(2rem, 4.4vw, 3rem); }
    .category-page-subtitle { max-width: 680px; font-size: .98rem; }
    .cat-glass-wrap { right: 20px; bottom: 20px; width: min(700px, calc(100% - 40px)); }
    .cat-category-link { padding: .7rem .95rem; font-size: .9rem; }
}

/* ==============================
   Tablet (768px - 991px)
============================== */
@media (max-width: 991.98px) {
    #category-breadcrumbs { min-height: 420px; align-items: flex-end; }
    .category-page-title { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.2; }
    .category-page-subtitle { max-width: 100%; font-size: .96rem; line-height: 1.65; padding-inline: 8px; }
    .category-title-accent { width: 68px; margin-top: .9rem; }
    .cat-glass-wrap { right: 16px; left: 16px; bottom: 16px; width: auto; padding: .35rem; }
    .cat-glass-meta { gap: .55rem; padding: .1rem 0 .25rem; }
    .cat-category-link { min-height: 42px; padding: .65rem .9rem; font-size: .88rem; }
    .cat-category-link img { width: 30px; height: 30px; }
}

/* ==============================
   Large Mobile (576px - 767px)
============================== */
@media (max-width: 767.98px) {
    #category-breadcrumbs { min-height: 390px; }
    .category-page-title { font-size: 1.9rem; margin-bottom: .65rem; }
    .category-page-subtitle { font-size: .94rem; line-height: 1.6; }
    .category-title-accent { width: 60px; height: 3px; }
    .cat-glass-wrap { left: 12px; right: 12px; bottom: 12px; padding: .3rem; }
    .cat-glass-meta { gap: .5rem; scrollbar-width: none; }
    .cat-glass-meta::-webkit-scrollbar { display: none; }
    .cat-category-link { padding: .62rem .85rem; min-height: 40px; font-size: .85rem; gap: .5rem; }
    .cat-category-link img { width: 28px; height: 28px; }
}

/* ==============================
   Small Mobile (up to 575px)
============================== */
@media (max-width: 575.98px) {
    #category-breadcrumbs { min-height: 360px; }
    .category-page-title { font-size: 1.65rem; line-height: 1.22; margin-bottom: .55rem; }
    .category-page-subtitle { font-size: .9rem; line-height: 1.55; padding-inline: 0; }
    .category-title-accent { width: 52px; margin-top: .8rem; }
    .cat-glass-wrap { left: 10px; right: 10px; bottom: 10px; padding: .25rem; }
    .cat-glass-meta { gap: .45rem; padding-bottom: .15rem; }
    .cat-category-link { min-height: 38px; padding: .58rem .78rem; font-size: .82rem; border-width: 1px; }
    .cat-category-link img { width: 26px; height: 26px; padding: 1.5px; }
}

/* ==============================
   Extra Small Mobile (up to 399px)
============================== */
@media (max-width: 399.98px) {
    #category-breadcrumbs { min-height: 340px; }
    .category-page-title { font-size: 1.45rem; }
    .category-page-subtitle { font-size: .86rem; line-height: 1.5; }
    .cat-glass-wrap { left: 8px; right: 8px; bottom: 8px; }
    .cat-category-link { min-height: 36px; padding: .50rem 0.56rem; font-size: .78rem; gap: .4rem; }
    .cat-category-link img { width: 24px; height: 24px; }
}

/* ==============================
   Landscape Phones
============================== */
@media (max-height: 500px) and (orientation: landscape) {
    #category-breadcrumbs { min-height: 320px; }
    .category-page-title { font-size: 1.55rem; margin-bottom: .45rem; }
    .category-page-subtitle { font-size: .88rem; line-height: 1.45; }
    .cat-glass-wrap { bottom: 8px; }
    .cat-category-link { min-height: 36px; padding: .5rem .75rem; font-size: .8rem; }
    .cat-category-link img { width: 24px; height: 24px; }
}

/* ==============================
   Touch Device & Accessibility
============================== */
@media (hover: none) and (pointer: coarse) {
    .cat-category-link:hover {
        transform: none;
        background: linear-gradient(90deg, rgba(0,0,0,.20), rgba(0,0,0,.08));
        border-color: rgba(255,255,255,.10);
    }
    .cat-category-link:active {
        transform: scale(.98);
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
