/* WorldBites interactive map. Uses the page theme variables (--card, --text, --teal, --gold...). */
body.map-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.map-page header { width: 100%; max-width: none; padding-left: max(40px, calc((100% - 1200px) / 2)); padding-right: max(40px, calc((100% - 1200px) / 2)); background: var(--bg); position: relative; z-index: 1001; }

.map-shell { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe9e7; }
.map-night #map { background: #0e1716; }
.leaflet-container { font: inherit; }
/* Filter the whole pane, not each tile layer, so zoom levels cross-fading during a zoom don't show seams */
.leaflet-tile-pane { filter: saturate(.55) contrast(.92) brightness(1.04) sepia(.08); transition: filter .5s ease; }
.map-night .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.82) contrast(.9) saturate(.45); }
.leaflet-container a { color: var(--teal); }

/* Vignette so the floating UI reads well over any tile colour */
.map-shell::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 401;
  background: radial-gradient(120% 90% at 50% 50%, transparent 60%, rgba(10, 30, 28, .14) 100%);
}
.map-night .map-shell::after { background: radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .45) 100%); }

/* ---------- floating panel ---------- */
.map-panel {
  position: absolute; top: 20px; left: 20px; z-index: 1000; width: min(380px, calc(100% - 40px));
  padding: 20px 20px 16px; border-radius: 20px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: 0 18px 50px rgba(12, 40, 36, .18), 0 2px 6px rgba(12, 40, 36, .08);
  animation: mapRise .6s cubic-bezier(.2, .9, .25, 1) both;
}
.map-eyebrow { font-size: .7rem; font-weight: 800; letter-spacing: .16em; color: var(--teal); text-transform: uppercase; margin: 0 0 6px; }
.map-panel h1 {
  margin: 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-weight: 600;
  font-size: 1.85rem; line-height: 1.1; color: var(--text);
}
.map-panel h1 em { font-style: italic; color: var(--gold); }
.map-count { margin: 8px 0 14px; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-status { margin: 12px 0 0; font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.map-status.err { color: #d9534f; }

.map-panel .feed-pills { margin: 0 -20px; padding: 2px 20px 4px; }
.map-panel .feed-pill { padding: 7px 12px; font-size: .8rem; }

/* ---------- floating controls ---------- */
.map-tools { position: absolute; top: 20px; right: 20px; z-index: 1000; display: flex; gap: 8px; animation: mapRise .6s .08s cubic-bezier(.2, .9, .25, 1) both; }
.map-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: 999px;
  font: inherit; font-size: .85rem; font-weight: 650; cursor: pointer; color: var(--text);
  background: color-mix(in srgb, var(--card) 85%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: 0 8px 24px rgba(12, 40, 36, .14);
  transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.map-btn:hover { transform: translateY(-1px); border-color: var(--teal); color: var(--teal); }
.map-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.map-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-btn.busy svg { animation: mapSpin 1s linear infinite; }
.map-btn[aria-pressed="true"] { background: #0f2a2a; color: #FFE066; border-color: #2c4a46; }

.leaflet-bottomright .leaflet-control-zoom { margin: 0 20px 34px 0; border: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 8px 24px rgba(12, 40, 36, .18); }
.leaflet-control-zoom a {
  width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important;
  color: var(--text) !important; background: color-mix(in srgb, var(--card) 90%, transparent) !important;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { color: var(--teal) !important; }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--card) 70%, transparent) !important; border-radius: 8px 0 0 0; }

/* ---------- pins ---------- */
.wb-pin-wrap { background: none; border: 0; }
.wb-pin {
  position: relative; width: 44px; height: 44px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: linear-gradient(135deg, #1A9B8E, #0c3d38); border: 2.5px solid #D4AF37;
  box-shadow: 0 10px 18px rgba(8, 40, 36, .35), 0 0 0 4px rgba(212, 175, 55, .18);
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1), box-shadow .25s ease;
  animation: pinDrop .55s cubic-bezier(.3, 1.4, .5, 1) both;
}
.wb-pin-face {
  position: absolute; inset: 4px; border-radius: 50%; overflow: hidden; transform: rotate(45deg);
  background: #0f2a2a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFE066' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M7 3v8M5 3v4a2 2 0 0 0 4 0V3M7 11v10M16 3c-2 1-3 4-3 7h3v11'/%3E%3C/svg%3E") center / 55% no-repeat;
}
.wb-pin-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.leaflet-marker-icon:hover .wb-pin, .leaflet-marker-icon:focus .wb-pin { transform: rotate(-45deg) scale(1.14); box-shadow: 0 14px 24px rgba(8, 40, 36, .4), 0 0 0 7px rgba(212, 175, 55, .28); }
.leaflet-marker-icon:focus { outline: none; }
.leaflet-marker-icon:focus-visible .wb-pin { outline: 3px solid #FFE066; outline-offset: 3px; }

.wb-cluster-wrap { background: none; border: 0; }
.wb-cluster {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #FFE066, #D4AF37 55%, #997A15);
  color: #0c3d38; font-weight: 800; font-size: .92rem; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 6px rgba(212, 175, 55, .28), 0 0 0 12px rgba(212, 175, 55, .12), 0 10px 22px rgba(8, 40, 36, .35);
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.wb-cluster-wrap:hover .wb-cluster { transform: scale(1.1); }

/* ---------- popup preview card ---------- */
.wb-popup .leaflet-popup-content-wrapper { padding: 0; border-radius: 18px; overflow: hidden; background: var(--card); box-shadow: 0 24px 60px rgba(8, 30, 28, .35); }
.wb-popup .leaflet-popup-content { margin: 0; width: 280px !important; }
.wb-popup .leaflet-popup-tip { background: var(--card); }
.wb-popup .leaflet-popup-close-button {
  top: 10px !important; right: 10px !important; width: 28px !important; height: 28px !important; border-radius: 50%;
  background: rgba(15, 30, 28, .55) !important; color: #fff !important; font: 18px/28px system-ui, sans-serif !important; z-index: 2;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.leaflet-popup { animation: popIn .28s cubic-bezier(.2, .9, .25, 1.2) both; }

.wb-card { display: block; width: 100%; padding: 0; border: 0; margin: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wb-card:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.wb-card-cover { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: #0f2a2a; }
.wb-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2, .9, .25, 1); }
.wb-card:hover .wb-card-cover img { transform: scale(1.06); }
.wb-card-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .35)); }
.wb-card-rating {
  position: absolute; left: 12px; bottom: 10px; z-index: 1; padding: 4px 9px; border-radius: 999px;
  background: rgba(15, 30, 28, .7); color: #fff; font-size: .75rem; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.wb-card-rating b { color: #FFE066; font-size: .9rem; }
.wb-card-body { display: block; padding: 13px 15px 14px; }
.wb-card-eyebrow { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.08rem; font-weight: 600; line-height: 1.25; }
.wb-card-stars { display: block; margin-top: 5px; color: var(--gold); letter-spacing: 2px; font-size: .85rem; }
.wb-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .78rem; color: var(--muted); min-width: 0; }
.wb-card-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; border: 1.5px solid var(--border); }
.wb-card-author { font-weight: 650; color: var(--text); flex: none; }
.wb-card-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-card-place::before { content: '·'; margin-right: 6px; }
.wb-card-cta { display: inline-block; margin-top: 11px; font-size: .8rem; font-weight: 700; color: var(--teal); }
.wb-card-cta span { display: inline-block; transition: transform .2s ease; }
.wb-card:hover .wb-card-cta span { transform: translateX(4px); }

/* ---------- night mode ---------- */
.map-night .map-panel, .map-night .map-btn:not([aria-pressed="true"]), .map-night .leaflet-control-zoom a,
.map-night .wb-popup .leaflet-popup-content-wrapper, .map-night .wb-popup .leaflet-popup-tip, .map-night .leaflet-control-attribution {
  --card: #13201f; --text: #EAF4F2; --muted: #9BB5B1; --border: #2c4a46;
}
.map-night .map-panel { background: rgba(14, 26, 25, .78); }
.map-night .map-panel h1 { color: #EAF4F2; }
.map-night .map-panel .feed-pill:not([aria-pressed="true"]) { background: rgba(255, 255, 255, .06); color: #DCEBE8; border-color: #2c4a46; }
.map-night .map-btn:not([aria-pressed="true"]) { background: rgba(14, 26, 25, .78); }
.map-night .leaflet-control-attribution, .map-night .leaflet-control-attribution a { color: #9BB5B1; }

/* ---------- motion ---------- */
@keyframes mapRise { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes pinDrop { from { opacity: 0; transform: rotate(-45deg) translate(14px, -14px) scale(.6); } to { opacity: 1; transform: rotate(-45deg); } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes mapSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .map-panel, .map-tools, .wb-pin, .leaflet-popup { animation: none; }
  .wb-pin, .wb-cluster, .wb-card-cover img { transition: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  body.map-page header { padding: 12px 14px; }
}
@media (max-width: 760px) {
  .map-panel { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; padding: 14px 16px 12px; border-radius: 18px; }
  .map-panel h1 { font-size: 1.35rem; }
  .map-eyebrow { display: none; }
  .map-count { margin: 4px 0 10px; font-size: .82rem; }
  .map-panel .feed-pills { margin: 0 -16px; padding: 2px 16px 4px; }
  .map-status { margin-top: 8px; }
  .map-tools { top: 12px; right: 12px; left: 12px; justify-content: flex-end; gap: 6px; }
  .map-btn { height: 36px; padding: 0 12px; font-size: .8rem; }
  #locateBtn, #styleToggle { width: 36px; padding: 0; justify-content: center; }
  #locateBtn .map-btn-label, #styleToggle .map-btn-label { display: none; }
  /* Pinch to zoom on touch screens; the attribution moves above the bottom panel's reach */
  .leaflet-control-zoom { display: none !important; }
  .leaflet-bottom.leaflet-right { bottom: auto; top: 54px; }
  .leaflet-control-attribution { border-radius: 8px 0 0 8px; }
}
