/* The Listed Buildings of Glasgow. Adapted from /plaques/css/style.css. */

:root {
  --cat-a: #8c2346;            /* Mackintosh rose, darkened for contrast */
  --cat-b: #1f4f8a;
  --cat-c: #2f6b4f;
  --paper: #f2f3f0;            /* cool limewash white, not cream */
  --paper-raised: #fafbf9;
  --ink: #1c2023;
  --ink-soft: #4d555b;
  --rule: #cdd1cb;
  --focus: #1f4f8a;

  --font-display: "Marcellus", "Optima", serif;
  --font-body: "Lato", "Gill Sans", "Gill Sans MT", "Helvetica Neue", sans-serif;

  --radius: 4px;
  color-scheme: light;
  accent-color: var(--cat-b);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
::selection { background: var(--cat-b); color: var(--paper); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  caret-color: var(--cat-a);
}

h2, h3, .chip, .result-count { font-family: var(--font-display); font-weight: 400; }

a { color: var(--cat-b); text-underline-offset: 3px; }
a:hover { color: var(--cat-a); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

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

/* ---------- masthead: one dark line fixed to the top, heading and menu button only ---------- */
.masthead {
  position: sticky; top: 0; z-index: 1200;
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(16px, 3vw, 40px) 12px;
  background: var(--ink);
  color: var(--paper);
}
.masthead h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .02em;
  flex: 1; min-width: 0;
  /* one line beside the 44px menu button: the heading is ~14.8em wide in Marcellus */
  font-size: min(3rem, calc((100vw - 2 * clamp(16px, 3vw, 40px) - 56px) / 15.1));
  line-height: 1;
  white-space: nowrap;
}
.lede { margin: 4px 0 24px; text-wrap: pretty; font-size: 1.05rem; color: var(--ink-soft); }
.lede strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.menu-btn, .menu-close {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius);
  background: transparent; color: inherit;
  cursor: pointer;
}
.menu-btn:hover { opacity: .75; }
.menu-btn:focus-visible { outline-color: var(--paper); }
.nw { white-space: nowrap; }
.sq { display: inline-block; width: .62em; height: .62em; margin: 0 .3em 0 .1em; vertical-align: .02em; }
.sq.a { background: var(--cat-a); }
.sq.b { background: var(--cat-b); }
.sq.c { background: var(--cat-c); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: clamp(16px, 2.4vw, 32px);
  margin: clamp(16px, 2.4vw, 32px) clamp(16px, 3vw, 40px) 0;
  align-items: start;
}

.map-panel {
  position: sticky; top: calc(var(--header-h, 0px) + 16px);
  height: calc(88vh - var(--header-h, 0px));
  min-height: 460px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--ink);
}
#map { width: 100%; height: 100%; background: #dfe1dc; }
.map-loader {
  position: absolute; inset: 0; z-index: 1100;
  display: grid; place-items: center;
  background: #dfe1dc;
  transition: opacity .4s cubic-bezier(.16, 1, .3, 1), visibility .4s;
}
.map-loader.is-done { opacity: 0; visibility: hidden; }
.map-loader-text { font-size: .95rem; color: var(--ink-soft); }

/* mute the tiles so the markers read first */
.leaflet-tile-pane { filter: saturate(.5) contrast(.95) brightness(1.03); }

.legend {
  position: absolute; left: 10px; bottom: 24px; z-index: 500;
  list-style: none; margin: 0; padding: 8px 10px;
  background: var(--paper-raised);
  border-radius: var(--radius);
  font-size: .82rem;
  display: grid; gap: 4px;
}
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .dot {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--paper); font: 700 10px/1 var(--font-body);
}

/* ---------- controls ---------- */
.list-panel { min-width: 0; }
.controls {
  position: sticky; top: var(--header-h, 0px); z-index: 10;
  background: var(--paper);
  padding: 14px 0 12px;
}
.search input {
  width: 100%;
  font: inherit;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%234d555b' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") 13px center no-repeat;
  color: var(--ink);
}
.search input::placeholder { color: var(--ink-soft); }
.search-row { display: flex; gap: 8px; }
.search { flex: 1; min-width: 0; margin: 0; }
.search label { display: block; }
.near {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 14px;
  font: inherit; font-size: .95rem;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink);
  cursor: pointer;
}
.near:hover { background: #e6e8e3; }
.near[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.near:disabled { cursor: progress; color: var(--ink-soft); }
.near-status { margin: 8px 0 0; font-size: .9rem; color: var(--ink); }
.near-status.is-error { color: var(--cat-a); }
.card .dist { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.here-marker {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--focus);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(31, 79, 138, .22);
}
.here-marker.is-place { background: var(--ink); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: none; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: .88rem;
  min-height: 34px;
  padding: 5px 12px 4px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--paper-raised); }
.chip .n { font-family: var(--font-body); font-size: .78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"] .n { color: #d5d9d3; }
.chip .swatch { width: 9px; height: 9px; }

.result-count { margin: 10px 0 0; font-size: .92rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- list ---------- */
.plaque-list { list-style: none; margin: 4px 0 40px; padding: 0; }

.card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 96px;
}
.card:hover { background: var(--paper-raised); }
.card.is-active { background: #e6e8e3; }
.card[hidden], .empty[hidden] { display: none; }

/* photo with the category letter in its corner, or just the letter */
.card-thumb { position: relative; width: 64px; height: 64px; background: #e3e5e0; }
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-badge {
  position: absolute; left: 0; bottom: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--kind);
  color: var(--paper);
  font: .85rem/1 var(--font-display);
}
.card-badge.is-large { inset: 0; width: auto; height: auto; font-size: 1.6rem; }
.card-body { min-width: 0; }
.card h3 { margin: 0 0 3px; font-size: 1.08rem; line-height: 1.25; overflow-wrap: anywhere; }
.card .meta { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.card .actions { display: flex; gap: 16px; font-size: .88rem; padding-top: 6px; }

.empty { padding: 32px 8px; color: var(--ink-soft); }
.link { font: inherit; padding: 0; border: 0; background: none; color: var(--cat-b); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- map markers ---------- */
.plaque-marker {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--kind);
  color: var(--paper);
  font: 700 10px/1 var(--font-body);
  border: 2px solid var(--paper);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.plaque-marker.is-active { transform: scale(1.5); border-color: var(--ink); }

.plaque-cluster {
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-display);
  border: 3px solid var(--kind, var(--ink));
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.plaque-cluster.sm { width: 34px; height: 34px; font-size: .95rem; }
.plaque-cluster.md { width: 42px; height: 42px; font-size: 1.05rem; }
.plaque-cluster.lg { width: 52px; height: 52px; font-size: 1.15rem; }

/* ---------- popups, in the category's colour ---------- */
.leaflet-popup { --kind: var(--cat-a); }
.leaflet-popup.cat-B { --kind: var(--cat-b); }
.leaflet-popup.cat-C { --kind: var(--cat-c); }
.leaflet-popup-content-wrapper {
  background: var(--kind);
  color: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px -8px rgba(28, 32, 35, .5);
  padding: 0;
}
.leaflet-popup-tip { background: var(--kind); box-shadow: none; }
.leaflet-popup-content { margin: 0; width: 280px !important; }
.leaflet-container a.leaflet-popup-close-button { color: var(--paper); top: 6px; right: 6px; width: 28px; height: 28px; font-size: 22px; }
.leaflet-container a.leaflet-popup-close-button:hover { color: #fff; }

.popup-photo { display: block; width: 100%; height: 180px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; background: rgba(0, 0, 0, .15); }
.popup .credit { margin: 6px 0 0; font-size: .74rem; color: rgba(250, 251, 249, .8); }
.popup .credit a { font-size: inherit; }

/* text on the coloured ground is tinted from the foreground, never grey */
.popup-body { padding: 16px 18px 14px; }
.popup h3 { margin: 0 32px 4px 0; font-size: 1.18rem; line-height: 1.2; color: var(--paper); }
.popup-address { margin: 0; font-size: .88rem; color: rgba(250, 251, 249, .92); }
.popup-cat { margin: 2px 0 10px; font-size: .82rem; color: rgba(250, 251, 249, .85); }
.popup .label { display: block; margin: 0; font-size: .8rem; font-weight: 700; color: var(--paper); }
.popup .summary { margin: 0 0 10px; font-size: .82rem; line-height: 1.4; color: rgba(250, 251, 249, .9); }
.entities { margin: 2px 0 10px; padding: 0 0 0 1.1em; font-size: .82rem; line-height: 1.35; color: rgba(250, 251, 249, .9); }
.entities li + li { margin-top: 2px; }
.entities .more { list-style: none; margin-left: -1.1em; }
.popup a { color: var(--paper); font-size: .88rem; }
.popup a:hover { color: #fff; }
.popup .src { font-size: .78rem; color: rgba(250, 251, 249, .8); margin: 6px 0 0; font-variant-numeric: tabular-nums; }

.leaflet-container { font-family: var(--font-body); }
.leaflet-control-attribution { font-size: 11px; }

/* ---------- menu: about, credits and newsletter, in a drawer from the right ---------- */
.menu {
  margin: 0 0 0 auto;
  width: min(440px, 100vw); max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  padding: 0 clamp(18px, 4vw, 28px) 32px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu[open] { animation: menu-in .28s cubic-bezier(.16, 1, .3, 1); }
@keyframes menu-in { from { transform: translateX(24px); opacity: 0; } }
.menu::backdrop { background: rgba(28, 32, 35, .5); }
.menu-head {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px;
  background: var(--paper);
}
.menu-head h2 { margin: 0; font-size: 1.5rem; }
.menu-close:hover { opacity: .65; }

.about { margin: 8px 0 0; }
.about h3 { margin: 0 0 6px; font-size: 1.2rem; }
.about > p { margin: 0 0 16px; color: var(--ink-soft); }
.about-list { margin: 0; display: grid; gap: 14px; }
.about-list dt { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.05rem; }
.about-list .badge { width: 26px; height: 26px; display: grid; place-items: center; background: var(--kind); color: var(--paper); font-size: .95rem; }
.about-list dd { margin: 4px 0 0 36px; color: var(--ink-soft); font-size: .95rem; }

.footer { margin: 28px 0 0; font-size: .88rem; color: var(--ink-soft); }

.newsletter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 18px; }
.newsletter-row { display: flex; gap: 6px; }
.newsletter input[type="email"] {
  width: 15rem; min-width: 0;
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink);
}
.newsletter button {
  font: inherit;
  padding: 6px 14px;
  border: 0; border-radius: var(--radius);
  background: var(--ink); color: var(--paper);
  cursor: pointer;
}
.newsletter button:hover { background: var(--cat-b); }
.newsletter button:disabled { opacity: .6; cursor: wait; }
.newsletter-note { margin: 0; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .map-panel { position: relative; top: 0; height: 50vh; min-height: 300px; }
}
@media (max-width: 560px) {
  .layout { margin-left: 16px; margin-right: 16px; }
  .newsletter-row { flex-basis: 100%; }
  .newsletter input[type="email"] { flex: 1; width: auto; }
  .legend { display: none; }
  .newsletter input[type="email"] { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
