:root {
  color-scheme: light dark;
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6b655b;
  --border: #e4ddd0;
  --accent: #8a4b14;
  --accent-text: #ffffff;
  --rare-bg: #fbe7d3;
  --rare-text: #7a3a06;
  --error-bg: #fdecec;
  --error-text: #8c1d1d;
  --bar-bg: #2a211a;
  --bar-text: #f6efe4;
  --store: #2f6690;
  --highlight: #d1495b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --surface: #221f1b;
    --text: #efe9df;
    --muted: #aaa294;
    --border: #3a352e;
    --accent: #e0a15e;
    --accent-text: #1a1206;
    --rare-bg: #4a2c10;
    --rare-text: #f6c792;
    --error-bg: #3d1c1c;
    --error-text: #f5b5b5;
    --bar-bg: #0f0d0b;
    --bar-text: #efe9df;
    --store: #7fb3d8;
    --highlight: #ff7b8b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Header, content, footer: the content grows so a short page still puts the footer at the bottom. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main {
  flex: 1 0 auto;
  width: 100%;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000; /* above the map's panes */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px max(16px, calc((100% - 1200px) / 2));
  background: var(--bar-bg);
  color: var(--bar-text);
  flex-wrap: wrap;
}

/* Phones: keep the bar to one row. The link to the current page is redundant there (the logo
   links home), so only the other page's link shows. */
@media (max-width: 480px) {
  .topbar {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand {
    gap: 6px;
    font-size: 1rem;
  }

  .logo {
    width: 26px;
    height: 26px;
  }

  .topnav a {
    padding: 6px 6px;
    font-size: 0.9rem;
  }

  .topnav a[aria-current="page"] {
    display: none;
  }
}

/* Which day's OLCC report the results come from, filled in after the first search. */
.inventory-date {
  margin: 0;
  padding: 6px 16px;
  border: 1px solid rgba(224, 161, 94, 0.55);
  border-radius: 999px;
  background: rgba(224, 161, 94, 0.16);
  color: #f6dcbc;
  font-size: 0.95rem;
}

.inventory-date strong {
  color: #ffffff;
}

/* Narrow screens: its own row under the logo and links. */
@media (max-width: 640px) {
  .inventory-date {
    order: 3;
    flex-basis: 100%;
    text-align: center;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.logo {
  width: 32px;
  height: 32px;
  color: #e0a15e;
}

.topnav {
  display: flex;
  gap: 4px;
}

.topnav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

.topnav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.topnav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.16);
}

/* Page layout: search and map on the left, bottles on the right; stacked on narrow screens. */

.layout,
.faq {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.layout {
  display: grid;
  gap: 20px;
  padding-top: 20px;
}

@media (min-width: 900px) {
  /* Search and map take half the page; the bottle list the other half. */
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .search-panel {
    position: sticky;
    top: 72px; /* below the header bar */
  }

  .map {
    height: min(60vh, 560px);
  }
}

.tagline,
.map-note,
.site-footer {
  color: var(--muted);
}

.tagline {
  margin: 0 0 12px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.location {
  flex-basis: 100%;
  margin: 0;
}

.zip,
.radius {
  display: flex;
  gap: 8px;
  align-items: center;
}

.find {
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 999px;
}

/* Before the first search: the button, centered in the space the results will fill. */
.intro {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  min-height: 320px;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

.intro p {
  margin: 0;
}

@media (min-width: 900px) {
  .intro {
    min-height: min(60vh, 560px);
  }
}

.intro[hidden] {
  display: none;
}

input,
select,
button {
  font: inherit;
  color: inherit;
}

input,
select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#zip {
  width: 6.5em;
}

button {
  padding: 6px 14px;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

/* Map */

.map {
  height: 360px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.map-note {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

.leaflet-popup-content {
  margin: 10px 12px;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.leaflet-popup-content p {
  margin: 2px 0;
}

/* Liquor-type filter */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  padding: 4px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
}

.chip .count {
  color: var(--muted);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.chip[aria-pressed="true"] .count {
  color: inherit;
  opacity: 0.8;
}

/* Bottle list */

.message {
  padding: 12px 16px;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius);
}

.results {
  list-style: none;
  margin: 0 0 32px;
  padding: 0;
  display: grid;
  gap: 8px;
}

/* Loading: a bottle with a radar sweeping around it, shown in place of the list. */

/* Stacked layout: just below the filters. Side by side, app.js adds a top margin that lines the
   radar up with the middle of the map. */
.loader {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--muted);
}

.loader[hidden] {
  display: none;
}

.radar {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background:
    radial-gradient(circle, transparent 31%, color-mix(in srgb, var(--accent) 30%, transparent) 32%, transparent 33.5%),
    radial-gradient(circle, transparent 64%, color-mix(in srgb, var(--accent) 30%, transparent) 65%, transparent 66.5%),
    var(--surface);
  overflow: hidden;
}

.radar-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* A fading wedge with a bright leading edge, turned by the animation. */
  background: conic-gradient(
    from 0deg,
    transparent 0deg 270deg,
    color-mix(in srgb, var(--accent) 40%, transparent) 356deg,
    var(--accent) 359deg,
    transparent 360deg
  );
  animation: radar-sweep 1.8s linear infinite;
}

.radar-bottle {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.radar-blip {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--highlight);
  opacity: 0;
  animation: radar-blip 1.8s linear infinite;
}

/* Each blip lights up as the sweep passes its angle. */
.radar-blip:nth-of-type(1) { top: 22%; left: 68%; animation-delay: 0.17s; }  /* ~33deg */
.radar-blip:nth-of-type(2) { top: 70%; left: 74%; animation-delay: 0.65s; }  /* ~130deg */
.radar-blip:nth-of-type(3) { top: 60%; left: 16%; animation-delay: 1.27s; }  /* ~254deg */

@keyframes radar-sweep {
  to {
    transform: rotate(1turn);
  }
}

@keyframes radar-blip {
  0% { opacity: 1; transform: scale(1.3); }
  60% { opacity: 0; transform: scale(1); }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .radar-sweep,
  .radar-blip {
    animation: none;
  }
}

/* Two lines per bottle: name, size, price and rarity; then category details and the store toggle. */
.bottle {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bottle:hover,
.bottle:focus-within,
.bottle:focus-visible {
  border-color: var(--highlight);
}

.bottle-head,
.bottle-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.bottle-name {
  margin: 0;
  font-size: 1.05rem;
}

.bottle-size {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.bottle-price {
  font-weight: 600;
  white-space: nowrap;
}

.rarity {
  margin-left: auto; /* right-aligned */
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.rarity.rare {
  background: var(--rare-bg);
  color: var(--rare-text);
  border-color: transparent;
}

.bottle-sub {
  margin-top: 2px;
}

.bottle-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stores-toggle {
  margin-left: auto; /* right side of the second line */
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: 0.9rem;
  white-space: nowrap;
}

.stores-toggle::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4em;
  transition: transform 0.15s;
}

.stores-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.store-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.store-list[hidden] {
  display: none;
}

.store-list li {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.store-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
}

.store-head span,
.hours {
  color: var(--muted);
}

.hours {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

/* FAQ page */

.faq {
  max-width: 760px;
  padding-top: 24px;
  padding-bottom: 16px;
}

.faq h1 {
  font-size: 1.8rem;
  margin: 0 0 16px;
}

.faq section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.faq h2 {
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.faq p {
  margin: 0;
}

/* Always visible: sticks to the bottom of the window while scrolling, and sits below the content
   at the end of the page, so it never covers the last bottle. */
.site-footer {
  position: sticky;
  bottom: 0;
  z-index: 1000; /* above the map's panes */
  margin-top: 24px;
  padding: 10px max(16px, calc((100% - 1200px) / 2));
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}
