/* =====================================================
   달빛 카페 – 스타일
   1. 색·폰트 변수   2. 기본   3. 앱 틀·화면 전환
   4. 메뉴판 (상단 바, 인사, 탭, 메뉴 목록, 장바구니 버튼)
   5. 하위 화면 (장바구니, 주문 완료, 주문 내역, 테이블 안내)
   6. 올라오는 창 (메뉴 상세, 카페 정보)
   7. 공통 부품 (버튼, 합계, 안내, 빈 화면)
   ===================================================== */


/* ---------- 1. 색·폰트 변수 (기획서 8번 색표) ---------- */
:root {
  --night:      #0B1026;   /* 배경 : 깊은 밤하늘 */
  --pond:       #13213F;   /* 연못·카드 : 물에 비친 밤 */
  --pond-line:  #22345C;   /* 카드 테두리, 구분선 */
  --moon:       #F4D58D;   /* 메인 포인트 : 은은한 달빛 금색 */
  --moon-soft:  rgba(244, 213, 141, 0.14);
  --dan-red:    #D9573B;   /* 단청 주홍 : 할인, 주문 버튼 */
  --dan-green:  #2F8F83;   /* 단청 청록 : 배지, 선택 상태 */
  --paper:      #F5F1E6;   /* 글자 : 한지 같은 따뜻한 흰색 */
  --paper-dim:  #A9AEC2;   /* 보조 글자 */

  --font-title: "Gowun Batang", serif;
  --font-body:  "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius:     14px;
  --gap:        16px;
  --topbar-h:   56px;
  --ease:       0.25s ease;
}


/* ---------- 2. 기본 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  /* 탭으로 이동할 때 상단 바·탭에 가리지 않도록 */
  scroll-padding-top: calc(var(--topbar-h) + 56px);
}

body {
  margin: 0;
  background: var(--night);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}


/* ---------- 3. 앱 틀·화면 전환 ---------- */
.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 한 번에 화면 하나만 보임 : main.js 가 .is-active 를 옮김 */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.screen__body {
  flex: 1;
  padding: var(--gap);
}

.screen__foot {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 10px;
  padding: var(--gap);
  padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  background: var(--night);
  border-top: 1px solid var(--pond-line);
}


/* ---------- 4. 메뉴판 ---------- */

/* 상단 바 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 var(--gap);
  background: var(--night);
}

.topbar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-size: 19px;
  font-weight: 700;
  color: var(--moon);
}

.topbar__moon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--moon);
  box-shadow: 0 0 12px var(--moon);
}

.topbar__table {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--moon-soft);
  color: var(--moon);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  gap: 4px;
}

/* 인사 영역 */
.hero {
  position: relative;
  padding: 0 var(--gap) var(--gap);
}

/* 동궁과 월지 배경 자리 (8단계에서 그림으로 교체) */
.hero__scene {
  height: 140px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 75% 35%, var(--moon) 0 22px, rgba(244, 213, 141, 0.25) 23px 40px, transparent 41px),
    linear-gradient(to bottom, #1A2550 0%, var(--pond) 60%, #0E1833 100%);
}

.hero__greeting {
  margin-top: 12px;
  font-family: var(--font-title);
  font-size: 17px;
}

.hero__greeting strong {
  color: var(--moon);
}

/* 카테고리 탭 : 상단 바 아래에 고정, 가로 스크롤 */
.tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px var(--gap);
  overflow-x: auto;
  background: var(--night);
  border-bottom: 1px solid var(--pond-line);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs__item {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--pond-line);
  color: var(--paper-dim);
  font-size: 14px;
  white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.tabs__item.is-active {
  background: var(--moon);
  border-color: var(--moon);
  color: var(--night);
  font-weight: 700;
}

/* 메뉴 목록 */
.menu {
  padding: 0 var(--gap) 120px;   /* 아래 장바구니 버튼에 가리지 않도록 */
}

.menu-group {
  padding-top: 24px;
}

/* 마지막 카테고리도 탭 바로 아래까지 올라올 수 있도록 최소 높이 확보 */
.menu-group:last-child {
  min-height: calc(100vh - var(--topbar-h) - 160px);
}

.menu-group__title {
  margin-bottom: 8px;
  font-family: var(--font-title);
  font-size: 18px;
  color: var(--moon);
}

/* 메뉴가 아직 없을 때 자리 표시 (3단계에서 실제 메뉴로 채워짐) */
.menu-list:empty::before {
  content: "메뉴 준비 중";
  display: block;
  padding: 20px;
  border: 1px dashed var(--pond-line);
  border-radius: var(--radius);
  color: var(--paper-dim);
  font-size: 13px;
  text-align: center;
}

/* 메뉴 한 줄 : 왼쪽 글, 오른쪽 사진 */
.menu-list > li + li {
  border-top: 1px solid var(--pond-line);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 0;
  border: 0;
  background: none;
  text-align: left;
  transition: opacity var(--ease);
}

.menu-item:active {
  opacity: 0.7;
}

.menu-item__info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.menu-item__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.menu-item__badges:not(:empty) {
  margin-bottom: 6px;
}

.menu-item__name {
  font-size: 16px;
  font-weight: 700;
}

.menu-item__en {
  color: var(--paper-dim);
  font-size: 12px;
}

.menu-item__desc {
  margin-top: 4px;
  color: var(--paper-dim);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item__price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
}

.menu-item__price strong {
  font-size: 16px;
  color: var(--moon);
}

.menu-item__old {
  color: var(--paper-dim);
  font-size: 13px;
}

.menu-item__rate {
  color: var(--dan-red);
  font-size: 14px;
  font-weight: 700;
}

/* 사진 자리 (8단계에서 실제 사진) */
.menu-item__photo {
  display: grid;
  flex: none;
  place-items: center;
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius);
  background: var(--pond);
  font-size: 36px;
}

/* 품절 : 흐리게 + 사진 위에 "품절" */
.menu-item.is-soldout {
  cursor: not-allowed;
}

.menu-item.is-soldout .menu-item__info,
.menu-item.is-soldout .menu-item__photo {
  opacity: 0.4;
}

.menu-item.is-soldout .menu-item__photo::after {
  content: "품절";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: rgba(11, 16, 38, 0.6);
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
}

/* 배지 */
.badge {
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}

.badge--recommend {
  background: var(--moon-soft);
  color: var(--moon);
}

.badge--signature {
  background: rgba(47, 143, 131, 0.22);
  color: #6FD1C3;
}

.badge--sale {
  background: rgba(217, 87, 59, 0.2);
  color: #F08A70;
}

.badge--soldout {
  background: rgba(169, 174, 194, 0.2);
  color: var(--paper-dim);
}

/* 하단 장바구니 버튼 */
.cartbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px var(--gap);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--night) 70%, transparent);
}

.cartbar .btn {
  justify-content: space-between;
}

.cartbar__count {
  min-width: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--dan-red);
  font-weight: 700;
}


/* ---------- 5. 하위 화면 ---------- */

/* 장바구니·주문 내역 상단 */
.subbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 8px;
  background: var(--night);
  border-bottom: 1px solid var(--pond-line);
}

.subbar__title {
  font-family: var(--font-title);
  font-size: 18px;
}

/* 주문 완료 */
.done {
  text-align: center;
  padding-top: 48px;
}

.done__cat,
.empty__cat,
.table-guide__cat {
  /* 월이 자리 (8단계에서 SVG 로 교체) */
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--pond);
  border: 2px dashed var(--moon);
}

.done__label {
  color: var(--paper-dim);
  font-size: 14px;
}

.done__number {
  font-family: var(--font-title);
  font-size: 44px;
  font-weight: 700;
  color: var(--moon);
}

.done__message {
  margin: 12px 0 24px;
}

/* 테이블 안내 */
.table-guide {
  text-align: center;
  padding-top: 64px;
}

.table-guide__title {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--moon);
}

.table-guide__desc {
  margin-top: 8px;
  color: var(--paper-dim);
}

.table-guide__demo {
  margin: 40px 0 12px;
  color: var(--paper-dim);
  font-size: 13px;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}

.table-grid__btn {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--pond);
  border: 1px solid var(--pond-line);
  font-weight: 700;
  transition: border-color var(--ease), color var(--ease);
}

.table-grid__btn:hover,
.table-grid__btn:focus-visible {
  border-color: var(--moon);
  color: var(--moon);
}


/* ---------- 6. 올라오는 창 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
}

.sheet.is-open {
  visibility: visible;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity var(--ease);
}

.sheet.is-open .sheet__backdrop {
  opacity: 1;
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px var(--gap);
  padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--pond);
  transform: translateY(100%);
  transition: transform var(--ease);
}

.sheet.is-open .sheet__panel {
  transform: translateY(0);
}

.sheet__close {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* 메뉴 상세 */
.detail__photo {
  height: 180px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--night);
}

.detail__name {
  font-family: var(--font-title);
  font-size: 22px;
}

.detail__desc {
  margin-top: 4px;
  color: var(--paper-dim);
}

.detail__price {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--moon);
}

.options {
  margin: 16px 0;
}

.qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.qty__control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qty__value {
  min-width: 24px;
  font-weight: 700;
  text-align: center;
}

/* 카페 정보 */
.info__title {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--moon);
  margin-bottom: 16px;
}


/* ---------- 7. 공통 부품 ---------- */

/* 버튼 */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  transition: filter var(--ease);
}

.btn:hover {
  filter: brightness(1.08);
}

.btn--primary {
  background: var(--dan-red);
  color: var(--paper);
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--pond-line);
}

.btn--block {
  width: 100%;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 18px;
}

.icon-btn:hover {
  background: var(--moon-soft);
}

/* 포커스 표시 : 키보드로 움직일 때 위치가 보이게 */
:focus-visible {
  outline: 2px solid var(--moon);
  outline-offset: 2px;
}

/* 합계 */
.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
}

.total dd {
  font-size: 20px;
  color: var(--moon);
}

/* 안내 문구 */
.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--moon-soft);
  color: var(--moon);
  font-size: 13px;
  text-align: center;
}

/* 빈 화면 */
.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--paper-dim);
}

/* 짧은 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--night);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity var(--ease), transform var(--ease);
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 움직임을 줄이고 싶은 사용자 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
