/* Sign-in, photo reporting and the mobile layout.
   Loaded after the base <style> in index.html, so it also carries the
   responsive overrides for the existing map chrome. */

:root {
  --report: #0f7d6b;
  --danger: #b3261e;
  --shadow-1: 0 1px 4px rgba(0, 0, 0, .12);
  --shadow-2: 0 8px 30px rgba(0, 0, 0, .18);
  --peek: 48px;               /* visible height of the collapsed bottom sheet */
}

body.noscroll { overflow: hidden; }
/* display:flex on a component would otherwise beat the [hidden] UA rule */
[hidden] { display: none !important; }

/* ---------- buttons ------------------------------------------------------ */
.btn {
  font: inherit; font-size: 14px; border: 1px solid transparent; border-radius: 8px;
  padding: 11px 16px; cursor: pointer; background: #fff; color: var(--ink);
  min-height: 44px;
}
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:disabled { background: #d8d3cd; color: #fff; cursor: not-allowed; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: #eccdcb; color: var(--danger); background: #fdf6f5; }
.btn.link {
  background: none; border: none; color: var(--accent); padding: 8px 4px;
  text-decoration: underline; min-height: 0;
}
.btn.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.btn.small { font-size: 12.5px; padding: 4px 6px; min-height: 0; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.iconbtn {
  border: none; background: none; font-size: 18px; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 8px; border-radius: 8px; min-width: 40px; min-height: 40px;
}
.iconbtn:hover { background: #f3f5f8; }

/* ---------- header account chip ----------------------------------------- */
header { position: relative; }
#account { margin-left: auto; position: relative; align-self: center; }
.chip {
  font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.chip .avatar {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 11px;
}
.acctmenu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; z-index: 40;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-2);
  overflow: hidden; min-width: 130px;
}
.acctmenu button {
  display: block; width: 100%; text-align: left; padding: 10px 14px; font: inherit;
  font-size: 13px; border: none; background: none; cursor: pointer;
}
.acctmenu button:hover { background: #f6f8fa; }

/* ---------- overlays (sign-in + composer) ------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 27, 35, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }

.authcard, .sheetcard {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-2);
  width: 100%; max-width: 400px; padding: 24px; position: relative;
}
.authbrand {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.authcard h2 { font-size: 21px; margin: 0 0 6px; }
.authsub { font-size: 13.5px; color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.authfine { font-size: 11.5px; color: var(--muted); margin: 14px 0 0; line-height: 1.4; }
.authtick {
  width: 46px; height: 46px; border-radius: 50%; background: #e7f4ef; color: var(--report);
  display: grid; place-items: center; font-size: 24px; margin-bottom: 12px;
}
.btn.back { position: absolute; top: 14px; right: 16px; font-size: 12.5px; }
.fieldlabel {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.phonefield {
  display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden;
}
.phonefield:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179, 84, 30, .12); }
.phonefield .cc {
  background: #f6f8fa; padding: 12px 12px; font-size: 15px; color: var(--muted);
  border-right: 1px solid var(--line); display: flex; align-items: center;
}
.phonefield input {
  flex: 1; min-width: 0; border: none; outline: none; padding: 12px;
  font: inherit; font-size: 17px; letter-spacing: .04em;
}
.otpboxes { display: flex; gap: 8px; margin-bottom: 4px; }
.otpbox {
  flex: 1; min-width: 0; text-align: center; font: inherit; font-size: 22px;
  padding: 12px 0; border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.otpbox:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179, 84, 30, .12); }
.autherr {
  color: var(--danger); font-size: 12.5px; margin-top: 10px;
  background: #fdf1f0; border: 1px solid #f3d6d3; border-radius: 8px; padding: 8px 10px;
}

/* ---------- composer ----------------------------------------------------- */
.sheetcard { max-width: 440px; padding: 0; display: flex; flex-direction: column; max-height: 92vh; }
.sheetcard > header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: none;
}
.sheetcard > header h2 { font-size: 17px; margin: 0; }
.compbody { padding: 16px; overflow-y: auto; }
.sheetcard > footer {
  display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line);
}
.sheetcard > footer .btn { flex: 1; }

.photodrop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
  border: 1.5px dashed #cfd8e2; border-radius: 12px; padding: 26px 16px; text-align: center;
  background: #fafbfc;
}
.photodrop:hover { border-color: var(--accent); background: #fdf8f4; }
.photodrop .camicon { font-size: 28px; }
.photodrop .dropmain { font-weight: 600; font-size: 14.5px; }
.photodrop .dropsub { font-size: 12px; color: var(--muted); }
.photopreview { position: relative; }
.photopreview img {
  width: 100%; border-radius: 12px; display: block; max-height: 260px; object-fit: cover;
}
.photopreview .btn {
  position: absolute; right: 8px; bottom: 8px; background: rgba(255, 255, 255, .93);
  border: 1px solid var(--line); border-radius: 8px;
}
#compcomment {
  width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); outline: none; resize: vertical;
}
#compcomment:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179, 84, 30, .12); }

.geobox {
  margin: 14px 0; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px;
}
.georow { display: flex; align-items: flex-start; gap: 10px; }
.geotext { flex: 1; min-width: 0; }
.geoactions {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0 19px;
}
.geobox .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.geobox .sub.warn { color: #8a6116; }
.geodot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.geobox.locating { background: #f6f8fa; }
.geobox.locating .geodot { background: #8a919b; animation: pulse 1.1s ease-in-out infinite; }
.geobox.ok { background: #f0f8f5; border-color: #cfe7de; }
.geobox.ok .geodot { background: var(--report); }
.geobox.bad { background: #fdf1f0; border-color: #f3d6d3; }
.geobox.bad .geodot { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- report markers, cards and detail ---------------------------- */
.reportmarker {
  border: none; background: none; padding: 0; cursor: pointer; display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .35));
}
.reportmarker img {
  width: 42px; height: 42px; object-fit: cover; border-radius: 9px;
  border: 2.5px solid var(--report); background: #fff; display: block;
}
.reportmarker .tail {
  display: block; width: 0; height: 0; margin: -1px auto 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 7px solid var(--report);
}
.reportmarker:hover img { border-color: var(--accent); }
.reportmarker:hover .tail { border-top-color: var(--accent); }

.reportgrid { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.reportcard {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  cursor: pointer; font: inherit;
}
.reportcard:hover { border-color: var(--report); }
.reportcard img { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; flex: none; }
.rc-body { min-width: 0; }
.rc-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 12.5px; line-height: 1.35;
}
.rc-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.reportphoto { width: 100%; border-radius: 10px; display: block; margin: 10px 0; }
.reportcomment { font-size: 14px; line-height: 1.45; margin: 0 0 10px; }

/* ---------- map chrome --------------------------------------------------- */
#mapui {
  position: absolute; top: 10px; left: 10px; right: 58px; z-index: 4;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
  align-items: flex-start;
}
#mapui > *, #controls > * { pointer-events: auto; }
#topbar { display: flex; gap: 8px; width: 100%; }
#controls { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#ctrltoggle { display: none; }

/* the base stylesheet positions these absolutely; inside #mapui they stack */
#searchbox, #layertoggle, #metricsel, #tendertoggle, #reporttoggle, #searcherr {
  position: static; top: auto; left: auto;
}
#reporttoggle {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  font-size: 12.5px; box-shadow: var(--shadow-1); cursor: pointer;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
#reporttoggle .dot {
  width: 9px; height: 9px; border-radius: 3px; background: var(--report);
  border: 1px solid rgba(0, 0, 0, .15);
}
#searcherr { box-shadow: var(--shadow-1); }

#fab {
  position: absolute; right: 14px; bottom: 24px; z-index: 6; display: flex;
  align-items: center; gap: 8px; border: none; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600;
  padding: 13px 20px; box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
#fab:hover { background: #9c4818; }
#fab .fabicon { font-size: 16px; }

#legend .legendhead { display: none; }   /* mobile-only collapse control */

/* ---------- mobile ------------------------------------------------------- */
@media (max-width: 760px) {
  html, body { height: 100%; overscroll-behavior-y: none; }
  #app { height: 100dvh; }

  header { padding: 9px 12px; gap: 4px 10px; flex-wrap: nowrap; align-items: center; }
  header h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chip.signedin .phonetext { display: none; }   /* avatar only on narrow headers */
  .chip.signedin { padding: 5px; border-radius: 50%; }
  header .caveat { display: none; }
  header.expanded { flex-wrap: wrap; }
  header.expanded .caveat { display: block; font-size: 11.5px; width: 100%; }
  #infotoggle { display: inline-flex; }

  #main { display: block; position: relative; }
  #mapwrap { position: absolute; inset: 0; }

  #mapui { right: 10px; top: 8px; left: 8px; }
  #topbar { align-items: stretch; }
  #searchbox { flex: 1; }
  #searchbox input { width: 100%; font-size: 16px; }   /* 16px stops iOS zoom-on-focus */
  #searchbox button { padding: 9px 14px; }
  #ctrltoggle {
    display: flex; align-items: center; gap: 6px; background: #fff; color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; font: inherit;
    font-size: 13px; box-shadow: var(--shadow-1); cursor: pointer; white-space: nowrap;
  }
  #ctrltoggle[aria-expanded="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
  #controls {
    display: none; background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px; box-shadow: var(--shadow-2); width: 100%; max-width: 320px;
  }
  #controls.open { display: flex; }
  #layertoggle, #metricsel { width: 100%; box-shadow: none; }
  #layertoggle button { flex: 1; padding: 9px 8px; }
  #metricsel { max-width: none; padding: 9px 8px; font-size: 13px; }
  #tendertoggle, #reporttoggle { box-shadow: none; padding: 4px 2px; border: none; }

  .maplibregl-ctrl-top-right { top: 52px; }

  #legend {
    bottom: calc(var(--peek) + 12px); left: 8px; max-width: 62vw; padding: 7px 10px;
    font-size: 11px;
  }
  #legend .legendhead {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-weight: 700; font-size: 11.5px;
  }
  #legend.collapsed .legendbody { display: none; }
  #legend .legendtoggle {
    border: none; background: none; font-size: 16px; line-height: 1;
    color: var(--muted); cursor: pointer; padding: 2px 6px; min-width: 28px;
  }

  #fab { bottom: calc(var(--peek) + 12px); right: 8px; padding: 12px 16px; }

  /* Attribution (tiles, spend data, the ODbL boundary credit) has to stay readable,
     and at this width it otherwise sits under the bottom sheet and the report FAB —
     the ⓘ toggle included, so the credit could not even be opened. Lift it clear. */
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--peek) + 66px); }
  .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
    max-width: calc(100vw - 32px);
  }

  /* the details panel becomes a drag-to-open bottom sheet */
  #panelwrap {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 84dvh;
    background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
    display: flex; flex-direction: column; border-left: none;
    transform: translateY(calc(100% - var(--peek)));
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    touch-action: none;
  }
  #panelwrap.open { transform: translateY(0); }
  #panelwrap.dragging { transition: none; }
  #sheetgrip {
    display: block; padding: 7px 16px 9px; cursor: grab; flex: none;
    border-bottom: 1px solid var(--line); user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  #sheetgrip .bar {
    display: block; width: 40px; height: 4px; border-radius: 2px; background: #cfd6de;
    margin: 0 auto 7px;
  }
  #sheettitle {
    display: block; font-size: 13px; font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  #sheettitle .hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }
  #panel {
    width: 100%; max-width: none; border: none; flex: 1; min-height: 0;
    -webkit-overflow-scrolling: touch; padding-bottom: 40px; touch-action: pan-y;
  }

  .overlay { padding: 0; align-items: flex-end; }
  .authcard, .sheetcard {
    max-width: none; border-radius: 16px 16px 0 0; max-height: 94dvh; overflow-y: auto;
  }
  .sheetcard { overflow: hidden; }
  .authcard { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .sheetcard > footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* desktop: sheet chrome is not used */
@media (min-width: 761px) {
  #sheetgrip { display: none; }
  #panelwrap {
    width: var(--panel-w); max-width: 45vw; border-left: 1px solid var(--line);
    display: flex; flex-direction: column; min-height: 0;
  }
  #panel { width: 100%; max-width: none; border-left: none; flex: 1; }
  #infotoggle { display: none; }
}

/* Clerk's Smart CAPTCHA; usually invisible, but reserve room so the sheet
   doesn't jump when a challenge is actually shown. */
.authcaptcha:not(:empty) { margin: 10px 0; display: flex; justify-content: center; }
