/* =========================================================================
   0. 디자인 토큰 — Figma 확정되면 이 값들만 교체하면 전체에 반영됩니다.
   ========================================================================= */
:root {
  --color-bg: #f6f0e4;        /* 한지 톤 아이보리 배경 */
  --color-bg-blank: #efe4cf;  /* PC 좌우 여백(블랭크) 배경 */
  --color-ink: #2b2420;       /* 본문 텍스트 */
  --color-accent: #a83a2c;    /* 다홍 — 포인트 컬러 */
  --color-gold: #ab8a45;      /* 금박 톤 — 보조 포인트 */
  --color-card-bg: #ffffff;

  --font-display: 'Noto Serif KR', serif;
  --font-body: 'Pretendard', -apple-system, sans-serif;

  --gap: 16px;
  --radius: 4px;

  --a4-ratio: 210 / 297;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
}

/* =========================================================================
   1. 배경 레이어 — body에 직접 background-attachment:fixed 사용 금지
      (iOS Safari 미지원 이슈, 지난 검토 내용) → 전용 fixed 레이어로 분리
   ========================================================================= */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--color-bg);
  pointer-events: none;
}

/* =========================================================================
   2. 상단 카테고리 네비게이션 (스크롤스파이 대상)
   ========================================================================= */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  background: rgba(246, 240, 228, 0.92);
  backdrop-filter: blur(4px);
}

.nav-tab {
  flex: none;
  border: 1px solid var(--color-gold);
  background: transparent;
  color: var(--color-ink);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}

.nav-tab.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* =========================================================================
   3. 모바일 기본(모바일퍼스트) — 미디어쿼리 없는 기본값 = 모바일 스타일
      스냅 없음, 2열 흐름, 카드는 자유 높이
   ========================================================================= */
#catalog-root {
  padding: 12px;
}

.page {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 모바일: 항상 2열 (페이지 타입 무관) */
  gap: var(--gap);
  margin-bottom: 32px;
}

.card {
  background: var(--color-card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card__image {
  aspect-ratio: 1 / 1;
  background-color: #eee;
  background-size: cover;
  background-position: center;
}

.card__body {
  padding: 10px;
  position: relative;
}

.card__badge {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.card__name {
  font-size: 14px;
  margin: 0 0 4px;
  line-height: 1.3;
}

.card__price {
  font-weight: 700;
  margin: 0;
  color: var(--color-accent);
}

/* PDF 다운로드 버튼: 모바일에서는 완전 숨김 */
.pdf-download-btn { display: none; }

/* =========================================================================
   4. PC 확장 (min-width) — A4 비율 콘텐츠 영역 + 좌우 블랭크 + 페이지 타입별
      그리드 + 원페이지 스냅 스크롤
   ========================================================================= */
@media (min-width: 768px) {
  .bg-layer { background: var(--color-bg-blank); }
   html, body { height: 100%; overflow: hidden; }
   .top-nav { position: fixed; top: 0; left: 0; right: 0; }

  #catalog-root {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
  }

  .page {
    flex: none;
    width: auto;
    height: 100vh;
    max-width: 100vw;
    aspect-ratio: var(--a4-ratio); /* 비율만 고정, 실제 mm 강제 아님 */
    scroll-snap-align: start;
    background: var(--color-card-bg);
    margin-bottom: 0;
    padding: 24px;
    /* 페이지 타입별 --cols, --rows 는 JS(render.js)에서 인라인으로 주입 */
    grid-template-columns: repeat(var(--cols, 4), 1fr);
    grid-template-rows: repeat(var(--rows, 1), 1fr);
  }

  .card--hero .card__image { aspect-ratio: auto; height: 100%; }

  .pdf-download-btn {
    display: inline-flex;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 20;
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
  }
}

/* =========================================================================
   5. 인쇄(=PDF) 전용 — 화면용 제약을 전부 명시적으로 해제하고 A4 강제
   ========================================================================= */
@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print,
  .top-nav,
  .pdf-download-btn,
  .bg-layer {
    display: none !important;
  }

  #catalog-root {
    height: auto !important;
    overflow: visible !important;
    scroll-snap-type: none !important;
    display: block !important;
  }

  .page {
    height: auto !important;
    aspect-ratio: unset !important;
    max-width: none !important;
    width: 100% !important;
    break-after: page;
    break-inside: avoid;
    grid-template-columns: repeat(var(--cols, 4), 1fr);
  }

  .card { break-inside: avoid; }
}
