/* ==========================================================================
   CoffeeCup stylesheet
   Tokens first, then layout, then components, then responsive rules.
   The old file had the same blocks pasted several times over (.search-container
   twice, the 768px media query three times) and styles for components that had
   been commented out of the JS. This replaces it.
   ========================================================================== */

/* ----------------------------------------------------------------- tokens */

:root {
  --espresso: #3a2419;
  --coffee:   #6f4423;
  --caramel:  #b57a46;
  --cream:    #f3e2d4;

  --bg:          #f7ece3;
  --bg-sunken:   #efded0;
  --surface:     #fffaf6;
  --surface-alt: #faf0e8;
  --border:      #e3cdb9;
  --border-firm: #d2b49a;

  --text:        #2d1c13;
  --text-soft:   #6d5546;
  --text-faint:  #93796a;
  --on-accent:   #fffaf6;

  --accent:       #7a4a24;
  --accent-hover: #603718;
  --accent-soft:  #f0dccb;
  --focus:        #b1651f;

  --open:   #1f7a46;
  --closed: #a8372c;
  --unsure: #8a7261;

  --radius-sm: 8px;
  --radius:    13px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(58, 36, 25, .07), 0 1px 3px rgba(58, 36, 25, .05);
  --shadow:    0 2px 4px rgba(58, 36, 25, .06), 0 6px 16px rgba(58, 36, 25, .09);
  --shadow-lg: 0 10px 34px rgba(58, 36, 25, .17);

  --bar-height: 64px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

[data-theme="dark"] {
  --bg:          #171010;
  --bg-sunken:   #110c0c;
  --surface:     #231917;
  --surface-alt: #2c2020;
  --border:      #3b2b27;
  --border-firm: #4d3a34;

  --text:        #f4e7de;
  --text-soft:   #bda79a;
  --text-faint:  #947d70;
  --on-accent:   #1d1310;

  --accent:       #d9a26b;
  --accent-hover: #e8b681;
  --accent-soft:  #33241e;
  --focus:        #e8b681;

  --open:   #58c98a;
  --closed: #f0837a;
  --unsure: #a48d7e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 2px 6px rgba(0, 0, 0, .45), 0 8px 22px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 38px rgba(0, 0, 0, .55);
}

/* ------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

/* An explicit `display` in author CSS beats the browser's rule for [hidden],
   so elements toggled through the hidden attribute need this to stay hidden. */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: -60px;
  transform: translateX(-50%);
  z-index: 2000;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; color: var(--on-accent); }

/* --------------------------------------------------------------- controls */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 19px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-firm);
  transition: background-color .16s ease, border-color .16s ease, transform .1s ease;
}
.button:hover { background: var(--surface-alt); }
.button:active { transform: translateY(1px); }

.button-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}
.button-primary:hover { background: var(--accent-hover); }

.button-quiet { padding: 10px 15px; }

.button:disabled, .icon-button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border-firm);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.icon-button:hover { background: var(--surface-alt); color: var(--text); }
.icon-button svg { width: 20px; height: 20px; }

/* The toggle shows the theme you would switch to. */
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { color: var(--accent-hover); }

.select {
  min-height: 42px;
  padding: 9px 32px 9px 13px;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-pill);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%236d5546' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 17px;
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%23bda79a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------ search form */

.search-form {
  display: flex;
  gap: 10px;
  width: 100%;
}

.search-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px; height: 19px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px 12px 43px;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
/* Hide the browser's own clear button so the layout stays steady. */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.form-hint {
  min-height: 20px;
  margin-top: 9px;
  font-size: .9rem;
  color: var(--closed);
  opacity: 0;
  transition: opacity .16s ease;
}
.form-hint.is-visible { opacity: 1; }

/* ------------------------------------------------------------- home page */

.page-home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 520px at 50% -8%, var(--accent-soft) 0%, transparent 62%),
    var(--bg);
}

.home-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(16px, 4vw, 36px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  text-decoration: none;
}
.brand img { display: block; }

.home {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
}

.home-inner {
  width: 100%;
  max-width: 580px;
  text-align: center;
}

.home-art {
  width: clamp(96px, 24vw, 132px);
  height: auto;
  filter: drop-shadow(0 10px 20px rgba(58, 36, 25, .22));
  transition: transform .3s ease;
}
.home-art:hover { transform: translateY(-4px) scale(1.03); }

.home-title {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 9vw, 3.3rem);
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--espresso);
}
[data-theme="dark"] .home-title { color: var(--cream); }

.home-tagline {
  margin: 10px auto 0;
  max-width: 36ch;
  font-size: 1.04rem;
  color: var(--text-soft);
}

.home .search-form { margin-top: 26px; }

.locate-link { margin-top: 2px; }
.locate-link.is-busy { opacity: .6; }

.suggestions { margin-top: 26px; }

.recent-label {
  display: block;
  margin-bottom: 10px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.recent-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
}
.recent-head .recent-label { margin-bottom: 10px; }
.recent-head .link-button { font-size: .85rem; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 8px 15px;
  min-height: 38px;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-soft);
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
.chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.home-foot {
  padding: 18px 16px 26px;
  text-align: center;
  font-size: .85rem;
  color: var(--text-faint);
}

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

.page-results {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  min-height: var(--bar-height);
  padding: 10px clamp(12px, 2.4vw, 22px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 600;
}

.top-bar .search-form-compact {
  flex: 1 1 auto;
  max-width: 540px;
  margin: 0 auto;
}
.top-bar .search-input { min-height: 44px; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.results-shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(380px, 46%) 1fr;
  min-height: 0;
}

/* --------------------------------------------------------------- list pane */

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

.list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  flex: 0 0 auto;
  padding: 16px clamp(14px, 2vw, 22px) 13px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.list-head-text { min-width: 0; }

.results-count {
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: .1px;
}

.results-place {
  margin-top: 2px;
  font-size: .88rem;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 44ch;
}

.list-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-wrap { position: relative; }

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: .76rem;
  font-weight: 700;
}

.filter-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 700;
  width: 254px;
  padding: 15px 16px 13px;
  background: var(--surface);
  border: 1px solid var(--border-firm);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.filter-title {
  margin-bottom: 9px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  font-size: .95rem;
}
.check input {
  width: 18px; height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-note {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  line-height: 1.45;
  color: var(--text-faint);
}

.results-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px clamp(14px, 2vw, 22px) 26px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* ------------------------------------------------------------ cafe cards */

.cafe-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: start;
  gap: 13px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.cafe-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-firm);
  box-shadow: var(--shadow);
}
.cafe-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 36%, transparent), var(--shadow);
}

/* OSM has no photos, so each card gets a calm generated tile instead of the
   missing default-cafe.jpg the old code pointed at. */
.cafe-thumb {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  border-radius: 11px;
  background:
    linear-gradient(145deg,
      hsl(var(--hue, 25) 42% 74%) 0%,
      hsl(calc(var(--hue, 25) + 18) 38% 58%) 100%);
  color: #fffaf6;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
}
[data-theme="dark"] .cafe-thumb {
  background:
    linear-gradient(145deg,
      hsl(var(--hue, 25) 34% 40%) 0%,
      hsl(calc(var(--hue, 25) + 18) 30% 27%) 100%);
}

.cafe-body { min-width: 0; }

.cafe-name {
  font-size: 1.03rem;
  font-weight: 650;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cafe-sub {
  margin-top: 1px;
  font-size: .83rem;
  color: var(--text-faint);
  text-transform: capitalize;
}

.cafe-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: .87rem;
  font-weight: 600;
}
.cafe-status .dot {
  width: 8px; height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}
.status-open    { color: var(--open); }
.status-closed  { color: var(--closed); }
.status-unknown { color: var(--unsure); font-weight: 500; }

.cafe-meta {
  margin-top: 4px;
  font-size: .87rem;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.badge {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--text-soft);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.cafe-distance {
  flex: 0 0 auto;
  padding-top: 2px;
  font-size: .83rem;
  font-weight: 700;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- empty states */

.state-panel {
  margin: auto;
  padding: 34px 20px;
  max-width: 34ch;
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
}

.state-panel h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.state-panel p {
  margin-top: 7px;
  font-size: .93rem;
  color: var(--text-soft);
}

.state-panel .button { margin-top: 17px; }

/* ------------------------------------------------------------- skeletons */

.cafe-card.is-skeleton {
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.cafe-card.is-skeleton:hover { transform: none; }
.cafe-card.is-skeleton .cafe-thumb { background: var(--bg-sunken); }

.sk {
  height: 11px;
  border-radius: 6px;
  background: var(--bg-sunken);
  animation: pulse 1.4s ease-in-out infinite;
}
.sk-title { width: 58%; height: 14px; margin-bottom: 10px; }
.sk-line { width: 88%; margin-bottom: 7px; }
.sk-short { width: 44%; margin-bottom: 0; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

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

.map-pane {
  position: relative;
  min-height: 0;
  background: var(--bg-sunken);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-sunken);
}

/* OpenStreetMap only serves light tiles, and every good-looking dark basemap
   now needs an API key, so dark mode re-tones the tiles here instead. */
[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(185deg) brightness(.92) contrast(.88) saturate(.7);
}

.marker-pin {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--unsure);
  border: 2px solid #fffaf6;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
  transition: transform .14s ease;
}
.marker-pin svg {
  width: 17px; height: 17px;
  transform: rotate(45deg);
  fill: #fffaf6;
}
.marker-pin.marker-open { background: var(--open); }
.marker-pin.marker-active {
  background: var(--accent);
  transform: rotate(-45deg) scale(1.22);
  z-index: 500;
}

/* ------------------------------------------------------- marker clusters */

/* The plugin ships its own blue-green bubbles; these replace them so the map
   matches the rest of the app. */
.cluster-pin {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--surface);
  box-shadow: 0 3px 10px rgba(58, 36, 25, .4);
  transition: transform .15s ease;
}

/* A ring that grows with the group, so size reads before the number does. */
.cluster-pin::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .22;
}

.cluster-sm { font-size: .8rem; }
.cluster-md { font-size: .84rem; transform: scale(1.12); }
.cluster-lg { font-size: .86rem; transform: scale(1.26); }

.marker-cluster:hover .cluster-pin { transform: scale(1.14); }
.marker-cluster-md:hover .cluster-pin { transform: scale(1.24); }

.leaflet-marker-icon .cluster-pin span { position: relative; }

.marker-center {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #2f6fd0;
  border: 3px solid #fffaf6;
  box-shadow: 0 0 0 4px rgba(47, 111, 208, .26);
}

.leaflet-container .search-radius {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 6;
  fill: var(--accent);
  fill-opacity: .055;
}

/* Leaflet popups, themed. */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 13px 15px; font-family: var(--font); font-size: .9rem; }
.leaflet-popup-close-button { color: var(--text-faint) !important; }

.popup h3 {
  font-size: 1.04rem;
  font-weight: 700;
  padding-right: 14px;
  line-height: 1.3;
}
.popup .cafe-status { margin-top: 5px; }
.popup-row { margin-top: 5px; color: var(--text-soft); }

.popup-hours { margin-top: 9px; }
.popup-hours summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.popup-hours dl { margin: 7px 0 0; }
.popup-hours div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 0;
  font-size: .85rem;
}
.popup-hours dt { color: var(--text-soft); }
.popup-hours dd { margin: 0; font-variant-numeric: tabular-nums; }

.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}
.popup-link {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent) !important;
  font-size: .83rem;
  font-weight: 650;
  text-decoration: none;
}
.popup-link:hover { background: var(--accent); color: var(--on-accent) !important; }

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
  color: var(--text-faint) !important;
  font-size: 10.5px !important;
}
.leaflet-control-attribution a { color: var(--text-soft) !important; }

.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface-alt) !important; }

/* --------------------------------------------------------- view toggle */

/* Only used on narrow screens; hidden on desktop where both panes show. */
.view-toggle {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 800;
  padding: 4px;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
}

.view-toggle button {
  min-width: 82px;
  min-height: 38px;
  padding: 8px 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.view-toggle button.is-active {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 1500;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: var(--espresso);
  color: var(--cream);
  font-size: .92rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-error { background: var(--closed); color: #fff; }
[data-theme="dark"] .toast { background: var(--surface-alt); color: var(--text); }

/* --------------------------------------------------------------- scrollbars */

.results-list::-webkit-scrollbar { width: 10px; }
.results-list::-webkit-scrollbar-track { background: transparent; }
.results-list::-webkit-scrollbar-thumb {
  background: var(--border-firm);
  border: 3px solid var(--bg);
  border-radius: var(--radius-pill);
}
.results-list::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.results-list { scrollbar-width: thin; scrollbar-color: var(--border-firm) transparent; }

/* ========================================================== responsive */

/* Tablet: give the list less room so the map stays usable. */
@media (max-width: 1100px) {
  .results-shell { grid-template-columns: minmax(330px, 42%) 1fr; }
}

/* Phone and small tablet: one pane at a time, switched by the toggle. */
@media (max-width: 900px) {
  .top-bar {
    flex-wrap: wrap;
    padding: 10px 14px;
    row-gap: 10px;
  }
  .top-bar .search-form-compact {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
  }
  .brand span { display: none; }

  .results-shell { grid-template-columns: 1fr; }

  .list-pane, .map-pane {
    grid-column: 1;
    grid-row: 1;
    border-right: 0;
  }

  .results-shell[data-mobile-view="list"] .map-pane { display: none; }
  .results-shell[data-mobile-view="map"]  .list-pane { display: none; }

  .view-toggle { display: flex; }

  /* Leave room for the floating toggle. */
  .results-list { padding-bottom: 86px; }

  .leaflet-bottom.leaflet-right { bottom: 62px; }

  .list-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .list-controls { width: 100%; }
  .list-controls .select { flex: 1 1 auto; min-width: 0; }
  .filter-panel {
    right: auto;
    left: 0;
    width: min(300px, calc(100vw - 36px));
  }
}

@media (max-width: 540px) {
  .cafe-card {
    grid-template-columns: 46px 1fr;
    gap: 11px;
  }
  .cafe-thumb { width: 46px; height: 46px; font-size: .95rem; }
  /* Move the distance under the name rather than squeezing a third column. */
  .cafe-distance {
    grid-column: 2;
    grid-row: 2;
    padding-top: 0;
    margin-top: 2px;
  }
  .home .search-form { flex-direction: column; }
  .home .search-form .button { width: 100%; }
}

/* ------------------------------------------------------- user preferences */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root { --border: #8a6a52; --border-firm: #6b4a33; --text-soft: #44301f; }
  .cafe-card { border-width: 2px; }
}

@media print {
  .top-bar, .map-pane, .view-toggle, .list-controls, .toast, .skip-link { display: none !important; }
  .page-results { height: auto; overflow: visible; }
  .results-shell { grid-template-columns: 1fr; }
  .results-list { overflow: visible; }
  .cafe-card { break-inside: avoid; box-shadow: none; }
}

/* ==========================================================================
   Coffee near you - cup illustrations drifting across the landing page
   Flat 2D artwork with a gentle float. The field covers the hero and ignores
   pointer events, so the search stays usable; only the cups are clickable.
   Before a location is shared the same cups drift on their own as decoration.
   ========================================================================== */

.home { position: relative; }

.cup-field {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;      /* the field never blocks the hero */
  overflow: hidden;
}

.cup-rail { position: absolute; inset: 0; }

/* The hero sits above the drifting cups. */
.home-inner {
  position: relative;
  z-index: 3;
}

.nearby-ask { margin-top: 22px; }

.nearby-sub {
  margin-top: 16px;
  font-size: .9rem;
  color: var(--text-soft);
}

.nearby-status {
  margin-top: 8px;
  min-height: 20px;
  font-size: .88rem;
  color: var(--text-faint);
}

/* --------------------------------------------------------------- the cup */

.cup {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: var(--w, 140px);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: center;
  pointer-events: auto;      /* the cups themselves stay clickable */
  /* Each cup drifts on its own clock, staggered by its index. */
  animation: cup-float 7s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * -1.15s);
}

@keyframes cup-float {
  0%, 100% { transform: translate(-50%, -50%) translateY(0)     rotate(var(--tilt, 0deg)); }
  50%      { transform: translate(-50%, -50%) translateY(-16px) rotate(calc(var(--tilt, 0deg) * -1)); }
}

.cup-art {
  display: block;
  width: 100%;
  height: auto;
  opacity: var(--fade, 1);
  filter: drop-shadow(0 12px 16px rgba(58, 36, 25, .22));
  transition: transform .25s ease, filter .25s ease;
}
[data-theme="dark"] .cup-art {
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .55));
}

/* ------------------------------------------------------- the label card */

.cup-label {
  display: block;
  width: 100%;
  padding: 8px 10px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  /* The label keeps its own width so a small cup does not squash the text,
     and it never takes the depth fade, which would hurt readability. */
  min-width: 136px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.cup-name {
  display: -webkit-box;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  /* Names vary a lot in length, so allow two lines and then clip. */
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cup-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 4px;
  font-size: .72rem;
  font-weight: 650;
}
.cup-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.cup-distance {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.cup-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  margin-top: 6px;
}
.cup-badges .badge {
  padding: 2px 6px;
  font-size: .64rem;
}

/* ------------------------------------------------------------ interaction */

.cup[data-cafe-lat] { cursor: pointer; }

.cup[data-cafe-lat]:hover,
.cup[data-cafe-lat]:focus-visible { z-index: 10; }

.cup[data-cafe-lat]:hover .cup-art,
.cup[data-cafe-lat]:focus-visible .cup-art {
  transform: translateY(-6px) scale(1.07);
  opacity: 1;
  filter: drop-shadow(0 18px 22px rgba(58, 36, 25, .32));
}

.cup[data-cafe-lat]:hover .cup-label,
.cup[data-cafe-lat]:focus-visible .cup-label {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  opacity: 1;
}

.cup:focus { outline: none; }
.cup:focus-visible .cup-label {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ------------------------------------------------- decorative (no data) */

/* Shown before a location is shared, and when nothing is mapped nearby. */
.cup.is-decor {
  pointer-events: none;
  cursor: default;
}
.cup.is-decor .cup-art { opacity: var(--fade, .4); }

/* ---------------------------------------------------------- loading cups */

.cup.is-loading { pointer-events: none; }
.cup.is-loading .cup-name,
.cup.is-loading .cup-status,
.cup.is-loading .cup-distance {
  color: transparent;
  background: var(--bg-sunken);
  border-radius: 6px;
  animation: pulse 1.4s ease-in-out infinite;
}

/* ============================================================ responsive */

/* The scattered field needs width. On tablets and phones the cups become a
   swipeable row under the hero, which stays readable and easy to tap. */
@media (max-width: 900px) {
  /* .home centres a single hero on desktop. Once the cup field joins the flow
     it becomes a second flex item, so the row has to become a column and the
     hero has to keep its place above the cups. */
  .home {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
  .home-inner { order: 1; }

  .cup-field {
    order: 2;
    position: static;
    width: 100%;
    overflow: visible;
    margin-top: 24px;
  }

  .cup-rail {
    position: static;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    padding: 8px max(16px, calc(50vw - 140px)) 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cup-rail::-webkit-scrollbar { display: none; }

  .cup {
    position: relative;
    left: auto;
    top: auto;
    flex: 0 0 auto;
    width: 138px;
    scroll-snap-align: center;
    /* Flatten the staged depth so every cup reads equally while swiping. */
    --fade: 1;
    --tilt: 0deg;
    animation-name: cup-float-flat;
  }

  @keyframes cup-float-flat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
  }

  /* Decorative cups carry no text, so a scroll row would look empty. */
  .cup-rail.is-decor-only {
    justify-content: center;
    padding-inline: 16px;
    overflow-x: hidden;
  }
  .cup-rail.is-decor-only .cup { width: clamp(72px, 21vw, 104px); }
  .cup-rail.is-decor-only .cup:nth-child(n + 5) { display: none; }
}

@media (max-width: 420px) {
  .cup { width: 128px; }
  .cup-distance { font-size: .94rem; }
  .cup-name { font-size: .79rem; }
}

/* Drifting artwork is exactly what reduced-motion asks us to stop. */
@media (prefers-reduced-motion: reduce) {
  .cup { animation: none; transform: translate(-50%, -50%); }
}
@media (prefers-reduced-motion: reduce) and (max-width: 900px) {
  .cup { transform: none; }
}
