/* Map-first restaurant finder (components/rest-map-app.njk,
   assets/js/rest-map-app.js). The map fills the first screen; search and
   filters float on it; the list lives in a bottom sheet on phones and a side
   panel on wide screens. Colours come from the site tokens, so dark mode and
   the brand green follow automatically. */

.rmap {
  --rmap-gap: 0.85rem;
  --rmap-peek: 10.25rem;
  --rmap-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.08);
  position: relative;
  height: calc(100svh - 4.25rem);
  min-height: 34rem;
  max-height: 60rem;
  overflow: hidden;
  background: hsl(var(--muted));
  isolation: isolate;
}

.rmap__map {
  position: absolute;
  inset: 0;
}

/* Country and city pages: the same map under the page heading, short enough
   to leave the page's own list in reach. */
.rmap--inline {
  height: min(68svh, 40rem);
  min-height: 26rem;
}

.rmap [hidden] {
  display: none !important;
}

/* ---- Search ------------------------------------------------------------ */
.rmap__search {
  position: absolute;
  z-index: 5;
  top: var(--rmap-gap);
  inset-inline: var(--rmap-gap);
  max-width: 36rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 3.25rem;
  padding-inline: 0.65rem 1rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 999px;
  background: hsl(var(--background));
  box-shadow: var(--rmap-shadow);
}

.rmap__search-mark {
  flex: none;
  width: 2rem;
  height: 2rem;
}

.rmap__search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 1rem;
  outline: none;
}

.rmap__search-input::placeholder {
  color: hsl(var(--muted-foreground));
}

.rmap__search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.rmap__search-icon {
  flex: none;
  color: hsl(var(--primary));
}

.rmap__search:focus-within {
  border-color: hsl(var(--primary) / 0.6);
  box-shadow: var(--rmap-shadow), 0 0 0 3px hsl(var(--primary) / 0.18);
}

.rmap__results {
  position: absolute;
  top: calc(100% + 0.45rem);
  inset-inline: 0;
  max-height: min(60vh, 26rem);
  overflow-y: auto;
  padding: 0.4rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 1.1rem;
  background: hsl(var(--background));
  box-shadow: var(--rmap-shadow);
}

.rmap__results-group {
  margin: 0.45rem 0.65rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

[dir="rtl"] .rmap__results-group {
  letter-spacing: 0;
}

.rmap__result {
  display: grid;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.rmap__result:hover,
.rmap__result:focus-visible {
  background: hsl(var(--primary) / 0.08);
  outline: none;
}

.rmap__result-label {
  font-weight: 650;
}

.rmap__result-sub {
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

/* ---- Filter chips ------------------------------------------------------- */
.rmap__chips {
  position: absolute;
  z-index: 4;
  top: calc(var(--rmap-gap) + 3.85rem);
  inset-inline: 0;
  display: flex;
  gap: 0.45rem;
  padding-inline: var(--rmap-gap);
  overflow-x: auto;
  scrollbar-width: none;
}

.rmap__chips::-webkit-scrollbar {
  display: none;
}

.rmap__chip {
  flex: none;
  min-height: 2.35rem;
  padding: 0 1rem;
  border: 1px solid hsl(var(--border) / 0.9);
  border-radius: 999px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  box-shadow: 0 4px 14px -8px rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.rmap__chip[aria-pressed="true"] {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.rmap__chip:focus-visible,
.rmap__locate:focus-visible,
.rmap__handle:focus-visible,
.rmap__item:focus-visible,
.rmap__action:focus-visible,
.rmap__back:focus-visible {
  outline: 3px solid hsl(var(--primary) / 0.45);
  outline-offset: 2px;
}

/* ---- Near me ------------------------------------------------------------ */
.rmap__locate {
  position: absolute;
  z-index: 4;
  inset-inline-end: var(--rmap-gap);
  bottom: calc(var(--rmap-peek) + var(--rmap-gap) + 1.9rem);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font: inherit;
  font-weight: 700;
  box-shadow: var(--rmap-shadow);
  cursor: pointer;
}

.rmap__locate.is-busy svg {
  animation: rmap-pulse 1s ease-in-out infinite;
}

/* The button rides on top of the sheet, and steps aside when the list is
   full screen. */
.rmap__panel[data-sheet="half"] ~ .rmap__locate {
  bottom: calc(52% + var(--rmap-gap));
}

.rmap__panel[data-sheet="full"] ~ .rmap__locate {
  display: none;
}

@keyframes rmap-pulse {
  50% { opacity: 0.35; }
}

/* ---- Panel: bottom sheet on phones -------------------------------------- */
.rmap__panel {
  position: absolute;
  z-index: 6;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: var(--rmap-peek);
  border-radius: 1.4rem 1.4rem 0 0;
  background: hsl(var(--background));
  box-shadow: 0 -12px 30px -14px rgba(15, 23, 42, 0.4);
  transition: height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rmap__panel[data-sheet="half"] {
  height: 52%;
}

.rmap__panel[data-sheet="full"] {
  height: calc(100% - 4.6rem);
}

.rmap__handle {
  flex: none;
  display: grid;
  place-items: center;
  height: 1.6rem;
  border: 0;
  border-radius: 1.4rem 1.4rem 0 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.rmap__handle span {
  width: 2.75rem;
  height: 0.3rem;
  border-radius: 999px;
  background: hsl(var(--muted-foreground) / 0.45);
}

.rmap__panel-head {
  flex: none;
  padding: 0 1.15rem 0.6rem;
}

.rmap__title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 750;
  line-height: 1.25;
  color: hsl(var(--foreground));
}

.rmap__status {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: hsl(var(--muted-foreground));
}

.rmap__list,
.rmap__detail {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 0.6rem 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.rmap__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.6rem;
  border: 0;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.rmap__item:hover {
  background: hsl(var(--primary) / 0.05);
}

.rmap__item-dot {
  flex: none;
  width: 0.95rem;
  height: 0.95rem;
  margin-top: 0.25rem;
  border: 3px solid hsl(var(--primary));
  border-radius: 999px;
  background: hsl(var(--background));
}

.rmap__item-dot--checked,
.rmap__item-dot--only {
  background: hsl(var(--primary));
}

.rmap__item-dot--checked {
  box-shadow: 0 0 0 4px hsl(var(--primary) / 0.18);
}

.rmap__item-dot--limited {
  border-color: #b45309;
}

/* Branches on a chain's own Halal list, KFC and Nando's (map pin #9f1239). */
.rmap__item-dot--chain {
  border-color: #9f1239;
  background: #9f1239;
}

.rmap__item-body {
  display: grid;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.rmap__item-name {
  font-weight: 700;
  color: hsl(var(--foreground));
}

.rmap__item-meta,
.rmap__item-addr {
  font-size: 0.84rem;
  color: hsl(var(--muted-foreground));
}

.rmap__item-addr {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rmap__item-km {
  flex: none;
  font-size: 0.84rem;
  font-weight: 650;
  color: hsl(var(--primary));
}

.rmap__badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground) / 0.8);
  font-size: 0.74rem;
  font-weight: 700;
}

.rmap__badge--checked {
  background: hsl(var(--primary) / 0.14);
  color: hsl(var(--primary));
}

.rmap__badge--limited {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
}

.rmap__badge--chain {
  background: rgba(159, 18, 57, 0.1);
  color: #9f1239;
}

.dark .rmap__badge--chain {
  background: rgba(251, 113, 133, 0.16);
  color: #fda4af;
}

/* ---- Selected place ------------------------------------------------------ */
.rmap__back {
  margin: 0 0.4rem 0.6rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
}

.rmap__back::before {
  content: "← ";
}

[dir="rtl"] .rmap__back::before {
  content: "→ ";
}

.rmap__card {
  display: grid;
  gap: 0.45rem;
  margin: 0 0.4rem;
  padding: 1rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 1.1rem;
  background: hsl(var(--background));
}

.rmap__card > .rmap__badge {
  justify-self: start;
}

.rmap__card--checked {
  border-color: hsl(var(--primary) / 0.45);
  background: hsl(var(--primary) / 0.04);
}

.rmap__card--chain {
  border-color: rgba(159, 18, 57, 0.35);
}

.rmap__card-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1.2;
  color: hsl(var(--foreground));
}

.rmap__card-cuisine,
.rmap__card-addr,
.rmap__card-hours,
.rmap__card-km {
  margin: 0;
  font-size: 0.92rem;
  color: hsl(var(--foreground) / 0.85);
}

.rmap__card-km {
  font-weight: 700;
  color: hsl(var(--primary));
}

.rmap__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.15rem 0;
  padding: 0;
  list-style: none;
}

.rmap__facts li {
  padding: 0.15rem 0.6rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.rmap__card-note {
  margin: 0.2rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: hsl(var(--muted) / 0.7);
  font-size: 0.86rem;
  line-height: 1.45;
  color: hsl(var(--foreground) / 0.85);
}

.rmap__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.rmap__action {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  color: hsl(var(--foreground));
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.rmap__action--primary {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* ---- Panel footer -------------------------------------------------------- */
.rmap__panel-foot {
  flex: none;
  display: grid;
  gap: 0.3rem;
  padding: 0.6rem 1.15rem 0.85rem;
  border-top: 1px solid hsl(var(--border) / 0.6);
  font-size: 0.82rem;
}

.rmap__add,
.rmap__browse {
  font-weight: 650;
  color: hsl(var(--primary));
}

.rmap__sources {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: hsl(var(--muted-foreground));
}

.rmap__panel[data-sheet="peek"] .rmap__panel-foot,
.rmap__panel[data-sheet="peek"] .rmap__list,
.rmap__panel[data-sheet="peek"] .rmap__detail {
  visibility: hidden;
}

/* A selected place gets the whole sheet on phones: the count, city chips
   and footer (links and map credits) would otherwise squeeze the card into
   a thin strip under the footer. The wide-screen panel restores them. */
.rmap__panel[data-detail] .rmap__status,
.rmap__panel[data-detail] .rmap__cities,
.rmap__panel[data-detail] .rmap__panel-foot {
  display: none;
}

.rmap__panel[data-detail] .rmap__panel-head {
  padding-bottom: 0.35rem;
}

.rmap__noscript {
  position: absolute;
  inset: auto 1rem 1rem;
  z-index: 7;
  padding: 1rem;
  border-radius: 1rem;
  background: hsl(var(--background));
}

/* MapLibre controls clear of our floating UI. */
.rmap .maplibregl-ctrl-top-right,
.rmap .maplibregl-ctrl-top-left {
  top: calc(var(--rmap-gap) + 7rem);
}

.rmap .maplibregl-ctrl-bottom-right,
.rmap .maplibregl-ctrl-bottom-left {
  bottom: var(--rmap-peek);
}

.rmap .maplibregl-ctrl-group {
  border-radius: 0.8rem;
  box-shadow: var(--rmap-shadow);
}

/* ---- Wide screens: side panel ------------------------------------------- */
@media (min-width: 900px) {
  .rmap__panel[data-detail] .rmap__status {
    display: block;
  }

  .rmap__panel[data-detail] .rmap__panel-foot {
    display: grid;
  }

  .rmap__panel[data-detail] .rmap__cities {
    display: flex;
  }

  .rmap {
    --rmap-panel: 25rem;
    height: calc(100vh - 4.5rem);
  }

  .rmap__search {
    inset-inline: var(--rmap-gap) auto;
    width: var(--rmap-panel);
    max-width: none;
    margin: 0;
  }

  [dir="rtl"] .rmap__search {
    inset-inline: auto var(--rmap-gap);
  }

  .rmap__chips {
    top: calc(var(--rmap-gap) + 0.45rem);
    inset-inline: calc(var(--rmap-panel) + 2 * var(--rmap-gap)) auto;
    padding: 0;
    overflow: visible;
  }

  [dir="rtl"] .rmap__chips {
    inset-inline: auto calc(var(--rmap-panel) + 2 * var(--rmap-gap));
  }

  .rmap__panel,
  .rmap__panel[data-sheet="half"],
  .rmap__panel[data-sheet="full"] {
    top: calc(var(--rmap-gap) + 4rem);
    bottom: var(--rmap-gap);
    inset-inline: var(--rmap-gap) auto;
    width: var(--rmap-panel);
    height: auto;
    border-radius: 1.25rem;
    box-shadow: var(--rmap-shadow);
  }

  [dir="rtl"] .rmap__panel,
  [dir="rtl"] .rmap__panel[data-sheet="half"],
  [dir="rtl"] .rmap__panel[data-sheet="full"] {
    inset-inline: auto var(--rmap-gap);
  }

  .rmap__panel-head {
    padding-top: 1rem;
  }

  .rmap__handle {
    display: none;
  }

  .rmap__panel[data-sheet="peek"] .rmap__panel-foot,
  .rmap__panel[data-sheet="peek"] .rmap__list,
  .rmap__panel[data-sheet="peek"] .rmap__detail {
    visibility: visible;
  }

  .rmap__locate,
  .rmap__panel[data-sheet="half"] ~ .rmap__locate {
    display: inline-flex;
    bottom: calc(var(--rmap-gap) + 1.5rem);
  }

  .rmap .maplibregl-ctrl-top-right,
  .rmap .maplibregl-ctrl-top-left {
    top: var(--rmap-gap);
  }

  .rmap .maplibregl-ctrl-bottom-right,
  .rmap .maplibregl-ctrl-bottom-left {
    bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rmap__panel {
    transition: none;
  }
  .rmap__locate.is-busy svg {
    animation: none;
  }
}

/* ---- Below the map: browse by country and chain --------------------------- */
.rest-page--below-map {
  border-top: 1px solid hsl(var(--border) / 0.7);
}

.rest-page--below-map .rest-browse__title {
  margin-top: 0;
}

/* ---- City shortcuts (panel head) ---------------------------------------- */
.rmap__cities {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.15rem;
}

.rmap__cities::-webkit-scrollbar {
  display: none;
}

.rmap__city {
  flex: none;
  min-height: 2.1rem;
  padding: 0 0.85rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.rmap__city--near {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.rmap__city:focus-visible {
  outline: 3px solid hsl(var(--primary) / 0.45);
  outline-offset: 2px;
}
