/* Mobile first: on phones the panel is a sheet at the bottom that can be minimized.
   On wide screens it becomes a sidebar on the left. */
:root {
  --ink: #16233a;
  --muted: #55627a;
  --line: #8793a6;        /* visible border colour for inputs and buttons */
  --line-soft: #d5dbe5;
  --blue: #0b5cad;
  --red: #d21034;
  --topbar-height: 48px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font: 15px/1.4 system-ui, sans-serif;
  color: var(--ink);
}

[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  z-index: 700;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 12px;
  background: var(--blue);
  color: #fff;
}
.topbar strong { flex: 1; }
.topbar a { color: #fff; }

/* ---------- Map and the two always-visible controls on it ---------- */
#map {
  position: absolute;
  inset: 0;
}

.cta {
  position: absolute;
  z-index: 550;
  top: calc(var(--topbar-height) + 12px);
  left: 12px;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  border: 1.5px solid #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

.map-switch {
  position: absolute;
  z-index: 550;
  top: calc(var(--topbar-height) + 12px);
  right: 12px;
  width: auto;
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

/* ---------- Panel ---------- */
#panel {
  position: absolute;
  z-index: 600;
  left: 0; right: 0; bottom: 0;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0 14px 14px;
  background: #fff;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, .3);
}

/* The handle stays at the top of the panel while it scrolls. */
.panel-toggle {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: calc(100% + 28px);
  margin: 0 -14px 6px;
  padding: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 14px 14px 0 0;
}

/* Minimized: only the handle remains, so the map is fully visible. */
#panel.minimized { overflow: hidden; max-height: none; padding-bottom: 0; }
#panel.minimized > section { display: none !important; }
#panel.minimized .panel-toggle { border-bottom: 0; margin-bottom: 0; }

@media (min-width: 800px) {
  #panel {
    top: var(--topbar-height);
    right: auto;
    width: 400px;
    max-height: none;
    border-radius: 0;
  }
  #panel.minimized {
    bottom: auto;
    width: auto;
    border-radius: 0 0 12px 0;
  }
  .panel-toggle { border-radius: 0; }
  /* Start the controls to the right of the sidebar so nothing is hidden behind it. */
  .cta { left: 416px; }
}

/* The map's zoom buttons and copyright line sit just above the panel, never behind it. */
.leaflet-bottom { bottom: var(--panel-offset, 0px); }

/* ---------- Language switch (top bar) ---------- */
.lang-form { margin: 0; }
.lang-select {
  width: auto;
  margin: 0;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  border-color: #fff;
}

/* ---------- Text ---------- */
h2 { margin: 0 0 6px; font-size: 18px; }
h3 { margin: 14px 0 4px; font-size: 14px; }
p { margin: 4px 0 8px; color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); }

.note {
  padding: 8px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #eef5ff;
  font-size: 13px;
  color: var(--ink);
}

/* ---------- Form fields: clearly visible borders ---------- */
label { display: block; margin-top: 4px; font-size: 13px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  margin: 2px 0 8px;
  padding: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 7px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 92, 173, .25);
}

button {
  margin: 3px 3px 3px 0;
  padding: 8px 11px;
  font: inherit;
  font-size: 12px;
  color: var(--blue);
  background: #fff;
  border: 1.5px solid var(--blue);
  border-radius: 7px;
  cursor: pointer;
}
button.primary { color: #fff; background: var(--blue); }
button.danger { color: var(--red); border-color: var(--red); }
button:disabled { opacity: .4; cursor: default; }

/* Small, quiet text link (used for "About this project") */
button.link {
  margin: 0;
  padding: 4px 0;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
}
.footer-link { margin-top: 18px; text-align: center; }

.row { display: flex; gap: 6px; }
.row > * { flex: 1; min-width: 0; }

.legend span { display: block; font-size: 13px; }
.legend i {
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 6px;
  border-radius: 3px;
}

.card {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1.5px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  color: #fff;
  border-radius: 10px;
}

/* Drawing markers. The marker box is large (easy to grab with a finger); the dot inside is smaller. */
.vertex, .midpoint {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
}
.vertex span {
  width: 16px; height: 16px;
  background: #fff;
  border: 3px solid var(--red);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
/* Small dots between two points: drag or tap one to add a new point there */
.midpoint span {
  width: 10px; height: 10px;
  background: rgba(255, 255, 255, .85);
  border: 2px solid var(--red);
  border-radius: 50%;
  opacity: .85;
}
.midpoint:hover span { opacity: 1; transform: scale(1.3); }

/* ---------- Emphasis animations (SVG outlines drawn by Leaflet) ---------- */
@keyframes outline-pulse {
  0%, 100% { stroke-opacity: 1; }
  50%      { stroke-opacity: .3; }
}
.selected-outline { animation: outline-pulse 1.4s ease-in-out infinite; }  /* the clicked quarter */
.area-highlight   { animation: outline-pulse .9s ease-in-out infinite; }   /* the chosen department/commune/section */

/* Visitors who asked their device for less motion get a steady (still very visible) outline. */
@media (prefers-reduced-motion: reduce) {
  .selected-outline, .area-highlight { animation: none; }
}

/* ---------- "Show my location" button and the blue dot ---------- */
.locate-control a { display: flex; align-items: center; justify-content: center; color: var(--ink); }
.locate-control a.locating svg { animation: outline-pulse .8s ease-in-out infinite; }
.me-marker span {
  display: block;
  width: 16px; height: 16px;
  margin: 3px;
  background: #1a73e8;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .45);
}

/* ---------- Review page ---------- */
body.review { display: flex; flex-direction: column; height: auto; min-height: 100%; }
body.review .topbar { position: static; }
#review-map { height: 55vh; }
.review-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 12px; }
.review-controls select, .review-controls input { width: auto; margin: 0; }
.review-controls label { display: flex; align-items: center; gap: 6px; margin: 0; }
.review-table { padding: 0 12px 24px; overflow-x: auto; }
.review-table table { width: 100%; border-collapse: collapse; }
.review-table th, .review-table td {
  padding: 6px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
.review-table form input, .review-table form select { width: auto; margin: 2px 0; font-size: 12px; padding: 5px; }
