/*
 * たいけんナビTOKYO MVPデモ（板橋区）
 * デザイントークン・レイアウトは scratchpad で作成した子ども向け新UI
 * （マスコット・タイル選択・ボトムシート詳細）に準拠。
 * 地図は Leaflet + OpenStreetMap の実地図を「ちず」タブの中身として使用する。
 */
:root {
  --bg: #eaf4fb;
  --bg-dot: rgba(47, 155, 214, 0.16);
  --surface: #ffffff;
  --surface-alt: #f1f8fd;
  --ink: #22313f;
  --ink-soft: #5c7285;
  --ink-faint: #93a6b5;
  --line: #cfe6f5;
  --brand: #278c52;
  --brand-light: #dff3e7;
  --on-brand: #ffffff;
  --sky: #2f93d1;
  --sky-light: #d8effc;
  --coral: #d9435e;
  --coral-light: #fce0e4;
  --lime: #7a9e1f;
  --lime-light: #eef6d6;
  --plum: #8d5cb0;
  --plum-light: #ebe0f5;
  --notice: #d98a1f;
  --notice-light: #fdf0dc;
  --icon-stroke: #1f2937;
  --today-bg: #ffc93c;
  --today-ink: #4a3200;
  --free-bg: var(--lime);
  --free-ink: #ffffff;
  --map-ground: #f2f9fc;
  --map-park: #dcefda;
  --map-river: #cfe9f7;
  --map-line: #bcd8e8;
  --shadow-soft: 0 10px 24px -14px rgba(34, 49, 63, 0.28);
  --shadow-pop: 0 14px 28px -14px rgba(34, 49, 63, 0.32);
  --font-display: "Hiragino Maru Gothic ProN", "UD Digital Kyokasho NK-R",
    "BIZ UDPGothic", "Yu Gothic UI", "Rounded Mplus 1c", sans-serif;
  --font-body: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic",
    "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  --font-mono: "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1c27;
    --bg-dot: rgba(63, 169, 232, 0.16);
    --surface: #17232f;
    --surface-alt: #1d2b39;
    --ink: #eaf3fa;
    --ink-soft: #a9bccb;
    --ink-faint: #71879a;
    --line: #28394a;
    --brand: #3fbe7c;
    --brand-light: #1c3327;
    --on-brand: #0b1f14;
    --sky: #5cc2f5;
    --sky-light: #173142;
    --coral: #ee8296;
    --coral-light: #3a2430;
    --lime: #b6d95e;
    --lime-light: #2b321a;
    --plum: #bc93de;
    --plum-light: #2e2438;
    --notice: #f0b258;
    --notice-light: #3a2c14;
    --icon-stroke: #16222c;
    --today-bg: #ffd466;
    --today-ink: #3a2600;
    --free-bg: var(--lime);
    --free-ink: #12210a;
    --map-ground: #18242e;
    --map-park: #1c3327;
    --map-river: #163040;
    --map-line: #28394a;
    --shadow-soft: 0 12px 26px -14px rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 16px 30px -14px rgba(0, 0, 0, 0.65);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1c27;
  --bg-dot: rgba(63, 169, 232, 0.16);
  --surface: #17232f;
  --surface-alt: #1d2b39;
  --ink: #eaf3fa;
  --ink-soft: #a9bccb;
  --ink-faint: #71879a;
  --line: #28394a;
  --brand: #3fbe7c;
  --brand-light: #1c3327;
  --on-brand: #0b1f14;
  --sky: #5cc2f5;
  --sky-light: #173142;
  --coral: #ee8296;
  --coral-light: #3a2430;
  --lime: #b6d95e;
  --lime-light: #2b321a;
  --plum: #bc93de;
  --plum-light: #2e2438;
  --notice: #f0b258;
  --notice-light: #3a2c14;
  --icon-stroke: #16222c;
  --today-bg: #ffd466;
  --today-ink: #3a2600;
  --free-bg: var(--lime);
  --free-ink: #12210a;
  --map-ground: #18242e;
  --map-park: #1c3327;
  --map-river: #163040;
  --map-line: #28394a;
  --shadow-soft: 0 12px 26px -14px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 16px 30px -14px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.3px, transparent 1.3px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand); }

:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

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

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 22px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Top strip: dummy notice (compact, always visible) ---------- */
.notice-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--notice-light);
  border: 1.5px solid var(--notice);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.75rem;
  line-height: 1.4;
}
.notice-strip .emoji { flex: none; }
.notice-strip strong { color: var(--notice); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 6px 4px 0;
}
.hero-blob {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 220px;
  height: 150px;
  z-index: 0;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}
.mascot { width: 84px; height: 84px; flex: none; }
.hero-text h1 {
  font-size: clamp(1.5rem, 1.15rem + 1.3vw, 1.9rem);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}
.hero-text .app-name {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-light);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Section ---------- */
.section {
  background: var(--surface);
  border: 2.5px solid var(--brand);
  border-radius: 26px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Category tiles ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tile {
  appearance: none;
  border: 2.5px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { border-color: var(--tile-color, var(--brand)); }
.tile:active { transform: scale(0.96); }
.tile-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  padding: 11px;
  background: var(--tile-light, var(--surface-alt));
}
.tile-icon svg { display: block; width: 100%; height: 100%; }
.tile-label { font-size: 0.9375rem; font-weight: 800; color: var(--ink); line-height: 1.3; }
.tile-sub { font-size: 0.6875rem; font-weight: 600; color: var(--ink-faint); }
.tile.active {
  border-color: var(--tile-color, var(--brand));
  background: var(--tile-light, var(--brand-light));
  box-shadow: var(--shadow-pop);
}
.tile.active .tile-icon { background: var(--surface); }

/* ---------- Big toggle row ---------- */
.toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle-btn {
  appearance: none;
  border: 2.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 13px 10px;
  font-size: 0.9375rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.toggle-btn:active { transform: scale(0.97); }
.toggle-btn.active {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-pop);
}
.toggle-btn .emoji { font-size: 1.1rem; }

.free-toggle {
  margin-top: 10px;
  width: 100%;
}
.free-toggle.active { background: var(--today-bg); border-color: var(--today-bg); color: var(--today-ink); }

/* ---------- Guardian disclosure ---------- */
details.guardian {
  margin-top: 12px;
  border-top: 2px dashed var(--line);
  padding-top: 10px;
}
details.guardian summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-soft);
  list-style: none;
  display: flex; align-items: center; gap: 6px;
}
details.guardian summary::-webkit-details-marker { display: none; }
details.guardian summary::before { content: "▸"; color: var(--ink-faint); transition: transform 0.15s ease; }
details.guardian[open] summary::before { transform: rotate(90deg); }
details.guardian summary:hover { color: var(--brand); }
.guardian-body { padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.filter-label { font-size: 0.75rem; font-weight: 700; color: var(--ink-faint); flex: none; }
.chip {
  appearance: none; border: 2px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 999px; padding: 6px 13px;
  font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.reset-link {
  appearance: none; background: none; border: none; color: var(--ink-soft);
  font-size: 0.75rem; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 2px;
}

/* ---------- Results ---------- */
.results-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.results-count {
  font-size: 1.05rem; font-weight: 800; color: var(--ink);
}
.results-count strong { color: var(--brand); font-size: 1.2em; }
.view-tabs {
  display: inline-flex; gap: 4px;
  background: var(--surface-alt); border: 2px solid var(--line); border-radius: 999px; padding: 4px;
}
.view-tabs button {
  appearance: none; border: none; background: none;
  padding: 7px 14px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 800; color: var(--ink-soft); cursor: pointer;
}
.view-tabs button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-soft); }

/* ---------- Cards (list view) ---------- */
.card-feed { display: flex; flex-direction: column; gap: 10px; }
.spot-card {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 13px;
  background: var(--surface);
  border: 2.5px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.spot-card:hover { border-color: var(--card-color, var(--brand)); transform: translateY(-1px); }
.spot-card .badge-icon {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: grid; place-items: center; padding: 11px;
}
.spot-card .badge-icon svg { display: block; width: 100%; height: 100%; }
.spot-card .info { min-width: 0; flex: 1; }
.spot-card .name { display: block; font-size: 1rem; font-weight: 800; color: var(--ink); line-height: 1.35; }
.spot-card .sub { display: block; margin-top: 2px; font-size: 0.75rem; font-weight: 600; color: var(--ink-faint); }
.spot-card .chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.spot-card .chev { flex: none; font-size: 1.3rem; color: var(--ink-faint); }

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.8;
  font-weight: 700;
}
.empty-state .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; }

/* ---------- Info chips (on cards + modal) ---------- */
.ichip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.6875rem; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: 0.01em;
}
.ichip-today { background: var(--today-bg); color: var(--today-ink); }
.ichip-free { background: var(--free-bg); color: var(--free-ink); }
.ichip-info { background: var(--sky-light); color: var(--sky); }

/* ---------- Map view (guardian-leaning, secondary) ---------- */
.map-view { display: none; flex-direction: column; gap: 10px; }
.map-view.active-view { display: flex; }
.card-feed.hidden-view { display: none; }
.map-canvas {
  position: relative; width: 100%; aspect-ratio: 88 / 100;
  border-radius: 18px; overflow: hidden; border: 2.5px solid var(--line);
}

/* 実地図（Leaflet + OpenStreetMap）。svg模式化マップの代わりに実座標の地図タイルを表示する。 */
.leaflet-map { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--map-ground); }
.leaflet-map .leaflet-popup-content { font-family: var(--font-body); font-size: 0.8125rem; }
.leaflet-map .leaflet-control-attribution { font-size: 9px; }

.spot-pin-icon {
  width: 32px; height: 32px;
  border-radius: 50%; border: 2.5px solid var(--surface);
  box-shadow: 0 2px 6px -1px rgba(0,0,0,0.35);
  display: grid; place-items: center; padding: 7px;
  position: relative;
}
.spot-pin-icon svg { display: block; width: 100%; height: 100%; }
.spot-pin-icon .star { position: absolute; top: -8px; right: -8px; font-size: 13px; line-height: 1; }

.legend {
  display: flex; flex-wrap: wrap; gap: 9px 14px;
  font-size: 0.75rem; font-weight: 700; color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item .swatch {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center; padding: 4px;
}
.legend-item .swatch svg { display: block; width: 100%; height: 100%; }

/* ---------- Detail modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--ink) 50%, transparent);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0; z-index: 1100;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: 100%; max-width: 560px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  border: 2.5px solid var(--line);
  border-bottom: none;
  box-shadow: 0 -10px 40px -14px rgba(0,0,0,0.35);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 18px; }
  .modal-card { border-radius: 28px; border-bottom: 2.5px solid var(--line); }
}
.modal-top { display: flex; justify-content: center; margin-bottom: 6px; }
.modal-grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--line); }
.modal-head { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.modal-icon { width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center; padding: 12px; }
.modal-icon svg { display: block; width: 100%; height: 100%; }
.modal-name { font-size: 1.2rem; font-weight: 800; color: var(--ink); line-height: 1.35; }
.modal-sub { margin-top: 2px; font-size: 0.75rem; font-weight: 700; color: var(--ink-faint); }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  appearance: none; border: 2px solid var(--line); background: var(--surface-alt);
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--ink-soft); font-size: 1rem; font-weight: 700; cursor: pointer;
}
.modal-close:hover { color: var(--brand); border-color: var(--brand); }
.modal-card { position: relative; }

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 16px;
}
.info-tile {
  background: var(--surface-alt); border-radius: 16px; padding: 11px 13px;
}
.info-tile .k { font-size: 0.6875rem; font-weight: 700; color: var(--ink-faint); }
.info-tile .v { margin-top: 3px; font-size: 0.9375rem; font-weight: 800; color: var(--ink); line-height: 1.4; }
.info-tile.wide { grid-column: 1 / -1; }

.address-line {
  margin-top: 12px; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.6;
}
.address-line .k { font-weight: 700; color: var(--ink-faint); margin-right: 6px; }

.grownup-box {
  margin-top: 18px;
  background: var(--brand-light);
  border: 2px dashed var(--brand);
  border-radius: 18px;
  padding: 14px 16px;
}
.grownup-box .gtitle {
  font-size: 0.8125rem; font-weight: 800; color: var(--brand);
  display: flex; align-items: center; gap: 6px;
}
.grownup-box p { margin-top: 6px; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.6; }
.reserve-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left;
  margin-top: 12px;
  background: var(--brand);
  color: var(--on-brand);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9375rem;
  padding: 8px 8px 8px 18px;
  border-radius: 999px;
  border: none;
  box-shadow: 0 8px 18px -8px rgba(39, 140, 82, 0.55);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.reserve-btn .arrow-circle {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--on-brand) 25%, transparent);
  display: grid; place-items: center; font-size: 1.05rem;
}
.reserve-btn:not(.no-reservation):hover { filter: brightness(1.06); }
.reserve-btn:not(.no-reservation):active { transform: scale(0.98); }
.reserve-btn.no-reservation {
  background: var(--surface); color: var(--ink-soft);
  box-shadow: none; border: 2px solid var(--line);
  cursor: default; justify-content: center; padding: 12px;
}
.reserve-note {
  margin-top: 8px; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.6;
}
.reserve-note-standalone {
  margin-top: 12px; padding: 12px 14px;
  background: var(--surface); border: 2px dashed var(--line); border-radius: 14px;
  font-weight: 700; color: var(--ink);
}

/* ---------- About footer (collapsed) ---------- */
details.about {
  font-size: 0.75rem;
  color: var(--ink-faint);
}
details.about summary {
  cursor: pointer; font-weight: 700; color: var(--ink-soft);
  list-style: none;
}
details.about summary::-webkit-details-marker { display: none; }
details.about summary::before { content: "▸ "; }
details.about[open] summary::before { content: "▾ "; }
details.about .about-body { margin-top: 8px; line-height: 1.7; }
details.about code {
  background: var(--surface-alt); padding: 1px 6px; border-radius: 6px; font-family: var(--font-mono);
}
