/* ============================================================================
   Gospel Village 2026 — stile
   ========================================================================== */
:root {
  --bg: #f4ede0;
  --surface: #fffdf8;
  --surface-2: #f3ebdc;
  --text: #221d2e;
  --text-soft: #5d5670;
  --line: #e3d9c6;
  --brand: #e07b1f;       /* arancio tramonto */
  --brand-2: #7c5cff;     /* viola */
  --accent: #2f9bd6;
  --danger: #e23b3b;
  --ok: #2faa57;
  --shadow: 0 10px 30px rgba(40,30,20,.18);
  --shadow-sm: 0 4px 14px rgba(40,30,20,.14);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17141f;
    --surface: #221d2e;
    --surface-2: #2c2640;
    --text: #f3eefc;
    --text-soft: #b6acc9;
    --line: #3a3350;
    --shadow: 0 10px 34px rgba(0,0,0,.5);
    --shadow-sm: 0 4px 16px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
/* Override manuale tema */
html[data-theme="light"] { color-scheme: light;
  --bg:#f4ede0;--surface:#fffdf8;--surface-2:#f3ebdc;--text:#221d2e;--text-soft:#5d5670;--line:#e3d9c6;
  --shadow:0 10px 30px rgba(40,30,20,.18);--shadow-sm:0 4px 14px rgba(40,30,20,.14);}
html[data-theme="dark"] { color-scheme: dark;
  --bg:#17141f;--surface:#221d2e;--surface-2:#2c2640;--text:#f3eefc;--text-soft:#b6acc9;--line:#3a3350;
  --shadow:0 10px 34px rgba(0,0,0,.5);--shadow-sm:0 4px 16px rgba(0,0,0,.4);}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
.visually-hidden, .skip-link:not(:focus) {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200; background: var(--brand);
  color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 700; text-decoration: none;
}
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }

/* ---------------- App bar ---------------- */
.appbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) 10px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface) 70%, transparent));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar__title { display: flex; align-items: center; gap: 10px; font-size: 16px; min-width: 0; }
.appbar__logo { font-size: 22px; }
.appbar__title strong { display: block; line-height: 1.05; }
.appbar__title small { color: var(--text-soft); font-size: 12px; }
.appbar__actions { display: flex; gap: 6px; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--text); font-size: 18px; cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 24px; height: 24px; fill: currentColor; }
.iconbtn--lg { width: 48px; height: 48px; font-size: 26px; background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }

/* ---------------- Next-event banner ---------------- */
.nextbar {
  position: fixed; left: 8px; right: 8px; z-index: 45;
  top: calc(var(--appbar-h) + var(--safe-top) + 8px);
  display: flex; align-items: stretch; gap: 4px;
  background: linear-gradient(100deg, var(--brand), var(--brand-2));
  color: #fff; border-radius: 14px; box-shadow: var(--shadow);
  animation: drop .35s ease;
}
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }
.nextbar__body {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  background: transparent; border: 0; color: inherit; text-align: left;
  padding: 10px 12px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.nextbar__icon { font-size: 20px; }
.nextbar__text { min-width: 0; }
.nextbar__close { color: #fff; width: 40px; }

/* ---------------- Map ---------------- */
.map {
  position: fixed; inset: 0; overflow: hidden; touch-action: none;
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--brand) 22%, var(--bg)), var(--bg));
}
.map__world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.map__img { display: block; width: 1700px; max-width: none; height: auto; user-select: none; -webkit-user-drag: none; }
.map__markers { position: absolute; inset: 0; }

/* Pin a goccia: la PUNTA è ancorata esattamente sul punto (x%, y%). */
.marker {
  position: absolute; transform: translate(-50%, -100%) scale(var(--inv, 1));
  transform-origin: 50% 100%; will-change: transform;
}
.marker__btn {
  position: relative; display: block; width: 30px; height: 41px;
  border: 0; background: transparent; cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.marker__btn .pin {
  display: block; width: 30px; height: 41px;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.45));
  transition: transform .12s ease;
}
.marker__btn:hover .pin { transform: translateY(-2px) scale(1.06); }
.marker__btn:focus-visible { outline: none; }
.marker__btn:focus-visible .pin { transform: scale(1.12); }
.marker__btn:focus-visible .pin .pin-ring { stroke: var(--brand-2); stroke-width: 3; opacity: 1; }
.marker--active .pin { transform: scale(1.14); }
.marker--active .pin .pin-ring { stroke: var(--brand-2); stroke-width: 3; opacity: 1; }

/* anello pulsante "in corso" attorno alla testa del pin */
.marker__btn::before {
  content: ""; position: absolute; left: 50%; top: 15px; width: 26px; height: 26px;
  transform: translate(-50%, -50%); border-radius: 50%; opacity: 0; pointer-events: none;
}
.marker--live .marker__btn::before {
  opacity: 1; box-shadow: 0 0 0 2px var(--ok); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 2px var(--ok); }
  50%     { box-shadow: 0 0 0 9px color-mix(in srgb, var(--ok) 0%, transparent); }
}
.marker__badge {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  min-width: 17px; height: 16px; padding: 0 4px; white-space: nowrap;
  border-radius: 8px; background: var(--ok); color: #fff; font-size: 9.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.45); z-index: 2;
}
.marker__badge--soon { background: var(--brand); }

/* user position dot */
.userdot {
  position: absolute; transform: translate(-50%,-50%) scale(var(--inv,1));
  width: 22px; height: 22px; pointer-events: none;
}
.userdot::before {
  content:""; position:absolute; inset:0; border-radius:50%;
  background:#1a73e8; border:3px solid #fff; box-shadow:0 0 0 2px rgba(26,115,232,.4), 0 2px 6px rgba(0,0,0,.4);
}
.userdot::after {
  content:""; position:absolute; left:50%; top:50%; width:46px; height:46px; transform:translate(-50%,-50%);
  border-radius:50%; background:radial-gradient(circle, rgba(26,115,232,.32), transparent 70%); animation:ping 2s ease-out infinite;
}
@keyframes ping { 0%{transform:translate(-50%,-50%) scale(.4);opacity:.9} 100%{transform:translate(-50%,-50%) scale(1);opacity:0} }

/* ---------------- Floating buttons ---------------- */
.zoomctrl {
  position: fixed; right: 12px; bottom: calc(150px + var(--safe-bottom)); z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
}
.fab {
  position: fixed; z-index: 40; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 12px 16px; border-radius: 999px; box-shadow: var(--shadow); cursor: pointer;
  font-weight: 700; font-size: 14px;
}
.fab:active { transform: scale(.96); }
.fab svg { width: 22px; height: 22px; fill: currentColor; }
.fab--locate { left: 12px; bottom: calc(16px + var(--safe-bottom)); }
.fab--list   { right: 12px; bottom: calc(16px + var(--safe-bottom)); background: var(--brand); color: #fff; border-color: transparent; }
.fab--locate.is-on { background: var(--accent); color: #fff; border-color: transparent; }

/* ---------------- Bottom sheets shared ---------------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,6,20,.5);
  backdrop-filter: blur(2px); animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }

.listsheet, .detail, .gpspanel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding-bottom: var(--safe-bottom);
  animation: slideup .32s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; display: flex; flex-direction: column;
}
@keyframes slideup { from { transform: translateY(100%); } }
.detail, .gpspanel { z-index: 75; }
.listsheet__grabber, .detail__grabber {
  width: 44px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 8px auto 4px; flex: none;
}
.detail__close { position: absolute; top: 10px; right: 10px; z-index: 2; background: var(--surface-2); }

/* List sheet */
.listsheet__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 14px 8px; }
.listsheet__head h2 { margin: 0; font-size: 18px; }
.listsheet__tools { padding: 0 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; }
.searchbox svg { width: 20px; height: 20px; fill: var(--text-soft); flex: none; }
.searchbox input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 16px; padding: 12px 0; outline: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; flex: none;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

.poi-list { list-style: none; margin: 0; padding: 4px 10px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.poi-cat-label { padding: 12px 8px 4px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.poi-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 14px; padding: 10px 8px; cursor: pointer; color: inherit;
}
.poi-item:hover { background: var(--surface-2); }
.poi-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.poi-main { flex: 1; min-width: 0; }
.poi-main h3 { margin: 0; font-size: 15px; }
.poi-main p { margin: 2px 0 0; font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poi-meta { flex: none; text-align: right; font-size: 12px; color: var(--text-soft); }
.statuspill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.statuspill--live { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.statuspill--soon { background: color-mix(in srgb, var(--brand) 24%, transparent); color: var(--brand); }
.statuspill--done { background: var(--surface-2); color: var(--text-soft); }
.statuspill--open { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* Detail sheet */
.detail__body { overflow-y: auto; padding: 0 18px 22px; }
.detail__hero { display: flex; align-items: center; gap: 14px; padding: 6px 44px 12px 0; }
.detail__num {
  flex: none; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 22px; border: 3px solid #fff; box-shadow: var(--shadow-sm);
}
.detail__headtext h2 { margin: 0; font-size: 21px; line-height: 1.1; }
.detail__cat { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.detail__rows { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.detail__row { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; }
.detail__row .ic { font-size: 18px; width: 22px; text-align: center; flex: none; }
.detail__desc { font-size: 15px; line-height: 1.55; color: var(--text); }
.detail__actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 13px 18px; border-radius: 14px; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  flex: 1; min-width: 140px;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn--block { width: 100%; flex: 1 1 100%; }

/* GPS panel */
.gpspanel__body { overflow-y: auto; padding: 4px 18px 22px; }
.gpspanel__body h2 { margin: 4px 0 6px; font-size: 20px; padding-right: 44px; }
.gps-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 12px; background: var(--surface-2);
}
.gps-card h3 { margin: 0 0 4px; font-size: 16px; }
.gps-dist { font-size: 26px; font-weight: 800; color: var(--brand); }
.gps-sub { font-size: 13px; color: var(--text-soft); }
.gps-note { font-size: 13px; color: var(--text-soft); margin-top: 12px; line-height: 1.5; }
.gps-status { font-size: 14px; padding: 10px 0; }

/* Toasts */
.toasts {
  position: fixed; left: 10px; right: 10px; z-index: 90;
  top: calc(var(--appbar-h) + var(--safe-top) + 8px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-left: 5px solid var(--brand);
  border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start; animation: drop .3s ease;
}
.toast--live { border-left-color: var(--ok); }
.toast--preview { border-left-color: var(--brand-2); border-style: dashed; }
.toast__tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  background: color-mix(in srgb, var(--brand-2) 22%, transparent); color: var(--brand-2);
  vertical-align: middle;
}
.toast__ic { font-size: 22px; }
.toast__txt { flex: 1; font-size: 14px; }
.toast__txt b { display: block; font-size: 15px; }
.toast__close { background: transparent; border: 0; color: var(--text-soft); font-size: 18px; cursor: pointer; }

/* Help */
.help {
  position: fixed; inset: auto 0 0 0; z-index: 80; background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto;
  padding-bottom: var(--safe-bottom); animation: slideup .32s cubic-bezier(.2,.8,.2,1);
}
.help__body { padding: 26px 20px 24px; }
.help__body h2 { margin: 0 0 6px; font-size: 22px; padding-right: 48px; }
.help__lead { margin: 0 0 14px; color: var(--text-soft); }
.help__list { margin: 0 0 18px; padding-left: 20px; line-height: 1.6; font-size: 15px; }
.help__list li { margin-bottom: 8px; }
.help__actions { display: flex; flex-direction: column; gap: 12px; }
.help__demo { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); }
.help__demo-controls { font-size: 14px; }
.help__demo-controls input { font-size: 16px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.help__foot { margin-top: 18px; font-size: 13px; color: var(--text-soft); }
.help__foot a { color: var(--brand-2); }

/* Larger screens: list as side panel */
@media (min-width: 760px) {
  .listsheet {
    left: auto; right: 12px; top: calc(var(--appbar-h) + var(--safe-top) + 12px); bottom: 12px;
    width: 380px; border-radius: 22px; max-height: none;
  }
  .detail, .gpspanel { left: auto; right: 12px; bottom: 12px; width: 420px; border-radius: 22px; }
  .help { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: min(520px, 92vw); border-radius: 22px; max-height: 86vh; }
  .toasts { left: auto; right: 12px; width: 360px; }
}

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

/* High-contrast / forced colors */
@media (forced-colors: active) {
  .marker__btn, .iconbtn--lg, .fab, .btn { border: 2px solid; }
}
