/* ---------------------------------------------------------------
   Albertus — the typeface of London's blue plaques and street signs.
   It is a commercial Monotype font, so it isn't bundled here.
   If it's installed on the machine (Albertus, Albertus MT, Albertus Nova)
   it is used automatically; or drop licensed files into /fonts
   as Albertus.woff2 / Albertus.woff. Marcellus is the free fallback.
---------------------------------------------------------------- */
@font-face {
  font-family: "Albertus Plaque";
  src: local("Albertus Nova"), local("AlbertusNova"),
       local("Albertus MT"), local("AlbertusMT"),
       local("Albertus"), local("Albertus Medium"),
       url("../fonts/Albertus.woff2") format("woff2"),
       url("../fonts/Albertus.woff") format("woff");
  font-display: swap;
}

:root {
  /* enamel & metal */
  --plaque-blue: #174a8b;
  --plaque-blue-deep: #0f3566;
  --plaque-blue-light: #2f66ad;
  --enamel: #f4f1e8;
  --bronze: #8a6433;
  --bronze-light: #c29a5b;
  --brass: #d4b16a;
  --verdigris: #4e8b7c;
  --cast-iron: #1f2326;
  --sandstone: #9c4632;        /* Glasgow red sandstone */
  --sandstone-pale: #e9dccd;
  --stone: #ece6da;            /* honey sandstone ashlar */
  --ink: #22262a;
  --ink-soft: #545a60;
  --rule: #cfc5b3;

  --font-plaque: "Albertus Plaque", "Albertus Nova", "Albertus MT", "Albertus", "Marcellus", "Optima", serif;
  --font-body: "Gill Sans", "Gill Sans MT", "Lato", "Helvetica Neue", sans-serif;

  --radius: 6px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--stone);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.35), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(156,70,50,.06), transparent 45%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .eyebrow, .roundel, .chip, .result-count {
  font-family: var(--font-plaque);
  font-weight: 400;
  letter-spacing: .02em;
}

a { color: var(--plaque-blue); text-underline-offset: 2px; }
a:hover { color: var(--sandstone); }

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

/* ---------- masthead: a long enamel plaque ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 48px);
  margin: 24px clamp(16px, 3vw, 40px);
  padding: clamp(20px, 3.5vw, 40px) clamp(20px, 4vw, 56px);
  background: linear-gradient(160deg, var(--plaque-blue-light) -20%, var(--plaque-blue) 35%, var(--plaque-blue-deep) 110%);
  color: var(--enamel);
  border-radius: 14px;
  border: 6px solid var(--enamel);
  box-shadow:
    0 0 0 2px var(--plaque-blue-deep),
    inset 0 2px 0 rgba(255,255,255,.18),
    inset 0 -3px 8px rgba(0,0,0,.25),
    0 14px 30px -12px rgba(15,53,102,.55);
  position: relative;
}
/* screw heads */
.masthead::before, .masthead::after {
  content: "";
  position: absolute; top: 50%;
  width: 12px; height: 12px; margin-top: -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 15%, #b9b9b9 40%, #6d6d6d 100%);
  box-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.masthead::before { left: 12px; }
.masthead::after  { right: 12px; }

.roundel {
  flex: none;
  width: clamp(120px, 16vw, 176px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: var(--plaque-blue);
  border: 5px solid var(--enamel);
  box-shadow: 0 0 0 3px var(--plaque-blue-deep), 0 0 0 5px rgba(244,241,232,.4), inset 0 -4px 10px rgba(0,0,0,.3);
  line-height: 1.05;
}
.roundel-top, .roundel-bottom { font-size: clamp(.7rem, 1.2vw, .9rem); text-transform: uppercase; letter-spacing: .14em; }
.roundel-mid { font-size: clamp(1.25rem, 2.4vw, 1.75rem); margin: .2em 0; }
.roundel-rule { width: 50%; height: 2px; background: var(--enamel); margin: .25em 0 .4em; }

.masthead-text { max-width: 82ch; }
.eyebrow {
  margin: 0 0 .25rem;
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: .8rem;
  color: var(--brass);
}
.masthead h1 {
  margin: 0 0 .6rem;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.lede { margin: 0; font-size: clamp(1rem, 1.5vw, 1.15rem); color: rgba(244,241,232,.9); }
.lede strong { color: #fff; font-family: var(--font-plaque); font-weight: 400; font-size: 1.1em; }

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

.map-panel {
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
  min-height: 460px;
  border-radius: 10px;
  overflow: hidden;
  border: 4px solid var(--cast-iron);
  box-shadow: 0 0 0 2px var(--bronze-light), 0 12px 28px -14px rgba(0,0,0,.5);
}
#map { width: 100%; height: 100%; background: #dcd6c8; }
/* shown over the map until the first tiles arrive */
.map-loader {
  position: absolute; inset: 0; z-index: 1100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #dcd6c8;
  transition: opacity .45s ease, visibility .45s;
}
.map-loader.is-done { opacity: 0; visibility: hidden; }
.map-loader-roundel {
  position: relative; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--plaque-blue); color: var(--enamel);
  box-shadow: 0 0 0 3px var(--enamel), 0 0 0 5px var(--plaque-blue-deep);
  font: 30px/1 var(--font-plaque);
  animation: loader-pulse 1.6s ease-in-out infinite;
}
.map-loader-roundel::after {
  content: ""; position: absolute; inset: -11px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--brass); border-right-color: var(--brass);
  animation: loader-spin 1.1s linear infinite;
}
.map-loader-text {
  font: 13px/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
@keyframes loader-spin { to { transform: rotate(360deg); } }
@keyframes loader-pulse { 50% { transform: scale(.94); } }

/* soften the tiles so the plaques read first */
.leaflet-tile-pane { filter: saturate(.55) sepia(.18) contrast(.95) brightness(1.02); }

.legend {
  position: absolute; left: 12px; bottom: 26px; z-index: 500;
  list-style: none; margin: 0; padding: 8px 12px;
  background: rgba(244,241,232,.95);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: .8rem;
  display: grid; gap: 4px;
  box-shadow: 0 4px 12px -6px rgba(0,0,0,.4);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--enamel); box-shadow: 0 0 0 1px rgba(0,0,0,.35); }

/* ---------- controls ---------- */
.list-panel { min-width: 0; }
.controls {
  position: sticky; top: 0; z-index: 10;
  background: var(--stone);
  padding: 16px 0 10px;
  border-bottom: 1px solid var(--rule);
}
.search input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px 12px 42px;
  border: 2px solid var(--cast-iron);
  border-radius: var(--radius);
  background: #fbf9f4 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23545a60' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") 14px center no-repeat;
  color: var(--ink);
}
.search input:focus { outline: 3px solid var(--brass); outline-offset: 1px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: .82rem;
  padding: 6px 12px 5px;
  border-radius: 999px;
  border: 1.5px solid var(--cast-iron);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .n { font-family: var(--font-body); font-size: .75rem; opacity: .7; }
.chip[aria-pressed="true"] { background: var(--cast-iron); color: var(--enamel); }
.chip:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; }

.result-count { margin: 10px 0 0; font-size: .9rem; color: var(--ink-soft); }

/* ---------- plaque cards ---------- */
.plaque-list { list-style: none; margin: 14px 0 32px; padding: 0; display: grid; gap: 12px; }

.card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  padding: 10px;
  background: #fbf9f4;
  border: 1px solid var(--rule);
  border-left: 6px solid var(--kind, var(--plaque-blue));
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover, .card.is-active {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -10px rgba(0,0,0,.45);
  border-color: var(--kind, var(--plaque-blue));
}
.card.is-active { background: #fff; }
.card[hidden], .empty[hidden] { display: none; }
.card:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.card-thumb {
  width: 104px; height: 104px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--sandstone-pale);
  display: block;
}
.card-body { min-width: 0; display: flex; flex-direction: column; }
.card h3 {
  margin: 2px 0 4px;
  font-size: 1.06rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card .meta { margin: 0; font-size: .82rem; color: var(--ink-soft); }
.card .actions { margin-top: auto; display: flex; gap: 14px; font-size: .85rem; padding-top: 6px; }
.kind-tag {
  display: inline-block;
  font-family: var(--font-plaque);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--kind, var(--plaque-blue));
}

.estimate-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
  padding: 3px 6px 2px;
  margin-right: 4px;
  border-radius: 3px;
  border: 1px dashed currentColor;
  color: var(--bronze);
  background: rgba(212,177,106,.14);
  vertical-align: 1px;
  white-space: nowrap;
}
.popup .estimate-tag { margin-top: 8px; color: var(--brass); background: rgba(212,177,106,.12); }
.unmapped[hidden], .lede [hidden] { display: none; }

.empty { padding: 32px 8px; text-align: center; color: var(--ink-soft); }

/* ---------- map markers: little roundels ---------- */
.plaque-marker {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--kind, var(--plaque-blue));
  border: 3px solid var(--enamel);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.45), 0 3px 6px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.plaque-marker.is-active { transform: scale(1.45); box-shadow: 0 0 0 2px var(--brass), 0 3px 8px rgba(0,0,0,.45); }

.plaque-cluster {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--plaque-blue);
  color: var(--enamel);
  font-family: var(--font-plaque);
  border: 3px solid var(--enamel);
  box-shadow: 0 0 0 2px var(--plaque-blue-deep), 0 4px 10px rgba(0,0,0,.4);
  line-height: 1;
}
.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.2rem; }

/* ---------- popups: an enamel plaque ---------- */
.leaflet-popup-content-wrapper {
  background: var(--plaque-blue);
  color: var(--enamel);
  border-radius: 10px;
  border: 4px solid var(--enamel);
  box-shadow: 0 0 0 2px var(--plaque-blue-deep), 0 12px 24px -8px rgba(0,0,0,.5);
  padding: 0;
}
.leaflet-popup-tip { background: var(--enamel); }
.leaflet-popup-content { margin: 0; width: 260px !important; }
.leaflet-container a.leaflet-popup-close-button { color: var(--enamel); top: 6px; right: 6px; font-size: 22px; }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--brass); }
.popup img { display: block; width: 100%; height: 170px; object-fit: cover; border-radius: 6px 6px 0 0; background: var(--plaque-blue-deep); }
.popup-gallery {
  display: flex; gap: 4px;
  padding: 6px 8px 0;
  overflow-x: auto;
  background: var(--plaque-blue-deep);
}
.popup-thumb {
  flex: none;
  width: 38px; height: 38px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  opacity: .7;
}
.popup-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.popup-thumb:hover { opacity: 1; }
.popup-thumb[aria-pressed="true"] { border-color: var(--brass); opacity: 1; }
.popup-thumb:focus-visible { outline: 2px solid var(--enamel); outline-offset: 1px; }
.popup-gallery + .popup-body { padding-top: 10px; }

.photo-count { margin: 0 0 2px; font-size: .78rem; color: var(--ink-soft); }
.photo-count::before { content: "▦ "; }

.popup-body { padding: 12px 14px 14px; text-align: center; }
.popup h3 { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.2; color: var(--enamel); }
.popup .kind-tag { color: var(--brass); }
.popup .summary { margin: 0 0 4px; font-size: .85rem; line-height: 1.4; color: rgba(244,241,232,.88); text-align: left; }
.popup .rule { width: 40%; height: 1.5px; background: rgba(244,241,232,.6); margin: 8px auto; }
.popup a { color: var(--enamel); font-size: .85rem; }
.popup a:hover { color: var(--brass); }
.popup .src { font-size: .75rem; opacity: .75; margin: 6px 0 0; }

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

/* ---------- unmapped ---------- */
.unmapped {
  margin: 24px clamp(16px, 3vw, 40px) 0;
  padding: clamp(20px, 3vw, 36px);
  background: var(--cast-iron);
  color: var(--enamel);
  border-radius: 12px;
  border: 4px solid var(--bronze);
  box-shadow: inset 0 0 0 2px var(--brass);
}
.section-plate { max-width: 70ch; margin-bottom: 20px; }
.section-plate h2 { margin: 0 0 6px; font-size: clamp(1.5rem, 3vw, 2.2rem); color: var(--brass); }
.section-plate p { margin: 0; color: rgba(244,241,232,.8); }

.unmapped-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.unmapped-grid a {
  display: block; height: 100%;
  text-decoration: none; color: var(--enamel);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(212,177,106,.4);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.unmapped-grid a:hover { border-color: var(--brass); transform: translateY(-2px); }
.unmapped-grid img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #2c3136; }
.unmapped-grid span { display: block; padding: 8px 10px 10px; font-family: var(--font-plaque); font-size: .92rem; line-height: 1.25; }

/* ---------- footer ---------- */
.footer {
  margin: 24px clamp(16px, 3vw, 40px) 32px;
  font-size: .85rem;
  color: var(--ink-soft);
  max-width: 90ch;
}

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .map-panel { position: relative; top: 0; height: 60vh; min-height: 340px; }
}
@media (max-width: 560px) {
  .masthead { flex-direction: column; align-items: flex-start; margin: 16px; }
  .masthead::before, .masthead::after { display: none; }
  .roundel { width: 110px; }
  .layout, .unmapped, .footer { margin-left: 16px; margin-right: 16px; }
  .card { grid-template-columns: 80px minmax(0, 1fr); }
  .card-thumb { width: 80px; height: 80px; }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .map-loader-roundel, .map-loader-roundel::after { animation: none; }
}
