/* layout.css — 공통 레이아웃 */
.page {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 페이지 로더 */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff;
}

.page-loader.is-hidden {
  display: none;
}

.page-loader__icon {
  display: block;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  max-width: 48px;
}

.page-loader__text {
  font-size: 17px;
  font-weight: 600;
  color: #4b5563;
  word-break: keep-all;
}

#app-main {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
}

#app-main.is-loading {
  visibility: hidden;
}

/* 헤더 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  overflow: visible;
  background: #fff;
  border-bottom: 1px solid #eee;
  padding-block: 12px;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--site-brand-text-color, #1a1a1a);
  text-decoration: none;
  flex-shrink: 0;
}

.site-header__logo-icon {
  display: block;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  color: var(--site-brand-logo-color, #e57373);
}

.site-header__logo-icon--img {
  display: block;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.site-header__logo-text {
  line-height: 1.2;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.site-header__cart,
.site-header__guide,
.site-header__notifications,
.site-header__menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  min-height: 44px;
  color: #6b7280;
  text-decoration: none;
}

.site-header__nav-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 8px;
}

.site-header__nav-icon {
  display: block;
  width: 24px;
  height: 24px;
}

/* 담긴 수량·읽지 않은 알림 뱃지 — 0이면 hidden */
.site-header__nav-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 1.125rem;
  height: 1.125rem;
  padding-inline: 4px;
  border-radius: 999px;
  background: #e57373;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
}

.site-header__nav-badge[hidden] {
  display: none;
}

.site-header__notifications.is-unread .site-header__nav-icon {
  transform-origin: top center;
  animation: notice-bell-ring 1.1s ease-in-out 4;
}

@keyframes notice-bell-ring {
  0%,
  100% { transform: rotate(0deg); }
  12% { transform: rotate(14deg); }
  24% { transform: rotate(-12deg); }
  36% { transform: rotate(10deg); }
  48% { transform: rotate(-8deg); }
  60% { transform: rotate(5deg); }
  72% { transform: rotate(-3deg); }
}

/* Fly-to-cart 날아가는 복제 아이콘 */
.cart-fly__ghost {
  position: fixed;
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 6px 16px rgb(37 99 235 / 35%);
  pointer-events: none;
  will-change: transform, opacity;
}

.cart-fly__ghost svg {
  display: block;
  width: 20px;
  height: 20px;
  color: inherit;
  fill: currentColor;
}

.site-header__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.user-avatar {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.user-avatar > img[data-user-avatar],
.user-avatar > [data-user-avatar-fallback] {
  position: absolute;
  inset: 0;
}

.user-avatar > img[data-user-avatar][hidden],
.user-avatar.is-avatar-failed > img[data-user-avatar] {
  display: none !important;
}

.user-avatar > [data-user-avatar-fallback][hidden] {
  display: none !important;
}

/* 헤더 프로필 드롭다운 */
.profile-menu {
  position: relative;
  flex-shrink: 0;
}

.profile-menu__trigger {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.profile-menu__avatar {
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  background: #e8eef6;
  color: #64748b;
  box-shadow: inset 0 0 0 1px #e5e7eb;
}

.profile-menu__avatar > img[data-user-avatar] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-menu__avatar > [data-user-avatar-fallback] {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8eef6;
}

.profile-menu__avatar-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.site-account-drawer {
  display: none;
}

@media (max-width: 767px) {
  .site-account-drawer {
    display: contents;
  }
}

.profile-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 120;
  min-width: 11.5rem;
  padding-block: 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgb(15 23 42 / 12%);
}

.profile-menu__panel[hidden] {
  display: none;
}

.profile-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-inline: var(--control-inset);
  color: inherit;
  text-decoration: none;
  font-size: 1rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.profile-menu__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.profile-menu__item:hover,
.profile-menu__item:focus-visible {
  background: #f0f7ff;
  outline: none;
}

.profile-menu__item--logout {
  color: #dc2626;
}

.profile-menu__item--logout:hover,
.profile-menu__item--logout:focus-visible {
  background: #fef2f2;
}

.profile-menu__divider {
  margin: 4px var(--control-inset);
  border: none;
  border-top: 1px solid #e5e7eb;
}

/* 드롭다운·선택 UI 공통 inset (design-ui 규칙) */
:root {
  --control-inset: 16px;
}

/* 커스텀 드롭다운 — select 외 트리거·메뉴 항목 */
.dropdown__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding-inline: var(--control-inset);
  border: 1px solid #ddd;
  border-radius: 999px;
  background: #fff;
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
}

.dropdown__trigger-icon {
  flex-shrink: 0;
  width: 12px;
  height: 8px;
}

.dropdown__menu {
  min-width: 12rem;
  padding-block: 4px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 10%);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-inline: var(--control-inset);
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dropdown__item:hover,
.dropdown__item:focus-visible {
  background: #f0f7ff;
  outline: none;
}

.dropdown__item-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

/* 푸터 */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  padding-block: 32px;
  background: #f8f9fa;
  border-top: 1px solid #eee;
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.site-footer__row {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}

.site-footer__nav a {
  color: #555;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 1rem;
  line-height: 1.6;
}

.site-footer__copy {
  margin: 0;
  font-size: 0.875rem;
  color: #888;
}

/* 푸터 언어 선택 — 이용약관 등과 같은 글자 크기·높이 */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.lang-switcher__icon {
  flex-shrink: 0;
  display: block;
  width: 20px;
  height: 20px;
  color: #555;
}

.lang-switcher__select {
  --select-inset: 12px;
  width: auto;
  max-width: 100%;
  min-width: 7rem;
  min-height: 44px;
  padding-block: 6px;
  font-size: 1rem;
  line-height: 1.6;
  color: #555;
  border-color: #ddd;
  border-radius: 8px;
  background-color: #fff;
  text-align: left;
}

/* 섹션 공통 */
.section {
  padding-block: 32px;
}

.section__title {
  margin: 0 0 20px;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 700;
  line-height: 1.35;
}

/* 모달·토스트 */
.modal-root[hidden],
.toast-root:empty {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 45%);
}

.modal {
  width: 100%;
  max-width: min(100% - 32px, 400px);
  background: #fff;
  border-radius: 12px;
  padding: 24px;
}

.modal__message {
  margin: 0 0 20px;
  line-height: 1.6;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-root {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100% - 32px, 400px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgb(15 23 42 / 10%);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: #2563eb;
  color: #fff;
}

.btn--ghost {
  background: #f0f0f0;
  color: #1a1a1a;
}

.btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.65;
  cursor: not-allowed;
}

.empty-state {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: #888;
  background: #f8f9fa;
  border-radius: 12px;
}

.scroll-jump {
  position: absolute;
  right: max(12px, env(safe-area-inset-right, 0px));
  top: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.scroll-jump.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scroll-jump__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #e8edf3;
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
}

.scroll-jump__btn:hover {
  background: #f8fafc;
  color: #475569;
}

.scroll-jump__btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.scroll-jump__icon {
  display: block;
  width: 22px;
  height: 22px;
  max-width: none;
  color: inherit;
}

/* 모바일 하단 탭 — PC·채팅에서는 숨김 */
.mobile-tabbar {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  align-items: stretch;
  justify-content: space-around;
  box-sizing: border-box;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 -4px 12px rgb(15 23 42 / 6%);
}

body:not(.body--chat) {
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

body.body--chat .mobile-tabbar {
  display: none;
}

.mobile-tabbar__link {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b7280;
  text-decoration: none;
  cursor: pointer;
}

.mobile-tabbar__link[aria-current="page"] {
  color: #2563eb;
}

.mobile-tabbar__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
}

.mobile-tabbar__link:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.mobile-tabbar__icon {
  display: block;
  width: 26px;
  height: 26px;
  max-width: none;
  color: inherit;
}

.mobile-tabbar__badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 1.125rem;
  height: 1.125rem;
  padding-inline: 4px;
  border-radius: 999px;
  background: #e57373;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
}

@media (min-width: 768px) {
  .mobile-tabbar {
    display: none;
  }

  body:not(.body--chat) {
    padding-bottom: 0;
  }
}
