:root {
  --bg: #0e0e0c;
  --surface: #171714;
  --off-surface: #1c1c18;
  --text: #f2f0ea;
  --muted: #aca99e;
  --yellow: #ffc93c;
  --yellow-ink: #1a1400;
  --candle: #d98a4a;
  --line: #000;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

.brand {
  padding: 1rem 1rem 0.35rem;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

main {
  max-width: 640px;
  margin: 0 auto;
  /* Extra bottom padding so the fixed "Where light dey" button never
     permanently covers the Share button. */
  padding: 0 1rem calc(2rem + 3.75rem + env(safe-area-inset-bottom, 0px));
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.15rem 0 1rem;
}

.report-btn {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 1.85rem 0.6rem;
  border-radius: 0.4rem;
  border: 2px solid var(--line);
  cursor: pointer;
  line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 4px 4px 0 var(--line);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.report-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--line);
}

.report-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.report-btn--on {
  background: var(--yellow);
  color: var(--yellow-ink);
}

.report-btn--off {
  background: var(--off-surface);
  color: var(--candle);
}

@media (prefers-reduced-motion: reduce) {
  .report-btn {
    transition: none;
  }
}

.report-btn--on.glow {
  animation: bulbGlow 0.55s ease-out;
}

@keyframes bulbGlow {
  0% {
    box-shadow: 4px 4px 0 var(--line), 0 0 0 rgba(255, 201, 60, 0);
  }
  45% {
    box-shadow: 4px 4px 0 var(--line), 0 0 28px 10px rgba(255, 201, 60, 0.85);
  }
  100% {
    box-shadow: 4px 4px 0 var(--line), 0 0 0 rgba(255, 201, 60, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .report-btn--on.glow {
    animation: none;
  }
}

.status {
  min-height: 1.4rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  padding: 0.15rem 0;
}

.last-report {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9375rem;
  color: var(--muted);
  text-align: center;
  margin: 0 0 0.85rem;
  letter-spacing: 0.01em;
}

.map-wrap {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid var(--line);
}

#map {
  position: relative;
  height: 52vh;
  min-height: 300px;
  width: 100%;
  background: #0e0e0c;
  overflow: hidden;
}

/* Dark theme for MapLibre's default controls — its zoom buttons are a
   white card by default, which would break the "no default-library look"
   rule the same way Leaflet's white controls would have.
   Scoped under #map (not just the maplibre classes) because maplibre-gl.css
   is injected dynamically, after this stylesheet, so equal-specificity
   rules would otherwise lose to its defaults by source order — the extra
   #map makes these win regardless of load order. */
#map .maplibregl-ctrl-group {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 0.35rem;
  box-shadow: 3px 3px 0 var(--line);
  overflow: hidden;
}

#map .maplibregl-ctrl-group button {
  background-color: transparent;
}

#map .maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--off-surface);
}

#map .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.6);
}

#map .maplibregl-ctrl-attrib,
#map .maplibregl-ctrl-attrib-inner {
  background: transparent;
  color: var(--muted);
  font-size: 0.6875rem;
}

#map .maplibregl-ctrl-attrib a {
  color: var(--muted);
}

#map .maplibregl-ctrl-attrib-button {
  filter: invert(1) brightness(1.6);
}

/* Dark theme for the per-area tap popups (MapLibre, same idea as the old
   Leaflet popup styling). */
#map .maplibregl-popup-content {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 0.4rem;
  box-shadow: 3px 3px 0 var(--line);
  padding: 0.7rem 0.8rem;
  line-height: 1.4;
}

#map .maplibregl-popup-tip {
  border-top-color: var(--surface);
  border-bottom-color: var(--surface);
}

#map .maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 1.1rem;
}

/* No-WebGL / slow-connection fallback: flat colored patches, no basemap
   imagery, positioned with simple local math instead of a map projection. */
.map-fallback__note {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  z-index: 1;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
  text-align: center;
}

.map-fallback__dots {
  position: absolute;
  inset: 0;
}

.map-fallback__dot {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid var(--line);
  padding: 0;
  cursor: pointer;
}

.map-fallback__dot--on {
  background: var(--yellow);
  box-shadow: 0 0 16px 4px rgba(255, 201, 60, 0.45);
}

.map-fallback__dot--off {
  background: var(--candle);
  opacity: 0.8;
}

.map-fallback__dot--uncertain {
  background: var(--muted);
  opacity: 0.6;
}

.corner-btn {
  position: absolute;
  bottom: 0.75rem;
  z-index: 500;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9375rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.5rem 0.8rem;
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.corner-btn--left {
  left: 0.75rem;
}

.corner-btn--right {
  right: 0.75rem;
}

.corner-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .corner-btn {
    transition: none;
  }
}

.caption {
  text-align: center;
  color: var(--muted);
  font-size: 0.9375rem;
  margin: 0.85rem 0 0;
}

.caption--muted {
  margin-top: 0.3rem;
  opacity: 0.8;
}

/* "Your area" line: plain text, no card/shadow — just the status word
   picking up the one accent colour, same as everywhere else. */
.saved-area {
  text-align: center;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.15rem 0 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--off-surface);
}

.saved-area__prefix {
  color: var(--muted);
  font-weight: 500;
  margin-right: 0.35rem;
}

.saved-area__status--on {
  color: var(--yellow);
}

.saved-area__status--off {
  color: var(--candle);
}

.saved-area__status--uncertain {
  color: var(--muted);
}

.saved-area__meta {
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--muted);
  margin-left: 0.4rem;
}

/* "Light no dey your area" block: plain text + a short tappable list, no
   card/shadow — same restrained treatment as the rest of the page. */
.nearby-light {
  margin: 0 0 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--off-surface);
}

.nearby-light__headline {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.nearby-light__list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nearby-light__item {
  display: block;
  width: 100%;
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--off-surface);
  border: 2px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 2px 2px 0 var(--line);
}

.nearby-light__item::before {
  content: "💡 ";
}

.nearby-light__item:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .nearby-light__item {
    transition: none;
  }
}

.nearby-light__count {
  margin: 0;
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9375rem;
  color: var(--muted);
}

.share-btn {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.9375rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.75rem;
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.share-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .share-btn {
    transition: none;
  }
}

.cell-popup__label {
  display: block;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.cell-popup__label--on {
  color: var(--yellow);
}

.cell-popup__label--off {
  color: var(--candle);
}

.cell-popup__label--uncertain {
  color: var(--muted);
}

.cell-popup__meta {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9375rem;
  color: var(--text);
}

.cell-popup__note {
  display: block;
  font-size: 0.9375rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* Fixed "Where light dey" button: same flat/dark/offset-shadow language as
   the rest of the app, just pinned to the bottom of the viewport (not the
   page flow) so it's always within thumb reach. Not solid bulb-yellow —
   the accent is reserved for places that actually HAVE light, and this
   button doesn't claim that. */
.where-light-btn {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  z-index: 600;
  max-width: 608px; /* main's max-width (640px) minus its side padding */
  margin: 0 auto;
  display: block;
  width: calc(100% - 2rem);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.85rem;
  box-shadow: 4px 4px 0 var(--line);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.where-light-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .where-light-btn {
    transition: none;
  }
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  padding: 0;
}

/* Bottom sheet: flat dark surface, hard top border instead of a soft
   blurred shadow, minimal corner rounding — stays in the app's language
   rather than reading as a default Material/iOS sheet. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 701;
  max-width: 640px;
  margin: 0 auto;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 2px solid var(--line);
  border-bottom: none;
  border-radius: 0.6rem 0.6rem 0 0;
  padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  transition: transform 0.2s ease;
}

/* .sheet sets its own `display`, which (being an author rule) would
   otherwise silently beat the browser default [hidden]{display:none} —
   same-origin rules lose to author rules regardless of specificity, so
   without this override the sheet would stay visible even while hidden. */
.sheet[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    transition: none;
  }
}

.sheet__handle {
  width: 2.5rem;
  height: 0.3rem;
  margin: 0.35rem auto 0.6rem;
  border-radius: 999px;
  background: var(--off-surface);
  /* Swipe-to-dismiss is bound to this handle (and the header), not the
     whole sheet, so the list below keeps normal touch scrolling. */
  touch-action: none;
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  touch-action: none;
}

.sheet__title {
  margin: 0;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.sheet__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
}

.sheet__list {
  overflow-y: auto;
}

.sheet__empty {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

@media (min-width: 480px) {
  .report-btn {
    font-size: 1.3rem;
  }
}
