/* ============================================================ */
/* LIQUID GLASS UI                                              */
/* Additive layer — loaded after style.css and auth.css.       */
/* All glass effects are guarded with @supports or theme vars. */
/* ============================================================ */


/* ============================================================ */
/* PHASE 1 — Design Token Layer                                 */
/* ============================================================ */

:root {
    /* Blur / saturation */
    --lg-blur: 20px;
    --lg-saturate: 180%;

    /* Surface backgrounds */
    --lg-bg: rgba(255, 255, 255, 0.18);
    --lg-bg-card: rgba(255, 255, 255, 0.13);

    /* Specular border */
    --lg-border: rgba(255, 255, 255, 0.32);

    /* Meniscus shine — top-edge highlight stripe */
    --lg-shine: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.50) 0%,
        rgba(255, 255, 255, 0.18) 35%,
        rgba(255, 255, 255, 0.00) 65%
    );

    /* Multi-layer depth shadow */
    --lg-shadow:
        0 1px 1px rgba(0, 0, 0, 0.04),
        0 4px 8px rgba(0, 0, 0, 0.07),
        0 12px 24px rgba(0, 0, 0, 0.09),
        0 24px 48px rgba(0, 0, 0, 0.05);

    /* Radii */
    --lg-radius-pill: 999px;
    --lg-radius-card: 20px;
    --lg-radius-header: 22px;

    /* Typography */
    --lg-font-display: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --lg-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.dark-mode {
    --lg-blur: 24px;
    --lg-bg: rgba(255, 255, 255, 0.06);
    --lg-bg-card: rgba(255, 255, 255, 0.05);
    --lg-border: rgba(255, 255, 255, 0.11);
    --lg-shine: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.18) 0%,
        rgba(255, 255, 255, 0.06) 35%,
        rgba(255, 255, 255, 0.00) 65%
    );
    --lg-shadow:
        0 1px 1px rgba(0, 0, 0, 0.14),
        0 4px 8px rgba(0, 0, 0, 0.22),
        0 12px 24px rgba(0, 0, 0, 0.30),
        0 24px 48px rgba(0, 0, 0, 0.18);
}


/* ============================================================ */
/* PHASE 2 — Background Atmosphere                              */
/* Rich multi-stop radial gradient so glass picks up colour.   */
/* ============================================================ */

body {
    font-family: var(--lg-font-body);
    background:
        radial-gradient(ellipse at 12% 8%,  hsla(220, 88%, 62%, 0.20), transparent 42%),
        radial-gradient(ellipse at 88% 6%,  hsla(278, 78%, 58%, 0.16), transparent 40%),
        radial-gradient(ellipse at 50% 88%, hsla(140, 68%, 48%, 0.12), transparent 44%),
        radial-gradient(ellipse at 72% 52%, hsla(32,  88%, 62%, 0.08), transparent 36%),
        radial-gradient(ellipse at 18% 72%, hsla(200, 78%, 58%, 0.09), transparent 40%),
        var(--oc-bg);
}

body.dark-mode {
    background:
        radial-gradient(ellipse at 12% 8%,  hsla(220, 88%, 62%, 0.14), transparent 42%),
        radial-gradient(ellipse at 88% 6%,  hsla(278, 78%, 58%, 0.11), transparent 40%),
        radial-gradient(ellipse at 50% 88%, hsla(140, 68%, 48%, 0.08), transparent 44%),
        radial-gradient(ellipse at 72% 52%, hsla(32,  88%, 62%, 0.05), transparent 36%),
        radial-gradient(ellipse at 18% 72%, hsla(200, 78%, 58%, 0.06), transparent 40%),
        var(--oc-bg);
}

h1, h2, h3 {
    font-family: var(--lg-font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
}


/* ============================================================ */
/* PHASE 3 — Header / Navigation Bar                            */
/* Floating glass panel with meniscus highlight.               */
/* ============================================================ */

header {
    background: var(--lg-bg);
    backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
    border: 1px solid var(--lg-border);
    border-radius: var(--lg-radius-header);
    margin: 10px 14px 0;
    box-shadow: var(--lg-shadow);
    border-bottom: none;
    position: relative;
    overflow: visible;
    transition:
        padding    0.30s cubic-bezier(0.4, 0, 0.2, 1),
        margin     0.30s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.30s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Meniscus shine stripe */
header::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--lg-shine);
    pointer-events: none;
    z-index: 0;
}

/* All header children sit above the shine */
header > * {
    position: relative;
    z-index: 1;
}

/* Compact scrolled pill */
header.scrolled {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-radius: var(--lg-radius-pill);
    margin: 6px 20px 0;
}

/* Search — glass capsule */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .search-container input {
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid var(--lg-border);
        border-radius: var(--lg-radius-pill);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.28),
            0 2px 8px rgba(0, 0, 0, 0.06);
        color: var(--oc-text);
        transition: background 0.22s ease, box-shadow 0.22s ease;
    }

    .search-container input:focus {
        background: rgba(255, 255, 255, 0.24);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.38),
            0 0 0 3px rgba(110, 162, 255, 0.28),
            0 2px 8px rgba(0, 0, 0, 0.06);
        outline: none;
    }

    body.dark-mode .search-container input {
        background: rgba(255, 255, 255, 0.07);
    }

    body.dark-mode .search-container input:focus {
        background: rgba(255, 255, 255, 0.12);
    }

    /* Toggle buttons — glass pills */
    .toggles button {
        background: rgba(255, 255, 255, 0.16);
        border: 1px solid var(--lg-border);
        border-radius: var(--lg-radius-pill);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.38),
            var(--lg-shadow);
        color: var(--oc-text);
        transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .toggles button:hover {
        background: rgba(255, 255, 255, 0.26);
        transform: translateY(-2px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.45),
            0 8px 24px rgba(0, 0, 0, 0.14);
    }

    .toggles button:active {
        transform: translateY(0) scale(0.96);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.20);
    }

    body.dark-mode .toggles button {
        background: rgba(255, 255, 255, 0.07);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.14),
            var(--lg-shadow);
    }

    body.dark-mode .toggles button:hover {
        background: rgba(255, 255, 255, 0.13);
    }

    /* Sort select — glass */
    .sort-container select {
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid var(--lg-border);
        border-radius: 14px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
        color: var(--oc-text);
    }

    body.dark-mode .sort-container select {
        background: rgba(255, 255, 255, 0.07);
    }

    /* Auth buttons — glass pills */
    #auth-controls .auth-login-btn,
    #auth-controls .auth-signup-btn,
    .user-menu-trigger {
        background: rgba(255, 255, 255, 0.16);
        border: 1px solid var(--lg-border);
        border-radius: var(--lg-radius-pill);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.30),
            var(--lg-shadow);
        color: var(--oc-text);
        transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    #auth-controls .auth-login-btn:hover,
    #auth-controls .auth-signup-btn:hover,
    .user-menu-trigger:hover {
        background: rgba(255, 255, 255, 0.26);
        transform: translateY(-1px);
    }

    body.dark-mode #auth-controls .auth-login-btn,
    body.dark-mode #auth-controls .auth-signup-btn,
    body.dark-mode .user-menu-trigger {
        background: rgba(255, 255, 255, 0.07);
    }
}


/* ============================================================ */
/* PHASE 4 — Pokémon Cards                                      */
/* Glass cards tinted by primary type hue.                      */
/* ============================================================ */

/* Per-type hue → --badge-hue for frosted type badges */
.type-normal  { --badge-hue: 30;  }
.type-fire    { --badge-hue: 15;  }
.type-water   { --badge-hue: 210; }
.type-electric{ --badge-hue: 55;  }
.type-grass   { --badge-hue: 120; }
.type-ice     { --badge-hue: 190; }
.type-fighting{ --badge-hue: 0;   }
.type-poison  { --badge-hue: 280; }
.type-ground  { --badge-hue: 35;  }
.type-flying  { --badge-hue: 200; }
.type-psychic { --badge-hue: 330; }
.type-bug     { --badge-hue: 90;  }
.type-rock    { --badge-hue: 40;  }
.type-ghost   { --badge-hue: 270; }
.type-dragon  { --badge-hue: 240; }
.type-dark    { --badge-hue: 20;  }
.type-steel   { --badge-hue: 210; }
.type-fairy   { --badge-hue: 320; }

@keyframes lg-card-reveal {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .pokemon-card {
        background:
            linear-gradient(
                140deg,
                hsla(var(--type-hue, 200), 55%, 62%, 0.17),
                hsla(var(--type-hue, 200), 42%, 50%, 0.09)
            ),
            var(--lg-bg-card);
        backdrop-filter: blur(var(--lg-blur)) saturate(150%);
        -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(150%);
        border: 1px solid var(--lg-border);
        box-shadow: var(--lg-shadow);
        overflow: visible;
        position: relative;
        animation: lg-card-reveal 0.38s ease both;
        animation-delay: clamp(0ms, calc(var(--card-index, 0) * 25ms), 1000ms);
        transition:
            transform    0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
            box-shadow   0.28s ease;
    }

    /* Meniscus shine stripe */
    .pokemon-card::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: var(--lg-shine);
        pointer-events: none;
        z-index: 0;
    }

    /* Card children sit above shine */
    .pokemon-card > * {
        position: relative;
        z-index: 1;
    }

    .pokemon-card:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow:
            0 2px 2px rgba(0, 0, 0, 0.06),
            0 8px 16px rgba(0, 0, 0, 0.12),
            0 20px 40px rgba(0, 0, 0, 0.14),
            0 32px 64px rgba(0, 0, 0, 0.08);
    }

    .pokemon-card:active {
        transform: translateY(0) scale(0.97);
        transition-duration: 0.12s;
    }

    /* Frosted type badge */
    .pokemon-types span {
        background: hsla(var(--badge-hue, 200), 55%, 58%, 0.22);
        border: 1px solid hsla(var(--badge-hue, 200), 60%, 68%, 0.35);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        border-radius: var(--lg-radius-pill);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
        color: var(--oc-text);
        font-weight: 500;
        letter-spacing: 0.01em;
        transition: background 0.22s ease;
    }

    body.dark-mode .pokemon-types span {
        background: hsla(var(--badge-hue, 200), 55%, 58%, 0.16);
    }

    /* Pokemon image — subtle float on hover */
    .pokemon-card img {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
        transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .pokemon-card:hover img {
        transform: translateY(-4px) scale(1.06);
    }
}


/* ============================================================ */
/* PHASE 5 — SVG Refraction Filter Gate                         */
/* Apply liquid-glass SVG filter only where @supports detects   */
/* backdrop-filter URL() (Chromium-only progressive enhancement).*/
/* ============================================================ */

@supports (backdrop-filter: url('#x')) {
    .pokemon-card {
        backdrop-filter:
            blur(var(--lg-blur))
            saturate(150%)
            url('#liquid-glass-filter');
        -webkit-backdrop-filter:
            blur(var(--lg-blur))
            saturate(150%);
    }
}


/* ============================================================ */
/* PHASE 6 — Pokémon Detail Modal                               */
/* Full-screen glass overlay with spring-entrance panel.        */
/* ============================================================ */

/* Overlay backdrop gets blur when modal shows */
.pokemon-detail-view.show {
    background-color: rgba(0, 0, 0, 0.38) !important;
    backdrop-filter: blur(18px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(160%) !important;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    /* Glass panel */
    .detail-modal-content {
        background:
            linear-gradient(
                135deg,
                hsla(var(--type-hue, 220), 55%, 68%, 0.22),
                hsla(var(--type-hue, 220), 42%, 55%, 0.10)
            ),
            var(--lg-bg);
        backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
        -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
        border: 1px solid var(--lg-border);
        border-radius: 32px !important;
        box-shadow:
            var(--lg-shadow),
            0 0 0 1px rgba(255, 255, 255, 0.08) inset;
        overflow-x: hidden;
        transform: scale(0.92) translateY(20px);
        transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    /* Spring entry */
    .pokemon-detail-view.show .detail-modal-content {
        transform: scale(1) translateY(0);
    }

    /* Meniscus shine on modal panel */
    .detail-modal-content::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: var(--lg-shine);
        pointer-events: none;
        z-index: 0;
    }

    /* Sub-sections get a lighter frosted layer */
    #detail-content .detail-section {
        background: rgba(255, 255, 255, 0.09);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 16px;
    }

    body.dark-mode #detail-content .detail-section {
        background: rgba(255, 255, 255, 0.04);
    }

    /* Stat fill bar glow */
    .stat-item-fill {
        overflow: hidden;
        box-shadow: 0 0 10px hsla(var(--type-hue, 10), 70%, 60%, 0.40);
    }

    @keyframes lg-stat-sweep {
        from { transform: translateX(-100%); opacity: 0.6; }
        to   { transform: translateX(200%); opacity: 0; }
    }

    .stat-item-fill::after {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
        animation: lg-stat-sweep 1.1s ease 0.55s both;
    }
}


/* ============================================================ */
/* PHASE 7 — Page-level Polish                                  */
/* Quick-jump rail, scrollbar, footer, skip link.               */
/* ============================================================ */

/* Quick-jump rail — glass pill strip */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    #quick-jump-rail {
        background: var(--lg-bg);
        backdrop-filter: blur(12px) saturate(160%);
        -webkit-backdrop-filter: blur(12px) saturate(160%);
        border: 1px solid var(--lg-border);
        border-radius: var(--lg-radius-pill);
        box-shadow: var(--lg-shadow);
    }

    .quick-jump-btn {
        background: rgba(255, 255, 255, 0.10);
        border: 1px solid rgba(255, 255, 255, 0.16);
        border-radius: var(--lg-radius-pill);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        color: var(--oc-text);
        transition: background 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .quick-jump-btn:hover {
        background: rgba(255, 255, 255, 0.22);
        transform: translateY(-2px);
    }

    body.dark-mode .quick-jump-btn {
        background: rgba(255, 255, 255, 0.05);
    }

    /* Team panel */
    #team-panel {
        background: var(--lg-bg);
        backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
        -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
        border: 1px solid var(--lg-border);
        box-shadow: var(--lg-shadow);
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--lg-border);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.48);
}

/* Footer glass */
footer {
    background: var(--lg-bg);
    border: 1px solid var(--lg-border);
    border-radius: var(--lg-radius-header);
    margin: 0 14px 10px;
    backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
    box-shadow: var(--lg-shadow);
}