:root {
  --color-bg: #f6f1e7;
  --color-bg-raised: #efe8d9;
  --color-fg: #1c1917;
  --color-fg-muted: #5c564c;
  --color-border: #ddd3bf;
  --color-accent: #b8451f;
  --color-accent-fg: #f6f1e7;
  --color-accent-ink: #8a3216;

  --tier-plenty: #1a7f37;
  --tier-limited: #9a6700;
  --tier-very-limited: #cf222e;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  line-height: 1.5;
}

a {
  color: var(--color-accent-ink);
}

.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 2rem 1.5rem 1.5rem;
}

.site-header-inner {
  max-width: 72rem;
  margin: 0 auto;
}

.site-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.subtitle {
  color: var(--color-fg-muted);
  font-size: 0.95rem;
  max-width: 42rem;
  margin: 0;
}

.layout {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.status {
  margin: 0;
  color: var(--color-fg-muted);
}

/* --- Search --- */

.search-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.search-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
}

.search-box {
  position: relative;
  max-width: 32rem;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--color-fg);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
}

#search-input:focus {
  outline: 2px solid var(--color-accent-ink);
  outline-offset: 1px;
}

#search-input:disabled {
  opacity: 0.6;
}

.search-results {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  box-shadow: 0 0.5rem 1.25rem rgba(28, 25, 23, 0.12);
  max-height: 20rem;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item:focus {
  background: var(--color-bg);
}

.search-result-name {
  font-weight: 600;
}

.search-result-group {
  padding: 0.4rem 0.65rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-fg-muted);
}

.search-result-group:not(:first-child) {
  margin-top: 0.3rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}

.empty-state {
  color: var(--color-fg-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* --- Result columns --- */

.result-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

/* `[hidden]` and `.result-columns` are equal-specificity selectors, so
   without this the `display: grid` above would win and the section would
   stay visible (as an empty grid) even while `hidden`. */
.result-columns[hidden] {
  display: none;
}

/* A selected destination has no single carpark's forecast/tier/chart, and
   `#result-side`'s alternatives are redundant with `#destination-panel`'s
   full ranked list, so it's hidden -- this collapses the grid to one
   column instead of leaving the (defined but now-empty) second track. */
.result-columns.destination-mode {
  grid-template-columns: 1fr;
}

@media (max-width: 860px) {
  .result-columns {
    grid-template-columns: 1fr;
  }
}

.result-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.primary-result,
.detail-panel,
.destination-panel {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.destination-panel h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

.destination-sub {
  color: var(--color-fg-muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 1rem;
}

.primary-result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.primary-result-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

.primary-result .lots {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-fg-muted);
  margin: 0.5rem 0 0.15rem;
}

.primary-result .state {
  color: var(--color-fg-muted);
  font-size: 0.85rem;
  margin: 0;
}

.detail-panel h3,
.result-side h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 0.9rem;
}

/* --- Chart --- */

.chart-container {
  min-height: 4rem;
}

.chart-message {
  color: var(--color-fg-muted);
  font-size: 0.9rem;
  margin: 0;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid {
  stroke: var(--color-border);
  stroke-width: 1;
}

.chart-line {
  stroke: var(--color-accent-ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-tick {
  fill: var(--color-fg-muted);
  font-size: 10px;
  font-family: var(--font-mono);
}

.chart-now-typical {
  fill: var(--color-bg-raised);
  stroke: var(--color-accent-ink);
  stroke-width: 2;
}

.chart-now-live {
  fill: var(--color-accent);
  stroke: var(--color-fg);
  stroke-width: 1;
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-fg-muted);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-legend-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  display: inline-block;
}

.chart-legend-typical {
  background: var(--color-bg-raised);
  border: 2px solid var(--color-accent-ink);
}

.chart-legend-live {
  background: var(--color-accent);
  border: 1px solid var(--color-fg);
}

/* --- Alternatives --- */

.result-side {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.alternatives-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.alternative-item {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.alternative-item:last-child {
  border-bottom: none;
}

.alternative-item:hover .name {
  color: var(--color-accent-ink);
}

.alternative-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.alternative-item .name {
  font-weight: 600;
}

.alternative-meta {
  color: var(--color-fg-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  margin-top: 0.15rem;
}

.alternatives-empty {
  color: var(--color-fg-muted);
  font-size: 0.85rem;
}

/* --- Tier pill (shared: search results, primary result, alternatives, map popups) --- */

.tier {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  background: var(--color-border);
  white-space: nowrap;
}

.tier-plenty {
  background: var(--tier-plenty);
}

.tier-limited {
  background: var(--tier-limited);
}

.tier-very_limited {
  background: var(--tier-very-limited);
}

.tier-none {
  background: var(--color-fg-muted);
}

.generated-at {
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin: 0;
}

/* --- Map toggle --- */

.map-toggle-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.map-toggle {
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent-ink);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.map-toggle:hover {
  background: var(--color-bg-raised);
}

.map-panel {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.map {
  height: 50vh;
  min-height: 20rem;
  width: 100%;
}

.map-status {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-fg-muted);
}

.leaflet-popup-content-wrapper {
  background: var(--color-bg-raised);
  color: var(--color-fg);
  border-radius: 0.5rem;
  font-family: var(--font-body);
}

.popup strong {
  font-family: var(--font-display);
  font-weight: 600;
}

.popup-tier {
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.popup-lots {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-fg-muted);
  margin-top: 0.15rem;
}

.site-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
}

.attribution {
  color: var(--color-fg-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
}
