@font-face {
  font-family: 'Gmarket Sans';
  font-weight: 700;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansBold.woff') format('woff');
}

/* 같은 사이트 안에서 페이지를 이동할 때 흰 화면 대신 이전 화면에서 다음 화면으로 자연스럽게 넘어간다 */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --tile: #f1f3f6;
  --paper: #ffffff;
  --ink: #1f2430;
  --ink-soft: #5b6273;
  --line: #dfe2e8;
  --tag: #ffd23f;
  --tag-edge: #e6b800;
  --in: #0e8a5f;
  --out: #a3a9b5;
  --err: #d64545;
  --display: 'Gmarket Sans', 'Pretendard Variable', sans-serif;
  --body: 'Pretendard Variable', Pretendard, -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  word-break: keep-all;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #2b6cd4; outline-offset: 2px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* 상단 */
.top { padding: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font: 700 18px/1 var(--display); text-decoration: none; letter-spacing: -0.01em; }
.top a.back { font-size: 15px; color: var(--ink-soft); text-decoration: none; }
.top a.back:hover { color: var(--ink); text-decoration: underline; }

/* 메인 */
.intro { padding: 40px 0 28px; max-width: 34em; }
.intro h1 { font: 700 clamp(28px, 6vw, 44px)/1.2 var(--display); margin: 0 0 14px; letter-spacing: -0.02em; }
.intro p { margin: 0; color: var(--ink-soft); font-size: 17px; }

/* 상품 그리드: 카드팩마다 패키지 색에 맞춘 연한 타일 위에 놓는다 */
.packs { list-style: none; margin: 0; padding: 0; display: grid; gap: 32px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.packs a { display: block; text-decoration: none; border-radius: 16px; }
.tile {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  background: var(--tint, var(--tile));
  overflow: hidden;
}
.tile img {
  position: absolute; inset: 18% 12% 8%;
  height: 74%; width: 76%; object-fit: contain;
  filter: drop-shadow(0 14px 18px rgb(31 36 48 / 0.22));
  transition: transform 0.2s ease-out;
}
.packs a:hover .tile img, .packs a:focus-visible .tile img { transform: translateY(-6px) rotate(-2deg); }
.tile .badge {
  position: absolute; left: 12px; top: 12px; z-index: 1;
  background: var(--paper); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.packs .info { padding: 12px 2px 0; }
.packs .name { display: block; font-weight: 700; font-size: 15px; line-height: 1.4; }
.packs .series { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.packs .won { display: block; margin-top: 8px; font: 700 18px/1 var(--display); font-variant-numeric: tabular-nums; }
.packs .won small { font: 500 13px/1 var(--body); color: var(--ink-soft); margin-left: 4px; }

@media (min-width: 720px) {
  .packs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 24px; }
}
@media (min-width: 960px) {
  .packs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 카드팩 화면: 목록보다 좁게 두어 매장 목록이 한눈에 들어오게 한다 */
.pack-head { display: grid; grid-template-columns: 80px 1fr; gap: 16px; align-items: center; padding: 16px 0 20px; }
/* 카드팩 정보는 JS가 채운다. 채워지기 전에도 자리를 잡아 두어 아래 내용이 밀리지 않게 한다 */
.pack-head:empty { min-height: 136px; }
.pack-head .tile { border-radius: 12px; }
.pack-head .tile img { filter: drop-shadow(0 6px 8px rgb(31 36 48 / 0.2)); }
.pack-head h1 { font: 700 clamp(20px, 5vw, 28px)/1.25 var(--display); margin: 0 0 4px; letter-spacing: -0.02em; }
.pack-head p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.pack-head .price { margin-top: 6px; }
.pack-head .price strong { font: 700 17px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 2px; }
.pack-head .barcode { display: block; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }

/* 지역: 정한 뒤에는 한 줄로 접혀 화면 위에 고정된다 */
.where {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.where button, .where select {
  height: 44px; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 0 14px; font-size: 15px;
}
.where button { font-weight: 600; cursor: pointer; white-space: nowrap; }
.where button:hover, .where select:hover:not(:disabled) { border-color: var(--ink-soft); }
.where button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.where button.primary:hover { background: #000; }
.where select {
  appearance: none; -webkit-appearance: none;
  width: 100%; min-width: 0; padding-right: 38px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6273' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  text-overflow: ellipsis; cursor: pointer;
}
.where select:disabled { color: var(--out); background-color: var(--tile); cursor: default; }
.where:has(.current[hidden]) { border-bottom-color: transparent; }
.where .current { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.where .current p { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where .current strong { font: 700 17px/1.2 var(--display); }
.where .current span { font-size: 14px; color: var(--ink-soft); margin-left: 6px; }
.where .pick { display: grid; gap: 8px; }
.where .current:not([hidden]) + .pick { margin-top: 10px; }
.where .pick[hidden], .where .current[hidden] { display: none; }
.where .selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.where .hint { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); }
.where .hint:empty { display: none; }

@media (min-width: 560px) {
  .where .pick { grid-template-columns: auto 1fr; }
}

.summary { padding: 20px 0 12px; }
.summary h2 { font: 700 21px/1.35 var(--display); margin: 0; letter-spacing: -0.01em; }
.summary p { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }
.summary .refresh {
  background: none; border: 0; padding: 4px 0; font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: var(--ink);
}
.summary .refresh:disabled { color: var(--out); text-decoration: none; cursor: default; }

/* 편의점별 필터. 누르면 그 편의점만 표시한다 */
.chains { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 14px; }
.chain {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.chain:hover { border-color: var(--ink-soft); }
.chain .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chain .state { color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.chain.has .state { color: var(--in); font-weight: 700; }
.chain.failed .state, .chain.pending .state { color: var(--out); }
.chain[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chain[aria-pressed='true'] .state { color: #fff; }

.note { margin: -4px 0 14px; font-size: 13px; color: var(--ink-soft); }

/* 매장 목록 */
.stores { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.store { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.store p { margin: 0; grid-column: 1; }
.store .meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.store .dist { font: 700 16px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 4px; }
.store .meta .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.store .name { font-weight: 700; font-size: 17px; line-height: 1.4; margin-top: 6px; }
.store .addr { font-size: 14px; color: var(--ink-soft); }
.store .links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.store .links a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.store .links a:hover { border-color: var(--ink-soft); }

/* 수량 가격표 */
.qty {
  grid-row: 1 / span 3; grid-column: 2; align-self: start;
  min-width: 68px; text-align: center;
  padding: 6px 10px 8px;
  font: 700 26px/1 var(--display); font-variant-numeric: tabular-nums;
}
.qty small { display: block; font: 500 12px/1.4 var(--body); margin-top: 4px; }
.qty.in { background: var(--tag); border-bottom: 3px solid var(--tag-edge); }
.qty.out { color: var(--out); font: 600 14px/1.4 var(--body); padding: 4px 0; }
.qty.unknown { color: var(--ink-soft); font: 600 14px/1.4 var(--body); padding: 4px 0; }

.more { margin-top: 8px; }
.more summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: 15px; color: var(--ink-soft); }
.more summary:hover { color: var(--ink); }
.more .stores { margin-top: 4px; }
.more .store .name { font-size: 16px; }

.empty { padding: 20px; background: var(--tile); border-radius: 12px; color: var(--ink-soft); font-size: 15px; }
.empty p { margin: 0 0 12px; }
.empty button {
  height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); font-weight: 600; cursor: pointer;
}

.loading p { margin: 6px 0 8px; }
.loading .bar { height: 3px; background: var(--line); overflow: hidden; border-radius: 2px; }
.loading .bar::after { content: ''; display: block; height: 100%; width: 30%; background: var(--ink); animation: scan 1.1s ease-in-out infinite; }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* 광고 자리: 승인 전에는 비워 둔다 */
.ad-slot:empty { display: none; }
.ad-slot { margin: 32px 0; }

/* 하단 */
.foot { margin-top: 56px; padding: 24px 0 40px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-soft);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.foot p { margin: 0; }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* 안내 페이지 */
.doc { max-width: 40em; padding: 24px 0; }
.doc h1 { font: 700 28px/1.3 var(--display); margin: 0 0 16px; }
.doc h2 { font: 700 18px/1.4 var(--display); margin: 32px 0 8px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (min-width: 720px) {
  .pack-head { grid-template-columns: 112px 1fr; gap: 24px; padding: 24px 0 28px; }
}

/* 첫 방문 안내는 오른쪽 열이 비는 데스크톱에서만 표시한다 */
.placeholder { display: none; }

/* 데스크톱 상세: 왼쪽에 카드팩·지역을 고정하고 오른쪽에 매장 목록을 둔다. 메인과 같은 960px 틀을 쓴다. */
@media (min-width: 900px) {
  .detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 16px; }
  .detail .side { position: sticky; top: 24px; }
  .pack-head { grid-template-columns: 1fr; gap: 16px; padding: 8px 0 24px; }
  .pack-head:empty { min-height: 480px; }
  .pack-head .tile { aspect-ratio: 4 / 3; }
  .pack-head h1 { font-size: 26px; }
  .where { position: static; padding: 16px 0 0; border-bottom: 0; border-top: 1px solid var(--line); }
  .where .pick { grid-template-columns: 1fr; }
  .summary { padding-top: 8px; }
  .placeholder { display: block; margin: 8px 0 0; padding: 48px 24px; border-radius: 16px; background: var(--tile); color: var(--ink-soft); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
