:root {
  --paper: #efece5;
  --ink: #14120f;
  --accent: #b4472c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Archivo, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  position: fixed;
  inset: 0;
  background: #f4f2ee;
}

/* ---- map ---- */
.map { position: absolute; inset: 0; }
.map .mapboxgl-canvas-container canvas {
  filter: grayscale(1) contrast(.72) brightness(1.06);
}
.mapboxgl-ctrl-logo { opacity: .45; }
.mapboxgl-ctrl-attrib {
  font-size: 9px !important;
  background: rgba(255,255,255,.6) !important;
  color: rgba(0,0,0,.5);
  font-family: Archivo, sans-serif;
}
.mapboxgl-ctrl-attrib a { color: rgba(0,0,0,.55); }

.grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .18;
  mix-blend-mode: multiply;
  filter: url(#grainf);
}

/* ---- pins (round photo + label, Snap Map style) ---- */
.pin {
  /* no `position` here: Mapbox positions the marker absolutely itself */
  width: 40px;
  height: 40px;
  cursor: default;
}
.pin-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid #fff;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.28);
  transition: transform .18s cubic-bezier(.2,.8,.3,1), box-shadow .18s ease;
}
/* The photos carry a white frame of ~5% on each side; zoom in 12% so the
   frame falls outside the circle and the image fills the whole ball. */
.pin-thumb img {
  position: absolute;
  top: -6%;
  left: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
}
.pin-label {
  position: absolute;
  left: calc(100% + 7px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  max-width: 150px;
  padding: 6px 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font: 600 12px/1.25 Archivo, sans-serif;
  color: var(--ink);
  white-space: normal;
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,.8,.3,1);
}
.pin-label:empty { display: none; }
.mapboxgl-marker.is-selected { z-index: 5; }
.pin.sel .pin-thumb {
  box-shadow: 0 0 0 2.5px var(--accent), 0 3px 8px rgba(0,0,0,.3);
  transform: scale(1.15);
}

/* every few seconds a random pin lights up as an invitation to tap it */
.pin.glow { cursor: pointer; }
.pin.glow .pin-thumb {
  transform: scale(1.25);
  animation: pin-glow 1.4s ease-in-out infinite;
}
.pin.glow:hover .pin-thumb { transform: scale(1.35); }
.pin.glow .pin-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
  left: calc(100% + 12px);
}
/* near the right edge the label sits on the left of the photo */
.pin.flip .pin-label {
  left: auto;
  right: calc(100% + 7px);
  transform: translateY(-50%) translateX(6px);
}
.pin.flip.glow .pin-label {
  left: auto;
  right: calc(100% + 12px);
  transform: translateY(-50%) translateX(0);
}
.mapboxgl-marker.is-glow { z-index: 6; }
@keyframes pin-glow {
  0%, 100% { box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 2.5px rgba(180,71,44,.5), 0 3px 8px rgba(0,0,0,.3); }
  50%      { box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 11px rgba(180,71,44,0), 0 3px 8px rgba(0,0,0,.3); }
}
@media (prefers-reduced-motion: reduce) {
  .pin.glow .pin-thumb { animation: none; box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 7px rgba(180,71,44,.2), 0 3px 8px rgba(0,0,0,.3); }
}
.pin-home {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 2px 6px rgba(0,0,0,.3);
}

/* ---- chrome ---- */
.chip-lc {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 14px;
  z-index: 10;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px 0 15px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 100px;
  font: 600 17px/1 Archivo, sans-serif;
  letter-spacing: -.01em;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.chip-lc svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.fabs {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
.fab {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  box-shadow: 0 3px 12px rgba(0,0,0,.2);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.quote {
  position: absolute;
  right: 14px;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 9;
  width: 206px;
  padding: 15px 16px;
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 14px;
  font: 400 13.5px/1.5 Archivo, sans-serif;
  color: rgba(20,18,15,.78);
  text-align: right;
  text-wrap: pretty;
  transition: opacity .3s ease;
}
.quote.hide, .quote:empty { opacity: 0; pointer-events: none; }

/* ---- bottom sheet ---- */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  transform: translateY(104%);
  transition: transform .42s cubic-bezier(.22,.9,.24,1);
  background: var(--paper);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px -8px rgba(0,0,0,.35);
  padding: 10px 10px calc(26px + var(--safe-bottom));
}
.sheet.open { transform: translateY(0); }
.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(20,18,15,.2);
  margin: 2px auto 10px;
}
.sheet-photo {
  position: relative;
  margin: 0;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  padding: 11px;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
}
.sheet-photo img { display: block; width: 100%; height: 100%; object-fit: cover; background: #ddd9d1; }
.sheet-caption {
  margin: 12px 4px 0;
  font: 400 13px/1.5 Archivo, sans-serif;
  color: rgba(20,18,15,.7);
  text-wrap: pretty;
}
.sheet-caption b { font-weight: 600; color: var(--ink); }
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 4px;
}
.sheet-nav { display: flex; gap: 8px; }
.btn {
  border: 1px solid rgba(20,18,15,.18);
  background: none;
  border-radius: 100px;
  padding: 8px 14px;
  font: 500 11.5px Archivo, sans-serif;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: rgba(20,18,15,.06); }
.counter {
  font: 500 11px ui-monospace, Menlo, monospace;
  letter-spacing: .06em;
  color: rgba(20,18,15,.5);
}

/* Wider screens: the sheet becomes a card in the bottom-left corner */
@media (min-width: 720px) {
  .sheet {
    left: 20px;
    right: auto;
    bottom: 20px;
    width: 400px;
    border-radius: 26px;
    padding-bottom: 20px;
    transform: translateY(calc(100% + 40px));
  }
  .sheet.open { transform: translateY(0); }
  .quote { bottom: 24px; }
}

/* Short viewports: keep the photo from swallowing the whole screen */
@media (max-height: 640px) {
  .sheet-photo { width: min(100%, 56vh); margin: 0 auto; }
}

.error {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  max-width: 320px;
  padding: 16px 18px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  font: 400 13px/1.5 Archivo, sans-serif;
}
