/* ============================================================
   Experience History — UK Museum Map
   ============================================================ */

/* ─── Fonts ─── */
@font-face {
  font-family: 'Louis George Cafe';
  src: url('../../fonts/louis_george_cafe_bold-webfont.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Louis George Cafe';
  src: url('../../fonts/louis_george_cafe-webfont.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Louis George Cafe';
  src: url('../../fonts/louis_george_cafe_light-webfont.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}

/* ─── Brand tokens ─── */
:root {
  --navy:          #192656;
  --navy-light:    #28469E;
  --navy-dark:     #10193d;
  --orange:        #F5A21F;
  --orange-dark:   #F27533;
  --sky:           #CAE8E7;
  --white:         #FEFCF9;
  --off-white:     #f2efeb;
  --text:          #1a1a1a;
  --text-muted:    #5a6480;
  --text-light:    #9aa3b8;
  --border:        #e0e4ee;

  --cat-independent:    #F5A21F;
  --cat-national:       #1a4a8a;
  --cat-national-trust: #005e41;
  --cat-english-heritage: #8b1a1a;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.10);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --header-height:   70px;
  --controls-height: 70px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Louis George Cafe', system-ui, sans-serif;
  color: var(--text);
  background: var(--off-white);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Skip link ─── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--orange);
  color: var(--navy);
  padding: 8px 16px;
  font-weight: 700;
  z-index: 9999;
  transition: top .2s;
}
.skip-link:focus { top: 0; }

/* ─── Header ─── */
.site-header {
  height: var(--header-height);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.site-header__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity .2s;
}
.site-header__logo:hover { opacity: .85; }
.site-header__logo img {
  height: 36px;
  width: auto;
}

.site-header__divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
}

.site-header__title { flex: 1; }

.site-header__title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  letter-spacing: -.01em;
}

.site-header__title p {
  font-size: 0.78rem;
  color: rgba(254,252,249,.6);
  margin-top: 1px;
}

.site-header__count-badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: var(--white);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Controls bar ─── */
.controls-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: var(--controls-height);
  z-index: 99;
  position: relative;
  box-shadow: var(--shadow-sm);
}

/* Search */
.search-wrap {
  position: relative;
  flex: 0 0 240px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-light);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 8px 10px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--off-white);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

#search::placeholder { color: var(--text-light); }

#search:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245,162,31,.2);
  background: var(--white);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 2px;
  display: none;
  line-height: 1;
  font-size: 1rem;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--text); }

/* Separator */
.controls-separator {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* Filter label */
.filter-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Filter buttons */
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  transition: all .18s;
  white-space: nowrap;
  line-height: 1;
}

.filter-btn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-btn[data-category="all"] .dot           { background: linear-gradient(135deg, var(--cat-independent) 0%, var(--cat-national) 50%, var(--cat-english-heritage) 100%); }
.filter-btn[data-category="independent"] .dot    { background: var(--cat-independent); }
.filter-btn[data-category="national"] .dot       { background: var(--cat-national); }
.filter-btn[data-category="national-trust"] .dot  { background: var(--cat-national-trust); }
.filter-btn[data-category="english-heritage"] .dot { background: var(--cat-english-heritage); }

.filter-btn:hover {
  border-color: var(--orange);
  color: var(--text);
  background: var(--off-white);
}

.filter-btn.active {
  border-color: transparent;
  color: var(--white);
  background: var(--navy);
}

.filter-btn[data-category="independent"].active   { background: var(--cat-independent); color: var(--navy); }
.filter-btn[data-category="national"].active      { background: var(--cat-national); }
.filter-btn[data-category="national-trust"].active { background: var(--cat-national-trust); }
.filter-btn[data-category="english-heritage"].active { background: var(--cat-english-heritage); }

.filter-count {
  background: rgba(255,255,255,.3);
  border-radius: 10px;
  padding: 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.filter-btn:not(.active) .filter-count {
  background: var(--off-white);
  color: var(--text-muted);
}

/* ─── Map layout ─── */
.map-layout {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#map {
  flex: 1;
  z-index: 1;
}

/* ─── Leaflet overrides ─── */
.leaflet-container { font-family: inherit; }

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
  padding: 0 !important;
  overflow: hidden;
  min-width: 260px;
  max-width: 320px;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}

.leaflet-popup-tip-container { margin-top: -1px; }

/* ─── Popup ─── */
.popup-inner { padding: 0; }

.popup-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.popup-inner--basic .popup-header { border-bottom: none; }

.popup-header-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
}

.popup-category-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
}
.popup-category-tag.cat-independent   { background: var(--cat-independent); color: var(--navy); }
.popup-category-tag.cat-national      { background: var(--cat-national); }
.popup-category-tag.cat-national-trust { background: var(--cat-national-trust); }
.popup-category-tag.cat-english-heritage { background: var(--cat-english-heritage); }

.popup-tier-badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  white-space: nowrap;
}
.popup-tier-badge.basic {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}
.popup-tier-badge.featured {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.popup-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}

.popup-body { padding: 10px 16px; }

.popup-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 8px;
}

.popup-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.popup-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.popup-meta-row svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--orange);
}

.popup-rating {
  display: flex;
  align-items: center;
  gap: 5px;
}

.popup-stars { display: flex; gap: 1px; }

.popup-star { font-size: 0.75rem; line-height: 1; }
.popup-star.full  { color: #f59e0b; }
.popup-star.half  { color: #f59e0b; }
.popup-star.empty { color: #d1d5db; }

.popup-rating-value {
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--navy);
}

.popup-review-count {
  color: var(--text-light);
  font-size: 0.75rem;
}

.popup-admission {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--off-white);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.popup-admission.free {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.popup-footer {
  display: flex;
  gap: 8px;
  padding: 10px 16px 14px;
  flex-wrap: wrap;
}

.popup-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: all .15s;
  text-align: center;
  min-height: 34px;
}

.popup-btn-primary {
  background: var(--navy);
  border-color: var(--navy);
}

/* Override Leaflet's link colour inside popups */
.leaflet-popup-content .popup-btn-primary,
.leaflet-popup-content .popup-btn-primary:link,
.leaflet-popup-content .popup-btn-primary:visited {
  color: var(--white);
}
.leaflet-popup-content .popup-btn-primary:hover {
  background: var(--navy-light);
  border-color: var(--navy-light);
  color: var(--white);
}

.popup-btn-secondary {
  background: var(--white);
}
.leaflet-popup-content .popup-btn-secondary,
.leaflet-popup-content .popup-btn-secondary:link,
.leaflet-popup-content .popup-btn-secondary:visited {
  color: var(--text-muted);
}
.leaflet-popup-content .popup-btn-secondary:hover {
  background: var(--off-white);
  color: var(--navy);
  border-color: var(--orange);
}

/* ─── Map markers ─── */
.museum-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.museum-marker:hover { box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.museum-marker.cat-independent    { background-color: var(--cat-independent); }
.museum-marker.cat-national       { background-color: var(--cat-national); }
.museum-marker.cat-national-trust  { background-color: var(--cat-national-trust); }
.museum-marker.cat-english-heritage { background-color: var(--cat-english-heritage); }
.museum-marker.marker-basic { opacity: 0.6; border-color: rgba(255,255,255,.6); }

/* ─── Loading overlay ─── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(242,239,235,.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  gap: 16px;
}
#loading-overlay.hidden { display: none; }

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Error state ─── */
#error-state {
  position: absolute;
  inset: 0;
  background: rgba(242,239,235,.97);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
#error-state.visible { display: flex; }

.error-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

.error-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 360px;
}
.error-message a { color: var(--orange-dark); }

/* ─── No results ─── */
#no-results {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  text-align: center;
  box-shadow: var(--shadow-md);
  z-index: 50;
  pointer-events: none;
  display: none;
}
#no-results.visible { display: block; }
#no-results strong { font-size: 1rem; color: var(--navy); }
#no-results p { font-size: 0.875rem; color: var(--text-muted); margin-top: 8px; }

/* ─── Legend ─── */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  min-width: 190px;
}
.map-legend h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.8125rem;
  color: var(--navy);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.8);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.legend-dot.cat-independent    { background: var(--cat-independent); }
.legend-dot.cat-national       { background: var(--cat-national); }
.legend-dot.cat-national-trust  { background: var(--cat-national-trust); }
.legend-dot.cat-english-heritage { background: var(--cat-english-heritage); }

/* ─── Footer ─── */
.site-footer {
  background: var(--navy-dark);
  color: rgba(254,252,249,.5);
  text-align: center;
  padding: 12px 24px;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.site-footer a { color: var(--orange); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --controls-height: auto;
  }

  .site-header { padding: 0 16px; gap: 12px; }
  .site-header__logo img { height: 28px; }
  .site-header__title h1 { font-size: 0.9rem; }
  .site-header__title p { display: none; }
  .site-header__count-badge { display: none; }

  .controls-bar { padding: 8px 16px; gap: 8px; }

  .search-wrap { flex: 1 1 100%; order: -1; }

  .controls-separator { display: none; }
  .filter-label { display: none; }

  .filters {
    flex: 1 1 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }

  .filter-btn { flex-shrink: 0; font-size: 0.75rem; padding: 5px 10px; }

  .map-legend { display: none; }
}

@media (max-width: 480px) {
  .leaflet-popup-content-wrapper {
    min-width: 240px !important;
    max-width: calc(100vw - 32px) !important;
  }
}

/* ─── Print ─── */
@media print {
  .controls-bar, .site-footer, .map-legend { display: none; }
  #map { height: 100vh; }
}
