﻿/* =========================================================
   CrazyNuts Header (Desktop + Mobile Drawer)
   FINAL FIX:
   - Search icon inside bar
   - Suggestions dropdown floats ABOVE everything (front layer)
   - No duplicate cn-searchDrop
   - Burger correct
   - Logo responsive (desktop big, mobile normal)
   ========================================================= */

:root {
    --cn-black: #070708;
    --cn-black-2: #0b0b0d;
    --cn-red-dark: #691D0E;
    --cn-red-deep: #3a0b07;
    --cn-white: #ffffff;
    --cn-white-soft: rgba(255,255,255,0.78);
    --cn-border: rgba(255,255,255,0.16);
    --cn-border-2: rgba(255,255,255,0.10);
    --cn-glow: rgba(255, 80, 40, 0.35);
    --cn-motion: 12s;
    --cn-sheen: 5.5s;
    --cn-shadow: 0 14px 40px rgba(0,0,0,.25);
}

/* =========================================================
   Header wrapper + animated radiant background
   ========================================================= */

.cn-top {
    position: relative;
    z-index: 10;
    color: var(--cn-white);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    /* IMPORTANT: allow dropdown to escape */
    overflow: visible;
    background: radial-gradient(1050px 280px at 12% 0%, rgba(105,29,14,0.78), transparent 62%), radial-gradient(820px 320px at 28% 30%, rgba(58,11,7,0.62), transparent 68%), radial-gradient(700px 280px at 70% 25%, rgba(255,80,40,0.12), transparent 60%), linear-gradient(115deg, var(--cn-red-dark) 0%, var(--cn-red-deep) 50%, var(--cn-black-2) 70%, var(--cn-black) 100% );
    background-size: 170% 170%;
    animation: cnHeaderDrift var(--cn-motion) ease-in-out infinite alternate;
}

    /* overlays stay BEHIND everything */
    .cn-top::before,
    .cn-top::after {
        content: "";
        position: absolute;
        inset: -2px;
        pointer-events: none;
        z-index: 0;
    }

    .cn-top::before {
        background: radial-gradient(900px 260px at 12% 15%, rgba(255,80,40,0.14), transparent 62%), radial-gradient(680px 240px at 35% 0%, rgba(105,29,14,0.22), transparent 65%), radial-gradient(760px 260px at 88% 10%, rgba(0,0,0,0.22), transparent 60%);
        opacity: 1;
        inset: -2px;
    }

    .cn-top::after {
        inset: -40%;
        background: linear-gradient( 110deg, transparent 0%, rgba(255,255,255,0.10) 45%, rgba(255,255,255,0.02) 52%, transparent 62% );
        transform: translateX(-35%) rotate(6deg);
        animation: cnSheen var(--cn-sheen) ease-in-out infinite;
        opacity: 0.70;
    }

@media (prefers-reduced-motion: reduce) {
    .cn-top {
        animation: none;
        background-size: cover;
    }

        .cn-top::after {
            animation: none;
            opacity: 0.35;
        }
}

@keyframes cnHeaderDrift {
    0% {
        background-position: 0% 30%;
    }

    50% {
        background-position: 45% 42%;
    }

    100% {
        background-position: 100% 28%;
    }
}

@keyframes cnSheen {
    0% {
        transform: translateX(-45%) rotate(6deg);
        opacity: 0;
    }

    20% {
        opacity: 0.70;
    }

    50% {
        opacity: 0.22;
    }

    100% {
        transform: translateX(45%) rotate(6deg);
        opacity: 0;
    }
}

.cn-top a {
    color: var(--cn-white);
    text-decoration: none;
}

/* =========================================================
   Rows
   ========================================================= */

.cn-top__row {
    display: flex;
    align-items: center;
    padding: 16px 28px;
    position: relative;
}

.cn-top__row--main {
    gap: 22px;
    z-index: 3;
}

.cn-top__row--nav {
    padding-top: 6px;
    padding-bottom: 10px;
    margin-top: 8px;
    z-index: 2;
}

/* =========================================================
   Logo
   ========================================================= */

.cn-top__logo img {
    height: 72px;
    width: 160px;
    object-fit: contain;
    display: block;
    transition: transform .18s ease;
}

.cn-top__logo:hover img {
    transform: scale(1.04);
}

/* =========================================================
   Search (icon inside + dropdown front layer)
   ========================================================= */

/* Important: this is the dropdown anchor */
.cn-top__search {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 50; /* above header content */
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

/* input fills the container */
.cn-top__searchInput {
    width: 100%;
    border: 1px solid var(--cn-border);
    outline: none;
    background: rgba(255,255,255,0.12);
    color: var(--cn-white);
    padding: 12px 52px 12px 18px; /* room for icon */
    border-radius: 999px;
    font-size: 16px;
    backdrop-filter: blur(8px);
}

    .cn-top__searchInput::placeholder {
        color: rgba(255,255,255,0.70);
        text-transform: lowercase;
    }

/* icon button INSIDE the search bar */
.cn-top__searchBtn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: rgba(255,255,255,0.95);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    z-index: 2;
}

    .cn-top__searchBtn:hover {
        background: rgba(255,255,255,0.10);
    }

    .cn-top__searchBtn svg {
        display: block;
    }

/* ✅ THE IMPORTANT PART:
   Make dropdown "front layer" + not merged with header */
.cn-searchDrop {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 12px);
    width: 100%;
    background: rgba(10,10,12,0.95);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 14px;
    box-shadow: 0 28px 90px rgba(0,0,0,0.70);
    backdrop-filter: blur(14px);
    overflow: hidden;
    /* 🔥 EXTREMELY HIGH: above nav + header + everything */
    z-index: 2147483647;
    /* make it feel like a floating panel */
    transform: translateY(2px);
}

.cn-searchDrop__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 14px;
    color: var(--cn-white);
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

    .cn-searchDrop__item:hover {
        background: rgba(255,255,255,0.06);
    }

.cn-searchDrop__name {
    font-weight: 850;
    line-height: 1.2;
    color: var(--cn-white);
}

.cn-searchDrop__meta {
    font-weight: 700;
    font-size: 12px;
    opacity: .75;
    text-transform: capitalize;
    color: rgba(255,255,255,0.72);
}

.cn-searchDrop__empty {
    padding: 12px 14px;
    font-weight: 700;
    opacity: .85;
    color: rgba(255,255,255,0.82);
}

/* =========================================================
   Account
   ========================================================= */

.cn-top__account {
    display: flex;
    align-items: center;
    gap: 14px;
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

.cn-top__accountLink {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

/* =========================================================
   Nav
   ========================================================= */

.cn-nav {
    display: flex;
    align-items: center;
    gap: 54px;
    justify-content: center;
    flex: 1;
    font-weight: 700;
    text-transform: capitalize;
}

.cn-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--cn-white);
    transition: opacity .18s ease, text-shadow .18s ease;
}

    .cn-nav__link:hover {
        opacity: 0.92;
        text-shadow: 0 0 18px var(--cn-glow);
    }

.cn-nav__right {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
}

.cn-nav__wish {
    text-transform: lowercase;
    font-weight: 700;
}

.cn-nav__cart {
    font-weight: 700;
}

.cn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--cn-white);
    font-size: 12px;
    font-weight: 800;
}

.cn-ico {
    display: inline-block;
    color: var(--cn-white);
}

/* =========================================================
   Burger + Mobile Drawer
   ========================================================= */

.cn-burger {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    color: var(--cn-white);
    position: relative;
    z-index: 3;
    transition: background-color .18s ease;
}

    .cn-burger:hover {
        background: rgba(255, 255, 255, 0.10);
    }

    .cn-burger:focus-visible {
        outline: 2px solid rgba(255, 255, 255, .75);
        outline-offset: 2px;
    }

.cn-burger__icon {
    display: block;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

/* Mobile menu wrapper */
.cn-mobileMenu {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}

.cn-mobileMenu__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.35);
    opacity: 0;
    transition: opacity .2s ease;
}

.cn-mobileMenu__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(86vw, 340px);
    background: radial-gradient(900px 260px at 10% 0%, rgba(105,29,14,0.70), transparent 62%), linear-gradient(115deg, var(--cn-red-dark) 0%, var(--cn-red-deep) 34%, var(--cn-black-2) 76%, var(--cn-black) 100%);
    transform: translateX(100%);
    transition: transform .22s ease;
    box-shadow: -20px 0 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    color: var(--cn-white);
}

.cn-mobileMenu__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.cn-mobileMenu__title {
    font-weight: 900;
    letter-spacing: .2px;
    text-transform: capitalize;
    color: var(--cn-white);
}

.cn-mobileMenu__close {
    width: 42px;
    height: 42px;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    color: var(--cn-white);
    font-size: 18px;
    font-weight: 900;
}

    .cn-mobileMenu__close:hover {
        background: rgba(255,255,255,0.10);
    }

.cn-mobileMenu__nav {
    padding: 12px 14px 16px;
    display: grid;
    gap: 8px;
    overflow: auto;
}

.cn-mobileMenu__link {
    text-decoration: none;
    color: var(--cn-white);
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
    font-weight: 800;
    text-transform: capitalize;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .cn-mobileMenu__link:hover {
        background: rgba(255,255,255,0.12);
    }

    .cn-mobileMenu__link:active {
        transform: scale(.99);
    }

.cn-mobileMenu__link--muted {
    opacity: .92;
    text-transform: none;
}

.cn-mobileMenu__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    color: var(--cn-white);
    font-size: 12px;
    font-weight: 900;
}

/* OPEN state */
.cn-mobileMenu.is-open {
    display: block;
}

    .cn-mobileMenu.is-open .cn-mobileMenu__backdrop {
        opacity: 1;
    }

    .cn-mobileMenu.is-open .cn-mobileMenu__panel {
        transform: translateX(0);
    }

/* =========================================================
   Top cart link (mobile shows it)
   ========================================================= */

.cn-top__cart {
    display: none;
    font-weight: 800;
    align-items: center;
    gap: 10px;
    color: var(--cn-white);
    transition: opacity .18s ease, text-shadow .18s ease;
    position: relative;
    z-index: 2;
}

    .cn-top__cart:hover {
        opacity: 0.92;
        text-shadow: 0 0 18px var(--cn-glow);
    }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 900px) {
    .cn-top__row--main {
        gap: 10px;
        padding: 10px 14px;
    }

    .cn-top__logo img {
        height: 48px;
        width: 120px;
    }

    .cn-nav {
        gap: 22px;
    }

    .cn-top__searchInput {
        font-size: 15px;
    }

    .cn-badge {
        min-width: 18px;
        height: 18px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .cn-burger {
        display: inline-flex;
    }

    .cn-top__row--nav {
        display: none;
    }

    .cn-top__row--main {
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-areas:
            "logo burger account"
            "search search search";
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
    }

    .cn-top__logo {
        grid-area: logo;
    }

    .cn-burger {
        grid-area: burger;
        justify-self: end;
    }

    .cn-top__account {
        grid-area: account;
        justify-self: end;
    }

    .cn-top__search {
        grid-area: search;
        max-width: none;
        width: 100%;
        justify-content: flex-start;
    }

    .cn-top__searchInput {
        width: 100%;
        height: 42px;
    }

    .cn-top__cart {
        display: inline-flex;
    }

    .cn-nav__cart {
        display: none;
    }

    .cn-top__row--main {
        grid-template-columns: 1fr auto auto auto;
        grid-template-areas:
            "logo burger cart account"
            "search search search search";
    }

    .cn-top__cart {
        grid-area: cart;
        justify-self: end;
    }

    .cn-top__logo img {
        height: 42px;
        width: 110px;
    }
}

@media (max-width: 420px) {
    .cn-top__logo img {
        height: 38px;
        width: 100px;
    }

    .cn-top__accountLink {
        font-size: 13px;
        gap: 6px;
    }
}
/* =========================================================
   STEP 17D
   FINAL PUBLIC HEADER RESPONSIVE OVERRIDES
   ========================================================= */

.cn-top *,
.cn-mobileMenu *,
.cn-top *::before,
.cn-top *::after,
.cn-mobileMenu *::before,
.cn-mobileMenu *::after {
    box-sizing: border-box;
}


body.cn-mobile-menu-open {
    overflow: hidden;
}


/* =========================================================
   HEADER WIDTH
   ========================================================= */

.cn-top__row {
    width: 100%;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
}

.cn-top__row--main {
    min-width: 0;
}

.cn-top__logo {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
}


/* =========================================================
   ACCOUNT
   ========================================================= */

.cn-top__account {
    min-width: 0;
}

.cn-top__accountLink {
    min-height: 44px;
    padding: 7px 9px;
    border-radius: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

    .cn-top__accountLink:hover {
        background: rgba(255, 255, 255, .08);
    }

    .cn-top__accountLink:focus-visible {
        outline: 2px solid rgba(255, 255, 255, .75);
        outline-offset: 2px;
    }

.cn-top__accountText {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================================================
   CART ICON
   ========================================================= */

.cn-top__cartIcon,
.cn-nav__cartIcon {
    display: block;
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
}


/* =========================================================
   SEARCH
   ========================================================= */

.cn-top__search {
    min-width: 0;
}

.cn-top__searchInput {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    min-height: 46px;
}

    .cn-top__searchInput:focus {
        border-color: rgba(255, 255, 255, .48);
        box-shadow: 0 0 0 3px rgba(255, 255, 255, .08);
    }

.cn-searchDrop {
    max-height: min( 460px, 65vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cn-searchDrop__item {
    min-width: 0;
}

.cn-searchDrop__name,
.cn-searchDrop__meta {
    width: 100%;
    overflow-wrap: anywhere;
}


/* =========================================================
   DESKTOP NAV
   ========================================================= */

.cn-nav {
    min-width: 0;
}

.cn-nav__right {
    flex: 0 0 auto;
}

.cn-nav__cart {
    min-height: 42px;
}


/* =========================================================
   IMPROVED MOBILE DRAWER
   ========================================================= */

.cn-mobileMenu {
    display: block;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease, visibility 0s linear .22s;
}

    .cn-mobileMenu.is-open {
        display: block;
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
        transition-delay: 0s;
    }

.cn-mobileMenu__panel {
    width: min( 360px, 88vw);
    max-width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
}

.cn-mobileMenu__head {
    min-height: 66px;
    padding: calc( 12px + env(safe-area-inset-top)) 14px 12px;
}

.cn-mobileMenu__close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
}

.cn-mobileMenu__nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 14px calc( 22px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cn-mobileMenu__link {
    min-height: 48px;
    gap: 14px;
    padding: 12px 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.cn-mobileMenu__divider {
    margin: 12px 4px 2px;
    color: rgba(255, 255, 255, .62);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}


/* =========================================================
   TABLET / MOBILE HEADER
   ========================================================= */

@media (max-width: 760px) {

    /*
       Desktop nav disappears earlier so tablets
       do not get a squeezed navigation row.
    */

    .cn-top__row--nav {
        display: none;
    }


    .cn-burger {
        display: inline-flex;
        grid-area: burger;
        justify-self: end;
    }


    .cn-top__row--main {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto auto;
        grid-template-areas:
            "logo account cart burger"
            "search search search search";
        align-items: center;
        gap: 9px;
        padding: 10px 14px;
    }


    /* LOGO */

    .cn-top__logo {
        grid-area: logo;
    }

        .cn-top__logo img {
            width: 108px;
            height: 44px;
            max-width: 100%;
            object-fit: contain;
        }


    /* ACCOUNT */

    .cn-top__account {
        grid-area: account;
        justify-self: end;
    }

    .cn-top__accountLink {
        display: inline-flex;
        width: 44px;
        height: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 1px solid rgba(255,255,255,.10);
        background: rgba(255,255,255,.04);
        border-radius: 12px;
    }

    .cn-top__accountText {
        display: none;
    }


    /* CART */

    .cn-top__cart {
        position: relative;
        grid-area: cart;
        display: inline-flex;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        justify-self: end;
        padding: 0;
        border: 1px solid rgba(255,255,255,.10);
        border-radius: 12px;
        background: rgba(255,255,255,.04);
    }

        .cn-top__cart .cn-badge {
            position: absolute;
            top: -4px;
            right: -5px;
            min-width: 19px;
            height: 19px;
            padding: 0 5px;
            background: #951f1f;
            border: 1px solid rgba(255,255,255,.45);
            font-size: 10px;
        }


    /* BURGER */

    .cn-burger {
        width: 44px;
        height: 44px;
        border: 1px solid rgba(255,255,255,.10);
        background: rgba(255,255,255,.04);
    }


    /* SEARCH */

    .cn-top__search {
        grid-area: search;
        width: 100%;
        max-width: none;
        margin: 1px 0 0;
    }

    .cn-top__searchInput {
        width: 100%;
        min-height: 46px;
        /*
           Prevents Safari/iPhone zooming
           into the input.
        */

        font-size: 16px;
        padding: 11px 50px 11px 16px;
    }

    .cn-top__searchBtn {
        right: 5px;
        width: 40px;
        height: 40px;
    }

    .cn-searchDrop {
        top: calc( 100% + 7px);
        max-height: min( 420px, 58vh);
        border-radius: 12px;
    }


    /*
       Desktop cart isn't needed because mobile
       cart now lives in row 1.
    */

    .cn-nav__cart {
        display: none;
    }
}


/* =========================================================
   SMALL PHONE
   ========================================================= */

@media (max-width: 420px) {

    .cn-top__row--main {
        gap: 6px;
        padding: 9px 10px;
    }

    .cn-top__logo img {
        width: 96px;
        height: 40px;
    }

    .cn-burger,
    .cn-top__cart,
    .cn-top__accountLink {
        width: 42px;
        height: 42px;
        min-height: 42px;
    }

    .cn-burger__icon {
        width: 24px;
        height: 24px;
    }

    .cn-top__cartIcon {
        width: 21px;
        height: 21px;
    }

    .cn-top__searchInput {
        min-height: 44px;
    }
}


/* =========================================================
   VERY SMALL PHONE
   ========================================================= */

@media (max-width: 360px) {

    .cn-top__row--main {
        padding-left: 8px;
        padding-right: 8px;
    }

    .cn-top__logo img {
        width: 86px;
        height: 38px;
    }

    .cn-burger,
    .cn-top__cart,
    .cn-top__accountLink {
        width: 40px;
        height: 40px;
        min-height: 40px;
    }
}


/* =========================================================
   HOVER DEVICES ONLY
   ========================================================= */

@media (hover: hover) and (pointer: fine) {

    .cn-mobileMenu__link:hover {
        background: rgba(255,255,255,.13);
    }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .cn-mobileMenu,
    .cn-mobileMenu__panel,
    .cn-mobileMenu__backdrop {
        transition: none;
    }
}