/* style.css: how every page looks (colours, fonts, spacing, layout).

   Design notes (for us, not for visitors):
   VOICE   everyday tool: calm, warm, precise
   IDEA    a speciality coffee bag: deep espresso band, crema gold, coffee-cherry red
   PICTURE the map is the hero; pins are espresso badges showing their rating
   COLOUR  white (night: roasted brown-black), espresso #2b1a11, crema #c98a4b, cherry #c4302b
   TYPE    Archivo (bold grotesk, like bag labels) + Inter (body)
   LAYOUT  laptop: header band, list on the left, map fills the rest.
           phone: header, map on top, list below. */

/* ---------- Fonts (stored in /static/fonts, no outside requests) ---------- */
@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Colours: light-dark(light value, dark value). Follows the device's setting. ---------- */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #14100d);
  --surface: light-dark(#f7f2ec, #1d1713);
  --raised: light-dark(#ffffff, #241d18);
  --ink: light-dark(#1f140e, #f3ebe3);
  --muted: light-dark(#6c5c4f, #b6a597);
  --line: light-dark(#e7dccf, #3a2e26);
  --espresso: light-dark(#2b1a11, #0f0a07);
  --crema: light-dark(#b97b3e, #e2a96f);
  --crema-soft: light-dark(#f6e9da, #33261c);
  --cherry: light-dark(#c4302b, #e5574d);
  --button: light-dark(#2b1a11, #f3ebe3);
  --button-ink: light-dark(#ffffff, #1f140e);
  --ok: light-dark(#2e7d32, #84c987);
  --danger: light-dark(#b3261e, #f08a82);
  --ring: light-dark(#e3b98a, #8a5a2e);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
}

/* ---------- Basics ---------- */
* { box-sizing: border-box; min-width: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--text);
  overflow-x: clip;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
a { color: inherit; text-decoration-color: var(--crema); text-underline-offset: 3px; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stars { color: var(--crema); letter-spacing: 1px; }
.rating { white-space: nowrap; }
.trap { position: absolute; left: -10000px; }

/* ---------- Buttons ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  font: 600 15px/1 var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
button:hover, .button:hover { background: color-mix(in srgb, var(--button) 85%, var(--crema)); }
button:active, .button:active { transform: scale(0.98); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: progress; }

.button.primary, button.primary { background: var(--cherry); color: #fff; }
.button.primary:hover, button.primary:hover { background: color-mix(in srgb, var(--cherry) 85%, #000); }
button.secondary, .button.secondary { background: var(--raised); color: var(--ink); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: var(--surface); }
button.ghost { background: transparent; color: var(--muted); padding: 0 0.6rem 0 0.3rem; }
button.ghost:hover { background: var(--surface); color: var(--ink); }
button.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ---------- Form fields ---------- */
label { display: block; margin-bottom: 1rem; font-size: 14px; font-weight: 500; }
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  color: var(--ink);
  font: 16px/1.4 var(--text);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--ring); outline-offset: 0; border-color: var(--crema); }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23977f6c' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 18px;
  cursor: pointer;
}

/* ---------- Header band ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.7rem max(20px, env(safe-area-inset-right)) 0.7rem max(20px, env(safe-area-inset-left));
  background: var(--espresso);
  color: #f6ece2;
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: #f6ece2; }
.brand-mark { width: 30px; height: 30px; color: #e2a96f; }
.brand-name { font: 800 22px/1 var(--display); letter-spacing: -0.03em; white-space: nowrap; }
.tagline { margin: 0; color: #c8b3a1; font-size: 14px; }
.topbar .button { margin-left: auto; white-space: nowrap; }

/* "Suggest a spot": the + sits in a small round badge, tight against the left edge */
.suggest-button { gap: 0.5rem; padding: 0 1.05rem 0 0.4rem; }
.plus-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: var(--cherry);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
  transition: transform 0.2s;
}
.plus-badge svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.suggest-button:hover .plus-badge { transform: rotate(90deg); }

/* ---------- The map page: header + (list | map), one screen tall ---------- */
body.app { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.layout { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 400px;
  flex: none;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overscroll-behavior: contain;
}

.search-field { position: relative; }
.search-field .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { margin: 0; height: 48px; padding-left: 44px; border-radius: var(--radius); background: var(--surface); border-color: transparent; }
.search-field input:focus { background: var(--raised); }

.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 20px; }
.filters label { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.filters select { margin-top: 4px; padding: 0.45rem 1.8rem 0.45rem 0.65rem; font-size: 15px; border-radius: 10px; }

.list-title { font-size: 20px; margin-bottom: 8px; }
.list-title .muted { font: 500 15px var(--text); letter-spacing: 0; }

#spot-list { list-style: none; margin: 0 -8px; padding: 0; }
#spot-list li {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.12s;
}
#spot-list li { position: relative; }
/* Thin divider between spots, hidden next to the one you hover */
#spot-list li + li::before { content: ""; position: absolute; top: 0; left: 12px; right: 12px; height: 1px; background: var(--line); }
#spot-list li:hover, #spot-list li:focus-visible { background: var(--surface); outline: none; }
#spot-list li:hover::before, #spot-list li:hover + li::before, #spot-list li:focus-visible::before { display: none; }
#spot-list strong { font-weight: 650; font-size: 16px; }
#no-results { padding: 24px 0; text-align: center; }

/* Detail panel */
#back-button { margin: -6px 0 6px -6px; }
.detail-title { font-size: clamp(28px, 3vw, 34px); font-weight: 800; margin: 4px 0 6px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 18px 0; padding: 16px 0; border-block: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 500; }
.notes { margin: 0 0 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--crema-soft); }
#detail-content > a { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; }
#detail-view > h3 { font-size: 20px; margin: 28px 0 8px; }

.review { padding: 14px 0; border-bottom: 1px solid var(--line); }
.review:last-child { border-bottom: none; }
.review p { margin: 6px 0 0; }

.review-form { margin-top: 20px; padding: 20px; border-radius: 16px; background: var(--surface); }
.review-form h3 { font-size: 18px; margin-bottom: 10px; }
.review-form input, .review-form textarea { background: var(--raised); }

/* Star picker: inputs are ordered 5..1 and shown reversed, so hovering a star
   also lights up the ones to its left. */
.star-input { display: inline-flex; flex-direction: row-reverse; margin-bottom: 0.75rem; }
.star-input input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.star-input label { margin: 0; padding: 0 2px; font-size: 34px; line-height: 1; color: var(--line); cursor: pointer; transition: color 0.1s, transform 0.1s; }
.star-input label:hover, .star-input label:hover ~ label, .star-input input:checked ~ label { color: var(--crema); }
.star-input label:hover { transform: scale(1.12); }
.star-input input:focus-visible + label { outline: 3px solid var(--ring); border-radius: 6px; }

#review-message, #form-message { min-height: 1.4em; margin: 0.25rem 0 0.75rem; font-size: 15px; }
.success-text { color: var(--ok); }
#review-message.error, #form-message.error { color: var(--danger); }

/* ---------- The map ---------- */
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

.leaflet-container { font-family: var(--text); background: light-dark(#f2f3f0, #1c1d1f); }
/* The map background is OpenFreeMap's modern "Positron" style (see basemap.js).
   Only the fallback classic OpenStreetMap map needs toning down. */
.classic-tiles { filter: grayscale(0.7) brightness(1.07) contrast(0.95); }
@media (prefers-color-scheme: dark) {
  .classic-tiles { filter: invert(1) hue-rotate(180deg) grayscale(0.7) brightness(0.8) contrast(0.9); }
}
.leaflet-bar { border: 1px solid var(--line) !important; border-radius: var(--radius) !important; overflow: hidden; box-shadow: 0 2px 8px rgb(0 0 0 / 0.08) !important; }
.leaflet-bar a { width: 38px !important; height: 38px !important; line-height: 38px !important; background: var(--raised) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--bg) 85%, transparent) !important; color: var(--muted) !important; font-size: 11px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip { padding: 4px 10px; border: none; border-radius: 8px; background: var(--espresso); color: #f6ece2; font: 600 13px var(--text); box-shadow: 0 2px 8px rgb(0 0 0 / 0.2); }
.leaflet-tooltip-top::before { border-top-color: var(--espresso); }
.leaflet-popup-content-wrapper { border-radius: 14px; background: var(--raised); color: var(--ink); box-shadow: 0 6px 24px rgb(0 0 0 / 0.18); }
.leaflet-popup-tip { background: var(--raised); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.5; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* Our pins: espresso badges with the rating (or a bean) inside */
.pin { background: none; border: none; }
.pin-body {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid light-dark(#ffffff, #e2a96f);
  background: var(--espresso);
  color: #e2a96f;
  font: 800 13px/1 var(--display);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
  transition: transform 0.15s, background-color 0.15s;
}
.pin-body svg { width: 22px; height: 22px; }
.pin:hover .pin-body, .pin.is-active .pin-body { transform: scale(1.18); background: var(--cherry); color: #fff; border-color: #fff; }
.pin.is-active { z-index: 1000 !important; }

/* Cafés found via OpenStreetMap: quiet dots */
.discovered-dot { stroke: var(--muted); fill: var(--raised); }
.discovered-dot:hover { stroke: var(--cherry); }

/* Popup content. Leaflet measures the content to size the popup; our general
   "min-width: 0" rule made it measure almost nothing, so give it a real minimum. */
.spot-card { display: grid; gap: 2px; min-width: 250px; max-width: 300px; white-space: normal; }
.spot-card > * { min-width: auto; }
.spot-card strong { font: 700 16px var(--display); }
.leaflet-container a.popup-button { justify-self: start; white-space: nowrap; margin-top: 10px; min-height: 38px; padding: 0 0.9rem; color: var(--button-ink); font-size: 14px; }

/* Buttons floating on the map */
.map-tools { position: absolute; top: 16px; right: 16px; z-index: 1000; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
button.floating { background: var(--raised); color: var(--ink); border-color: var(--line); box-shadow: 0 2px 8px rgb(0 0 0 / 0.1); }
button.floating:hover { background: var(--surface); }
button.floating.dark { background: var(--espresso); color: #f6ece2; border-color: transparent; }
button.floating.dark:hover { background: color-mix(in srgb, var(--espresso) 85%, var(--crema)); }

#map-message {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1000;
  width: max-content;
  max-width: min(30rem, calc(100% - 32px));
  margin: 0;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  background: var(--espresso);
  color: #f6ece2;
  font-size: 15px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
#map-message[hidden] { display: none; }

/* ---------- Normal pages (suggest, admin) ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 40px max(20px, env(safe-area-inset-left)) 72px; }
.page.narrow { max-width: 420px; }
.page.wide { max-width: 1240px; }
.page > h2 { font-size: clamp(32px, 4vw, 44px); font-weight: 800; margin-bottom: 10px; }
.page > p.muted { margin: 0 0 28px; font-size: 17px; max-width: 60ch; }
.page h3 { font-size: 20px; margin: 28px 0 12px; }

fieldset { margin: 0 0 20px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); }
legend { padding: 0 8px; margin-left: -8px; font: 700 18px var(--display); letter-spacing: -0.01em; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.search-row { display: flex; gap: 8px; }
.search-row input { margin: 0; }

#search-results { list-style: none; margin: 10px 0 0; padding: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#search-results:empty { display: none; }
#search-results li { padding: 0.7rem 0.9rem; font-size: 15px; cursor: pointer; }
#search-results li + li { border-top: 1px solid var(--line); }
#search-results li:hover { background: var(--surface); }

#pick-map, #edit-map { height: 340px; margin-top: 12px; border-radius: var(--radius); border: 1px solid var(--line); }
#edit-map { margin-bottom: 16px; }

.success { padding: 22px 24px; border-radius: 16px; background: color-mix(in srgb, var(--ok) 12%, var(--raised)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.success p { margin: 0.3rem 0; }
.error { padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--danger) 10%, var(--raised)); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.error p, .error ul { margin: 0.2rem 0; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); }

/* ---------- Footer and text pages ---------- */
.site-footer { padding: 28px 20px 40px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 14px; }
.site-footer a, .sidebar-footer a { color: var(--muted); }
.sidebar-footer { margin: 28px 0 0; font-size: 13px; }
.prose h3 { margin: 32px 0 8px; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.5rem; }
.prose p, .prose li { max-width: 68ch; }

/* ---------- Admin ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page .admin-head h2 { font-size: clamp(32px, 4vw, 44px); font-weight: 800; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 24px 0; padding: 4px; border-radius: 999px; background: var(--surface); }
.tabs a { padding: 0.5rem 1rem; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 15px; text-decoration: none; }
.tabs a.active { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); }
tr + tr td { border-top: 1px solid var(--line); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions button, .actions .button { min-height: 36px; padding: 0 0.85rem; font-size: 14px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--crema-soft); color: var(--muted); font-size: 12px; font-weight: 600; }

/* ---------- Narrower screens ---------- */
@media (max-width: 900px) {
  .tagline { display: none; }
  .sidebar { width: 340px; }
}

/* Phones: header, then the map, then the list (which scrolls) */
@media (max-width: 720px) {
  .topbar { padding-block: 0.55rem; }
  .brand-name { font-size: 19px; }
  .topbar .button { min-height: 40px; padding: 0 0.9rem 0 0.35rem; font-size: 14px; }
  .plus-badge { width: 28px; height: 28px; }
  .hide-phone { display: none; }

  .layout { flex-direction: column; }
  .map-wrap { flex: none; height: 46svh; order: -1; }
  .sidebar { width: auto; flex: 1; padding: 16px; border-right: none; border-top: 1px solid var(--line); }
  .filters select { font-size: 16px; }
  .map-tools { top: 10px; right: 10px; left: 10px; }
  .leaflet-control-zoom { display: none; } /* phones zoom with two fingers */
  .map-tools button { min-height: 40px; font-size: 14px; padding: 0 0.85rem; }
  #map-message { bottom: 16px; }

  .page { padding-top: 28px; }
  fieldset { padding: 16px; }
  .two-cols { grid-template-columns: minmax(0, 1fr); }
  #pick-map, #edit-map { height: 280px; }
  th, td { padding: 10px 12px; }
}

/* Respect visitors who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
