/* 공통: 리셋 + 재사용 컴포넌트
   버튼, 배지, 번호 태그, 구분 띠, 하단 바, 푸터, 아이콘, 아이콘 버튼, 상단 바, 섹션 제목,
   자막 태그, 썸네일, 수량 스테퍼, 입력 필드, 금액 요약 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--white);
  color: var(--grey-900);
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: var(--ls);
}
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; letter-spacing: inherit; }

/* 화면 폭: 모바일(600 미만)은 화면 폭 전체. 크기 단위(--u)만 480에서 멈춘다. 워드프레스가 고정 페이지의 body에도 page 클래스를 붙이므로 div 래퍼에만 적용한다 */
:where(div).page {
  position: relative;
  min-height: 100vh;
  background: var(--white);
}

/* 아이콘 (인라인 SVG): 선 굵기는 화면 기준 1.5px 고정 */
.icon { display: block; flex-shrink: 0; fill: none; stroke: currentColor; stroke-linejoin: round; }
.icon * { vector-effect: non-scaling-stroke; stroke-width: 1.5px; }

/* 버튼 */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  padding: 0 calc(16 * var(--u));
  border: 0;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}
.btn--lg { height: calc(50 * var(--u)); font-size: var(--fs-body1); }
.btn--md { height: calc(48 * var(--u)); font-size: var(--fs-body2); }
.btn--sm { height: calc(44 * var(--u)); font-size: var(--fs-body3); }
.btn--primary { background: var(--grey-900); color: var(--white); }
.btn--secondary { background: var(--white); color: var(--grey-900); box-shadow: inset 0 0 0 1px var(--grey-300); }
.btn--auto { width: auto; padding: 0 calc(24 * var(--u)); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 상태 배지 */
.badge {
  display: inline-flex; align-items: center;
  height: calc(24 * var(--u)); min-height: 24px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: var(--fs-caption2);
  font-weight: 600;
  white-space: nowrap;
}
.badge--live { gap: 4px; background: var(--purple-500); color: var(--white); }
.badge--live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--white); }
.badge--purple { background: var(--purple-50); color: var(--purple-700); }
.badge--grey { background: var(--grey-100); color: var(--grey-600); }

/* 번호 태그 (기본 / 방송 중 / 품절) */
.num-tag {
  display: flex; align-items: center; justify-content: center;
  width: calc(24 * var(--u)); height: calc(24 * var(--u));
  min-width: 24px; min-height: 24px;
  border-radius: 4px;
  background: var(--grey-900); color: var(--white);
  font-size: var(--fs-caption1);
}
.num-tag.is-live { background: var(--purple-500); }
.num-tag.is-soldout { background: var(--grey-400); }
.num-tag--sm { width: calc(22 * var(--u)); height: calc(22 * var(--u)); min-width: 22px; min-height: 22px; font-size: var(--fs-caption2); }

/* 구분 띠 */
.band { height: calc(8 * var(--u)); background: var(--grey-100); }
/* 탭 바: 같은 화면 안의 영역으로 이동 (시안 TabBar, 모바일 높이 48 / 웹 56) */
.tab-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--white); border-bottom: 1px solid var(--grey-200); }
.tab-bar a { display: flex; align-items: center; justify-content: center; height: calc(48 * var(--u)); margin-bottom: -1px; font-size: var(--fs-body2); font-weight: 500; color: var(--grey-400); white-space: nowrap; }
.tab-bar a[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--grey-900); font-weight: 600; color: var(--grey-900); }

/* 화면에는 숨기고 스크린리더에는 읽히는 텍스트 (숨김 라벨용) */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 아이콘 버튼 (터치 영역 44px) */
.icon-btn { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: inherit; }
/* 장바구니 개수 배지 (모바일: 아이콘 오른쪽 위. 0개면 숨김, 웹은 헤더 글자 옆 배지를 쓴다) */
.icon-btn__badge { position: absolute; top: 5px; right: 3px; display: flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--grey-900); color: var(--white); font-size: var(--fs-caption2); font-weight: 600; line-height: 1; }

/* 상단 바: 뒤로가기 / 제목 / 홈·장바구니 (제목이 없어도 우측 영역은 3열에 고정) */
.top-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: calc(8 * var(--u)); }
.top-bar__title { text-align: center; font-size: var(--fs-body1); font-weight: 600; }
.top-bar__actions { grid-column: 3; display: flex; justify-content: flex-end; }

/* 섹션 제목 / 큰 제목 / 기본 섹션 여백 */
.section-title { font-size: var(--fs-title3); font-weight: 600; }
.heading-lg { font-size: var(--fs-title1); font-weight: 600; line-height: 1.4; }
.section { display: flex; flex-direction: column; gap: calc(16 * var(--u)); padding: calc(24 * var(--u)) calc(20 * var(--u)) calc(32 * var(--u)); }
.section > .heading-lg { margin-bottom: calc(8 * var(--u)); }

/* 가격 줄: 할인율 + 판매가 + 정가(취소선) */
.price-line { display: flex; align-items: center; gap: 8px; font-size: var(--fs-price); font-weight: 600; }
.price-line__discount { color: var(--purple-500); }
.price-line__original { font-size: var(--fs-body3); font-weight: 400; color: var(--grey-400); text-decoration: line-through; }

/* 자막 태그 (방송 중 상품 번호 + 이름) */
.cap-tag { display: inline-flex; height: calc(32 * var(--u)); min-height: 32px; gap: 4px; color: var(--white); font-weight: 500; }
.cap-tag__no {
  display: flex; align-items: center; justify-content: center;
  width: calc(32 * var(--u)); min-width: 32px;
  border-radius: 4px;
  background: linear-gradient(180deg, #987AED 0%, var(--purple-500) 100%);
  font-size: var(--fs-body1);
}
.cap-tag__text {
  display: flex; align-items: center; padding: 0 12px;
  border-radius: 4px;
  background: rgba(25, 27, 32, 0.25);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: var(--fs-body3); white-space: nowrap;
}

/* 자막 태그 작은 크기 */
.cap-tag--sm .cap-tag__text { font-size: var(--fs-caption1); }

/* 썸네일 (이미지 꽉 채움 + 좌상단 번호 태그). 크기·비율은 쓰는 쪽에서 지정 */
.thumb { position: relative; overflow: hidden; border-radius: 4px; background: var(--grey-100); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .num-tag { position: absolute; left: 8px; top: 8px; }

/* 수량 스테퍼 */
.qty-stepper { display: inline-flex; align-items: center; height: calc(40 * var(--u)); border-radius: 4px; background: var(--white); box-shadow: inset 0 0 0 1px var(--grey-300); }
.qty-stepper__btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--grey-500); }
.qty-stepper__num { width: calc(28 * var(--u)); text-align: center; font-size: var(--fs-body1); font-weight: 600; }
.qty-stepper__btn:disabled { color: var(--grey-300); cursor: not-allowed; }
.qty-stepper--compact .qty-stepper__num { width: calc(20 * var(--u)); font-size: var(--fs-body3); }

/* 입력 필드 (라벨 + 입력 + 힌트). 검색형은 링크에 --search */
.text-field { display: flex; flex-direction: column; gap: calc(8 * var(--u)); }
.text-field__label { font-size: var(--fs-caption1); font-weight: 400; color: var(--grey-500); }
.text-field__control {
  height: calc(48 * var(--u)); padding: 0 calc(16 * var(--u));
  border: 1px solid var(--grey-300); border-radius: 4px;
  background: var(--white); color: var(--grey-900);
  font: inherit; font-size: var(--fs-body1); letter-spacing: inherit;
}
.text-field__control--search { display: flex; align-items: center; justify-content: space-between; border: 0; box-shadow: inset 0 0 0 1px var(--grey-300); font-weight: 400; color: var(--grey-400); }
.text-field__control--search .icon { color: var(--grey-600); }
.text-field__hint { font-size: var(--fs-caption1); font-weight: 400; line-height: 1.5; color: var(--grey-400); }

/* 금액 요약 (항목 행 + 합계 + 안내) */
.price-summary { display: flex; flex-direction: column; gap: calc(12 * var(--u)); padding: calc(24 * var(--u)) calc(20 * var(--u)) calc(32 * var(--u)); background: var(--white); }
.price-summary .section-title { margin-bottom: 4px; }
.price-summary__rows { display: flex; flex-direction: column; gap: calc(12 * var(--u)); }
.price-summary__row { display: flex; justify-content: space-between; gap: calc(12 * var(--u)); font-size: var(--fs-body2); }
.price-summary__label { font-weight: 400; color: var(--grey-500); }
.price-summary__total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; padding-top: calc(16 * var(--u)); box-shadow: inset 0 1px 0 var(--grey-200); }
.price-summary__total-label { font-size: var(--fs-body1); font-weight: 600; }
.price-summary__total-value { font-size: var(--fs-price); font-weight: 600; color: var(--purple-500); }
.price-summary__note { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; font-size: var(--fs-caption1); font-weight: 400; line-height: 1.55; color: var(--grey-500); }
.price-summary__note .icon { margin-top: 2px; color: var(--grey-400); }

/* 하단 고정 바 */
.bottom-bar {
  position: fixed; left: 50%; bottom: 0; z-index: 10;
  width: 100%;
  transform: translateX(-50%);
  padding: calc(12 * var(--u)) calc(20 * var(--u)) calc(24 * var(--u));
  background: var(--white);
  box-shadow: inset 0 1px 0 var(--grey-200);
}
.bottom-bar__summary { display: flex; align-items: center; gap: calc(16 * var(--u)); }
.bottom-bar__info { flex-grow: 1; }
.bottom-bar__label { font-size: var(--fs-caption1); font-weight: 400; color: var(--grey-500); }
.bottom-bar__value { font-size: var(--fs-title3); font-weight: 600; }
.bottom-bar__note { display: flex; justify-content: space-between; align-items: baseline; gap: calc(12 * var(--u)); margin-bottom: calc(12 * var(--u)); font-size: var(--fs-caption1); font-weight: 400; color: var(--grey-500); }
.bottom-bar__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bottom-bar__stack { display: flex; flex-direction: column; gap: 8px; }
/* 하단 바에 가려지지 않도록 페이지 아래 여백 (바 높이에 맞춰 선택) */
.page--bar { padding-bottom: calc(88 * var(--u)); }
.page--bar-note { padding-bottom: calc(120 * var(--u)); }
.page--bar-stack { padding-bottom: calc(148 * var(--u)); }

/* 판매자 정보 푸터 */
.site-footer {
  display: flex; flex-direction: column; gap: calc(12 * var(--u));
  padding: calc(24 * var(--u)) calc(20 * var(--u)) calc(32 * var(--u));
  background: var(--grey-100);
  color: var(--grey-400);
}
.site-footer__links { display: flex; flex-wrap: wrap; gap: 0 calc(16 * var(--u)); font-size: var(--fs-caption1); }
.site-footer__links a { display: flex; align-items: center; min-height: 32px; color: var(--grey-500); }
.site-footer__links a.is-strong { color: var(--grey-900); }
.site-footer__info {
  display: grid; grid-template-columns: auto 1fr; gap: 4px calc(12 * var(--u));
  font-size: var(--fs-caption2); font-weight: 400; line-height: 1.5;
}
.site-footer__info > div { display: contents; }

/* 입력 오류 문구, 알림 */
.text-field__error { font-size: var(--fs-caption1); font-weight: 600; line-height: 1.5; color: var(--red-500); }
.toast { position: fixed; left: 50%; bottom: calc(96 * var(--u)); z-index: 50; max-width: calc(100% - 40px); padding: calc(12 * var(--u)) calc(20 * var(--u)); border-radius: 4px; background: var(--grey-900); color: var(--white); font-size: var(--fs-body3); transform: translateX(-50%); }

/* 방송 상품 더 담기/보기 링크(장바구니·주문서 공통) */
.add-more { display: flex; align-items: center; gap: 6px; min-height: 52px; font-size: var(--fs-body3); font-weight: 600; color: var(--grey-600); }
.add-more span { font-weight: 500; }

/* ===== 웹 (600px 이상) 공통: 페이지에 .page--web 을 붙이면 적용된다 (시안 최대 폭 1200, 값은 고정 px) ===== */
.web-header, .web-only { display: none; }
.web-columns { display: contents; }
.web-header__brand, .web-header__title, .web-header__label, .web-header__badge { display: none; }
.web-header__nav { display: flex; }
@media (min-width: 600px) {
  .page--web {
    --u: 1px;
    --fs-title1: 24px; --fs-title2: 20px; --fs-title3: 17px; --fs-price: 22px;
    --fs-body1: 16px; --fs-body2: 15px; --fs-body3: 14px; --fs-caption1: 13px; --fs-caption2: 12px;
    /* 가로 여백: 폭이 1200을 넘으면 가운데 정렬처럼 늘어난다 */
    --gutter: max(clamp(20px, 3vw, 40px), calc((100% - 1200px) / 2 + clamp(20px, 3vw, 40px)));
    max-width: none; padding-bottom: 0;
  }
  .page--web .top-bar { display: none; }
  .page--web .icon-btn__badge { display: none; }
  .page--web .tab-bar a { height: 56px; }
  .page--web .web-only { display: revert; }
  /* 푸터 사업자 정보: 항목 하나씩 한 줄 */
  .page--web .site-footer__info { display: flex; flex-direction: column; gap: 4px; }
  .page--web .site-footer__info > div { display: flex; gap: 8px; }
  .page--web .mobile-only { display: none; }

  /* 웹 본문: 제목 아래 왼쪽 내용, 오른쪽 고정 카드 */
  .web-main { display: flex; flex-direction: column; gap: 24px; padding: 40px var(--gutter) 80px; }
  .web-title { font-size: 28px; font-weight: 600; }
  .web-columns { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 40px; }
  .web-aside { min-width: 0; position: sticky; top: 24px; border: 1px solid var(--grey-200); border-radius: 8px; overflow: hidden; }
  .web-aside .band, .web-aside .bottom-bar__note { display: none; }
  .page--web .web-aside .bottom-bar { padding: 0 20px 20px; }
  /* 하단 고정 바는 웹에서 일반 블록(본문 안 버튼 줄)이 된다 */
  .page--web .bottom-bar { position: static; width: auto; max-width: none; padding: 0; background: none; box-shadow: none; transform: none; }

  /* 웹 헤더: 브랜드 왼쪽, 주문 조회·장바구니 오른쪽 */
  .web-header { display: block; background: var(--white); box-shadow: inset 0 -1px 0 var(--grey-200); }
  .web-header__inner {
    display: flex; align-items: center; justify-content: space-between; height: 72px;
    padding: 0 max(clamp(12px, 3vw, 40px), calc((100% - 1200px) / 2 + clamp(12px, 3vw, 40px))) 0 var(--gutter);
  }
  .web-header__brand { display: block; font-size: 20px; font-weight: 600; white-space: nowrap; }
  /* 방송 중 제목: 브랜드 자리에 최대 2줄 */
  .web-header__title { display: -webkit-box; min-width: 0; margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .web-header__nav { flex-shrink: 0; gap: 4px; }
  .web-header__link { width: auto; gap: 6px; padding: 0 12px; font-size: 14px; }
  .web-header__link .icon { width: 20px; height: 20px; }
  .web-header__label { display: inline; }
  .web-header__badge {
    display: flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--grey-900); color: var(--white); font-size: 12px; font-weight: 600;
  }
}

/* ===== 웹 두 열(1024 이상) / 한 열(600~1023) ===== */
@media (min-width: 1024px) {
  .web-columns, .product-layout { flex-wrap: nowrap; }
}
/* 한 열로 쌓이는 폭에서는 하단 바를 모바일처럼 화면 아래에 고정한다 */
@media (min-width: 600px) and (max-width: 1023px) {
  .web-columns, .product-layout { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .web-aside { position: static; }
  /* 입력, 단일 작업 화면은 한 열에서 520 가운데 (홈은 목록이라 화면 폭을 채운다) */
  .web-main > *, .product-back, .product-layout .product-hero, .product-layout .product-info { flex: none; width: 100%; max-width: 520px; margin-inline: auto; }
  .page--web .bottom-bar, .page--web .web-aside .bottom-bar {
    position: fixed; left: 0; bottom: 0; z-index: 10; width: 100%;
    padding: calc(12 * var(--u)) max(20px, calc((100% - 520px) / 2)) calc(24 * var(--u)); background: var(--white); box-shadow: inset 0 1px 0 var(--grey-200);
  }
  .web-aside .bottom-bar__note { display: flex; }
  .page--web.page--bar { padding-bottom: calc(88 * var(--u)); }
  .page--web.page--bar-note { padding-bottom: calc(120 * var(--u)); }
}
