/* =============================================================
   핫딜러샵 스타일
   - 모바일 우선(Mobile First), 터치 타깃 44px+ 보장
   - 밝고 환한 하늘색 테마 + 야간(다크) 모드
   - 색상은 CSS 변수로 관리: [data-theme="dark"] 에서 재정의
   ============================================================= */

:root {
  --bg: #eaf4fc;
  --bg-grad: radial-gradient(1200px 500px at 50% -10%, #dbeeff 0%, #eaf4fc 45%, #eef7fd 100%);
  --surface: #ffffff;
  --surface-2: #f4faff;
  --text: #20303f;
  --text-muted: #6c8499;
  --primary: #38bdf8;
  --primary-strong: #0ea5e9;
  --primary-ink: #ffffff;
  --primary-soft: #e2f3fe;
  --accent: #ff5a7a;        /* 가격/핫 강조 */
  --accent-soft: #ffe3ea;
  --border: #e1ebf3;
  --shadow: 0 6px 20px rgba(56, 189, 248, 0.13);
  --shadow-sm: 0 2px 8px rgba(56, 189, 248, 0.10);
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 60px;
  --maxw: 760px;
}

[data-theme="dark"] {
  --bg: #0e1726;
  --bg-grad: radial-gradient(1200px 500px at 50% -10%, #13243a 0%, #0e1726 50%);
  --surface: #18243a;
  --surface-2: #1f2d46;
  --text: #e7eef7;
  --text-muted: #93a6bd;
  --primary: #38bdf8;
  --primary-strong: #7dd3fc;
  --primary-ink: #06283d;
  --primary-soft: #16324b;
  --accent: #ff7a93;
  --accent-soft: #3a2230;
  --border: #2a3a55;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

body.no-scroll { overflow: hidden; }

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

/* 인라인 SVG 아이콘 (텍스트 색 상속, 글자 높이에 맞춤) */
.ic { width: 1em; height: 1em; vertical-align: -0.125em; display: inline-block; flex-shrink: 0; }

/* ---------- 헤더 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
  color: var(--primary-strong);
}
.brand-icon { font-size: 20px; }

.search {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px 0 14px;
  min-width: 0;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 10px 4px;
  outline: none;
}
.search input::placeholder { color: var(--text-muted); }
.search-btn {
  border: 0;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.header-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  font-size: 19px;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--primary-soft); }

/* ---------- 드롭다운 메뉴 ---------- */
.menu-dropdown { position: relative; }
.menu-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 184px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}
.menu-content.show { display: flex; animation: menu-pop .14s ease; }
@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.menu-item:active { background: var(--primary-soft); }
@media (hover: hover) { .menu-item:hover { background: var(--primary-soft); } }
.menu-item-icon { font-size: 17px; }

/* 데스크탑(마우스): 호버 시 자동으로 펼침. 모바일(터치)은 탭으로 동작 */
@media (hover: hover) and (pointer: fine) {
  .menu-dropdown:hover .menu-content,
  .menu-dropdown:focus-within .menu-content { display: flex; }
  /* 버튼↔메뉴 사이 8px 간격에서 호버가 끊기지 않게 투명 다리 */
  .menu-content::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: -10px;
    height: 10px;
  }
}

/* ---------- 컨테이너 ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.page-heading {
  font-size: 20px;
  font-weight: 800;
  margin: 8px 2px 14px;
}

/* 데모/안내 배너 */
.banner {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  color: var(--primary-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- 핫딜 카드 ---------- */
.deal-list { display: flex; flex-direction: column; gap: 12px; }

.deal-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .2s ease;
  box-sizing: border-box;
  min-width: 0;      /* 긴 내용에 밀려 카드 폭이 늘어나지 않게(가로 고정) */
}
.deal-card:active { transform: scale(.99); }
@media (hover: hover) {
  .deal-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
}

.thumb {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback { font-size: 32px; }

.deal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }

.badges { display: flex; flex-wrap: nowrap; gap: 5px; overflow: hidden; min-width: 0; }
.badges .badge { flex: 0 0 auto; }
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-category { background: var(--primary-soft); color: var(--primary-strong); }
.badge-mall { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-community { background: var(--accent-soft); color: var(--accent); }
.badge-ended { background: #6b7785; color: #fff; }

/* 종료된 딜은 흐리게 */
.deal-card.is-ended { opacity: .6; }
.deal-card.is-ended .price { color: var(--text-muted); text-decoration: line-through; }
.view-card.is-ended .price-big { color: var(--text-muted); text-decoration: line-through; }

.deal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em; /* 항상 2줄 확보 → 카드 높이 균일 */
}
.deal-foot {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.price { font-size: 17px; font-weight: 800; color: var(--accent); }
.meta-right { display: inline-flex; align-items: baseline; gap: 8px; }
.views { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* 무한스크롤 보조 */
.end-note, .state-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 26px 10px;
  font-size: 14px;
}
.state-msg.small { padding: 14px; }
#scroll-sentinel { height: 1px; }

/* 스켈레톤 */
.skeleton { pointer-events: none; }
.sk {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
}
.sk::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary-soft) 70%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
.thumb.sk { width: 84px; height: 84px; }
.sk-line { height: 13px; margin: 4px 0; }
.sk-line.short { width: 35%; }
.sk-line.med { width: 60%; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- 상세 페이지 ---------- */
.back-link {
  display: inline-block;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
}
.view-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.view-title { font-size: 20px; font-weight: 800; line-height: 1.4; margin: 12px 0; }
.view-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.view-actions-inline { display: flex; gap: 14px; align-items: center; }
.link-muted {
  color: var(--primary-strong);
  font-weight: 600;
  background: none;
  border: 0;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}
.link-muted.danger { color: var(--accent); }

/* 상세 상단: 뱃지(좌) + 아이콘 액션(우) */
.view-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.view-top .badges { flex: 1; }
.view-icon-actions { display: flex; gap: 8px; flex-shrink: 0; }
.act-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.act-btn:active { background: var(--primary-soft); }
@media (hover: hover) { .act-btn:hover { color: var(--primary-strong); border-color: var(--primary); } }
.act-btn[aria-pressed="true"] { color: var(--primary-strong); border-color: var(--primary); background: var(--primary-soft); }

.price-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0;
}
.price-mall { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.price-big { font-size: 28px; font-weight: 800; color: var(--accent); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn-buy {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: var(--primary-ink);
  box-shadow: var(--shadow);
}
.btn-buy:active { filter: brightness(.96); }
/* 제휴 안내: 작은 'ⓘ 링크' + 호버(데스크탑)/탭(모바일) 툴팁 */
.aff-note {
  margin-top: 20px;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
}
.aff-note-label { line-height: 1; }
/* 호버 트리거는 이 아이콘에만 한정 */
.aff-note-ico {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
}
.aff-note-tip {
  text-align: left;
  position: absolute;
  top: calc(100% + 10px);
  left: -12px;
  background-color: #f5f5f5;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #555;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease, visibility .15s ease;
  z-index: 1000;
  min-width: 250px;
  white-space: normal;
  line-height: 1.4;
  user-select: text;
  -webkit-user-select: text;
}
.aff-note-tip.show { opacity: 1; visibility: visible; }
@media (hover: hover) {
  .aff-note-ico:hover ~ .aff-note-tip,
  .aff-note-ico:focus-visible ~ .aff-note-tip { opacity: 1; visibility: visible; }
}
[data-theme="dark"] .aff-note-tip {
  background-color: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-soft {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-soft:active { background: var(--primary-soft); }

.info-section { margin-top: 22px; }
.info-title {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-soft);
}
.info-body { font-size: 15px; color: var(--text); word-break: break-word; }
.info-img { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; border-radius: var(--radius-sm); }
.info-text { margin: 14px 0 0; }

/* 북마크 카드(삭제 버튼 포함) */
.bookmark-card { align-items: stretch; position: relative; }
.deal-card-link { flex: 1; display: flex; min-width: 0; }
.remove-bm { align-self: center; }

/* ---------- 정적 문서 페이지(약관 등) ---------- */
.doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.doc h1 { font-size: 22px; margin-top: 0; }
.doc h2 { font-size: 17px; margin-top: 26px; }
.doc p, .doc li { color: var(--text); font-size: 15px; }
.doc .muted { color: var(--text-muted); font-size: 13px; }

/* ---------- 푸터 ---------- */
.app-footer {
  max-width: var(--maxw);
  margin: 30px auto 0;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.affiliate-notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 14px;
  line-height: 1.6;
}
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 10px; }
.footer-links a { color: var(--text); font-weight: 600; }
.footer-links .dot { color: var(--border); }
.copyright { margin: 0; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--surface);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 데스크탑(태블릿+) 2열 그리드 ---------- */
@media (min-width: 640px) {
  .deal-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* 내용에 밀려 열이 넓어지지 않게 */
  }
}

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