:root {
  --sheet-h: 168px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
/* One animated value drives the sheet, the map and the buttons above it, so they move together. */
@property --sheet-h { syntax: "<length>"; inherits: true; initial-value: 168px; }
body { overflow: hidden; transition: --sheet-h .2s ease; }
@media (prefers-reduced-motion: reduce) { body { transition: none; } }

#map { position: absolute; inset: 0 0 var(--sheet-h) 0; }

/* user position */
.me { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 0 0 0 rgb(14 124 134 / .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgb(14 124 134 / 0); } 100% { box-shadow: 0 0 0 0 rgb(14 124 134 / 0); } }
@media (prefers-reduced-motion: reduce) { .me { animation: none; } }

/* report popup follows the theme (MapLibre's default is a white box, unreadable with our light-on-dark text) */
.maplibregl-popup-content { background: var(--surface); color: var(--fg); font-family: inherit; font-size: .95rem; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); }
.maplibregl-popup-content strong { display: block; font-size: 1.05rem; }
.maplibregl-popup-content .age { color: var(--muted); margin-top: 2px; }
.maplibregl-popup-content .refine { margin: 10px 0 8px; color: var(--muted); font-size: .9rem; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }

/* floating controls */
.fab-small { position: absolute; right: 12px; top: 12px; z-index: 5; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; }
#test-banner { position: absolute; left: 12px; right: 120px; top: 12px; z-index: 5; padding: 8px 12px; border-radius: 10px; background: #fff3cd; color: #3d3000; font-size: .85rem; box-shadow: var(--shadow); }
#report-button { position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--sheet-h) + 16px); min-width: 168px; height: 64px; padding: 0 28px; border: 0; border-radius: 32px; background: var(--danger); color: #fff; font-size: 1.25rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; box-shadow: var(--shadow); }
#report-button:active { transform: translateX(-50%) scale(.97); }
#report-button:focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--danger), var(--shadow); }

#sent-panel, #emergency-panel { position: absolute; z-index: 7; left: 12px; right: 12px; bottom: calc(var(--sheet-h) + 92px); max-width: 520px; margin: 0 auto; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
#sent-panel[hidden], #emergency-panel[hidden], #nearby-banner[hidden], #test-banner[hidden], #undo-button[hidden], #sent-categories[hidden], #nearby-empty[hidden] { display: none; }
.sent-row { display: flex; align-items: center; gap: 10px; }
.sent-row strong { flex: 1; }
#nearby-banner { position: absolute; left: 12px; top: 12px; z-index: 4; width: fit-content; max-width: calc(100% - 132px); min-height: 44px; display: flex; flex-direction: column; justify-content: center; padding: 3px 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); line-height: 1.2; }
#nearby-banner .label { color: var(--muted); font-size: .75rem; }
#nearby-banner .count { font-weight: 700; font-size: .95rem; }
.emergency-buttons { display: flex; gap: 8px; margin-top: 10px; }
/* Same colours in both themes, like the SIGNALER button: red for the emergency services, blue for the police */
.emergency-call { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 14px; border-radius: 24px; border: 0; background: #1b5fc2; color: #fff; font-weight: 700; text-decoration: none; }
.emergency-call.primary { background: var(--danger); }
.emergency-call:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
#undo-button { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 2px solid var(--fg); background: transparent; font-weight: 700; }
.icon-button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.4rem; line-height: 1; color: var(--muted); }
#sent-categories p { margin: 10px 0 8px; color: var(--muted); font-size: .9rem; }
#sent-done { align-self: flex-start; min-height: 44px; margin-top: 10px; padding: 0 22px; border-radius: 22px; border: 2px solid var(--fg); background: transparent; color: var(--fg); font: inherit; font-weight: 700; }
.category-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.category-buttons button { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); }
.category-buttons button[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* bottom sheet « Around you » */
#sheet { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; height: var(--sheet-h); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .18); padding-bottom: var(--safe-bottom); }
body.sheet-open { --sheet-h: 62dvh; }
#sheet-handle { all: unset; box-sizing: border-box; cursor: pointer; display: block; padding: 8px 16px 6px; }
#sheet-handle:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; border-radius: 12px; }
.grip { display: block; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 2px; background: var(--line); }
#sheet h2 { margin: 0; font-size: 1.05rem; }
#nearby-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; min-height: 0; }
#nearby-list button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 8px; min-height: 48px; border-bottom: 1px solid var(--line); cursor: pointer; }
#nearby-list button:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
#nearby-list .label { flex: 1; }
#nearby-list .meta { color: var(--muted); font-size: .85rem; text-align: right; white-space: nowrap; }
#nearby-empty { margin: 0; padding: 8px 16px; color: var(--muted); }
.emergency { margin: 0; padding: 8px 16px 10px; font-size: .78rem; color: var(--muted); }

/* profile button (next to the recenter button) and its menu */
#profile-button { right: 64px; }
#profile-menu { position: absolute; z-index: 9; right: 12px; top: 64px; min-width: 220px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
#profile-menu[hidden] { display: none; }
#profile-menu .who { margin: 0; padding: 8px 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
#profile-menu a, #profile-menu button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); font: inherit; text-decoration: none; text-align: left; cursor: pointer; }
#profile-menu a:hover, #profile-menu button:hover { background: var(--bg); }

/* walking route */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#route-button { position: absolute; z-index: 2; right: 12px; top: 6px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 2px solid var(--fg); border-radius: 22px; background: var(--surface); font-weight: 700; }
#route-panel { position: absolute; z-index: 7; top: 64px; left: 12px; right: 12px; max-width: 520px; margin: 0 auto; padding: 10px 56px 12px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
#route-panel[hidden], #route-message[hidden], #route-options[hidden], #route-detail[hidden] { display: none; }
#route-clear { position: absolute; top: 4px; right: 4px; }
#route-message { margin: 2px 0 8px; padding-top: 6px; color: var(--fg); }
#route-options { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.route-card { display: flex; align-items: stretch; gap: 10px; min-height: 60px; padding: 8px 10px; text-align: left; border: 2px solid var(--field-line); border-radius: 12px; background: var(--bg); }
.route-card[aria-pressed="true"] { border-color: var(--fg); }
.route-swatch { flex: none; width: 6px; border-radius: 3px; background: #6b7280; }
.route-swatch.safer { background: #1f9d55; }
.route-text { display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: .95rem; }
#route-open { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
#route-open[hidden] { display: none; }
#route-open-label { flex: 0 0 100%; color: var(--muted); font-size: .95rem; }
#route-open-note { flex: 0 0 100%; margin: 0; color: var(--muted); font-size: .85rem; }
#route-open-note[hidden] { display: none; }
.route-open-link { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 10px; border: 2px solid var(--field-line); border-radius: 12px; background: var(--bg); color: var(--fg); font-weight: 600; text-decoration: none; white-space: nowrap; }
#route-detail { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 0; color: var(--muted); font-size: .95rem; }
.dest { display: block; cursor: grab; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .4)); }
.dest svg { display: block; }

/* several reports on the same spot: no icon, a bubble with their number */
.stack-bubble { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; box-sizing: border-box; border: 3px solid #ffffff; border-radius: 18px; background: #1b2528; color: #ffffff; font-size: 16px; font-weight: 700; box-shadow: 0 1px 4px rgb(0 0 0 / .45); }
.stack-bubble.mine { background: var(--brand); }
.group-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; }
.group-list button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.group-list button:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
.group-list .label { flex: 1; }
.group-list .meta { color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* category picker: families, then the sub-categories of the chosen one */
.category-picker { display: flex; flex-direction: column; gap: 6px; }
.sub-caption { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.sub-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-buttons button { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--field-line); background: var(--bg); font-size: .95rem; }
.sub-buttons button[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
#sent-panel { max-height: calc(100dvh - var(--sheet-h) - 110px); overflow-y: auto; }

/* hold SIGNALER: a wheel of categories */
#report-button { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#report-button.holding { z-index: 11; }
#wheel { position: fixed; inset: 0; z-index: 10; pointer-events: none; background: rgb(0 0 0 / .4); }
#wheel[hidden] { display: none; }
#wheel-hint { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); box-sizing: border-box; margin: 0; padding: 6px 14px; border-radius: 16px; background: rgb(27 37 40 / .92); text-align: center; color: #ffffff; font-weight: 700; font-size: 1.05rem; }
.wheel-item { position: absolute; width: 82px; height: 82px; margin: -41px 0 0 -41px; box-sizing: border-box; padding: 2px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--surface); color: var(--fg); border: 3px solid var(--field-line); box-shadow: var(--shadow); font-size: .66rem; font-weight: 700; line-height: 1.1; text-align: center; transition: transform .1s; }
.wheel-item.active { transform: scale(1.28); border-color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .wheel-item { transition: none; } }

/* voice command */
#wheel-voice { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); box-sizing: border-box; margin: 0; padding: 4px 14px; border-radius: 16px; background: rgb(27 37 40 / .92); text-align: center; color: #ffffff; font-weight: 700; font-size: .95rem; }
#wheel-voice[hidden], #voice-toggle[hidden], #voice-note[hidden] { display: none; }
#voice-note { margin: 0; padding: 2px 12px 8px; color: var(--muted); font-size: .8rem; line-height: 1.35; }

/* while the voice command listens, the label of the report button gives way to an animated microphone */
#report-button .mic { display: none; overflow: visible; margin: 0 auto; }
#report-button.listening .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#report-button.listening .mic { display: block; }
.mic .wave { fill: none; stroke: currentColor; stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; animation: mic-wave 1.4s ease-out infinite; }
.mic .wave:nth-of-type(2) { animation-delay: .7s; }
@keyframes mic-wave { 0% { transform: scale(.55); opacity: .85; } 100% { transform: scale(1.45); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mic .wave { animation: none; opacity: .4; transform: scale(1.1); } }

/* the button of a map marker: reset the look only. Never reset `position`: MapLibre places markers with position: absolute. */
.marker-button { display: block; margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
