/* Dublin Parking Finder
   Design language: the DCC street sign. Every zone in Dublin is identified by
   a coloured strip on the sign plate; that strip is the app's signature —
   it runs down the left edge of every result card and colours every marker.
   Palette: sign-plate navy, kerb white, and the five statutory zone colours
   used strictly as data, never decoration. */

:root {
  --plate: #10243e;        /* DCC sign-plate navy */
  --plate-deep: #0a1a2f;
  --kerb: #f7f8f6;         /* kerbstone off-white */
  --ink: #14202e;
  --muted: #5a6b7d;
  --line: #d9dfe6;
  --warn: #b45309;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--kerb);
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------- header */

header {
  background: var(--plate);
  color: #fff;
  padding: 10px 14px 12px;
  position: relative;
  z-index: 1000;
}
.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand h1 .p-badge {
  display: inline-block;
  background: #fff;
  color: var(--plate);
  border-radius: 4px;
  padding: 0 6px;
  margin-right: 6px;
  font-weight: 900;
}
#settings-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.searchbar { display: flex; gap: 8px; margin-top: 10px; position: relative; }

#suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
}
#suggestions li {
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--plate, #10243e);
}
#suggestions li[aria-selected="true"],
#suggestions li:hover {
  background: var(--kerb, #f7f8f6);
}
#destination {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
}
#search-btn {
  background: #f5c400;
  color: var(--plate-deep);
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}
#search-btn:disabled { opacity: 0.6; }

.disclaimer {
  margin: 8px 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.75);
}

#settings {
  display: none;
  margin-top: 10px;
  padding: 10px;
  background: var(--plate-deep);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
#settings.open { display: block; }
#settings label { display: block; margin-bottom: 6px; }
#settings select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: none;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- map */

#map { height: 42vh; min-height: 260px; width: 100%; }

.zone-marker {
  width: 30px;
  height: 30px;
  border-radius: 6px 6px 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: rotate(-4deg);
}
.dest-marker {
  font-size: 26px;
  color: var(--plate);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

/* -------------------------------------------------------------- results */

main { flex: 1; overflow-y: auto; padding: 12px 12px 60px; }

#results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
#results-header h2 { font-size: 0.95rem; margin: 0; }
.sort {
  display: flex;
  gap: 4px;
  background: #e7ebef;
  border-radius: 999px;
  padding: 3px;
}
.sort label {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.sort input { display: none; }
.sort input:checked + span { font-weight: 700; }
.sort label:has(input:checked) { background: var(--plate); color: #fff; }

#results { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.card {
  display: grid;
  grid-template-columns: 8px 1fr;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.card.selected { outline: 3px solid var(--plate); }
.card-strip { background: var(--zone-color); }
.card-body { padding: 10px 12px; }

.card-top { display: flex; align-items: baseline; gap: 8px; }
.card-top .rank {
  font-weight: 900;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 1.2em;
}
.card-top h3 { margin: 0; font-size: 1rem; flex: 1; }
.card-top .rate { font-weight: 800; white-space: nowrap; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.zone-chip {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
}
.clearway { color: var(--warn); font-weight: 700; }

.rules { margin: 8px 0 0; font-size: 0.8rem; }
.rules div { display: flex; gap: 6px; }
.rules dt { font-weight: 700; min-width: 82px; color: var(--muted); }
.rules dd { margin: 0; }

.plate-note {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
}

.actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--plate); color: #fff; border-color: var(--plate); }
.btn:focus-visible, #search-btn:focus-visible, #settings-btn:focus-visible {
  outline: 3px solid #f5c400;
  outline-offset: 2px;
}

.empty {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

#error {
  background: #fdeaea;
  color: #8a1f1f;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}

#data-count {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 14px;
}

#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--plate-deep);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 2000;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}

@media (min-width: 900px) {
  body { flex-direction: row; flex-wrap: wrap; }
  header { width: 100%; }
  #map { width: 55%; height: calc(100vh - 120px); }
  main { width: 45%; height: calc(100vh - 120px); }
}
