/* style.css
   Vantage v2: light and airy, one sunset-orange accent, and four brand
   signatures — viewfinder corners, turf on the map, condensed display
   type, and film-edge mono captions. */

:root {
  /* Surfaces */
  --map-bg: #edeeef;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --border: #ebebeb;
  --border-strong: #dddddd;

  /* Text */
  --text: #222222;
  --text-dim: #6a6a6a;

  /* Sunset orange. --accent is deep enough to carry white text and to
     be read as text itself; --accent-bright is for marks and glows. */
  --accent: #c8430e;
  --accent-hover: #a93709;
  --accent-bright: #f2711c;
  --accent-soft: #fff4ec;

  /* Turf states */
  --held: #222222;
  --open-ring: #717171;

  --danger: #c62828;

  /* Type */
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  --header-h: 72px;
  /* How wide the card feed is beside the map on a computer. */
  --feed-w: clamp(440px, 52vw, 860px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--map-bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
}

/* "Hide this completely." Used all over the page; JS adds/removes it. */
.hidden {
  display: none !important;
}

/* Hidden from view but still usable (the real file input lives here —
   the styled .upload-drop label is what people click). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Brand signature #1: viewfinder corners                                  */
/* ---------------------------------------------------------------------- */
/* Add class="vf" to anything and it gets four camera crop-mark corners
   drawn just outside its edges. Set --vf-color to change their color
   (orange = yours, charcoal = someone else's). They're drawn with eight
   tiny gradient strips on one pseudo-element, so no extra HTML needed. */

.vf {
  position: relative;
}

.vf::after {
  content: "";
  position: absolute;
  inset: var(--vf-inset, -5px);
  pointer-events: none;
  --c: var(--vf-color, var(--accent));
  --l: var(--vf-len, 14px);
  --t: var(--vf-thick, 2.5px);
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l);
  background-repeat: no-repeat;
}

.vf--held {
  --vf-color: var(--held);
}

/* ---------------------------------------------------------------------- */
/* Brand signatures #3 and #4: display type and mono labels                */
/* ---------------------------------------------------------------------- */

.display-title {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.display-subtitle {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.mono-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.mono-label--dim {
  font-weight: 500;
  color: var(--text-dim);
}

/* The status line above a zone's name: a dot plus "HELD BY YOU" etc. */
.eyebrow {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px dashed var(--open-ring);
}

.eyebrow--held {
  color: var(--text);
}

.eyebrow--held::before {
  border: none;
  background: var(--held);
}

.eyebrow--mine {
  color: var(--accent);
}

.eyebrow--mine::before {
  border: none;
  background: var(--accent-bright);
}

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

.primary-btn {
  height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.primary-btn:disabled {
  background: var(--border-strong);
  color: var(--text-dim);
  cursor: not-allowed;
}

.primary-btn--pill {
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
}

.outline-btn {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--text);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.outline-btn:hover {
  background: var(--surface-2);
}

.text-btn {
  height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  background: var(--surface-2);
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.pill-btn svg {
  color: var(--accent);
}

.pill-btn:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close-btn:hover {
  background: var(--border);
}

/* ---------------------------------------------------------------------- */
/* Header                                                                  */
/* ---------------------------------------------------------------------- */

#app-header {
  position: relative;
  z-index: 1100; /* above the map and its panels, so the account menu shows */
  height: var(--header-h);
  flex-shrink: 0;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  flex-shrink: 0;
}

.brand-logo path {
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: square;
}

.brand-logo circle {
  fill: var(--accent-bright);
}

.brand-wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
}

.brand-tagline {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Account pill + its dropdown menu */

.account {
  position: relative;
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 7px 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.15s ease;
}

.account-btn:hover,
.account-btn[aria-expanded="true"] {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.avatar--me {
  background: var(--accent-bright);
  color: #ffffff;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 8px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.account-menu-label {
  margin: 0;
  padding: 8px 12px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.account-menu-name {
  margin: 0;
  padding: 2px 12px 10px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-item {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.account-menu-item:hover {
  background: var(--surface-2);
}

/* ---------------------------------------------------------------------- */
/* Explore screen: card feed + map                                         */
/* ---------------------------------------------------------------------- */

#explore {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  /* Keeps Leaflet's own z-indexes inside this box, so the panels and the
     header always stay on top of the map. */
  isolation: isolate;
}

#feed {
  width: var(--feed-w);
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

/* Title + chips stay pinned at the top while the cards scroll. */
.feed-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 32px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.feed-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Filter chips: one row that scrolls sideways if it doesn't fit. The
   scroller around it adds faded edges and arrow buttons on whichever side
   has more chips hidden (feed.js toggles the --more-left/right classes). */
.chips-scroller {
  position: relative;
  margin: 0 -32px;
}

.chips {
  display: flex;
  gap: 8px;
  padding: 2px 32px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.chips-scroller::before,
.chips-scroller::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 72px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.chips-scroller::before {
  left: 0;
  background: linear-gradient(to right, var(--surface) 35%, rgba(255, 255, 255, 0));
}

.chips-scroller::after {
  right: 0;
  background: linear-gradient(to left, var(--surface) 35%, rgba(255, 255, 255, 0));
}

.chips-scroller--more-left::before,
.chips-scroller--more-right::after {
  opacity: 1;
}

.chips-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.chips-arrow:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transform: scale(1.05);
}

.chips-arrow--prev {
  left: 24px;
}

.chips-arrow--next {
  right: 24px;
}

/* Arrows only on devices with a mouse — on a phone you just swipe. */
@media (hover: hover) and (pointer: fine) {
  .chips-scroller--more-left .chips-arrow--prev,
  .chips-scroller--more-right .chips-arrow--next {
    display: flex;
  }
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.chip:hover {
  border-color: var(--text);
}

.chip svg {
  color: var(--accent);
}

.chip--active {
  border-color: var(--text);
  background: var(--text);
  color: #ffffff;
}

.chip--active svg {
  color: var(--accent-bright);
}

.feed-status {
  margin: 16px 32px 0;
  font-size: 14px;
  color: var(--text-dim);
}

.feed-status:empty {
  display: none;
}

/* The cards: as many columns as fit, each at least 220px wide. */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 24px 32px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 36px 24px;
}

.feed-empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  font-size: 15px;
  color: var(--text-dim);
  text-align: center;
}

/* Each card fills its grid cell, so the footers in a row line up. */
.card-grid > li {
  display: flex;
}

.zone-card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  cursor: pointer;
}

/* The photo, with viewfinder corners that only show on hover/selection. */
.zone-card-media {
  position: relative;
  margin-bottom: 6px;
  aspect-ratio: 4 / 3;
  /* Without this, a tall (portrait) photo stretches the box taller than
     4:3, which made some cards bigger than their neighbors. */
  min-height: 0;
  border-radius: 12px;
  background: var(--surface-2);
  --vf-inset: -7px;
  --vf-len: 16px;
}

.zone-card-media::after {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.zone-card:hover .zone-card-media::after,
.zone-card--hover .zone-card-media::after,
.zone-card--active .zone-card-media::after {
  opacity: 1;
}

.zone-card--mine .zone-card-media {
  --vf-color: var(--accent);
}

.zone-card-img {
  /* Pinned to the box's edges, so the photo can never change the card's
     size — it just gets cropped to fit. */
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  transition: filter 0.2s ease;
}

.zone-card:hover .zone-card-img,
.zone-card--hover .zone-card-img {
  filter: brightness(1.05) saturate(1.08);
}

/* No photo yet: a sunset-orange "no shots yet" placeholder. */
.zone-card-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 20%, #ffe2cc 0, transparent 55%),
    linear-gradient(135deg, #fff4ec 0%, #ffd9bd 100%);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.zone-card-empty svg path {
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: square;
}

.zone-card-empty svg circle {
  fill: var(--accent-bright);
}

.zone-card-badge,
.zone-card-hot {
  position: absolute;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.zone-card-badge {
  left: 10px;
  background: var(--surface);
  color: var(--text);
}

.zone-card-badge--held {
  background: var(--held);
  color: #ffffff;
}

.zone-card-badge--mine {
  background: var(--accent);
  color: #ffffff;
}

.zone-card-hot {
  right: 10px;
  background: var(--surface);
  color: var(--accent);
}

.zone-card-caption {
  margin: -2px 0 0;
}

/* The Wikimedia credit: a small tag in the photo's corner (hover it to see
   the photographer; click it for the photo's page). It sits above the
   card's big click area so it can be clicked on its own. */
.zone-card-credit {
  position: absolute;
  z-index: 1;
  right: 8px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-card-credit:hover {
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
}

.zone-card-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* The zone name is the card's real button (for keyboards and screen
   readers); its invisible ::after stretches over the whole card so a
   click anywhere on it counts. */
.zone-card-open {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
}

.zone-card-open::after {
  content: "";
  position: absolute;
  inset: 0;
}

.zone-card-open:focus-visible {
  outline: none;
}

.zone-card:has(.zone-card-open:focus-visible) .zone-card-media {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.zone-card-meta {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}

/* The challenge is the reason to go, so it reads as a quote: a short
   orange rule beside it, the same orange as the challenge box in the
   zone panel. Two lines max. */
.zone-card-challenge {
  margin: 6px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent-bright);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Bottom line: who holds it + votes (or "Unclaimed" + photo count).
   margin-top: auto keeps it lined up across a row of cards. */
.zone-card-footer {
  margin: auto 0 0;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.zone-card-holder {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-card--open .zone-card-holder {
  font-weight: 500;
  color: var(--text-dim);
}

.zone-card-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px dashed var(--open-ring);
}

.avatar--sm {
  width: 22px;
  height: 22px;
  font-size: 11px;
  background: var(--held);
  color: #ffffff;
}

.avatar--sm.avatar--me {
  background: var(--accent-bright);
}

.zone-card-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

.zone-card--mine .zone-card-stat {
  color: var(--accent);
}

/* List/Map button: phones and tablets only (see the media query below). */
.view-toggle {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: bottom 0.2s ease;
}

/* The small card that pops up when you tap a dot in map view. */
.map-preview {
  position: absolute;
  z-index: 1001; /* above Leaflet's zoom buttons and credits */
  left: 12px;
  right: 12px;
  bottom: 16px;
  max-width: 520px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-preview-open {
  width: 100%;
  display: flex;
  gap: 14px;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.map-preview-media {
  position: relative;
  width: 112px;
  height: 112px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

.map-preview-media .zone-card-img,
.map-preview-media .zone-card-empty {
  border-radius: 0;
}

.map-preview-media .zone-card-empty {
  font-size: 12px;
  gap: 6px;
  padding: 6px;
}

.map-preview-media .zone-card-empty svg {
  width: 24px;
  height: 24px;
}

.map-preview-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding-right: 28px; /* room for the close button */
}

.map-preview-title {
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.map-preview-challenge {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

#map-wrap {
  position: relative;
  z-index: 0; /* Leaflet's layers stack inside this box, under the feed */
  flex: 1;
  min-width: 0;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--map-bg);
}

.leaflet-container {
  font-family: var(--font-body);
}

.leaflet-bar {
  border: none !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
}

.leaflet-bar a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  color: var(--text) !important;
  border-bottom-color: var(--border) !important;
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.8) !important;
}

/* Brand signature #2: the legend for the turf circles. */
#map-legend {
  position: absolute;
  z-index: 800;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.legend-swatch--open {
  border: 1.5px dashed var(--open-ring);
}

.legend-swatch--held {
  background: rgba(34, 34, 34, 0.18);
  border: 1.5px solid rgba(34, 34, 34, 0.55);
}

.legend-swatch--mine {
  background: rgba(242, 113, 28, 0.3);
  border: 1.5px solid var(--accent-bright);
}

/* Markers: a small dot. White ring = open, charcoal = held, orange =
   yours. The selected zone gets a bigger dot inside viewfinder corners,
   plus its name on a label above. */

.turf-pin {
  position: relative;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.turf-pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--open-ring);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
}

.turf-pin:hover .turf-pin-dot,
.turf-pin--highlighted .turf-pin-dot {
  transform: scale(1.3);
}

.turf-pin--held .turf-pin-dot {
  background: var(--held);
  border: 3px solid var(--surface);
}

.turf-pin--mine .turf-pin-dot {
  background: var(--accent-bright);
  border: 3px solid var(--surface);
}

.turf-pin--selected {
  width: 56px;
  height: 56px;
  --vf-inset: 0px;
  --vf-color: var(--text);
}

.turf-pin--selected.turf-pin--mine {
  --vf-color: var(--accent);
}

.turf-pin--selected .turf-pin-dot {
  width: 26px;
  height: 26px;
  border-width: 4px;
}

.turf-pin-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--text);
  color: #ffffff;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

/* ---------------------------------------------------------------------- */
/* Panels (zone + leaderboard share these)                                 */
/* ---------------------------------------------------------------------- */

.panel {
  position: absolute;
  z-index: 1000; /* above Leaflet's own panes */
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 44px; /* room for the close button */
}

.panel-desc {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* On a computer the zone panel floats over the map, just right of the
   card feed. A bit wider than the leaderboard and roomier inside: it's
   where the actual playing happens. */
#turf-panel {
  left: calc(var(--feed-w) + 24px);
  width: min(420px, calc(100vw - 48px));
  gap: 20px;
  padding: 0 28px 28px;
}

/* The photo across the top runs edge to edge (cancelling the panel's side
   padding), like the cover photo on a listing. */
.panel-hero {
  position: relative;
  flex-shrink: 0;
  margin: 0 -28px;
  aspect-ratio: 16 / 10;
  min-height: 0;
  background: var(--surface-2);
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-hero .zone-card-img,
.panel-hero .zone-card-empty {
  border-radius: 0;
}

/* Viewfinder corners sit inside the photo here (there's no room outside). */
.panel-hero.vf {
  --vf-inset: 14px;
  --vf-len: 22px;
  --vf-color: #ffffff;
}

.panel-hero.vf::after {
  z-index: 1;
}

/* The close button floats over the photo, so it gets a white backing. */
#turf-panel .close-btn {
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

#turf-panel .panel-head {
  gap: 8px;
  padding-right: 0;
}

#turf-panel .panel-desc {
  margin-top: 4px;
}

#leaderboard-panel {
  right: 24px;
  width: min(340px, calc(100vw - 48px));
}

.challenge-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: 12px;
}

.challenge-box p {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

/* Submit-a-photo form */

#turf-submit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* The photo picker: a big, tall drop area with the camera icon on top,
   so it reads as "this is where your shot goes". */
.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 150px;
  padding: 24px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.upload-drop:hover {
  border-color: var(--accent-bright);
  background: var(--accent-soft);
}

.upload-drop:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-drop--chosen {
  border-style: solid;
  border-color: var(--accent-bright);
}

.upload-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.upload-title {
  max-width: 100%;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-dim);
}

.upload-drop--chosen .upload-icon {
  background: var(--accent-bright);
  color: #ffffff;
}

.geofence-note {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.geofence-note svg {
  flex-shrink: 0;
  color: var(--accent);
}

.login-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-dim);
}

.status-line {
  margin: -6px 0 0;
  min-height: 1em;
  font-size: 13px;
  color: var(--text-dim);
}

.status-line:empty {
  display: none;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Submissions gallery: a two-column photo grid. */

#turf-submissions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
}

.turf-submissions-empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.turf-submission {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.turf-submission-frame {
  position: relative;
  margin: 4px;
  aspect-ratio: 4 / 3;
}

.turf-submission-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
}

.turf-submission-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--held);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.turf-submission--mine .turf-submission-badge {
  background: var(--accent);
}

/* Brand signature #4: the film-edge caption under each photo. */
.film-caption {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turf-submission-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.turf-submission-user {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turf-submission-vote {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.turf-submission-vote:hover:not(:disabled) {
  border-color: var(--accent-bright);
}

.turf-submission-vote--active {
  border-color: var(--accent-bright);
  color: var(--accent);
}

.turf-submission-vote--active svg {
  fill: currentColor;
}

.turf-submission-vote:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------- */
/* Leaderboard                                                             */
/* ---------------------------------------------------------------------- */

#leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text);
}

/* Your own row: soft orange plus viewfinder corners. */
.leaderboard-row--me {
  background: #fff8f3;
  --vf-inset: -3px;
  --vf-len: 12px;
}

.leaderboard-rank {
  width: 24px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dim);
}

.leaderboard-row:first-child .leaderboard-rank {
  color: var(--accent);
}

.leaderboard-player {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaderboard-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-you {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

.leaderboard-score {
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 24px;
  font-weight: 800;
}

/* ---------------------------------------------------------------------- */
/* Log in / sign up window                                                 */
/* ---------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(34, 34, 34, 0.45);
}

.modal {
  position: relative;
  width: min(420px, 100%);
  padding: 32px 28px 24px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.field input:focus {
  outline: 2px solid var(--text);
  outline-offset: -1px;
}

.error-line {
  margin: 0;
  font-size: 13px;
  color: var(--danger);
}

.error-line:empty {
  display: none;
}

.modal-switch {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

/* ---------------------------------------------------------------------- */
/* Small screens                                                           */
/* ---------------------------------------------------------------------- */

@media (max-width: 900px) {
  .brand-divider,
  .brand-tagline {
    display: none;
  }

  /* Phones and tablets: the feed and the map stack on top of each other,
     and the List/Map button decides which one you see. The map is always
     drawn underneath, so Leaflet never loses track of its size. */
  #feed {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: auto;
    border-right: none;
  }

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

  .view-map #feed {
    display: none;
  }

  .view-toggle {
    display: flex;
  }

  /* Lift the button above the preview card when that's showing, and hide
     it while a panel (zone or leaderboard) is open. */
  body:has(.map-preview:not(.hidden)) .view-toggle {
    bottom: 160px;
  }

  body:has(.panel:not(.hidden)) .view-toggle,
  body:has(.modal-backdrop:not(.hidden)) .view-toggle {
    display: none;
  }

  /* Leave room at the bottom of the feed for the button. */
  .card-grid {
    padding-bottom: 104px;
  }

  #turf-panel {
    left: 24px;
  }

  /* The legend moves to the top so the List button has the bottom. */
  #map-legend {
    top: 12px;
    bottom: auto;
  }

  /* Pinch to zoom instead — the +/- buttons would sit under the cards. */
  .leaflet-control-zoom {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --header-h: 64px;
  }

  #app-header {
    padding: 0 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-wordmark {
    font-size: 23px;
  }

  .header-actions {
    gap: 6px;
  }

  /* Leaderboard becomes an icon-only round button. */
  .pill-btn {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .pill-btn-label {
    display: none;
  }

  /* Panels become bottom sheets. Only one is open at a time on a phone
     (leaderboard.js and app.js close the other one). */
  .panel {
    top: auto;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    width: 100% !important;
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
    padding: 20px 20px 28px;
  }

  #map-legend {
    gap: 14px;
    padding: 8px 14px;
    font-size: 10px;
  }

  .feed-head {
    padding: 18px 16px 12px;
  }

  .chips-scroller {
    margin: 0 -16px;
  }

  .chips {
    padding: 2px 16px;
  }

  .feed-status {
    margin: 14px 16px 0;
  }

  /* One big card per row, like a delivery app. */
  .card-grid {
    grid-template-columns: 1fr;
    padding: 20px 16px 104px;
    gap: 32px;
  }

  .zone-card-media {
    --vf-inset: -6px;
  }

  .display-title {
    font-size: 30px;
  }

  /* Zone panel as a bottom sheet: slimmer sides and a shorter photo, so
     the challenge and the upload area still show without scrolling. */
  #turf-panel {
    padding: 0 20px 28px;
  }

  .panel-hero {
    margin: 0 -20px;
    aspect-ratio: 16 / 8;
    border-radius: 20px 20px 0 0;
  }
}
