/* travelPoints — map-first UI.
   Layout is a full-bleed map with floating surfaces on top: a top bar, a FAB,
   and a slide-over panel that becomes a bottom sheet on narrow screens. */

:root {
  --bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --text-soft: #64748b;
  --border: rgba(15, 23, 42, 0.1);
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.22);
  --panel-w: 400px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: rgba(17, 25, 40, 0.9);
    --surface-solid: #111928;
    --text: #e8edf7;
    --text-soft: #93a1b8;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #818cf8;
    --accent-soft: rgba(129, 140, 248, 0.16);
    --danger: #f87171;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

/* The UA rule for [hidden] is display:none, which any author `display` value
   beats. Panels, chips and overlays all set one, so restate it with priority. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  inset: 0;
}

svg {
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.15s ease;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.btn--tiny {
  padding: 5px 10px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}
.btn--block {
  width: 100%;
}

:where(button, a, input, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}

.topbar__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  margin-right: auto; /* pushes the install + account buttons to the right */
  gap: 8px;
  padding: 4px 6px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.brand__pin {
  font-size: 20px;
}
.brand__name {
  font-weight: 500;
  letter-spacing: -0.02em;
}
.brand__name b {
  font-weight: 800;
}

.account {
  white-space: nowrap;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* --- Filter chips -------------------------------------------------------- */

.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filters::-webkit-scrollbar {
  display: none;
}
.filters__chips {
  display: flex;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:hover {
  border-color: color-mix(in srgb, var(--chip-color, var(--accent)) 60%, transparent);
}
.chip[aria-pressed="true"] {
  background: var(--chip-color, var(--accent));
  border-color: var(--chip-color, var(--accent));
  color: #fff;
}
.chip__emoji {
  font-size: 15px;
  line-height: 1;
}
.chip--mode,
.chip--clear {
  font-weight: 500;
  color: var(--text-soft);
}

/* Static (non-interactive) tag pills used inside the panel. */
.tagpill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-color) 16%, transparent);
  color: color-mix(in srgb, var(--chip-color) 78%, var(--text));
  font-size: 13px;
  font-weight: 600;
}

/* --- FAB + pick hint ----------------------------------------------------- */

.fab-stack {
  position: absolute;
  right: 16px;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* MapLibre's own geolocate button lands under the top bar, out of thumb reach.
   Hide it and drive the control from .fab--round instead. */
.maplibregl-ctrl-group:has(.maplibregl-ctrl-geolocate) {
  display: none;
}

.fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 650;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}
.fab:hover {
  filter: brightness(1.08);
}
.fab:active {
  transform: translateY(1px);
}

/* Secondary action: a 52 px circle, comfortably above the 44 px touch minimum. */
.fab--round {
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
}
.fab--round svg {
  width: 22px;
  height: 22px;
}
.fab--round[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.fab--round.is-busy svg {
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.pick-hint {
  position: absolute;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

/* --- Panel --------------------------------------------------------------- */

.panel {
  position: absolute;
  top: calc(12px + var(--safe-top));
  bottom: 12px;
  left: 12px;
  z-index: 6;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slide-in 0.22s ease;
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
}
.panel__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.panel__body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel__content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.panel h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}
.panel p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.muted {
  color: var(--text-soft);
  font-size: 13.5px;
}

.tagrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.divider {
  height: 1px;
  background: var(--border);
}

/* Photo gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.gallery__item {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  aspect-ratio: 1;
}
.gallery__item:first-child:nth-last-child(n + 2) {
  grid-column: span 3;
  aspect-ratio: 16 / 10;
}
.gallery__item:only-child {
  grid-column: span 3;
  aspect-ratio: 16 / 10;
}
.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--accent-soft);
}
.gallery__del {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  cursor: pointer;
}
.gallery__del svg {
  width: 14px;
  height: 14px;
}

.placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  color: var(--text-soft);
  font-size: 34px;
}

/* --- Forms --------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-soft);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
  font: inherit;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}
.field textarea {
  min-height: 92px;
}

.dropzone {
  display: block;
  padding: 18px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input {
  display: none;
}

.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.previews img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
}

.coords {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.error {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
}

/* --- Modal --------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}
.modal__card {
  position: relative;
  width: min(420px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s ease;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}
.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: none;
  color: var(--text-soft);
  cursor: pointer;
}
.modal h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.modal form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 18px;
}
.modal__card--wide {
  width: min(580px, 100%);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.switcher {
  margin-top: 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-soft);
}
.switcher button {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}

/* --- Lightbox + toasts --------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 10, 20, 0.94);
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}
.lightbox__close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: none;
  color: #fff;
  cursor: pointer;
}
.lightbox__close svg {
  width: 28px;
  height: 28px;
}

/* --- Admin area ---------------------------------------------------------- */

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0 14px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.stat b {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat span {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.admin-create {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-bottom: 16px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.admin-create input[type="email"],
.admin-create input[type="text"],
.admin-create input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: inherit;
  font: inherit;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
}
.checkline input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.userlist {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.userrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.userrow:last-child {
  border-bottom: none;
}
.userrow__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 190px;
}
.userrow__name {
  display: flex;
  align-items: center;
  gap: 6px;
}
.userrow__actions {
  display: flex;
  gap: 6px;
}
.userrow .muted {
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge--admin {
  background: var(--accent);
  color: #fff;
}

.admin-reset {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}
.admin-reset input {
  flex: 1;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 13.5px;
}
.btn--solid {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 560px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- PWA chrome ---------------------------------------------------------- */

.install {
  white-space: nowrap;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.offline-banner {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 39;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  pointer-events: none;
}

.update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 41;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 40;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s ease;
}
.toast--error {
  background: var(--danger);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* --- Map chrome ---------------------------------------------------------- */

.maplibregl-ctrl-top-right {
  margin-top: calc(112px + var(--safe-top));
}
.map-picking .maplibregl-canvas-container {
  cursor: crosshair !important;
}

/* --- Responsive: panel becomes a bottom sheet ---------------------------- */

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 72vh;
    animation: sheet-up 0.22s ease;
  }
  @keyframes sheet-up {
    from {
      opacity: 0;
      transform: translateY(24px);
    }
  }
  .brand__name,
  .install span,
  .fab span {
    display: none;
  }
  .fab-stack {
    bottom: calc(20px + var(--safe-bottom));
  }
  .fab {
    padding: 16px;
  }
  .fab svg {
    width: 22px;
    height: 22px;
  }
  .fab--round {
    padding: 0;
  }
  .maplibregl-ctrl-top-right {
    margin-top: calc(120px + var(--safe-top));
  }
}

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