/* CraterHater — public app styles */
:root {
  --navy: #1b2533;
  --navy-2: #243044;
  --blue: #2f6fed;
  --blue-dark: #2159c9;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #121826;
  --muted: #5d6778;
  --line: #e3e7ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);

  --st-reported: #d93636;
  --st-verified: #e27d0c;
  --st-scheduled: #2f6fed;
  --st-fixed: #1f9d55;
  --st-rejected: #7a8494;

  --topbar-h: 64px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .75rem; }
.empty { color: var(--muted); text-align: center; padding: 1.25rem .5rem; list-style: none; }
svg { width: 24px; height: 24px; fill: currentColor; }
svg.outline, svg .outline { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.outline .fill { fill: currentColor; stroke: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 1rem 0;
  background: var(--navy);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 50px; height: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.brand-tag { font-size: .8rem; color: #c3cbd8; }

.offline-banner {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 999;
  background: #fff4d6; color: #6b4a00; font-size: .85rem; padding: .45rem 1rem; text-align: center;
  border-bottom: 1px solid #f1dc9c;
}

/* ---------- Main / pages ---------- */
.main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 1.5rem); }
.page { max-width: 720px; margin: 0 auto; padding: 1.25rem 1rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; margin-bottom: 1rem;
}

/* ---------- Maps ---------- */
.map { width: 100%; background: #dde3ea; }
.home-map { position: relative; height: 42vh; min-height: 260px; }
.home-map .map { height: 100%; }
.full-map { position: fixed; inset: calc(var(--topbar-h) + var(--safe-t)) 0 calc(var(--tabbar-h) + var(--safe-b)) 0; }
.full-map .map { height: 100%; }
.main-map { padding-bottom: 0; }
.map-small { height: 260px; border-radius: 10px; overflow: hidden; }
.map-buttons {
  position: absolute; right: .75rem; bottom: 2rem; z-index: 500;
  display: flex; flex-direction: column; gap: .6rem;
}
.full-map .map-buttons { bottom: 1.5rem; }
/* Keep the OSM attribution visible above the overlapping home sheet, and zoom clear of the filter chips */
.home-map .leaflet-bottom { bottom: 1.25rem; }
.full-map .leaflet-top { top: 3.25rem; }
.map-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.2);
  display: grid; place-items: center;
}
.map-btn:active { transform: scale(.96); }
.map-note {
  position: absolute; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 500;
  background: rgba(27, 37, 51, .9); color: #fff; padding: .4rem .8rem; border-radius: 999px; font-size: .85rem;
}
.filter-chips {
  position: absolute; top: .75rem; left: .75rem; right: .75rem; z-index: 500;
  display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none;
}
.chip {
  flex: none; display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 999px; padding: .35rem .75rem; font-size: .85rem; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.chip[aria-pressed="false"] { opacity: .55; }

/* Map pins: a teardrop in the status colour with a white centre */
.pin { background: none; border: 0; }
.pin span {
  position: absolute; left: 3px; top: 1px; width: 26px; height: 26px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--pin, var(--st-reported));
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.pin span::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #fff;
}
.pin-reported { --pin: var(--st-reported); }
.pin-verified { --pin: var(--st-verified); }
.pin-scheduled { --pin: var(--st-scheduled); }
.pin-fixed { --pin: var(--st-fixed); }
.pin-rejected { --pin: var(--st-rejected); }
.pin-new span { --pin: var(--navy); width: 30px; height: 30px; left: 1px; top: -3px; }
.me-dot {
  width: 16px; height: 16px; border-radius: 50%; background: #2f80ed; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47, 128, 237, .25);
}
.leaflet-popup-content { margin: .6rem .75rem; min-width: 180px; }
.popup { display: flex; gap: .6rem; align-items: flex-start; }
.popup .thumb { width: 56px; height: 56px; flex: none; border-radius: 8px; }
a.popup { color: inherit; }
a.popup:hover { text-decoration: none; }
.popup .meta { font-size: .8rem; color: var(--muted); }

/* ---------- Home sheet ---------- */
.sheet {
  position: relative; z-index: 600; margin-top: -1.25rem;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 1.25rem 1rem 0;
  max-width: 820px; margin-left: auto; margin-right: auto;
}
.btn-report {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  background: var(--blue); color: #fff; font-size: 1.35rem; font-weight: 700;
  border-radius: var(--radius); padding: 1.05rem 1rem; box-shadow: 0 4px 14px rgba(47, 111, 237, .35);
}
.btn-report:hover { background: var(--blue-dark); text-decoration: none; }
.btn-report svg { width: 32px; height: 32px; }
.btn-sub { text-align: center; color: var(--muted); margin: .6rem 0 1rem; }

.stat-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem .5rem; margin-bottom: 1.5rem;
}
.stat { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: 0 .4rem; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat strong { display: block; font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: .78rem; color: var(--muted); line-height: 1.2; }
.stat-icon { width: 30px; height: 30px; flex: none; }
.icon-warn { color: #5d6778; }
.icon-ok circle { fill: var(--st-fixed); }
.icon-ok .tick { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-people { color: #5d6778; }
@media (max-width: 420px) {
  .stat { flex-direction: column; text-align: center; gap: .25rem; }
  .stat-icon { width: 24px; height: 24px; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 1.25rem 0 .6rem; }
.section-head h2 { font-size: 1.3rem; margin: 0; }

/* ---------- Report lists ---------- */
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.report-card {
  display: flex; gap: .85rem; align-items: stretch;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .75rem;
  color: inherit;
}
a.report-card:hover { text-decoration: none; box-shadow: 0 2px 4px rgba(16,24,40,.08), 0 6px 18px rgba(16,24,40,.1); }
.report-card .thumb { width: 88px; height: 88px; flex: none; }
.thumb { object-fit: cover; border-radius: 10px; background: #d7dce3; display: block; }
.thumb-none {
  display: grid; place-items: center;
  background: #dfe3ea url("/static/icons/mark.png") center / 60% no-repeat;
}
/* Map crop used as the thumbnail for reports without a photo (see js/maptile.js) */
.map-thumb { position: relative; overflow: hidden; background-color: #dde3ea; }
.map-thumb-origin { position: absolute; left: 50%; top: 50%; }
.map-thumb img { position: absolute; width: 256px; height: 256px; max-width: none; }
.map-thumb .pin { position: absolute; left: -16px; top: -36px; width: 32px; height: 36px; }
.map-thumb.thumb-none .map-thumb-origin { display: none; }
.report-list.compact .map-thumb .pin, .admin-table .map-thumb .pin { transform: scale(.7); transform-origin: 16px 36px; }
.attribution { font-size: .75rem; color: var(--muted); text-align: center; margin: 1.25rem 0 0; }
.report-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.report-card .title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.report-card .title { font-weight: 700; }
.report-card .note { color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.report-card .meta { color: var(--muted); font-size: .82rem; margin-top: auto; }
.report-list.compact .report-card { padding: .5rem; box-shadow: none; border: 1px solid var(--line); }
.report-list.compact .thumb { width: 56px; height: 56px; }
.report-card .actions { display: flex; gap: .4rem; margin-top: .35rem; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
  font-size: .8rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, white);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-reported { --c: var(--st-reported); }
.badge-verified { --c: #b86200; }
.badge-scheduled { --c: var(--st-scheduled); }
.badge-fixed { --c: #17803f; }
.badge-rejected { --c: #5d6778; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.dot-reported { --c: var(--st-reported); }
.dot-verified { --c: var(--st-verified); }
.dot-scheduled { --c: var(--st-scheduled); }
.dot-fixed { --c: var(--st-fixed); }
.dot-rejected { --c: var(--st-rejected); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 10px; padding: .7rem 1.1rem; font: inherit; font-weight: 600;
  cursor: pointer; text-align: center; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: #e8eefc; color: var(--blue-dark); }
.btn-secondary:hover { background: #dbe5fb; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn-small { padding: .35rem .75rem; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; padding: .95rem; font-size: 1.1rem; }
:focus-visible { outline: 3px solid #8fb2ff; outline-offset: 2px; }

textarea, input[type="text"], input[type="password"], select {
  width: 100%; font: inherit; color: inherit; padding: .65rem .75rem;
  border: 1px solid #cfd5df; border-radius: 10px; background: #fff;
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .92rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.form-error { background: #fdecec; color: #9b1c1c; border-radius: 10px; padding: .7rem .9rem; }
.form-ok { background: #e7f6ed; color: #15623a; border-radius: 10px; padding: .7rem .9rem; }

/* ---------- Report form ---------- */
.report-form h2 { display: flex; align-items: center; gap: .5rem; }
.step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: .85rem;
}
.optional { font-weight: 400; color: var(--muted); font-size: .9rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .75rem; }
.photo-grid:empty { display: none; }
.photo-grid figure { position: relative; margin: 0; aspect-ratio: 1; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.photo-grid button {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.65); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.nearby { margin-top: 1rem; }

/* ---------- Detail ---------- */
.detail .gallery { display: flex; gap: .5rem; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -1rem 1rem; padding: 0 1rem; }
.detail .gallery figure { margin: 0; flex: 0 0 85%; scroll-snap-align: center; }
.detail .gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: #d7dce3; }
.detail .gallery figcaption { font-size: .8rem; color: var(--muted); text-transform: capitalize; margin-top: .25rem; }
.detail .gallery figure:only-child { flex-basis: 100%; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.detail-head h1 { margin: 0; }
.detail .note { font-size: 1.05rem; margin: .75rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.metoo { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.metoo .count { font-size: .95rem; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem .5rem; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1.1rem - 6px); top: .35rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--line); border: 2px solid #fff;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .85rem; margin-left: .35rem; }
.timeline p { margin: .3rem 0 0; overflow-wrap: anywhere; }

/* ---------- Stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; }
.tile .label { font-size: .85rem; color: var(--muted); }
.tile .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 7.5rem 1fr 3rem; align-items: center; gap: .6rem; }
.bar-row .name { font-size: .92rem; }
.bar-track { height: 14px; border-radius: 4px; background: #eef1f5; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--c); min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); color: #6a7384; font-size: .75rem; font-weight: 500;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--blue); font-weight: 700; }
.tab-report { justify-content: flex-end; padding-bottom: 8px; }
.fab {
  display: grid; place-items: center; width: 58px; height: 58px; margin-top: -30px; margin-bottom: 2px;
  border-radius: 50%; background: var(--blue); color: #fff;
  box-shadow: 0 4px 14px rgba(47, 111, 237, .45); border: 4px solid #fff;
}
.fab svg { width: 30px; height: 30px; stroke-width: 2.6; }

@media (min-width: 900px) {
  .home-map { height: 48vh; }
}
