/* ==========================================================================
   ArtMap Design System & Stylesheet
   ========================================================================== */

:root {
  /* ── Palette: Patina — cool stone + verdigris ── */
  --bg:       #EEF1EF;          /* light stone-grey with green breath */
  --surface:  #F8FAF9;          /* near-white cool surface */
  --surface2: #E0E6E3;          /* medium stone */
  --text:     #0D1E1A;          /* near-black, deep forest ink */
  --muted:    #4E6961;          /* muted teal-grey */
  --accent:   #2D7D6F;          /* deep verdigris — single accent */
  --line:     #C6D2CE;          /* cool grey divider */
  /* shadows: only map container & modal */
  --shadow:    0 20px 48px rgba(13, 30, 26, 0.14);
  --radius:    10px;
}

[data-theme="dark"] {
  --bg:       #090F0D;
  --surface:  #101916;
  --surface2: #172320;
  --text:     #DFF0EC;
  --muted:    #6EA89E;
  --accent:   #4AADA0;
  --line:     #1F3430;
  --shadow:   0 20px 48px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.7;
  font-size: 16px;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Header ── */
.site-header {
  height: 76px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  z-index: 200;
}

.brand {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
}
.brand-mark { color: var(--accent); margin-right: 8px; font-size: 1.4rem; }
.brand-sub {
  color: var(--muted);
  font-family: "DM Sans", sans-serif;
  font-size: 0.88rem;
  font-weight: 400;
  margin-left: 8px;
}

.site-header nav { display: flex; align-items: center; gap: 16px; font-size: 0.92rem; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  /* 44px touch target per WCAG */
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  font-size: 1rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Buttons ── */
.btn {
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  border: 1.5px solid var(--line);
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  font-family: "DM Sans", sans-serif;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 80%, #000);
  border-color: color-mix(in srgb, var(--accent) 80%, #000);
  transform: translateY(-1px);
}
.btn-ghost { background: var(--surface); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn-sm { padding: 7px 16px; font-size: 0.82rem; }

/* ── Hero Section ── */
.page-hero {
  padding: 56px 5% 28px;
  max-width: 1400px;
  margin: 0 auto;
}
.page-hero h1 {
  font: 700 clamp(2.4rem, 5vw, 3.8rem) / 1.12 "Playfair Display", serif;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
.page-hero h1 em { color: var(--accent); font-weight: 500; font-style: italic; }
.page-hero p { max-width: 680px; font-size: 1.05rem; color: var(--muted); margin: 0; line-height: 1.7; }

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 14px;
  text-transform: uppercase;
  font-family: "DM Sans", sans-serif;
}

.section {
  padding: 20px 5% 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Filter Toolbar ── */
.filter-toolbar-section { padding-top: 10px; padding-bottom: 10px; }
.filter-toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  /* No box-shadow — reserved for map container & modal only */
}

.filter-dropdowns { display: flex; gap: 12px; flex-wrap: wrap; }
.select-wrap { position: relative; }
.filter-select {
  padding: 10px 36px 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.88rem;
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 0.2s;
  min-height: 44px;
}
.filter-select:focus { border-color: var(--accent); }

.count-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ── Map & Sidebar Layout ── */
.map-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 30px;
  align-items: start;
}

/* Shadow type 1: map container */
.map-container-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaflet-map-view {
  height: 620px;
  width: 100%;
  background: var(--surface2);
}

[data-theme="dark"] .leaflet-tile {
  filter: brightness(0.65) invert(1) contrast(3) hue-rotate(200deg) saturate(0.35);
}

.map-overlay-hint {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 400;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 7px;
}
.map-overlay-hint svg { flex-shrink: 0; }

/* ── Custom Marker Pins ── */
.custom-map-pin {
  width: 32px;
  height: 32px;
  background: var(--pin-color, #2D7D6F);
  color: white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.custom-map-pin:hover {
  transform: rotate(-45deg) scale(1.18);
}
.custom-map-pin span {
  transform: rotate(45deg);
  font-weight: 700;
  font-size: 0.75rem;
}

/* ── Leaflet Popup Cards ── */
.map-popup-card { min-width: 210px; max-width: 260px; font-family: "DM Sans", sans-serif; }
.map-popup-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
  margin-bottom: 8px;
}
.map-popup-info h4 { margin: 4px 0 2px; font-family: "Playfair Display", serif; font-size: 1.05rem; line-height: 1.2; }
.map-popup-info p { margin: 2px 0 8px; color: #666; }
.map-popup-info .tag { margin-bottom: 4px; }

/* ── GeoJSON Vector Tooltips ── */
.leaflet-tooltip.map-geo-tooltip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: "DM Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
}
.leaflet-tooltip.map-geo-tooltip:before {
  border-top-color: var(--line);
}

/* ── Interactive Sidebar ── */
.map-info {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  min-height: 620px;
  /* No box-shadow — reserved for map container & modal only */
  display: flex;
  flex-direction: column;
}

.map-info-placeholder {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.map-info-placeholder h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.55rem;
  line-height: 1.2;
  margin: 0 0 12px;
}
.map-info-placeholder p { color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; line-height: 1.7; }

.quick-tips { display: flex; flex-direction: column; gap: 16px; margin-top: auto; }
.tip-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.tip-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 6px;
  color: var(--accent);
}
.tip-item strong { display: block; font-size: 0.9rem; margin-bottom: 3px; font-family: "DM Sans", sans-serif; }
.tip-item p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ── Selected Artifact Sidebar Content ── */
.map-info-content {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.map-info-img-wrap {
  width: 100%;
  height: 220px;
  background: var(--surface2);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}
.map-info-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
/* Fallback when no image: neutral surface, no gradient */
.map-info-visual {
  height: 180px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  font-size: 4rem;
  color: var(--muted);
  border-radius: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}

.map-info-body h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.65rem;
  margin: 8px 0 4px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.map-info-meta {
  font-size: 0.88rem;
  color: var(--accent);
  margin: 0 0 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-info-meta svg { flex-shrink: 0; }
.map-info-desc { font-size: 0.92rem; color: var(--muted); margin: 0 0 16px; line-height: 1.7; }

.map-info-pills { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.pill {
  font-size: 0.82rem;
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  line-height: 1.5;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent);
  font-family: "DM Sans", sans-serif;
}
.tag-sm { font-size: 0.67rem; }

/* ── Provenance Directory Grid ── */
.directory-section { padding-top: 10px; }
.directory-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.directory-header h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.8rem;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}
.directory-sub { font-size: 0.88rem; color: var(--muted); }

.pins-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.pin-dir-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
  /* No box-shadow — only map container & modal have shadows */
}
.pin-dir-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.pin-dir-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
}

.pin-dir-thumb {
  position: relative;
  width: 74px;
  height: 74px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.pin-dir-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.pin-dir-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--surface2);
  color: var(--muted);
}
.pin-badge-number {
  position: absolute;
  top: 4px;
  left: 4px;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
}

.pin-dir-location-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 4px;
}
.pin-dir-location-row svg { flex-shrink: 0; }

.pin-dir-content { flex: 1; min-width: 0; }
.pin-dir-content h4 {
  margin: 2px 0 4px;
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.date { color: var(--accent); font-size: 0.78rem; font-weight: 700; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state p { font-size: 1.05rem; color: var(--muted); margin: 0 0 14px; }

/* ── Modal Detail View ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
}
.modal.open { display: flex; }

/* Shadow type 2: modal */
.modal-box {
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  right: 20px;
  top: 18px;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-title-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.modal-box h2 {
  font: 700 2.4rem / 1.15 "Playfair Display", serif;
  margin: 4px 0 0;
  letter-spacing: -0.02em;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
  align-items: start;
}
.detail-visual-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.modal-image {
  width: 100%;
  height: 380px;
  object-fit: contain;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}
/* Fallback: neutral surface, no gradient placeholder */
.detail-visual {
  height: 380px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 5rem "Playfair Display", serif;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.image-credit {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface2);
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.image-credit a { color: var(--accent); font-weight: 600; text-decoration: underline; }
.license-badge {
  display: inline-block;
  align-self: flex-start;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.related-section { margin-top: 35px; padding-top: 25px; border-top: 1px solid var(--line); }
.related-heading { font: 600 1.25rem / 1.2 "Playfair Display", serif; margin: 0 0 18px; }
.related-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.related-card {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s, border-color 0.2s;
  color: var(--text);
}
.related-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.related-visual {
  height: 110px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
}
.related-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}
.related-title { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }

.modal-nav { display: flex; justify-content: space-between; gap: 14px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-nav button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Footer ── */
.site-footer {
  padding: 30px 5%;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 1400px;
  margin: 40px auto 0;
}

/* ── Accessibility Focus States ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .map-layout { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .modal-image { height: 280px; }
  .related-strip { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .site-header { flex-direction: column; height: auto; padding: 14px 5%; gap: 12px; }
  .filter-toolbar { flex-direction: column; align-items: stretch; }
  .filter-dropdowns { flex-direction: column; }
  .filter-select { width: 100%; }
  .leaflet-map-view { height: 440px; }
  .modal-box { padding: 24px; }
  .modal-box h2 { font-size: 1.8rem; }
  .site-footer { flex-direction: column; gap: 8px; text-align: center; }
}
