/* ==========================================================
   백딜 BackDeal - 공통 스타일
   레이아웃 구성: site-header / main.wrap > (page-head, section…) / site-footer / tabbar
   ========================================================== */

:root {
  /* color */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --border: #e6e6e1;
  --accent: #e5484d;
  --accent-strong: #d13438;
  --accent-soft: #fdecec;
  --link: #1f5fbf;

  /* spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* shape */
  --radius: 14px;
  --radius-sm: 10px;

  /* layout */
  --content: 880px;
  --prose: 720px;
  --header-h: 56px;
  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1d1d20;
    --text: #ececee;
    --muted: #9c9ca3;
    --border: #2e2e33;
    --accent: #ff6369;
    --accent-strong: #ff7a7f;
    --accent-soft: #3a1e20;
    --link: #7fb0ff;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--link); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.35; letter-spacing: -0.01em; }

.wrap { width: 100%; max-width: var(--content); margin: 0 auto; padding: 0 var(--s4); }
main.wrap { flex: 1; padding-top: var(--s6); padding-bottom: var(--s7); }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brand-name { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.78rem; font-weight: 600; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: var(--s4); }
.nav { display: flex; gap: var(--s5); font-size: 0.95rem; }
.nav a { color: var(--muted); text-decoration: none; padding: var(--s2) 0; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }

.install-btn {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: var(--s1) var(--s3);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.install-btn[hidden] { display: none; }

/* ---------- page head (모든 페이지 상단) ---------- */
.page-head { margin-bottom: var(--s6); }
.page-head h1 { font-size: 1.9rem; margin: 0 0 var(--s3); }
.page-head h1 em { font-style: normal; color: var(--accent); }
.page-head--hero h1 { font-size: 2.3rem; }
.eyebrow { margin: 0 0 var(--s2); color: var(--accent); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; }
.lead { margin: 0; color: var(--muted); font-size: 1.05rem; max-width: var(--prose); }
.meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.back-link { display: inline-block; margin-bottom: var(--s3); color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* ---------- sections ---------- */
.section + .section { margin-top: var(--s7); }
.section-title { font-size: 1.25rem; margin: 0 0 var(--s4); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s5);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.1s;
}
a.card:hover { border-color: var(--muted); }
a.card:active { transform: scale(0.98); }
.card h3 { margin: 0 0 var(--s1); font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.card-tag {
  display: inline-block;
  margin-bottom: var(--s2);
  padding: 2px var(--s2);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}
.card-num { display: block; margin-bottom: var(--s2); color: var(--accent); font-weight: 800; font-size: 0.95rem; }

/* ---------- prose (글 본문) ---------- */
.prose { max-width: var(--prose); }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.25rem; margin: var(--s6) 0 var(--s3); }
.prose p { margin: 0 0 var(--s4); }
.prose ul { margin: 0 0 var(--s4); padding-left: 1.3em; }
.prose li { margin-bottom: var(--s1); }
.callout {
  margin: var(--s5) 0;
  padding: var(--s4) var(--s5);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

/* ---------- deals ---------- */
.deal {
  display: flex;
  gap: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
}
.deal + .deal { margin-top: var(--s3); }
.deal img { width: 96px; height: 96px; object-fit: contain; border-radius: var(--radius-sm); background: #fff; flex-shrink: 0; }
.deal-body { flex: 1; min-width: 0; }
.deal-title { font-weight: 600; margin: 0 0 var(--s1); }
.deal-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.deal-price .rate { color: var(--accent); font-weight: 800; }
.deal-price .now { font-weight: 800; font-size: 1.1rem; }
.deal-price .before { color: var(--muted); text-decoration: line-through; font-size: 0.9rem; }
.deal-note { color: var(--muted); font-size: 0.85rem; margin: var(--s1) 0 0; }
.deal-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: var(--s3);
  padding: 0 var(--s4);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.empty {
  margin: 0;
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: var(--s5) 0 var(--s6); color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: var(--s1) 0; }
.footer-brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; color: var(--text); }
.footer-brand img { border-radius: 5px; }
.disclosure { font-weight: 600; color: var(--text); }

/* ---------- bottom tab bar ---------- */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  line-height: 1.2;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* ---------- 모바일 & 설치된 앱: 하단 탭바 레이아웃 ---------- */
@media (max-width: 720px) {
  .nav { display: none; }
  .tabbar { display: flex; }
  body { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  main.wrap { padding-top: var(--s5); }
  .page-head { margin-bottom: var(--s5); }
  .page-head h1 { font-size: 1.5rem; }
  .page-head--hero h1 { font-size: 1.8rem; }
  .lead { font-size: 1rem; }
  .section + .section { margin-top: var(--s6); }
  .grid { grid-template-columns: 1fr; }
  .card { padding: var(--s4); }
  .actions .btn { flex: 1; }
  .deal img { width: 80px; height: 80px; }
}

@media (display-mode: standalone) {
  .nav { display: none; }
  .tabbar { display: flex; }
  body { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); user-select: none; -webkit-user-select: none; }
  .prose, .deal-title { user-select: text; -webkit-user-select: text; }
  .install-btn { display: none; }
}
