@charset "utf-8";

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);

    /* 하단 탭바의 실제 높이 = 세로 padding*2 + 아이콘 + gap + 라벨 행높이.
       .site-footer__item a / __icon / __label 의 값에서 파생된다 (디자인 토큰 아님).
       탭바가 fixed라 #wrap 하단 여백을 이 값으로 확보한다 — 셋 중 하나를 바꾸면 여기도 같이 바꾼다. */
    --nav-height: calc(
        var(--space-27) * 2 +
        var(--size-icon-nav) +
        var(--space-10) +
        var(--fs-25) * var(--lh-base)
    );
}

/* ========================================
   공통 레이아웃 골격 (header / wrap / footer)
======================================== */

/* 스티키 푸터: body를 세로 flex로, #wrap이 남는 공간 차지 */
body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

/* 좌우 gutter는 #wrap이 아니라 .inner가 갖는다.
   #wrap이 gutter를 가지면 section 배경이 화면 끝까지 가지 못한다. */
#wrap {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
}


/* ========================================
   section / .inner
   - section에는 좌우 gutter를 주지 않는다 (배경이 화면 끝까지 가야 하므로)
   - .inner는 section의 직접 자식으로 정확히 1회. 중첩·반복 금지
======================================== */
section {
    width: 100%;
}

.sub-section {
    width: 100%;
}

.inner {
    width: 100%;
    max-width: var(--inner-max-width);   /* padding 포함 외곽 768px */
    margin-inline: auto;
    /* 노치 대응 — 세이프 영역이 gutter보다 넓을 때만 그만큼 벌어진다 */
    padding-left: max(var(--inner-padding-x), var(--safe-left));
    padding-right: max(var(--inner-padding-x), var(--safe-right));
}


/* <main class="wrap ..."> — 여러 페이지가 공통으로 쓰는 페이지 컨테이너 */
.wrap {width: 100%;flex: 1;}

.sub-wrap {
}

/* <section class="sec ..."> — 모든 페이지의 섹션 공통 래퍼 */
.sec {
}


/* ========================================
   loading
======================================== */

#loading-mask {
    position: fixed;
    z-index: 999;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: var(--color-bg);
}


/* ========================================
   header
======================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    border-bottom: 1px solid var(--color-line-gray);
    background: rgba(255, 255, 255, 0.9);

    /* 좌우 gutter는 .inner가 담당한다. 여기선 세로 여백과 상단 세이프 영역만. */
    padding-top: max(var(--space-20), var(--safe-top));
    padding-bottom: var(--space-20);

    backdrop-filter: blur(50px);
}

body.header-type-default .site-header[data-header-type="default"] {

}

body.header-type-logo_only .site-header[data-header-type="logo_only"] {}
body.header-type-title_only .site-header[data-header-type="title_only"] {
    border: 0;
    padding-top: var(--space-120)   
}

.site-header[data-header-type] > .inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-33);
}

/*
   타입별 선택자
   - body.header-type-default .site-header[data-header-type="default"]
   - body.header-type-logo_only .site-header[data-header-type="logo_only"]
   - body.header-type-title_only .site-header[data-header-type="title_only"]
   - body.header-type-custom .custom-header
*/
body.header-type-default .site-header[data-header-type="default"] > .inner {
    justify-content: space-between;
}

body.header-type-logo_only .site-header[data-header-type="logo_only"] > .inner,
body.header-type-title_only .site-header[data-header-type="title_only"] > .inner {
    justify-content: flex-start;
}

/* 로고 */
.site-header__logo {
    flex: 0 0 auto;
    margin: 0;
}

.site-header__logo-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-10);
}

.site-header__logo-icon {
    /* Figma 디자인에 사이트 헤더·로고가 없어 대응 토큰이 없다.
       기존 의도(52 x 2 = 104px)를 유지한 1회성 값이라 토큰화하지 않고 여기서 계산한다.
       244~768 기준: min 33.04px / max 104px */
    width: clamp(3.3042rem, 13.5417vw, 10.4rem);
    display: block;
}

.site-header__logo-text {
    font-size: var(--fs-22);
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
}

.site-header__page-title {
    width: 100%;
    margin: 0;
    font-size: var(--fs-22);
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}

/* default: 로고 + 햄버거 */
.site-header__menu-button {
    flex: 0 0 auto;
    width: 4.4rem;
    height: 4.4rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 0;
    border-radius: 50%;
    padding: 0;
    background: var(--color-bg-control);
    cursor: pointer;
}

.site-header__menu-button > span {
    width: 2rem;
    height: 2px;
    border-radius: 999px;
    background: var(--color-text);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header--default.is-menu-open .site-header__menu-button > span:nth-child(1) {
    transform: translateY(0.7rem) rotate(45deg);
}

.site-header--default.is-menu-open .site-header__menu-button > span:nth-child(2) {
    opacity: 0;
}

.site-header--default.is-menu-open .site-header__menu-button > span:nth-child(3) {
    transform: translateY(-0.7rem) rotate(-45deg);
}

.site-header__menu {
    position: absolute;
    top: calc(100% + var(--space-20));
    right: max(var(--inner-padding-x), var(--safe-right));
    width: min(32rem, calc(100vw - 4rem));
    padding: 1.2rem;
    border: 1px solid var(--color-line-gray);
    border-radius: 1.6rem;
    background: var(--color-bg);
    box-shadow: 0 1.2rem 3rem rgba(15, 23, 42, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.8rem);
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease;
}

.site-header--default.is-menu-open .site-header__menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.site-header__menu-list {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-header__menu-item a {
    display: block;
    padding: 1.2rem 1.4rem;
    border-radius: 1rem;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--color-text);
}

.site-header__menu-item a:hover,
.site-header__menu-item a:focus-visible,
.site-header__menu-item.is-active a {
    background: var(--color-bg-control);
    color: var(--color-primary);
}

/* custom/result 타입이 사용할 수 있는 최소 골격 */
body.header-type-custom .custom-header,
.result-header {
    width: 100%;
    padding-top: max(var(--space-20), var(--safe-top));
    padding-bottom: var(--space-20);
}

body.header-type-custom .custom-header > .inner,
.result-header > .inner {
    display: flex;
    align-items: center;
}

.result-header__back {
    width: 4.4rem;
    height: 4.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.result-header__back-icon,
.result-header__back-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}




/* ========================================
   footer (모바일 하단 탭바 내비게이션)
   - 데스크톱에서는 상단 .site-nav로 충분하여 숨김 처리, 768px 이하에서만 고정 탭바로 노출.
   - 모바일 하단 세이프 영역(홈 인디케이터/제스처 바)을 침범하지 않도록 env(safe-area-inset-bottom) 반영.
======================================== */
.site-footer {
    /* display: none; */
}

.site-footer__list {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-footer__item {
    flex: 1 1 0;
    min-width: 0;
}

.site-footer__item a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-10);          /* Figma: 아이콘 ↔ 라벨 10px */
    padding: var(--space-27) 0;    /* Figma: 27px 0 */
    color: var(--color-text-gray);
}

.site-footer__icon {
    position: relative;
    width: var(--size-icon-nav);
    height: var(--size-icon-nav);
    display: inline-flex;
    overflow: visible;
}

.site-footer__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 보관함 활성 탭의 찜 국가 수 뱃지 */
.site-footer__favorite-count[hidden] {
    display: none !important;
}

.site-footer__favorite-count {
    position: absolute;
    top: clamp(-0.5rem, -0.651vw, -0.3rem);
    right: clamp(-0.8rem, -1.0417vw, -0.5rem);
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(1.7rem, 2.2135vw, 2.2rem);
    height: clamp(1.7rem, 2.2135vw, 2.2rem);
    padding-inline: 0.35rem;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: clamp(1.05rem, 1.3672vw, 1.3rem);
    font-weight: 800;
    line-height: 1 !important;
    box-shadow: 0 0.3rem 0.8rem rgba(255, 107, 107, 0.28);
}

.site-footer__label {
    font-size: var(--fs-25);
    font-weight: 400;
    line-height: var(--lh-base);
    white-space: nowrap;
    color: var(--color-text-gray);
}

.site-footer__item.is-active a,
.site-footer__item.is-active .site-footer__label {
    color: var(--color-primary);
}

/* ========================================
    재사용
======================================== */
.box {
    background: var(--color-bg-card);
    width: 100%;
    border-radius: var(--radius-40);
    padding: var(--space-33) var(--space-22);
}


/* ========================================
   반응형
======================================== */

@media (max-width: 768px) {
    /* 하단 탭바 노출 — 홈 인디케이터/제스처 바 영역(safe-area-inset-bottom)만큼 여백 확보.
       좌우 세이프 영역은 .inner가 max()로 이미 처리한다. */
    .site-footer {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        background: var(--color-bg);
        box-shadow: var(--shadow-nav);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* 탭바에 가려지지 않도록 콘텐츠 하단 여백 확보 (탭바 자체 높이 + 세이프 영역) */
    .has-site-footer #wrap {
        padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
    }

    /* footer가 없는 페이지에는 탭바 보정 여백을 두지 않는다. */
    .no-site-footer #wrap,
    .is-result-header-page #wrap {
        padding-bottom: 0;
    }
}
