/* ============================================================
   TourForChild — styles.css
   Mobile-first, playful, family-friendly.
   ============================================================ */

:root {
  --bg: #fffdf7;
  --bg-soft: #fff6e6;
  --card: #ffffff;
  --ink: #2b2340;
  --ink-soft: #6b6480;
  --brand: #ff6b6b;
  --brand-2: #4ecdc4;
  --brand-3: #ffd166;
  --brand-4: #6a8cff;
  --accent: #9b5de5;
  --line: #efe7d8;
  --shadow: 0 8px 24px rgba(90, 70, 40, .10);
  --shadow-lg: 0 16px 40px rgba(90, 70, 40, .16);
  --radius: 20px;
  --radius-sm: 12px;
  --maxw: 1080px;
  --font: "Segoe UI", system-ui, -apple-system, "Apple SD Gothic Neo",
          "Malgun Gothic", "Hiragino Sans", "Yu Gothic UI",
          "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff0d6 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 0%, #e6fffb 0%, transparent 55%),
    var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 253, 247, .86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px;
  max-width: var(--maxw); margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.logo .globe { font-size: 1.5rem; animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo b { color: var(--brand); }
.logo i { color: var(--brand-2); font-style: normal; }
.header-spacer { flex: 1; }

.lang-switch { display: flex; gap: 4px; background: var(--bg-soft); border-radius: 999px; padding: 4px; }
.lang-switch button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 6px 10px; font-weight: 700; font-size: .8rem; color: var(--ink-soft);
}
.lang-switch button.active { background: var(--brand); color: #fff; box-shadow: var(--shadow); }

/* ---------- Search ---------- */
.searchbar { position: relative; }
.searchbar input {
  width: 100%; border: 2px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 14px 18px 14px 46px; font-size: 1rem; color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.searchbar input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(78,205,196,.18); }
.searchbar .search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.search-results a {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.active { background: var(--bg-soft); }
.search-results .r-emoji { font-size: 1.3rem; }
.search-results .r-city { font-weight: 700; }
.search-results .r-country { color: var(--ink-soft); font-size: .85rem; }
.search-empty { padding: 16px; color: var(--ink-soft); text-align: center; }

/* ---------- Hero (home) ---------- */
.hero { text-align: center; padding: 34px 0 10px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.8rem); margin: 0 0 8px; line-height: 1.15; }
.hero h1 .hl { color: var(--brand); }
.hero p { color: var(--ink-soft); font-size: 1.05rem; margin: 0 auto 22px; max-width: 620px; }
.hero .searchbar { max-width: 560px; margin: 0 auto; }

/* ---------- Section ---------- */
.section { padding: 26px 0; }
.section h2 { font-size: 1.3rem; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section .sub { color: var(--ink-soft); margin: -8px 0 16px; }

/* ---------- Continent chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: .9rem; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; transition: transform .12s, border-color .2s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.chip.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }

/* ---------- Grid cards ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card .emoji { font-size: 2.2rem; line-height: 1; }
.card .flag { position: absolute; top: 12px; right: 14px; font-size: 1.2rem; }
.card h3 { margin: 10px 0 2px; font-size: 1.08rem; }
.card .country { color: var(--ink-soft); font-size: .82rem; }
.card .tag { margin-top: 8px; font-size: .85rem; color: var(--ink); opacity: .9; }

/* country card */
.card.country-card .emoji { font-size: 2rem; }
.card.country-card .count { color: var(--ink-soft); font-size: .82rem; margin-top: 6px; }

/* ---------- City page ---------- */
.city-hero {
  border-radius: var(--radius); padding: 30px 22px; margin-top: 18px; color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 60%, var(--brand-4) 100%);
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.city-hero .bg-emoji { position: absolute; right: -10px; bottom: -22px; font-size: 9rem; opacity: .18; }
.city-hero .crumbs { font-size: .85rem; opacity: .92; margin-bottom: 8px; }
.city-hero .crumbs a { text-decoration: underline; }
.city-hero h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 0 0 6px; }
.city-hero .emoji { font-size: 2rem; }
.city-hero .tagline { font-size: 1.1rem; opacity: .96; max-width: 640px; }

.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 20px; box-shadow: var(--shadow); margin-top: 16px; }
.block h2 { margin: 0 0 12px; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.intro-text { font-size: 1.05rem; }

.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.facts li {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-soft); border-radius: var(--radius-sm); padding: 12px 14px;
}
.facts li .n { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-3); color: #7a5a00; font-weight: 800; display: grid; place-items: center; font-size: .9rem; }

.kidq { background: linear-gradient(135deg, #fff4d6, #ffe6e6); border: 2px dashed var(--brand);
        border-radius: var(--radius); padding: 16px 18px; margin-top: 16px; font-weight: 600; }
.kidq .label { color: var(--brand); font-weight: 800; margin-right: 6px; }

#map { height: 320px; border-radius: var(--radius-sm); margin-top: 6px; z-index: 0; }
.map-note { color: var(--ink-soft); font-size: .82rem; margin-top: 8px; }

.places { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.place {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px;
}
.place h4 { margin: 0 0 6px; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.place p { margin: 0; font-size: .92rem; color: var(--ink); }
.place .maplink { display: inline-block; margin-top: 8px; font-size: .82rem; color: var(--brand-4); font-weight: 700; }

/* ---------- Buttons / misc ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 10px 16px; font-weight: 700; background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-weight: 700; margin: 18px 0 0; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 22px 16px; color: var(--ink-soft); font-size: .9rem; }
.footer-inner a { color: var(--brand-4); font-weight: 700; }
.footer-inner .fix { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 12px; }

/* ---------- Loading / empty ---------- */
.loading { text-align: center; padding: 40px; color: var(--ink-soft); }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: sp 1s linear infinite; margin: 0 auto 12px; }
@keyframes sp { to { transform: rotate(360deg); } }

.fade-in { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 480px) {
  .logo span.full { display: none; }
  .header-inner { gap: 8px; }
  .lang-switch button { padding: 6px 8px; }
  #map { height: 260px; }
}

/* ---------- Header actions (random / quiz / passport) ---------- */
.header-actions { display: flex; gap: 6px; margin-right: 4px; }
.hbtn { position: relative; border: 2px solid var(--line); background: var(--card); border-radius: 999px;
  width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.hbtn:hover { border-color: var(--brand-2); transform: translateY(-2px); }
.hbtn .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--brand); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 800;
  display: none; place-items: center; }
@media (max-width: 480px) { .hbtn { width: 36px; height: 36px; font-size: 1rem; } }

/* ---------- Quick nav (home hero) ---------- */
.quicknav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.qbtn { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px;
  font-weight: 700; font-size: .9rem; color: var(--ink); cursor: pointer; }
.qbtn:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ---------- Theme row / cards ---------- */
.theme-row { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line);
  background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: .9rem; }
.theme-chip:hover { border-color: var(--brand-3); transform: translateY(-2px); }
.theme-chip .te { font-size: 1.1rem; }
.card.theme-card .emoji { font-size: 2.4rem; }

/* ---------- Passport ---------- */
.pass-stats { display: flex; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.pstat { flex: 1; min-width: 90px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; color: var(--ink-soft); font-weight: 700; box-shadow: var(--shadow); }
.pstat b { display: block; font-size: 1.8rem; color: var(--brand); }
.stamp-badge { position: absolute; top: 12px; left: 12px; font-size: 1.1rem; filter: saturate(1.2); }
.pass-tools { display: flex; justify-content: flex-end; margin: -6px 0 12px; }
.pass-card { position: relative; }
.pass-card .flag { display: none; }
.card-del { position: absolute; top: 8px; right: 8px; z-index: 3; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: rgba(255,107,107,.94); color: #fff; font-weight: 800;
  font-size: .82rem; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow); }
.card-del:hover { transform: scale(1.12); background: var(--brand); }

/* ---------- Stamp button / hero actions ---------- */
.hero-actions { margin-top: 14px; }
.stamp-btn { background: var(--brand-3); color: #7a5a00; }
.stamp-btn:hover { transform: translateY(-2px) rotate(-2deg); }
.stamped-note { display: inline-block; background: rgba(255,255,255,.25); border: 2px solid rgba(255,255,255,.6);
  color: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 800; }
.stamped-note.pop { animation: stamp .5s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stamp { 0% { transform: scale(2) rotate(-12deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- Block head + TTS ---------- */
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block-head h2 { margin: 0 0 12px; }
.tts-btn { border: 2px solid var(--brand-2); background: var(--card); color: var(--brand-2);
  border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: .85rem; }
.tts-btn.on { background: var(--brand-2); color: #fff; }

/* ---------- City hero photo ---------- */
.city-hero { background-size: cover; background-position: center; transition: background-image .3s; }
.city-hero.has-photo .bg-emoji { display: none; }
.photo-credit { margin-top: 10px; font-size: .72rem; opacity: .8; }

/* ---------- Quiz ---------- */
.quiz-wrap { display: flex; justify-content: center; }
.quiz-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 26px; max-width: 560px; width: 100%; text-align: center; }
.quiz-emoji { font-size: 3rem; }
.quiz-progress { color: var(--ink-soft); font-weight: 800; margin-bottom: 8px; }
.quiz-subject { font-size: 1.2rem; font-weight: 700; background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 14px; margin: 12px 0 18px; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt { border: 2px solid var(--line); background: var(--card); border-radius: var(--radius-sm);
  padding: 14px; font-size: 1rem; font-weight: 700; color: var(--ink); text-align: left; }
.quiz-opt:hover:not(:disabled) { border-color: var(--brand-4); transform: translateY(-2px); }
.quiz-opt:disabled { cursor: default; opacity: .95; }
.quiz-opt.correct { background: #e4f8ec; border-color: #34c77b; color: #147a45; }
.quiz-opt.wrong { background: #ffe9e9; border-color: var(--brand); color: #c0392b; }
.quiz-feedback { margin-top: 16px; }
.fb-ok { color: #147a45; font-weight: 800; margin-bottom: 12px; }
.fb-no { color: #c0392b; font-weight: 800; margin-bottom: 12px; }
.fb-no .ans, .fb-ok .ans { display: block; color: var(--ink-soft); font-weight: 600; font-size: .9rem; }

/* ---------- Maps ---------- */
#homeMap { height: 420px; border-radius: var(--radius-sm); margin-top: 12px; z-index: 0; }
.tfc-pin-wrap { background: none; border: 0; }
.tfc-pin { font-size: 1.4rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); text-align: center; }
@media (max-width: 480px) { #homeMap { height: 320px; } }

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #15121f; --bg-soft: #201a33; --card: #251e3a; --ink: #f3eefb; --ink-soft: #b4aacf;
  --line: #39304f; --shadow: 0 8px 24px rgba(0,0,0,.45); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a2140 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 0%, #14283a 0%, transparent 55%),
    var(--bg);
}
:root[data-theme="dark"] .site-header { background: rgba(21,18,31,.86); }
:root[data-theme="dark"] .kidq { background: linear-gradient(135deg,#2c2540,#3a2530); border-color: var(--brand); color: var(--ink); }
:root[data-theme="dark"] .quiz-opt.correct { background:#12341f; border-color:#2e9c63; color:#79e0a6; }
:root[data-theme="dark"] .quiz-opt.wrong { background:#3a1b1b; border-color:#c0392b; color:#f0a49b; }

/* ---------- share/print mini buttons + hero actions ---------- */
.hero-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.mini { padding: 8px 12px; font-size: .85rem; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow-lg); opacity: 0; transition: .35s; z-index: 210; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- confetti ---------- */
.confetti-wrap { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 200; }
.confetti { position: absolute; top: -24px; width: 10px; height: 14px; border-radius: 2px; opacity: .95;
  animation: fall 1.4s linear forwards; }
@keyframes fall { to { transform: translateY(108vh) rotate(620deg); } }

/* ---------- passport progress + badges ---------- */
.prog-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.prog-label { flex: 0 0 120px; font-weight: 700; font-size: .85rem; }
.prog-bar { flex: 1; height: 12px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.prog-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand-4)); border-radius: 999px; transition: width .6s; }
.prog-num { flex: 0 0 auto; font-size: .8rem; color: var(--ink-soft); font-weight: 700; min-width: 44px; text-align: right; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 84px; }
.badge-item .be { font-size: 1.8rem; }
.badge-item .bl { font-size: .72rem; color: var(--ink-soft); font-weight: 700; text-align: center; }
@media (max-width: 480px) { .prog-label { flex-basis: 86px; font-size: .78rem; } }

/* ---------- scroll to top ---------- */
.scrolltop { position: fixed; right: 16px; bottom: 16px; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff; font-size: 1.1rem; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translateY(10px); transition: .25s; z-index: 60; }
.scrolltop.show { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- print (clean one-pager for the car/plane) ---------- */
@media print {
  /* Always print in light mode, even if the site is in dark mode */
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    --bg: #ffffff; --bg-soft: #f6f6f6; --card: #ffffff; --ink: #111111; --ink-soft: #555555;
    --line: #cccccc; --shadow: none; --shadow-lg: none;
  }
  html, body { background: #fff !important; color: #000 !important; }
  .site-header, .site-footer, .hero-actions, .back-link, .quicknav, #map, .map-note,
  .maplink, .tts-btn, .scrolltop, .header-actions { display: none !important; }
  .city-hero { background: none !important; color: #000; box-shadow: none; border: 1px solid #ccc; }
  .city-hero h1, .city-hero .tagline, .city-hero .crumbs { color: #000; }
  .city-hero .bg-emoji { display: none; }
  .block { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; background: #fff !important; }
  .facts li, .place { background: #f6f6f6 !important; color: #000 !important; }
  .kidq { background: #fff4e6 !important; color: #111 !important; border-color: #ff9d9d !important; }
  .intro-text, .facts li span, .place p, .block h2 { color: #111 !important; }
  a { color: #000; text-decoration: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
