:root {
  color-scheme: light;
}

/* Utility: visually hide content while keeping it accessible to screen readers and crawlers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

* {
  box-sizing: border-box;
}

body.brand-harvest {
  --bg: #fffbf5;
  --surface: rgba(255, 255, 255, 0.75);
  --text: #3f1508;
  --ink: #3f1508;
  --muted: #7c4a32;
  --border: #e8c4a8;
  --metal-orange: #aa6228;     /* grounding "dark metallic orange" (Tony 2026-06-07) */
  --metal-orange-hi: #bd7a35;  /* metallic sheen highlight */
  --metal-orange-lo: #834e1d;  /* deep bronze */
  --accent: var(--metal-orange);
  --accent-soft: #fef3c7;
  --highlight: #0b5d54;
  --stripe: #ea580c;
  --safe: #166534;
  --warn: #b45309;
  --risk: #991b1b;
  --header-deep: #3f1206;
  --brand-font: "Source Sans 3", system-ui, sans-serif;
  --radius: 12px;
  --radius-pill: 999px;
  --shadow: 0 3px 12px rgba(124, 45, 18, 0.08);
  --shell-max: 1400px;
  margin: 0;
  min-height: 100vh;
  font-family: var(--brand-font);
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  /* Cathedral spire as a fixed backdrop under a warm wash; the translucent
     surfaces (--surface) let it hint through the whole interface (Tony). */
  background-image:
    linear-gradient(rgba(255, 251, 245, 0.78), rgba(255, 251, 245, 0.85)),
    url("../img/salisbury-cloister.jpg");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
  line-height: 1.55;
}

a {
  color: var(--highlight);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  /* Metallic bronze gradient laid over a Salisbury Cathedral photo (Pixabay).
     High alpha on the left keeps the title readable; the spire shows through right. */
  /* Wide Stonehenge panorama suits a wide-short band (Tony); bronze overlay keeps it on-brand. */
  background:
    linear-gradient(108deg, rgba(108, 62, 22, 0.84) 0%, rgba(146, 84, 33, 0.64) 50%, rgba(150, 86, 34, 0.5) 100%),
    url("../img/salisbury-stonehenge.jpg") center 28% / cover no-repeat;
  background-color: var(--metal-orange);
  color: #fff;
  min-height: 280px;
  padding: 1.8rem 1.5rem 1.4rem;
  box-shadow: 0 2px 14px rgba(74, 21, 8, 0.26);
}

.header-inner,
main,
footer {
  max-width: var(--shell-max);
  margin: 0 auto;
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem 1rem;
  align-items: center;
}

.brand-icon {
  width: 4.5rem;
  height: 4.5rem;
}

.brand-lockup h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 10px rgba(48, 20, 6, 0.55);
}

/* GF · Salisbury wordmark logo (white, on the dark header) */
.brand-logo {
  margin: 0;
  line-height: 0;
}
.brand-logo img {
  height: clamp(5.2rem, 14vw, 6.8rem);
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 6px rgba(48, 20, 6, 0.55));
}

.brand-tagline {
  display: block;
  margin-top: 0.1rem;
  color: #fde68a;
  font-weight: 600;
  text-shadow: 0 1px 8px rgba(48, 20, 6, 0.5);
}

button.admin-mode-link {
  font: inherit;
  cursor: pointer;
}

.admin-mode-link.map-edit-toggle.active {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.admin-mode-link {
  justify-self: end;
  align-self: center;
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.45rem 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff7ed;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(63, 18, 6, 0.16);
}

.admin-mode-link:hover,
.admin-mode-link:focus {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.guide-banner {
  max-width: var(--shell-max);
  margin: 0.7rem auto 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(55, 26, 10, 0.44);
  color: #fff7ed;
  font-size: 0.92rem;
  font-weight: 500;
}

main {
  padding: 1.5rem;
}

.hero-card,
.controls,
.listing-card,
.map-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 1.35rem;
  margin-bottom: 1rem;
}

.badge,
.pill,
.matrix-state {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
}

.badge {
  margin: 0 0 0.75rem;
  padding: 0.25rem 0.65rem;
  background: var(--accent-soft);
  color: #9a3412;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h2,
h3 {
  color: #9a3412;
  line-height: 1.15;
}

h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.45rem, 4vw, 2rem);
}

h3 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
}

p {
  margin: 0 0 0.85rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.stat {
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-pill);
  background: #fff7ed;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  align-items: end;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.controls-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: end;
  flex: 1 1 420px;
}

.controls-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin-left: auto;
}

.controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 9rem;
}

.controls input,
.controls select {
  width: 100%;
  min-height: 2.6rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  background: #fff;
  color: var(--text);
}

.locate-button {
  min-height: 2.6rem;
  border: 2px solid var(--highlight);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.8rem;
  background: #f0fdfa;
  color: var(--highlight);
  font-weight: 600;
  cursor: pointer;
}

.locate-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.view-tabs {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff7ed;
}

.view-tab {
  min-height: 2.35rem;
  border: 0;
  border-radius: calc(var(--radius) - 3px);
  padding: 0.35rem 0.85rem;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.view-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(124, 45, 18, 0.18);
}

.view-tab:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}

.result-count {
  margin: 0 0 0.85rem;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 600;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* Masonry columns: natural card heights, packed into balanced columns. */
.card-grid {
  columns: 320px;
  column-gap: 1rem;
}
.card-grid .listing-card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 1rem;
  width: 100%;
}

/* Distance sort: row batches into parallel column stacks (masonry flow, left→right rows). */
.card-grid--bucketed {
  columns: unset;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.card-grid__col {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.card-grid__col .listing-card {
  margin: 0;
  width: 100%;
}

.listing-card {
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem;
  border-left: 6px solid var(--accent);
}

.operator-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-self: end;
  align-self: center;
}

.admin-mode-link.active {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.listing-meta,
.listing-actions,
.evidence-links,
.matrix-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.45rem;
  align-items: center;
}

.check-grid span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 700;
}

.pill {
  padding: 0.2rem 0.55rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.pill.status {
  background: #ccfbf1;
  color: #0f766e;
  border-color: #99f6e4;
}

.pill.status.strong {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.pill.status.soft {
  background: #f3ece3;
  color: var(--muted);
  border-color: var(--border);
}

.pill.needs-checking {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.pill.priority-high {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.pill.priority-normal {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.pill.priority-low {
  background: #e0f2fe;
  color: #075985;
  border-color: #bae6fd;
}

.dimension-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.2rem;
  padding: 0.24rem 0.55rem;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid #86efac;
  color: var(--safe);
  font-weight: 600;
}

.section-label {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.before-order {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.matrix-state {
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #475569;
}

.matrix-state.found {
  background: #dcfce7;
  border-color: #86efac;
  color: var(--safe);
}

.matrix-state.not_checked {
  background: #fee2e2;
  border-color: #fecaca;
  color: var(--risk);
}

.matrix-state.checked_none_found,
.matrix-state.blocked {
  background: #fef3c7;
  border-color: #fcd34d;
  color: var(--warn);
}

.evidence-links a,
.listing-actions a {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.6rem;
  background: transparent;
  border: 1px solid #99f6e4;
  text-decoration: none;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1220px;
}

th,
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1d5bd;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fff7ed;
  color: #7c2d12;
  font-size: 0.9rem;
}

.sort-head {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.sort-head.active {
  color: var(--highlight);
}

.sort-indicator {
  display: inline-block;
  min-width: 0.8em;
  font-weight: 700;
}

.table-primary {
  margin: 0 0 0.25rem;
  max-width: 24rem;
}

.table-muted {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.distance-pending {
  color: var(--muted);
  font-size: 0.9rem;
}

.map-panel {
  padding: 1.25rem;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.map-toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.map-edit-banner {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
}

body.map-edit-active .map {
  outline: 3px solid rgba(194, 65, 12, 0.35);
  outline-offset: 2px;
}

.map-button-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--ink);
}

.map-button-secondary.active,
.map-button-secondary[aria-pressed="true"] {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.map-button {
  border: 2px solid var(--highlight);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.75rem;
  background: #f0fdfa;
  color: var(--highlight);
  font-weight: 600;
  cursor: pointer;
}

.map {
  height: 580px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leaflet-container {
  background: #edf7f2;
  overflow: hidden;
  position: relative;
  outline-style: none;
  touch-action: none;
}

/* Critical Leaflet layout fallback. The CDN stylesheet can fail or be blocked;
   without these rules, tiles and markers render as static inline content. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-tile-pane {
  z-index: 200;
  pointer-events: none;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
  pointer-events: auto;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom {
  margin: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom a {
  display: block;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-weight: 900;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid var(--border);
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  padding: 0.75rem;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
}

.leaflet-popup-tip-container {
  display: none;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 0.5rem;
}

.leaflet-right .leaflet-control {
  margin-right: 0.5rem;
}

.leaflet-control-attribution {
  padding: 0.1rem 0.35rem;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 0.72rem;
}

.map-note {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

.leaflet-popup-content {
  font-family: var(--brand-font);
}

.leaflet-popup-content strong {
  color: #9a3412;
}

.guide-marker {
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.map-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 2px 9px rgba(63, 21, 8, 0.35);
  color: #ffffff;
  cursor: pointer;
  pointer-events: auto;
}

.map-marker.ready {
  background: var(--highlight);
}

.map-marker.needs {
  background: var(--accent);
}

.map-marker.editable {
  width: 26px;
  height: 26px;
  cursor: grab;
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.25), 0 2px 9px rgba(63, 21, 8, 0.35);
}

.map-marker.editable:active {
  cursor: grabbing;
}

.map-marker.edited {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.45), 0 2px 9px rgba(63, 21, 8, 0.35);
}

/* Placeholder pins: venues with no real coordinates, shown at Salisbury centre
   in Map Edit / needs-relocation mode so the operator can drag them to position. */
.map-marker-placeholder {
  background: #fff;
  border: 2.5px dashed var(--risk, #991b1b);
  box-shadow: 0 0 0 2px rgba(153, 27, 27, 0.18), 0 2px 9px rgba(63, 21, 8, 0.3);
  color: var(--risk, #991b1b);
  opacity: 0.92;
}

.guide-marker-placeholder {
  cursor: grab;
  opacity: 0.9;
}

.map-popup-placeholder-note {
  color: var(--risk, #991b1b);
  font-size: 0.85em;
}

.guide-marker-editable {
  cursor: grab;
}

.map-popup-coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  color: var(--muted);
}

.map-popup-link {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--highlight);
  font-weight: 800;
}

footer {
  padding: 0 1.5rem 2rem;
  color: var(--muted);
}

.site-footer-line,
.site-footer-links {
  margin: 0 0 0.45rem;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
}

.site-footer-links a,
.footer-link-button {
  color: var(--highlight);
  font-weight: 600;
}

.site-footer-links a:hover,
.footer-link-button:hover {
  color: var(--metal-orange);
}

.footer-link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.about-body p + p {
  margin-top: 0.85rem;
}

@media (max-width: 820px) {
  .header-inner {
    grid-template-columns: 1fr;
  }

  .operator-nav {
    justify-self: stretch;
    justify-content: flex-start;
  }

  .controls-actions {
    margin-left: 0;
    width: 100%;
  }

  .view-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .view-tab {
    flex: 1 1 0;
    text-align: center;
  }

  .guide-banner {
    margin-top: 0.85rem;
    font-size: 0.88rem;
  }

  .map {
    height: 440px;
  }
}

/* ============================================================
   PHASE 1 — UX restyle (2026-06-07)
   Category colour system · lean cards · quick-view modal ·
   map category pins + distinct user-location marker.
   Additive. Consumes public-listings.v1 unchanged.
   Honours P-002 (evidence reachable in quick-view) and
   P-004 (freshness stays visible on the resting card).
   ============================================================ */

body.brand-harvest {
  /* Category colour system — 6 place_types, harmonised with Harvest/bronze.
     ALWAYS paired with an icon + text label (never colour alone) → colour-blind safe.
     Status (needs-checking) is a SEPARATE channel (amber ring), not a colour swap. */
  --cat-restaurant: #b83227;   /* terracotta red */
  --cat-pub:        #b7791f;   /* ale gold       */
  --cat-cafe:       #85603f;   /* mocha brown    */
  --cat-hotel:      #3f5b9a;   /* indigo (rest)  */
  --cat-retail:     #0f766e;   /* teal (brand)   */
  --cat-takeaway:   #8e4585;   /* plum           */
  --cat-other:      #7c4a32;   /* fallback brown */

  --cat-restaurant-soft: #fbe9e6; --cat-restaurant-ink: #8f2419;
  --cat-pub-soft:        #fdf0d7; --cat-pub-ink:        #855512;
  --cat-cafe-soft:       #f1e7dc; --cat-cafe-ink:       #5f4329;
  --cat-hotel-soft:      #e7ecf8; --cat-hotel-ink:      #2c4276;
  --cat-retail-soft:     #d8f0ec; --cat-retail-ink:     #0b5650;
  --cat-takeaway-soft:   #f4e6f2; --cat-takeaway-ink:   #6f3468;
  --cat-other-soft:      #f1e4d8; --cat-other-ink:      #5f3a22;

  --user-location: #2563eb;    /* reserved — never a category/status colour */
  --status-needs:  #b45309;    /* amber — needs-checking channel */

  --shadow-modal: 0 20px 54px rgba(63, 18, 6, 0.32);
}

/* --- Category chip: colour + icon + label (reused on cards, table, map popup) --- */
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  flex: none;
  padding: 0.2rem 0.6rem 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid rgba(63, 21, 8, 0.12);
  background: var(--cat-other-soft);
  color: var(--cat-other-ink);
}
.cat-chip svg { width: 0.95rem; height: 0.95rem; flex: none; }
.cat-chip[data-cat="restaurant"] { background: var(--cat-restaurant-soft); color: var(--cat-restaurant-ink); }
.cat-chip[data-cat="pub"]        { background: var(--cat-pub-soft);        color: var(--cat-pub-ink); }
.cat-chip[data-cat="cafe"]       { background: var(--cat-cafe-soft);       color: var(--cat-cafe-ink); }
.cat-chip[data-cat="hotel"]      { background: var(--cat-hotel-soft);      color: var(--cat-hotel-ink); }
.cat-chip[data-cat="retail"]     { background: var(--cat-retail-soft);     color: var(--cat-retail-ink); }
.cat-chip[data-cat="takeaway"]   { background: var(--cat-takeaway-soft);   color: var(--cat-takeaway-ink); }

/* --- Lean listing card (whole card is the quick-view trigger) --- */
.listing-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.95rem 1rem;
  cursor: pointer;
  /* Faint wash of the card's own category colour, over the translucent surface. */
  background:
    linear-gradient(color-mix(in srgb, var(--cat-color, var(--accent)) 12%, transparent),
                    color-mix(in srgb, var(--cat-color, var(--accent)) 12%, transparent)),
    var(--surface);
  border-left: 5px solid var(--cat-color, var(--accent));
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.listing-card { overflow: hidden; }
.listing-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(124, 45, 18, 0.15); }
.listing-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.4); }

/* Full-bleed venue hero at the top of the card. The negative margins pull it to
   the card edges (the left category accent border stays as a thin strip). */
.lc-media {
  margin: -0.95rem -1rem 0.5rem;
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 14%, #efe7dd);
}
.lc-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* Image gallery inside the quick-view modal (all approved images for the venue). */
.qv-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.qv-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
}
.qv-gallery figure { margin: 0; }
.qv-gallery figcaption {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.lc-name { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 1.12rem; line-height: 1.2; }
.lc-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lc-signals { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.lc-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: auto; padding-top: 0.1rem; }
.lc-fresh { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.lc-fresh.is-stale { color: var(--status-needs); }
.lc-distance { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.lc-more { color: var(--highlight); font-weight: 800; font-size: 0.82rem; white-space: nowrap; }
.listing-card:hover .lc-more { text-decoration: underline; }

/* --- Quick-view modal (shared by cards, table rows, map pins) --- */
.quickview[hidden] { display: none; }
.quickview {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.quickview-backdrop { position: absolute; inset: 0; background: rgba(28, 16, 8, 0.55); }
.quickview-dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--cat-color, var(--accent));
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
}
.quickview-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.05rem 1.2rem 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.quickview-title { margin: 0; font-size: 1.35rem; line-height: 1.18; }
.quickview-sub { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.5rem; }
.quickview-close {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.quickview-close:hover { background: var(--accent-soft); color: var(--text); }
.quickview-close:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.quickview-body { padding: 1rem 1.2rem 1.3rem; display: grid; gap: 1rem; }
.quickview-body p { margin: 0; }
.quickview-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.2rem; }
.quickview-actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  color: var(--highlight);
  font-weight: 800;
  text-decoration: none;
}
.quickview-actions a:hover { background: #ccfbf1; }
body.quickview-open { overflow: hidden; }
/* Modal stays solid — it sits over a dark scrim, not the cathedral backdrop. */
.quickview-dialog,
.quickview-head { background: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .quickview-dialog { animation: qv-in 0.16s ease; }
  @keyframes qv-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* --- Map: category-coloured pins + status channel + distinct user marker --- */
.map-marker.cat-pin {
  width: 24px;
  height: 24px;
  background: var(--pin, var(--accent));
}
.map-marker.cat-pin svg { width: 13px; height: 13px; color: #fff; }
.map-marker.cat-pin.needs { box-shadow: 0 0 0 2px var(--status-needs), 0 2px 9px rgba(63, 21, 8, 0.4); }
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.map-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.map-legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(63, 21, 8, 0.3);
}
.map-legend-swatch svg { width: 11px; height: 11px; color: #fff; }
.map-legend-user .map-legend-swatch { background: var(--user-location); }

/* --- Phase 2: lean scannable table (no forced horizontal scroll; row opens quick-view) --- */
#table-view table { min-width: 0; }
#table-view .table-primary {
  max-width: 30rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.table-row { cursor: pointer; }
.table-row:hover,
.table-row:focus-within { background: #fff7ed; }
.table-row td:first-child a { text-decoration: none; }
.table-row:hover td:first-child a { text-decoration: underline; }

/* --- Phase 2: multi-select category filter chips (one tap on/off; multiple allowed) --- */
.type-filter-group { display: flex; flex-direction: column; gap: 0.3rem; }
.control-label { color: var(--muted); font-weight: 600; }
.type-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.type-chip svg { width: 0.95rem; height: 0.95rem; flex: none; }
.type-chip:hover { border-color: var(--muted); }
.type-chip:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.type-chip[aria-pressed="true"] { background: var(--cat-other-soft); color: var(--cat-other-ink); border-color: var(--cat-other); }
.type-chip[data-cat="restaurant"][aria-pressed="true"] { background: var(--cat-restaurant-soft); color: var(--cat-restaurant-ink); border-color: var(--cat-restaurant); }
.type-chip[data-cat="pub"][aria-pressed="true"]        { background: var(--cat-pub-soft);        color: var(--cat-pub-ink);        border-color: var(--cat-pub); }
.type-chip[data-cat="cafe"][aria-pressed="true"]       { background: var(--cat-cafe-soft);       color: var(--cat-cafe-ink);       border-color: var(--cat-cafe); }
.type-chip[data-cat="hotel"][aria-pressed="true"]      { background: var(--cat-hotel-soft);      color: var(--cat-hotel-ink);      border-color: var(--cat-hotel); }
.type-chip[data-cat="retail"][aria-pressed="true"]     { background: var(--cat-retail-soft);     color: var(--cat-retail-ink);     border-color: var(--cat-retail); }
.type-chip[data-cat="takeaway"][aria-pressed="true"]   { background: var(--cat-takeaway-soft);   color: var(--cat-takeaway-ink);   border-color: var(--cat-takeaway); }

/* --- Phase 2: fluid width — exploit large screens; keep prose readable; wider map --- */
.hero-card p { max-width: 70ch; }

@media (min-width: 1024px) {
  /* The map is the most spatial view, so it breaks out wider than the reading
     shell and gets taller on big screens (Tony). Centred; small gutters kept. */
  #map-view {
    width: min(100vw - 2rem, 1760px);
    margin-inline: calc(50% - min(50vw - 1rem, 880px));
  }
  #map-view .map { height: min(72vh, 820px); }
}

/* Accessibility: honour reduced-motion preferences (disable transitions/animations). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
