/* ============================================================
   앱 다운로드 CTA — 투어 Preview · 매거진 기사 공통
   마크업은 _includes/app-cta.njk, 데이터는 scripts/lib/app-cta.mjs.

   .app-bar    작품 이미지 아래 안내 바
   .app-end    본문 끝 카드 (고양이 · 앞발 · 데스크톱 QR)
   .app-sheet  같은 미술관/투어 3번째 글의 바텀시트

   수치는 Musecat 디자인 시스템 시안(2026-10 CTA 핸드오프)을 따른다.
   사이트 토큰과 값이 같은 것은 사이트 토큰을 쓰고, 시안에만 있는 값은
   아래 --cta-* 로 둔다.
   ============================================================ */

:root {
  --cta-surface: #ffffff;
  --cta-hairline: #e7e3dc;
  --cta-tint: #eaefec;          /* 안내 바 아이콘 원 · 배지 */
  --cta-on-forest: #c3d0c9;     /* forest 위 작은 글씨 (5.7:1) */
  --cta-on-forest-2: #d7e0db;   /* forest 위 QR 라벨 (6.7:1) */
  --cta-radius-md: 14px;
  --cta-radius-lg: 18px;
  --cta-shadow: 0 2px 10px rgba(31, 31, 31, 0.06);
  --cta-serif-ja: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', serif;
}

/* ----- 안내 바 ------------------------------------------------------- */
.app-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 28px;
  padding: 14px 20px 14px 14px;
  background: var(--cta-surface);
  border: 1px solid var(--cta-hairline);
  border-radius: var(--cta-radius-md);
  box-shadow: var(--cta-shadow);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--t-base);
}
.app-bar:hover { border-color: var(--forest); color: var(--ink); }
.app-bar-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--cta-tint);
  color: var(--forest);
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-bar-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app-bar-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.app-bar-sub { font-size: 14px; color: var(--stone); line-height: 1.4; }
.app-bar-link {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--forest);
}

/* ----- 끝 카드 -------------------------------------------------------- */
/* 고양이 자리만큼 위를 비운다. 이미지 높이의 약 77% 만 보이고 나머지(목도리)는
   카드 뒤로 숨는다: 데스크톱 136px 폭 → 높이 153 → 보이는 118px. */
.app-end {
  position: relative;
  isolation: isolate;
  margin-top: 24px;
  padding-top: 118px;
}
.app-end-cat {
  position: absolute;
  z-index: 0;
  top: 0;
  /* QR 칸(폭 144, 오른쪽 안쪽 여백 56) 가운데 위 */
  right: 60px;
  width: 136px;
  height: auto;
}
.app-end-paw {
  position: absolute;
  z-index: 2;
  top: 96px;                    /* 카드 윗선보다 22px 위 */
  width: 44px;
  height: 39px;
  fill: var(--ink);
}
.app-end-paw-l { right: 165px; }
.app-end-paw-r { right: 46px; }

.app-end-card {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  padding: 48px 56px;
  background: var(--forest);
  border-radius: var(--cta-radius-lg);
}
.app-end-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.app-end-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cta-tint);
}
.app-end-headline {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 38px;
  line-height: 46px;
  letter-spacing: 0;
  color: var(--paper);
  text-wrap: balance;
}
/* 한 줄에 다 안 들어가면 문장 사이에서 줄을 바꾼다(본문 칸이 좁은 데스크톱). */
.app-end-headline span { display: inline-block; }
:lang(ja) .app-end-headline,
:lang(ja) .app-sheet-title,
:lang(ja) .app-sheet-tour-title { font-family: var(--cta-serif-ja); }

.app-end-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  margin-top: 10px;
  padding: 0 26px;
  border-radius: var(--cta-radius-md);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t-base);
}
.app-end-btn:hover { background: #ffffff; color: var(--ink); }
.app-play { width: 18px; height: 18px; flex: 0 0 auto; fill: var(--forest); }
.app-end-sub { margin: 0; font-size: 13px; color: var(--cta-on-forest); }

.app-end-qr {
  flex: 0 0 144px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.app-end-qr-box {
  display: block;
  width: 112px;
  height: 112px;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.app-qr-code { display: block; width: 100%; height: 100%; }
.app-end-qr-label { font-size: 13px; line-height: 1.35; color: var(--cta-on-forest-2); }

/* 모바일: 가운데 정렬 세로 스택. 고양이는 카드 가운데, 폭 112 → 보이는 97px. */
@media (max-width: 640px) {
  .app-bar { gap: 12px; padding: 12px 14px 12px 12px; margin-bottom: 24px; }
  .app-bar-title { font-size: 15px; }
  .app-bar-sub { font-size: 13px; }
  .app-bar-link-label { display: none; }

  .app-end { padding-top: 97px; }
  .app-end-cat { right: auto; left: 50%; width: 112px; margin-left: -56px; }
  .app-end-paw { top: 79px; width: 36px; height: 32px; }   /* 윗선보다 18px 위 */
  .app-end-paw-l { right: auto; left: calc(50% - 67px); }
  .app-end-paw-r { right: auto; left: calc(50% + 31px); }

  .app-end-card {
    flex-direction: column;
    padding: 40px 22px 24px;
    text-align: center;
  }
  .app-end-main { align-items: center; gap: 12px; width: 100%; }
  .app-end-headline { font-size: 30px; line-height: 36px; }
  .app-end-headline span { display: block; }
  .app-end-btn { align-self: stretch; margin-top: 8px; padding: 0 16px; }
  .app-play { width: 16px; height: 16px; }
  .app-end-qr { display: none; }
}

/* ----- 바텀시트 ------------------------------------------------------- */
.app-sheet[hidden] { display: none; }
.app-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.app-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 31, 31, 0.5);
  opacity: 0;
  transition: opacity var(--t-slow) var(--t-ease);
}
.app-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 22px calc(34px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-radius: var(--cta-radius-lg) var(--cta-radius-lg) 0 0;
  color: var(--ink);
  transform: translateY(100%);
  transition: transform var(--t-slow) var(--t-ease);
  outline: none;
}
.app-sheet.is-open .app-sheet-backdrop { opacity: 1; }
.app-sheet.is-open .app-sheet-panel { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .app-sheet-backdrop, .app-sheet-panel { transition: none; }
}
html.app-sheet-lock, html.app-sheet-lock body { overflow: hidden; }

.app-sheet-handle {
  align-self: center;
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #d8d3ca;
}
.app-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.app-sheet-heading { display: flex; flex-direction: column; gap: 6px; }
.app-sheet-eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--forest);
}
.app-sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 32px;
  letter-spacing: 0;
}
.app-sheet-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: -6px -10px 0 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--stone);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.app-sheet-close:hover { background: var(--paper-2); color: var(--ink); }

.app-sheet-tour {
  background: var(--cta-surface);
  border-radius: var(--cta-radius-lg);
  box-shadow: var(--cta-shadow);
  overflow: hidden;
}
.app-sheet-cover {
  position: relative;
  height: 150px;
  background: var(--forest-tint);
}
.app-sheet-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-sheet-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--cta-tint);
  color: var(--forest);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app-sheet-badge-inline { position: static; align-self: flex-start; margin-bottom: 6px; }
.app-sheet-tour-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px 18px;
}
.app-sheet-tour-title {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 27px;
}
.app-sheet-tour-meta { font-size: 14px; color: var(--stone); }
.app-sheet-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.app-sheet-progress-track {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: var(--cta-hairline);
  overflow: hidden;
}
.app-sheet-progress-fill { display: block; height: 100%; border-radius: 999px; background: var(--forest); }
.app-sheet-progress-label { font-size: 12px; font-weight: 600; color: var(--forest); font-variant-numeric: tabular-nums; }

.app-sheet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  border-radius: var(--cta-radius-md);
  background: var(--forest);
  color: var(--paper);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
}
.app-sheet-btn:hover { background: var(--forest-dark); color: var(--paper); }
.app-sheet-btn .app-play { width: 16px; height: 16px; fill: var(--paper); }
.app-sheet-sub { align-self: center; margin: -8px 0 0; font-size: 13px; color: var(--stone); }
.app-sheet-dismiss {
  align-self: center;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--stone);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}
.app-sheet-dismiss:hover { color: var(--ink); text-decoration: underline; }

/* ----- 이전/다음 카드 (시안의 흰 카드) --------------------------------- */
/* 모바일에서는 다음 글을 위로 — 읽는 방향이 다음이다. 데스크톱은 좌우 그대로. */
.app-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 32px;
}
.app-pager-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 24px;
  background: var(--cta-surface);
  border: 1px solid var(--cta-hairline);
  border-radius: var(--cta-radius-lg);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--t-base);
}
.app-pager-link:hover { border-color: var(--forest); color: var(--ink); }
.app-pager-next { grid-column: 2; text-align: right; }
.app-pager-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
}
.app-pager-title { font-size: 17px; font-weight: 500; line-height: 1.35; }

@media (max-width: 640px) {
  .app-pager { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
  .app-pager-link { gap: 4px; padding: 16px 18px; }
  .app-pager-next { order: -1; text-align: left; }
  .app-pager-title { font-size: 16px; }
}
