/* ===== 코지맘 헤더 매니저 — 프론트엔드 ===== */

/* ----- Astra 기존 주 메뉴 숨김 (중복 방지) ----- */
@media (min-width: 922px) {
    body.cozymom-hm-menu-desktop-enabled .ast-primary-header-bar .ast-builder-menu .main-header-menu,
    body.cozymom-hm-menu-desktop-enabled .ast-primary-header-bar .main-header-menu.ast-inline-flex,
    body.cozymom-hm-menu-desktop-enabled #ast-hf-menu-1.main-header-menu,
    body.cozymom-hm-menu-desktop-enabled .ast-builder-menu-1 > .main-header-menu,
    body.cozymom-hm-menu-desktop-enabled .ast-builder-menu-mobile .main-header-menu,
    body.cozymom-hm-menu-desktop-enabled .ast-above-header-bar,
    body.cozymom-hm-menu-desktop-enabled .ast-below-header-bar {
        display: none !important;
    }
}
@media (max-width: 921px) {
    body.cozymom-hm-menu-mobile-enabled .ast-primary-header-bar .ast-builder-menu .main-header-menu,
    body.cozymom-hm-menu-mobile-enabled .ast-primary-header-bar .main-header-menu.ast-inline-flex,
    body.cozymom-hm-menu-mobile-enabled #ast-hf-menu-1.main-header-menu,
    body.cozymom-hm-menu-mobile-enabled .ast-builder-menu-1 > .main-header-menu,
    body.cozymom-hm-menu-mobile-enabled .ast-builder-menu-mobile .main-header-menu,
    body.cozymom-hm-menu-mobile-enabled .ast-above-header-bar,
    body.cozymom-hm-menu-mobile-enabled .ast-below-header-bar {
        display: none !important;
    }
}

/* ----- 코지맘 로고 크기 ↑ ----- */
/* 데스크탑: 큰 로고 (헤더 영역 충분) */
body.cozymom-hm-enabled #ast-desktop-header .custom-logo-link .custom-logo {
    max-height: 100px !important;
    height: auto !important;
    width: auto !important;
    max-width: none !important;
}
/* 모바일: 적당히 키움 (모바일 폭에서 너무 크지 않게) */
body.cozymom-hm-enabled #ast-mobile-header .custom-logo-link .custom-logo {
    max-height: 75px !important;
    height: auto !important;
    width: auto !important;
    max-width: none !important;
}

/* ----- 이동된 로그인/로그아웃 링크 (카트 아이콘 옆) ----- */
.czm-header-icons .cozy-account-area {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(149, 89, 64, 0.18);
}
@media (min-width: 922px) {
    body:not(.cozymom-hm-menu-desktop-enabled) .czm-header-icons .cozy-account-area { display: none; }
}
@media (max-width: 921px) {
    body:not(.cozymom-hm-menu-mobile-enabled) .czm-header-icons .cozy-account-area { display: none; }
}
.czm-header-icons .cozy-account-link {
    font-size: 13px;
    color: #5c3a2a;
    text-decoration: none;
    line-height: 1;
    transition: color 0.15s;
}
.czm-header-icons .cozy-account-link:hover {
    color: #b54c34;
}

/* ----- 모바일: 헤더 아이콘 텍스트 숨김 (아이콘만 노출) ----- */
/* 좁은 viewport(인스타 인앱 360~393px)에서 셀이 squeeze되어 텍스트가 글자 단위로 줄바꿈 → 세로로 쌓이고 마지막 항목이 viewport 밖으로 잘리는 문제 방지. 데스크탑(769px↑)은 기존대로 아이콘+텍스트 유지. */
@media (max-width: 768px) {
    .czm-header-icon-link span {
        display: none !important;
    }
    .czm-header-icons {
        gap: 4px;
    }
    .czm-header-icon-link {
        padding: 0 6px;
    }
    .czm-header-icon-link i.czm-icon {
        font-size: 22px;
    }
    .czm-header-icons .cozy-account-area {
        margin-left: 6px;
        padding-left: 6px;
    }
    .czm-header-icons .cozy-account-link {
        font-size: 12px;
    }
}

/* ----- 메뉴 공통 ----- */
.cozymom-hm-menu-wrap {
    width: 100%;
    background: #fdfaf5;
    border-top: 1px solid rgba(149, 89, 64, 0.08);
    border-bottom: 1px solid rgba(149, 89, 64, 0.08);
}

.cozymom-hm-menu {
    margin: 0;
    padding: 0;
}

.cozymom-hm-menu__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.cozymom-hm-menu__list li {
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    list-style: none;
}

.cozymom-hm-menu__list li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #5c3a2a;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.cozymom-hm-menu__list li a:hover,
.cozymom-hm-menu__list li.current-menu-item > a,
.cozymom-hm-menu__list li.current-menu-parent > a {
    color: #b54c34;
}

/* ----- 서브 메뉴를 본 메뉴와 같은 줄에 인라인으로 ----- */
/* depth=2 출력이지만 시각적으로는 평면 한 줄 */
.cozymom-hm-menu__list > li.menu-item-has-children {
    display: contents;
}
.cozymom-hm-menu__list > li.menu-item-has-children > a {
    /* 부모 항목도 일반 항목과 같은 박스 */
}
.cozymom-hm-menu__list > li.menu-item-has-children > .sub-menu {
    display: contents;
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
}
.cozymom-hm-menu__list .sub-menu > li {
    flex-shrink: 0;
}

/* 부모 항목의 ▼ 화살표 제거 (인라인 평면화에선 불필요) */
.cozymom-hm-menu__list > li.menu-item-has-children > a::after {
    content: none !important;
}

/* ----- 데스크탑 메뉴 ----- */
.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 0 1rem;
    align-items: center;
}

.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list::-webkit-scrollbar {
    height: 4px;
}
.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list::-webkit-scrollbar-thumb {
    background: rgba(149, 89, 64, 0.2);
    border-radius: 2px;
}

.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list li > a {
    padding: 16px 22px;
    font-size: 17px;
    gap: 8px;
}
.cozymom-hm-menu-wrap--desktop .cozy-icon {
    font-size: 22px;
}
.cozymom-hm-menu-wrap--desktop .cozy-icon--empty {
    display: none;
}
.cozymom-hm-menu-wrap--desktop .cozy-label {
    font-weight: 600;
    font-size: 17px;
}
/* 서브 메뉴 항목도 본 메뉴와 동일한 폰트 사이즈 */
.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list .sub-menu > li > a {
    padding: 16px 22px;
    font-size: 17px;
    color: #7a5640;
}
.cozymom-hm-menu-wrap--desktop .cozymom-hm-menu__list .sub-menu > li .cozy-label {
    font-size: 17px;
    font-weight: 600;
}

/* ----- 모바일 메뉴 (가로 스크롤 + | 구분 + 이모지 크게 + 텍스트 두 줄) ----- */
.cozymom-hm-menu-wrap--mobile {
    padding: 12px 0;
    position: relative;
}
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    gap: 0;
    align-items: stretch;
}
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list::-webkit-scrollbar {
    display: none;
}

/* 각 아이템: 칸 + 오른쪽 구분선(|) */
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list > li,
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list .sub-menu > li {
    position: relative;
    flex: 0 0 auto;
}
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list > li::after,
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list .sub-menu > li::after {
    content: '';
    position: absolute;
    right: 0;
    top: 18%;
    bottom: 18%;
    width: 1px;
    background: rgba(149, 89, 64, 0.18);
}
/* 마지막 항목엔 구분선 없음 */
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list > li:last-child::after,
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list > li.menu-item:last-of-type::after {
    display: none;
}

/* 아이콘(위) + 라벨(아래) 세로 정렬 */
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list li > a {
    background: transparent;
    border: none;
    border-radius: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    min-width: 90px;
    text-align: center;
    line-height: 1.25;
    color: #3c261e;
    gap: 6px;
}

/* 이모지 (위, 큼) */
.cozymom-hm-menu-wrap--mobile .cozy-icon {
    font-size: 30px;
    line-height: 1;
    display: block;
}
.cozymom-hm-menu-wrap--mobile .cozy-icon--empty {
    height: 30px;
}

/* 메뉴명 (아래, 띄어쓰기에서 자동 줄바꿈) */
.cozymom-hm-menu-wrap--mobile .cozy-label {
    font-size: 17px;
    font-weight: 700;          /* 굵게 */
    display: block;
    line-height: 1.25;
    color: #3c261e;             /* 더 진한 잉크색 */
    text-align: center;
}
.cozymom-hm-menu-wrap--mobile .cozy-word {
    display: block;
    white-space: nowrap;
}
/* 단어 사이 공백 (세로 배치이므로 시각적으로 불필요) */
.cozymom-hm-menu-wrap--mobile .cozy-word-sep {
    display: none;
}

/* 현재 페이지 강조 */
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list li.current-menu-item > a,
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list li.current-menu-parent > a {
    color: #b54c34;
}
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list li.current-menu-item > a .cozy-label,
.cozymom-hm-menu-wrap--mobile .cozymom-hm-menu__list li.current-menu-parent > a .cozy-label {
    color: #b54c34;
}

/* 우측 페이드 (스크롤 더 있음을 시각적으로 암시) */
.cozymom-hm-menu-wrap--mobile::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 14px; /* 진행 바 영역 침범 방지 */
    width: 48px;
    background: linear-gradient(to right, rgba(253,250,245,0), rgba(253,250,245,0.95) 60%, rgba(253,250,245,1));
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.cozymom-hm-menu-wrap--mobile.is-scroll-end::after {
    opacity: 0;
}

/* 스크롤 진행 바 (쿠팡 스타일) — 메뉴 바로 아래 */
.cozymom-hm-menu__scroll-indicator {
    display: none;
    position: relative;
    width: 60px;
    height: 3px;
    margin: 6px auto 0;
    background: rgba(149, 89, 64, 0.15);
    border-radius: 2px;
    overflow: hidden;
}
.cozymom-hm-menu__scroll-indicator.is-active {
    display: block;
}
.cozymom-hm-menu__scroll-thumb {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: #3c261e;
    border-radius: 2px;
    transition: left 0.12s ease, width 0.12s ease;
}

/* ----- 배너 슬라이더 ----- */
.cozymom-hm-banner-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f5ede2;
}
.cozymom-hm-banner__track {
    position: relative;
    width: 100%;
    height: var(--cozymom-banner-h, 400px);
}
.cozymom-hm-banner__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}
.cozymom-hm-banner__slide.is-active {
    opacity: 1;
    pointer-events: auto;
}
.cozymom-hm-banner__slide a,
.cozymom-hm-banner__slide picture,
.cozymom-hm-banner__slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cozymom-hm-banner__link {
    position: relative;
    text-decoration: none;
}
.cozymom-hm-banner__dday {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #b54c34;
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.cozymom-hm-banner__gonggu {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    padding: 8px 16px;
    border-radius: 8px;
    max-width: 80%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

/* ----- 공구 DB 이벤트 슬라이드 (자동 노출) ----- */
.cozymom-hm-banner__slide--gonggu {
    background: linear-gradient(135deg, #fde8e6 0%, #fdf3f1 60%, #fdfaf5 100%);
}
.cozymom-hm-banner__slide--gonggu .cozymom-hm-banner__link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}
.cozymom-hm-gonggu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px 40px;
    box-sizing: border-box;
    gap: 36px;
}
.cozymom-hm-gonggu__text {
    max-width: 560px;
}
.cozymom-hm-gonggu__image {
    flex-shrink: 0;
    width: 280px;
    height: 280px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(149, 89, 64, 0.18);
    background: #fff;
}
.cozymom-hm-gonggu__image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
.cozymom-hm-gonggu__text {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 560px;
    color: #3c261e;
}
.cozymom-hm-gonggu__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.cozymom-hm-gonggu__pill {
    display: inline-block;
    background: #b54c34;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
}
.cozymom-hm-gonggu__badge {
    display: inline-block;
    background: #ff7043;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}
.cozymom-hm-gonggu__title {
    margin: 0 0 8px 0 !important;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.2;
    color: #3c261e;
}
.cozymom-hm-gonggu__highlight {
    font-size: 16px;
    font-weight: 600;
    color: #b54c34;
    margin-bottom: 8px;
}
.cozymom-hm-gonggu__period {
    font-size: 14px;
    color: #7c5b4d;
    margin-bottom: 10px;
}
.cozymom-hm-gonggu__timer {
    display: inline-block;
    font-size: 20px;
    font-weight: 800;
    color: #d32f2f;
    background: #fff1f0;
    padding: 6px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-variant-numeric: tabular-nums;
}
.cozymom-hm-gonggu__cta {
    display: inline-block;
    background: #b54c34;
    color: #fff;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
}

/* 모바일: 200px 높이에 맞춰 이미지 작게 + 텍스트 컴팩트 */
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu {
    flex-direction: row;
    padding: 12px 14px;
    gap: 12px;
    align-items: center;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__image {
    width: 140px;
    height: 140px;
    border-radius: 12px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__text {
    max-width: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__title {
    font-size: 15px;
    margin-bottom: 4px !important;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__highlight {
    display: none;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__period {
    display: none;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__timer {
    font-size: 13px;
    padding: 3px 8px;
    margin-bottom: 6px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__cta {
    padding: 5px 12px;
    font-size: 12px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__pill {
    font-size: 11px;
    padding: 3px 8px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__head {
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 4px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-gonggu__badge {
    font-size: 10px;
    padding: 2px 6px;
}
.cozymom-hm-banner-wrap[data-transition="slide"] .cozymom-hm-banner__track {
    display: flex;
    transition: transform 0.5s ease;
}
.cozymom-hm-banner-wrap[data-transition="slide"] .cozymom-hm-banner__slide {
    position: relative;
    inset: auto;
    flex: 0 0 100%;
    opacity: 1;
    pointer-events: none;
}
.cozymom-hm-banner-wrap[data-transition="slide"] .cozymom-hm-banner__slide.is-active {
    pointer-events: auto;
}
.cozymom-hm-banner__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.8);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    color: #5c3a2a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: background 0.15s;
    z-index: 5;
}
.cozymom-hm-banner__nav:hover { background: #fff; }
.cozymom-hm-banner__nav--prev { left: 12px; }
.cozymom-hm-banner__nav--next { right: 12px; }
.cozymom-hm-banner__dots {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 5;
}
.cozymom-hm-banner__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, transform 0.15s;
}
.cozymom-hm-banner__dot.is-active {
    background: #b54c34;
    transform: scale(1.3);
}
.cozymom-hm-banner__pause {
    width: 22px;
    height: 22px;
    margin-left: 3px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.82);
    color: #5c3a2a;
    font-size: 10px;
    font-weight: 800;
    line-height: 22px;
    cursor: pointer;
}
.cozymom-hm-banner__pause[aria-pressed="true"] {
    background: #b54c34;
    color: #fff;
}
.cozymom-hm-banner__nav:focus-visible,
.cozymom-hm-banner__dot:focus-visible,
.cozymom-hm-banner__pause:focus-visible,
.cozymom-hm-menu__list a:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 3px;
}
.cozymom-hm-banner-wrap--mobile .cozymom-hm-banner__nav { display: none; }
.cozymom-hm-banner-wrap--mobile .cozymom-hm-banner__dot { width: 6px; height: 6px; }

/* ----- 디바이스 분기 (CSS 미디어쿼리) ----- */
/* 데스크탑 폭일 때 모바일 요소 숨김, 모바일 폭일 때 데스크탑 요소 숨김 */
@media (max-width: 921px) {
    .cozymom-hm-menu-wrap--desktop,
    .cozymom-hm-banner-wrap--desktop {
        display: none !important;
    }
}
@media (min-width: 922px) {
    .cozymom-hm-menu-wrap--mobile,
    .cozymom-hm-banner-wrap--mobile {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cozymom-hm-banner__track,
    .cozymom-hm-banner__slide,
    .cozymom-hm-menu__scroll-thumb,
    .cozymom-hm-banner__dot {
        transition: none !important;
    }
}
