/* 검색엔진용 카페·지역 페이지 (서버가 그리는 /cafe/번호, /area/…, backend/app/pages.py).
   지도 화면(style.css)은 화면 전체를 지도로 쓰고 스크롤을 막으므로 따로 둔다. 색은 style.css 와 같다. */

:root {
  --bg: #f7f1e9;
  --surface: #ffffff;
  --surface-2: #f5eee4;
  --text: #2a1e15;
  --muted: #7c6a5b;
  --border: #eadfd1;
  --primary: #7a4a2a;
  --primary-ink: #ffffff;
  --owner: #c98a12;
  --owner-soft: #fdf2d6;
  --good: #2f7d4f;
  --good-soft: #e3f2e8;
  --bad: #b4432f;
  --bad-soft: #f8e4df;
  color-scheme: light;
}
/* 나이트 모드. data-theme 은 js/theme-init.js 가 정한다 (지도 화면에서 고른 것을 따른다) */
:root[data-theme="dark"] {
  --bg: #1c1814;
  --surface: #26211c;
  --surface-2: #2f2923;
  --text: #f1eae0;
  --muted: #a99a8a;
  --border: #3a322b;
  --primary: #d9a26b;
  --primary-ink: #1c1814;
  --owner: #e8b54a;
  --owner-soft: #3a3020;
  --good: #6cc38f;
  --good-soft: #1f3327;
  --bad: #e58a78;
  --bad-soft: #3a2420;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }

/* ---------- 상단 바 ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
}
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; color: var(--primary); }
.logo img { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 2px 6px rgba(74, 46, 22, 0.22); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 14.5px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn.pri { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.top .btn { height: 36px; font-size: 13.5px; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 본문 ---------- */
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }
.crumb { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
h1 { margin: 18px 0 4px; font-size: 26px; line-height: 1.3; letter-spacing: -0.02em; }
h1 small { font-size: 16px; color: var(--muted); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.meta + .meta { margin-top: 2px; }
.stars { color: var(--owner); letter-spacing: 1px; }
.stars .off { color: var(--border); }
.lead { margin: 14px 0 0; font-size: 15.5px; }

/* 사진: 큰 사진 1 + 작은 사진 4 */
.gal { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 150px 150px; gap: 6px; border-radius: 16px; overflow: hidden; }
.gal a { position: relative; display: block; background: var(--surface-2); }
.gal img { width: 100%; height: 100%; object-fit: cover; }
.gal a:first-child { grid-row: span 2; }
.gal .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); color: #fff; font-weight: 800; font-size: 20px; }
/* 사진 수에 맞춰 칸을 줄인다 */
.gal:has(> a:only-child) { grid-template-columns: 1fr; grid-template-rows: 300px; }
.gal:has(> a:nth-child(2):last-child) { grid-template-columns: 2fr 1fr; grid-template-rows: 300px; }
.gal:has(> a:nth-child(2):last-child) > a:first-child { grid-row: auto; }
.gal:has(> a:nth-child(3):last-child) { grid-template-columns: 2fr 1fr; }
.gal:has(> a:nth-child(4):last-child) { grid-template-columns: 2fr 1fr 1fr; }
.gal:has(> a:nth-child(4):last-child) > a:nth-child(4) { grid-column: span 2; }
@media (max-width: 600px) {
  .gal, .gal:has(> a) { grid-template-columns: repeat(4, 1fr); grid-template-rows: 220px 74px; }
  .gal:has(> a:only-child) { grid-template-rows: 240px; }
  .gal a:first-child { grid-column: 1 / -1; grid-row: auto; }
  .gal:has(> a:nth-child(4):last-child) > a:nth-child(4) { grid-column: auto; }
}

/* 사진 크게 보기 (js/gallery.js). 화면 안에 다 들어오게 맞추고 ← → 로 넘긴다 */
html.pv-open { overflow: hidden; }
.pv { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 56px 16px; background: rgba(10, 8, 6, 0.92); }
.pv[hidden] { display: none; }
.pv img { max-width: 100%; max-height: calc(100vh - 112px); max-height: calc(100dvh - 112px); width: auto; height: auto; object-fit: contain; border-radius: 6px; }
.pv button {
  position: absolute; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff; cursor: pointer; font: inherit; line-height: 1;
}
.pv button:hover { background: rgba(255, 255, 255, 0.26); }
.pv button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pv-close { top: calc(10px + env(safe-area-inset-top)); right: 12px; width: 40px; height: 40px; font-size: 18px; }
.pv-nav { top: 50%; width: 48px; height: 48px; margin-top: -24px; font-size: 32px; padding-bottom: 4px; }
.pv-nav.prev { left: 12px; }
.pv-nav.next { right: 12px; }
.pv-count { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 14px; font-weight: 600; }

/* 카드 */
.card { margin-top: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: baseline; gap: 6px; }
.card h2 small { color: var(--muted); font-weight: 600; font-size: 13px; }
.card.empty { text-align: center; padding: 40px 16px; margin-top: 40px; }
.card.empty h1 { margin-top: 0; font-size: 22px; }

/* 카공 정보: 첫 줄은 빠른 리뷰 항목, 둘째 줄은 나머지 */
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.facts + .facts { margin-top: 6px; }
.fact { display: inline-flex; gap: 6px; padding: 5px 11px; border-radius: 9px; background: var(--surface-2); font-size: 13.5px; }
.fact b { color: var(--muted); font-weight: 600; }
.fact.good { background: var(--good-soft); }
.fact.good span { color: var(--good); font-weight: 700; }
.fact.bad { background: var(--bad-soft); }
.fact.bad span { color: var(--bad); font-weight: 700; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.acts.single { grid-template-columns: 1fr; margin-top: 18px; }

/* 리뷰 */
.rv { padding: 14px 0; border-top: 1px solid var(--border); }
.rv:first-of-type { border-top: 0; padding-top: 0; }
.rv-h { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 14px; }
.rv-h .stars { font-size: 13px; }
.rv-h time { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.badge { padding: 1px 7px; border-radius: 6px; background: var(--owner-soft); color: var(--owner); font-size: 12px; font-weight: 700; }
.rv p { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.rv .mini { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.more-link { display: block; margin-top: 10px; text-align: center; font-weight: 700; color: var(--primary); text-decoration: none; font-size: 14px; }

/* 가까운 카공 카페 */
.near { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.near a { text-decoration: none; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.near a:hover { border-color: var(--primary); }
.near img, .near .noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.noimg { display: grid; place-items: center; background: var(--surface-2); font-size: 28px; }
.near div { padding: 8px 10px; font-size: 13px; }
.near strong { display: block; font-size: 14px; }
.near span { display: block; color: var(--muted); }
@media (max-width: 600px) {
  .near { grid-template-columns: 1fr; }
  .near a { display: grid; grid-template-columns: 96px 1fr; }
  .near img, .near .noimg { height: 100%; aspect-ratio: auto; }
}

/* 지역 목록 */
.areas { display: flex; flex-wrap: wrap; gap: 6px; }
.areas a { padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: 13.5px; background: var(--surface); }
.areas a:hover { border-color: var(--primary); }
.areas a span { color: var(--muted); font-size: 12px; }
.areas a.cur { border-color: var(--primary); color: var(--primary); font-weight: 700; }
/* 지역 페이지 위쪽의 조건별로 보기 (전체 · 콘센트 많은 · 조용한 …) */
.areas.conds { margin-top: 14px; }

/* 지역 페이지의 카페 목록 */
.area-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.area-list .cafe { display: grid; grid-template-columns: 168px 1fr; gap: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-decoration: none; }
.area-list .cafe:hover { border-color: var(--primary); }
.area-list img, .area-list .noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.area-list h2 { margin: 2px 0 2px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.area-list .no { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 7px; background: var(--primary); color: var(--primary-ink); font-size: 12px; }
.area-list .meta { font-size: 13px; margin-bottom: 8px; }
.area-list .quote { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }
@media (max-width: 600px) {
  .area-list .cafe { grid-template-columns: 1fr; }
  .area-list img, .area-list .noimg { aspect-ratio: auto; height: 180px; }
}

/* ---------- 바닥글 ---------- */
.ft { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: 12.5px; }
.ft p { margin: 2px 0; }

/* ---------- 카공 유형 테스트 (/test, backend/app/quiz.py · js/quiz.js) ---------- */
.quiz-intro, .quiz-result { text-align: center; padding: 28px 18px 20px; }
.quiz-intro h1, .quiz-result h1 { margin-top: 6px; }
.quiz-emoji { margin: 0; font-size: 56px; line-height: 1.2; }
.quiz-label { margin: 8px 0 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.quiz-tagline { margin: 6px 0 0; color: var(--primary); font-weight: 700; font-size: 16px; }
.quiz-result .lead { text-align: left; }
.quiz-q { padding: 22px 18px; }
.quiz-q[hidden] { display: none; }
.quiz-q h2 { display: block; margin: 4px 0 16px; font-size: 20px; line-height: 1.4; }
.quiz-step { margin: 0; color: var(--muted); font-weight: 700; font-size: 13px; }
.quiz-a {
  display: block; width: 100%; margin-top: 10px; padding: 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: inherit; font: inherit; font-weight: 600; font-size: 15.5px;
}
.quiz-a:hover { border-color: var(--primary); }
.quiz-a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.quiz-bar { height: 6px; margin-top: 12px; border-radius: 3px; background: var(--border); overflow: hidden; }
.quiz-bar[hidden] { display: none; }
.quiz-bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.25s; }
button.btn { cursor: pointer; font-family: inherit; color: inherit; }
button.btn.pri { color: var(--primary-ink); }
.quiz-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-pairs a { padding: 12px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; }
.quiz-pairs a:hover { border-color: var(--primary); }
.quiz-pairs span { display: block; color: var(--muted); font-size: 12.5px; }
.quiz-pairs strong { display: block; margin-top: 2px; }
@media (max-width: 600px) { .quiz-pairs { grid-template-columns: 1fr; } }

/* 카페·지역 페이지의 테스트 안내 칸 */
.promo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.promo strong { display: block; font-size: 16px; }
.promo span { display: block; color: var(--muted); font-size: 13.5px; }

/* ---------- 카공 준비물 추천 (제휴 링크, backend/app/gear.py) ---------- */
.gear-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gear-list a { text-decoration: none; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.gear-list a:hover { border-color: var(--primary); }
.gear-list img, .gear-list .noimg { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; }
.gear-list .noimg { background: var(--surface-2); }
.gear-list div { padding: 8px 10px; font-size: 13px; }
.gear-list strong { display: block; font-size: 14px; }
.gear-list span { display: block; color: var(--muted); }
.gear-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
@media (max-width: 600px) {
  .gear-list { grid-template-columns: 1fr; }
  .gear-list a { display: grid; grid-template-columns: 96px 1fr; align-items: center; }
  .gear-list img, .gear-list .noimg { height: 100%; min-height: 72px; aspect-ratio: auto; }
}
