/* ============================================================
   Floatfest Map – styles (mobile first)
   ============================================================ */
:root {
  --rose: #C8102E;
  --rose-dark: #9E0B22;
  --ink: #1B1B1F;
  --ink-2: #5A5B63;
  --line: #E4E4E9;
  --surface: #FFFFFF;
  --surface-2: #F6F6F8;
  --shadow: 0 2px 10px rgba(0,0,0,.18);
  --radius: 16px;
  --topbar-h: 56px;
  --chips-h: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #EDEDF0;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* No browser double-tap zoom and no 300 ms tap delay anywhere. */
  touch-action: manipulation;
}
button, .chip, .mk, .mk-wrap, .sheet, .sheet-close, .north, .topbar, .chips,
.mapboxgl-ctrl button, .maplibregl-ctrl button, .mapboxgl-ctrl-group, .maplibregl-ctrl-group { touch-action: manipulation; }
button { font-family: inherit; }
svg { display: block; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: url("../img/icon.svg") center/100% no-repeat;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0;
  font-size: 15px; font-weight: 700; cursor: pointer; line-height: 1;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--rose); color: #fff; }
.btn-primary:active { background: var(--rose-dark); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--ink-2); width: 40px; padding: 0; }
.btn-ghost:active { background: var(--surface-2); }

/* ---------- Category chips ---------- */
.chips {
  position: fixed; z-index: 29; left: 0; right: 0;
  top: calc(var(--topbar-h) + var(--safe-top));
  height: var(--chips-h);
  display: flex; gap: 8px; align-items: center;
  padding: 0 12px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  background: linear-gradient(to bottom, rgba(255,255,255,.96), rgba(255,255,255,0));
  overscroll-behavior-x: contain; touch-action: pan-x;
  scroll-padding: 0 12px;
}
.chips::-webkit-scrollbar { display: none; }
/* fade the edge when there are more chips that way */
.chips.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
.chips.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); }
.chips.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.12);
  font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.chip-dot {
  width: 20px; height: 20px; border-radius: 50%; background: var(--c, var(--ink-2));
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.chip-dot svg { width: 13px; height: 13px; fill: currentColor; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip[aria-pressed="true"] .chip-dot { background: #fff; color: var(--c, var(--ink)); }
.chip-all[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); }

/* ---------- Map ---------- */
#map { position: fixed; inset: 0; background: #EDEDF0; }
.mapboxgl-ctrl-bottom-right, .maplibregl-ctrl-bottom-right {
  bottom: calc(var(--safe-bottom) + 12px) !important; right: 8px !important;
}
.mapboxgl-ctrl-group, .maplibregl-ctrl-group { box-shadow: var(--shadow) !important; border-radius: 12px !important; overflow: hidden; }
.mapboxgl-ctrl-group button, .maplibregl-ctrl-group button { width: 42px !important; height: 42px !important; }
.mapboxgl-ctrl-bottom-left, .maplibregl-ctrl-bottom-left { bottom: calc(var(--safe-bottom) + 2px) !important; }
.mapboxgl-ctrl-attrib, .maplibregl-ctrl-attrib { font-size: 10px; }
.mapboxgl-ctrl-logo { opacity: .8; }

/* ---------- Markers ---------- */
.mk-wrap { position: relative; width: 0; height: 0; }
.mk {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; padding: 0; border: 2.5px solid #fff;
  background: var(--c, var(--ink-2)); color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; cursor: pointer;
  transition: transform .15s ease;
}
.mk::before { content: ""; position: absolute; inset: -7px; border-radius: 50%; } /* bigger tap target */
.mk svg { width: 19px; height: 19px; fill: currentColor; }
.mk-float { width: 30px; height: 30px; font-size: 13px; }
.mk-wrap.active .mk { transform: translate(-50%, -50%) scale(1.3); box-shadow: 0 0 0 4px rgba(200,16,46,.28), 0 2px 8px rgba(0,0,0,.4); }
.mk-wrap.dim { display: none; }
.mk-label {
  position: absolute; left: 0; top: 19px; transform: translateX(-50%);
  white-space: nowrap; font-size: 11px; font-weight: 700; color: var(--ink);
  background: rgba(255,255,255,.92); padding: 2px 6px; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); pointer-events: none; display: none;
}
.mk-award {
  position: absolute; right: -4px; top: -4px; width: 14px; height: 14px; border-radius: 50%;
  background: #FDE047; border: 1.5px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
body.zoomed .mk-label { display: block; }
body.zoomed-out .mk { width: 26px; height: 26px; border-width: 2px; }
body.zoomed-out .mk svg { width: 14px; height: 14px; }
body.zoomed-out .mk-float { width: 22px; height: 22px; font-size: 11px; }
body.zoomed-out .mk-award { width: 10px; height: 10px; right: -3px; top: -3px; }
body.zoomed .mk-float { width: 34px; height: 34px; font-size: 15px; }

/* ---------- Compass button ---------- */
.north {
  position: fixed; z-index: 28; right: 10px;
  top: calc(var(--topbar-h) + var(--chips-h) + var(--safe-top) + 8px);
  width: 48px; height: 48px; border-radius: 50%; background: var(--surface); border: 0; padding: 0;
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.north:active { background: var(--surface-2); }
.north svg { width: 28px; height: 28px; margin-top: -6px; transition: transform .3s ease; }
.north-label {
  position: absolute; bottom: 4px; left: 0; right: 0; text-align: center;
  font-size: 9px; font-weight: 800; letter-spacing: .04em; color: var(--ink-2);
}
.north.is-heading { box-shadow: 0 0 0 3px rgba(29,161,242,.45), var(--shadow); }
.north.is-heading .north-label { color: #1D9BF0; }

/* ---------- Loading indicator ---------- */
.loading {
  position: fixed; z-index: 27; left: 50%; transform: translateX(-50%);
  top: calc(var(--topbar-h) + var(--chips-h) + var(--safe-top) + 12px);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-size: 15px; font-weight: 700; color: var(--ink);
}
.loading[hidden] { display: none; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 3px solid var(--line); border-top-color: var(--rose);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- "Where am I?" (geolocate control as a pill) ---------- */
.ctrl-locate { border-radius: 999px !important; }
.ctrl-locate button {
  width: max-content !important; min-width: 42px; height: 44px !important;
  padding: 0 16px 0 10px !important; display: flex !important; align-items: center; gap: 8px;
  font: 700 15px var(--font) !important; color: var(--ink) !important; white-space: nowrap;
}
.ctrl-locate button::after { content: "Where am I?"; white-space: nowrap; }
.ctrl-locate button.mapboxgl-ctrl-geolocate-active::after, .ctrl-locate button.maplibregl-ctrl-geolocate-active::after { content: "Following you"; }
.ctrl-locate button.mapboxgl-ctrl-geolocate-background::after, .ctrl-locate button.maplibregl-ctrl-geolocate-background::after { content: "Locate me"; }
.ctrl-locate button:disabled::after { content: "Location unavailable"; color: var(--ink-2); }
.ctrl-locate button .mapboxgl-ctrl-icon, .ctrl-locate button .maplibregl-ctrl-icon { width: 24px !important; height: 24px !important; flex: none; }
.mapboxgl-user-location-dot, .maplibregl-user-location-dot { width: 18px; height: 18px; }
/* Heading wedge: a translucent blue cone pointing "up" (north) before rotation. */
.heading-wedge {
  width: 0; height: 0; pointer-events: none;
}
.heading-wedge::before {
  content: ""; position: absolute; left: -34px; top: -68px; width: 68px; height: 68px;
  background: conic-gradient(from -30deg at 50% 100%, rgba(29,161,242,.55) 0deg, rgba(29,161,242,.55) 60deg, transparent 60deg);
  border-radius: 68px 68px 0 0;
}

.sim-badge {
  position: fixed; z-index: 28; left: 50%; transform: translateX(-50%);
  top: calc(var(--topbar-h) + var(--chips-h) + var(--safe-top) + 12px);
  padding: 4px 10px; border-radius: 999px; background: #FDE68A; color: #78350F;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; pointer-events: none;
}
.sim-badge[hidden] { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%) translateY(10px);
  top: calc(var(--topbar-h) + var(--chips-h) + var(--safe-top) + 40px);
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 12px;
  background: rgba(27,27,31,.92); color: #fff; font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.map-error {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--ink-2); background: #EDEDF0;
}
.map-error[hidden] { display: none; }
.map-error p { margin: 4px 0; font-size: 16px; max-width: 32ch; }

/* ---------- Sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,.22); }
.scrim[hidden] { display: none; }
.sheet {
  position: fixed; z-index: 45; left: 0; right: 0; bottom: var(--kb, 0px); /* --kb = keyboard height on phones */
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2);
  max-height: 70vh; max-height: 70dvh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet.open { transform: translateY(0); }
.sheet[hidden] { display: none; }
.sheet-tall { max-height: 86vh; max-height: 86dvh; height: 86dvh; }
/* with the keyboard up, keep the whole sheet in the visible area above it */
.sheet-tall.kb { height: calc(100dvh - var(--kb, 0px) - var(--topbar-h) - var(--safe-top) - 8px); max-height: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #D5D5DB; margin: 8px auto 0; flex: none; }
.sheet-close {
  position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; border-radius: 50%; z-index: 3;
  border: 0; background: var(--surface-2); color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sheet-close svg { width: 20px; height: 20px; }
.sheet-body { overflow-y: auto; padding: 8px 18px 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.sheet-photo { margin: 4px -18px 12px; background: var(--surface-2); }
.sheet-photo img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; padding-right: 40px; }
.sheet-icon {
  flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--c, var(--ink-2)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
}
.sheet-icon svg { width: 24px; height: 24px; fill: currentColor; }
.sheet-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c, var(--ink-2)); }
.sheet-title { margin: 2px 0 0; font-size: 22px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
.sheet-sub { margin-top: 2px; font-size: 14px; color: var(--ink-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.badges:empty { display: none; }
.badge { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.badge-award { background: #FEF3C7; border-color: #FCD34D; color: #92400E; }
.meta { margin: 14px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 15px; }
.meta:empty { display: none; }
.meta dt { color: var(--ink-2); font-weight: 600; }
.meta dd { margin: 0; }
.sheet-desc { margin: 14px 0 0; font-size: 16px; line-height: 1.5; }
.sheet-desc:empty { display: none; }
.sheet-actions { margin-top: 16px; display: flex; gap: 8px; }
.sheet-actions .btn { flex: 1; }

/* Find sheet */
.find-head { padding: 8px 18px 10px; border-bottom: 1px solid var(--line); flex: none; }
.find-title { margin: 6px 44px 10px 0; font-size: 18px; font-weight: 800; }
.find-input {
  width: 100%; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2);
  padding: 0 14px; font-size: 16px; font-family: inherit; color: var(--ink); -webkit-appearance: none;
}
.find-input:focus { outline: 2px solid var(--rose); outline-offset: 1px; border-color: transparent; }
.find-list { overflow-y: auto; flex: 1; min-height: 0; padding: 6px 0 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.find-group { padding: 12px 18px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.find-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 18px; border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--ink);
}
.find-item:active { background: var(--surface-2); }
/* Pins inside lists: keep them positioned so the enlarged tap area (::before)
   stays on the pin instead of stretching over the whole sheet. */
.find-item .mk { position: relative; left: auto; top: auto; transform: none; width: 34px; height: 34px; flex: none; pointer-events: none; }
.find-item .mk::before { display: none; }
.find-item-text { display: flex; flex-direction: column; min-width: 0; }
.find-item-sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.find-empty { padding: 24px 18px; color: var(--ink-2); text-align: center; }

/* Info sheet */
.info-h { margin: 18px 0 6px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.tips { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.5; }
.credit { margin-top: 18px; font-size: 12px; color: var(--ink-2); }
.credit a { color: inherit; }

/* Larger screens: keep sheets as a card on the right */
@media (min-width: 760px) {
  .sheet { left: auto; right: 16px; bottom: 16px; width: 400px; border-radius: var(--radius); max-height: 80vh; }
  .sheet-tall { height: 80vh; }
  .scrim { background: transparent; }
  .chips { padding-left: 16px; }
}
/* Phone held sideways: shrink the header so the venue gets more height. */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --topbar-h: 44px; --chips-h: 40px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 16px; }
  .brand-sub { display: none; }
  .btn { min-height: 34px; font-size: 14px; }
  .btn-ghost { width: 34px; }
  .chip { height: 30px; font-size: 13px; }
  .chip-dot { width: 18px; height: 18px; }
  .north { width: 40px; height: 40px; }
  .north svg { width: 24px; height: 24px; }
  .sheet { max-height: 92vh; max-height: 92dvh; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .sheet, .toast, .mk { transition: none; }
}

/* ?debug overlay: shows which code path opened or closed a sheet */
.debug-log {
  position: fixed; z-index: 99; left: 8px; right: 8px; top: calc(var(--safe-top) + 2px);
  margin: 0; padding: 6px 8px; max-height: 22vh; overflow: hidden; pointer-events: none;
  font: 11px/1.35 ui-monospace, Menlo, monospace; color: #fff; background: rgba(0,0,0,.72); border-radius: 8px; white-space: pre-wrap;
}
