/* =========================
   THEME TOKENS
   ========================= */
:root {
  /* Base */
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  --text: #333333;
  --muted: #555555;
  --border: #dddddd;
  --shadow: rgba(0,0,0,0.6);

  /* Brand */
  --brand: #D7153A;
  --brand-strong: #630019;

  /* Links / Actions */
  --link: #0b5fff;
  --link-hover: #0056b3;

  /* Map */
  --map-back: #f4f4f9;

  /* Surfaces */
  --card: #ffffff;
  --card-soft: #f9f9f9;

  /* Popups */
  --popup-text: #333333;

  /* Inputs */
  --input-bg: #ffffff;
  --input-border: #dddddd;
  --input-text: #333333;

  /* Slider (noUi) */
  --slider-track: #f4f4f9;
  --slider-border: #dddddd;
  --slider-active: #f06277;
  --slider-handle: #ffffff;
  --slider-handle-border: #f06277;

  /* Misc */
  --success: #28a745;
  --overlay-bg: rgba(255, 255, 255, 0.9);   /* light mode overlay */
  --spinner-track: rgba(0, 0, 0, 0.1);
  --backdrop: rgba(0,0,0,0.45);        /* for .modal background */
}

:root.theme-dark {
  --bg: #0b0f14;
  --bg-soft: #111827;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --border: #2a3441;
  --shadow: rgba(11,15,20,0.7);

  --brand: #D7153A;         /* keep brand red the same */
  --brand-strong: #ff8ea6;

  --link: #7aa2ff;
  --link-hover: #a9c1ff;

  --map-back: #0d1117;

  --card: #0f1520;
  --card-soft: #0f1520;

  --popup-text: #e5e7eb;

  --input-bg: #ffffff;
  --input-text: #333333;
  --input-border: #2a3441;

  --slider-track: #0f1520;
  --slider-border: #2a3441;
  --slider-active: #f06277;
  --slider-handle: #0f1520;
  --slider-handle-border: #f06277;

  --success: #2ecc71;
  --overlay-bg: rgba(11, 15, 20, 0.85);     /* dark mode overlay */
  --spinner-track: rgba(255, 255, 255, 0.2);
  --backdrop: rgba(0,0,0,0.55);
}

/* =========================
   BASE
   ========================= */
html, body { background: var(--bg); color: var(--text); }
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Montserrat', sans-serif, Arial, Helvetica, sans-serif;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* =========================
   NAVBAR
   ========================= */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 60px; margin: auto; line-height: 20px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  background-color: var(--card);
  z-index: 1000;
}
.navbar-logo a { font-size: 1.4rem; color: var(--brand); font-weight: bold; text-decoration: none; }
.navbar-links { display: flex; gap: 20px; }
.navbar-links a { color: var(--brand); font-weight: 600; text-decoration: none; margin-right: 30px; transition: color .3s; }
.navbar-links a:hover { color: var(--brand-strong); }
.hamburger-menu { display: none; flex-direction: column; justify-content: space-around; height: 25px; cursor: pointer; }
.hamburger-menu span { display: block; width: 25px; height: 3px; background-color: var(--brand); border-radius: 3px; }

@media (max-width: 768px) {
  .navbar-logo { font-size: 16px; }
  .navbar-links a { font-size: 14px; }
}
@media (max-width: 560px) {
  .navbar-links {
    display: none; position: absolute; top: 60px; right: 20px;
    background-color: var(--card); padding: 10px; flex-direction: column; gap: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2); z-index: 1000;
  }
  .navbar-links.active { display: flex; }
  .hamburger-menu { display: flex; }
}

/* =========================
   MAP + SIDEBAR
   ========================= */
#map {
  position: absolute; top: 0; left: 350px;
  width: calc(100% - 350px); height: 100vh;
  z-index: 50; background: var(--map-back);
}
.sidebar {
  position: absolute; top: 0; left: 0;
  width: 350px; height: 100%;
  background-color: var(--bg-soft);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex; flex-direction: column;
  overflow: hidden; padding: 30px 5px 0;
}
.sidebar h2 { font-size: 1.2em; margin: 20px; color: var(--text); }

.sidebar-content {
  flex-grow: 1; overflow-y: auto; margin: 0; padding: 10px; box-sizing: border-box;
  scrollbar-width: none; -ms-overflow-style: none;
}
.sidebar-content::-webkit-scrollbar { display: none; }

.sidebar-content .sidebar-entry {
  margin-bottom: 15px; padding: 10px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 2px 4px var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.sidebar-content .sidebar-entry:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(0,0,0,.2); }
.sidebar-content .sidebar-entry h3 { font-size: 1.2em; margin: 0 0 5px 0; }
.sidebar-content .sidebar-entry p { margin: 0; line-height: 1.4; font-size: .9em; color: var(--muted); }

@media (max-width: 768px) {
  .sidebar { position: relative; width: 100%; height: auto; border-right: none; box-shadow: none; }
  #map { position: relative; top: 0; left: 0; width: 100%; height: 100vh; z-index: 50; }
}

/* =========================
   MAPBOX POPUPS & CONTROLS
   ========================= */
.custom-marker { box-shadow: 0 2px 5px rgba(0,0,0,.3); }
.custom-marker:hover { transform: scale(1.1); }

.mapboxgl-popup-content img { width: 100%; height: auto; border-radius: 5px; margin-bottom: 10px; }
.mapboxgl-popup-content h3 { font-size: 16px; margin: 5px 0; }
.mapboxgl-popup-content {
  font-family: 'Source Sans Pro', sans-serif; font-size: 14px;
  color: var(--popup-text); background: var(--card); border: 1px solid var(--border);
  line-height: 1.5; padding: 10px;
}
.mapboxgl-popup-close-button {
  font-size: 18px; width: 30px; height: 30px; line-height: 30px;
  color: var(--text); cursor: pointer;
}
.mapboxgl-popup-close-button:hover { background-color: var(--bg-soft); color: var(--text); }
.mapboxgl-ctrl-attrib { font-family: 'Montserrat', sans-serif; font-size: 12px; color: var(--muted); }

/* =========================
   TRUNCATION / FADES
   ========================= */
.description-container { position: relative; }
.truncate-text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis; max-height: 4.5em; position: relative; transition: max-height .3s ease;
}
.truncate-text.expanded { -webkit-line-clamp: unset; -webkit-box-orient: unset; overflow: visible; max-height: none; }
.description-container::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1.5em;
  background: linear-gradient(transparent, var(--card)); display: block; pointer-events: none; opacity: 1; transition: opacity .3s ease;
}
.truncate-text.expanded + .description-container::after { opacity: 0; }

.sidebar-entry.active {
  background-color: color-mix(in srgb, var(--brand) 18%, transparent);
  border-left: 4px solid var(--slider-active);
}

/* =========================
   ARTWORK CARDS
   ========================= */
.sidebar .artwork-card {
  width: 100%; max-width: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 10px var(--shadow);
  overflow: hidden; position: relative; cursor: pointer;
  transition: transform .2s ease-in-out; margin-bottom: 20px;
}
.artwork-card:hover { transform: translateY(-5px); }
.artwork-card img { width: 100%; height: 200px; object-fit: cover; display: block; }
.artwork-title {
  font-size: 1.1rem !important; line-height: 1.2 !important; font-weight: bold; position: absolute; top: -14px; left: -14px; max-width: 232px;
  background: rgba(0,0,0,.6); color: #fff !important; padding: 5px 8px; border-radius: 5px;
}
.artwork-artist {
  font-size: .9rem; font-weight: bold; position: absolute; bottom: 6px; right: 6px; max-width: 228px;
  text-align: right; background: rgba(0,0,0,.6); color: #fff !important; padding: 5px 8px; border-radius: 5px;
}
.artwork-card-content { padding: 10px 10px 2px 10px; position: relative; background: transparent; }
.artwork-description { font-family: 'Source Sans Pro', sans-serif; font-size: .9rem; color: var(--text); margin: -3px 0 5px; }
.arrow-indicator { position: absolute; bottom: 10px; right: 10px; font-size: 1.2rem; color: var(--brand); transition: transform .2s ease-in-out; }
.artwork-card:hover .arrow-indicator { transform: translateX(2px); }
.artwork-card a { color: inherit; text-decoration: none; }

/* Base card chrome (home + sidebar) */
.grid-cards .artwork-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 10px var(--shadow);
  height: 200px !important; 
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform .2s ease-in-out;
  container-type: inline-size;
}

.grid-cards .artwork-title {
  font-size: 1.1rem !important; line-height: 1.2 !important; font-weight: bold; position: absolute; top: 6px; left: 6px; max-width: 232px;
  text-align: left !important; background: rgba(0,0,0,.6); color: #fff !important; padding: 5px 8px; border-radius: 5px;
}
/* Keep the narrower constraint specifically in the sidebar */
.sidebar .artwork-card { max-width: 320px; }

/* Force exactly 4 columns on both feeds */
/* Four columns on desktop; responsive down below that */
#recent-painted-grid,
#recent-updated-grid {
  display: grid;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  max-width: 1200px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
@media (min-width: 1100px) {
  #recent-painted-grid,
  #recent-updated-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Remove extra bottom margin inside grids (gap already handles spacing) */
#recent-painted-grid .artwork-card,
#recent-updated-grid .artwork-card {
  margin: 0;
}

/* Hide title/artist when the card is very narrow */
@container (max-width: 130px) {
  .artwork-card .artwork-title,
  .artwork-card .artwork-artist {
    display: none !important;
  }
}

@container (max-width: 120px) {
  .city-button span {
    display: none !important;
  }
}

/* Tidy section spacing */
.home-feed { margin: 24px 0; }
.home-feed:last-of-type { margin-bottom: 0; }

/* =========================
   FILTERS / INPUTS / SLIDER
   ========================= */
#filters { padding: 5px 20px 20px; background-color: var(--card); border-radius: 8px; }
#filters h3 {
  font-size: 1.3em; margin: 20px 0; color: var(--text);
  border-top: 2px solid var(--border); padding: 10px 0 2px; width: 100%; box-sizing: border-box;
}
#filters label { display: flex; align-items: center; margin-bottom: 12px; font-size: 1em; color: var(--muted); }
#filters input[type="checkbox"] { margin-right: 10px; transform: scale(1.2); cursor: pointer; }

#yearRangeDisplay { font-weight: bold; margin-bottom: 20px; text-align: center; font-size: 1.1em; }

/* Inputs */
#artistSearch, #themeSearch {
  width: 100%; padding: 12px; margin: 0 0 10px 0;
  background: var(--input-bg); color: var(--input-text);
  border: 1px solid var(--input-border); border-radius: 6px;
  font-size: 1em; transition: border-color .3s;
}
#artistSearch:focus, #themeSearch:focus { border-color: var(--brand); outline: none; }

/* Suggestions */
#artistSuggestions, #themeSuggestions {
  position: absolute; left: 0; width: 100%; z-index: 999;
  background: var(--card); border-radius: 6px;
  box-shadow: 0 2px 6px var(--shadow); max-height: 200px; overflow-y: auto; list-style: none;
}
#artistSuggestions li, #themeSuggestions li { padding: 10px 12px; cursor: pointer; font-size: 1em; }
#artistSuggestions li:hover, #themeSuggestions li:hover { background: var(--bg-soft); }

/* noUi — final scoped overrides (load this CSS after nouislider.min.css) */
#filters #yearSlider.noUi-target {
  background: var(--slider-track);
  border: 1px solid var(--slider-border);
  border-radius: 8px;
  box-shadow: inset 0 2px 4px var(--shadow);
  height: 12px;
  margin-bottom: 25px;
}
#filters #yearSlider .noUi-connect { background: var(--slider-active); border-radius: 8px; }
#filters #yearSlider .noUi-handle {
  width: 20px; height: 20px; right: -10px; top: -6px;
  background: var(--slider-handle);
  border: 2px solid var(--slider-handle-border);
  border-radius: 50%;
  box-shadow: none;
}
#filters #yearSlider .noUi-handle:before,
#filters #yearSlider .noUi-handle:after { content: none; }
#filters #yearSlider .noUi-handle:hover { transform: scale(1.2); border-color: var(--brand); }
#filters #yearSlider .noUi-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* =========================
   ARTWORK PAGES (MAIN)
   ========================= */
.artwork-images img {
  max-width: 600px; height: auto; border-radius: 8px; object-fit: cover;
  margin: 2px 0; display: block; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.artwork-container {
  max-width: 900px; margin: 10px auto 40px; padding: 20px;
  background: var(--card); overflow: hidden; flex: 3;
}
.artwork-header { margin-bottom: 20px; }
.artwork-header h1 { font-size: 2rem; font-weight: 700; margin: 0; color: var(--text); }
.artwork-header p { font-size: 1.2rem; font-weight: 600; margin: 5px 0 0; color: var(--brand); }

.artwork-content { margin: 20px 0 100px; }
.artwork-content img { width: 100%; max-width: 800px; margin: 10px 0; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.artwork-details { margin-top: 20px; }
.artwork-details p { margin: 10px 0; line-height: 1.5; font-size: 1rem; color: var(--text); }
.artwork-details strong { color: var(--text); }

.content-container { display: flex; flex-direction: row; max-width: 1200px; margin: 100px auto; padding: 20px; gap: 20px; }
@media (max-width: 768px) {
  .content-container { flex-direction: column; gap: 10px; }
  .artwork-container { flex: none; }
  .side-panel { position: relative; max-height: none; top: auto; }
}

/* Side Panel (artwork page) */
.side-panel {
  top: 100px; flex: 1;
  background: var(--card-soft);
  padding: 20px;
  border-radius: 0; position: sticky; top: 100px;
  max-height: calc(100vh - 140px);
  overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.side-panel::-webkit-scrollbar { display: none; }

.thumbnail-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-bottom: 40px; }
.thumbnail-container img { width: 90px; height: 90px; object-fit: cover; border-radius: 2px; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.thumbnail-container img:hover { transform: scale(1.05); }

.side-panel-details p { font-size: 1rem; margin: 5px 0; color: var(--text); display: flex; align-items: center; padding: 6px; }
.side-panel-details a { text-decoration: none; color: var(--text); transition: color .3s ease; }
.side-panel-details a:hover { color: var(--brand); }
.side-panel-details i { width: 20px; height: 20px; display: flex; justify-content: center; margin-right: 16px; color: var(--muted); font-size: 24px; flex-shrink: 0; }

#main-image { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

/* Desktop: fixed-width sidebar + centered contents */
@media (min-width: 768px) {
  .side-panel {
    position: sticky;
    top: 100px;           /* you had two 'top' declarations; keep one */
    flex: 0 0 320px;      /* stop flexing; make it a fixed column */
    width: 320px;
    max-width: 320px;
  }

  /* Center all direct children (thumb grid, details, actions) */
  .side-panel > * {
    max-width: 320px;
    margin-left: 0px;
    margin-right: 0px;
  }

  /* Center the thumbnail grid, use fixed tracks so it doesn't sprawl */
  .side-panel .thumbnail-container {
    display: grid;
    grid-template-columns: repeat(3, 90px); /* 3 columns of fixed 90px */
    gap: 6px;
    justify-content: center;                 /* center the grid block */
    width: max-content;                      /* shrink-wrap to its tracks */
  }

  .side-panel .thumbnail-container img {
    width: 90px; height: 90px; object-fit: cover;
  }
}

/* Mobile already becomes full width; keep thumbs hidden there per your rule */
@media (max-width: 768px) {
  .side-panel { width: 100%; max-width: none; }
}

.bottom-panel {
  flex: 1; background: var(--card-soft);
  border-radius: 0; padding-top: 30px; top: 100px;
  font-size: .8em; color: var(--muted);
}

/* Skeletons */
.skeleton { position: relative; color: transparent; background: var(--card-soft); border-radius: 6px; }
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.06), transparent);
  animation: sanw-shimmer 1.1s infinite;
}
@keyframes sanw-shimmer { 100% { transform: translateX(100%); } }
.skeleton[aria-busy="false"] { color: inherit; background: transparent; }
.muted { opacity: .8; }

/* Progressive image blur-up */
.with-blur { filter: blur(10px); transition: filter .25s ease; }
.with-blur.is-ready { filter: blur(0); }

/* =========================
   FOOTER
   ========================= */
.footer {
  background-color: var(--bg); color: var(--text);
  text-align: center; padding: 20px 0; position: relative; bottom: 0; width: 100%; font-size: 1rem;
}
.footer p { margin: 0; font-size: 1rem; }
.footer a { color: var(--text); text-decoration: none; font-weight: 600; transition: color .3s; }
.footer a:hover { color: var(--muted); }

/* =========================
   MISC / UTIL
   ========================= */
.static-map-container { margin-top: 20px; text-align: center; overflow: hidden; }
.static-map { width: 100%; height: auto; border-radius: 8px; }

.side-panel-actions { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; justify-content: left; }
.side-panel-actions a { width: 20px; height: 20px; color: var(--muted); font-size: 24px; text-decoration: none; transition: color .3s ease; }
.side-panel-actions a:hover { color: var(--brand); }
.side-panel-actions i { display: inline-block; }

.return-to-map { color: var(--slider-active); text-decoration: underline; font-size: 16px; cursor: pointer; display: inline-block; margin-bottom: 10px; transition: color .3s ease; }
.return-to-map:hover { color: var(--brand); }

blockquote {
  margin: 20px 0; padding-left: 20px; border-left: 4px solid var(--brand);
  font-style: italic; background-color: var(--bg-soft); font-size: 1.1em;
}

/* Base: instant show */
.loading-overlay {
  position: fixed; inset: 0;
  display: flex; justify-content: center; align-items: center;
  background: var(--overlay-bg);
  z-index: 1000;
  opacity: 0; /* hidden until fade-in triggered */
  visibility: hidden;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity .35s ease, visibility .35s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility .35s ease;
}

/* First-visit only: fade-in on show */
.loading-overlay.fade-on-show{ opacity:0; }                 /* start transparent */
.loading-overlay.fade-on-show.is-visible{
  transition: opacity .35s ease;
  opacity:1;                                                /* fade to visible */
}

.loading-spinner{ display:flex; justify-content:center; align-items:center; background:transparent; }
.spinner{
  border:4px solid var(--spinner-track);
  border-top:4px solid var(--brand);
  border-radius:50%;
  width:50px; height:50px; animation:spin 1s linear infinite;
}
@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}

footer#loginStatus { text-align: center; font-size: 1.2em; color: var(--muted); padding: 10px; }
footer#loginStatus i { transition: color .3s ease; }

/* Modal */
.modal {
  display: none; position: fixed; z-index: 1000;
  left: 0; right: 0; bottom: 0; width: 100%;
  background: var(--backdrop); animation: slideUp .3s ease-out;
}
.modal-content {
  background-color: var(--card);
  padding: 20px; max-width: 500px; margin: 0 auto;
  border-radius: 12px 12px 0 0; position: relative; bottom: 0;
}
.close-btn { position: absolute; right: 15px; top: 10px; font-size: 24px; cursor: pointer; }
textarea {
  width: 100%; padding: 10px; font-family: inherit; font-size: 1rem;
  background: var(--input-bg); color: var(--input-text); border: 1px solid var(--input-border); border-radius: 6px; resize: vertical;
}
#submitSuggestion {
  margin-top: 10px; background-color: #285A98; color: #fff;
  padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer;
}
#suggestionStatus { margin-top: 10px; }

/* Theme toggle */
.theme-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 10px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  border: 1px solid color-mix(in srgb, var(--text) 20%, transparent);
  font: 500 14px/1 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  cursor: pointer; box-shadow: 0 2px 10px var(--shadow); user-select: none;
}
.theme-toggle svg { width: 18px; height: 18px; }
@media print { .theme-toggle { display: none; } }

/* Clamp exactly 3 lines, even if inner HTML has <p>, <br>, etc. */
.artwork-description {
  line-height: 1.2;
  /* the clamp */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;    /* number of lines */
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

/* Force block children to behave like inline content inside the clamp */
.artwork-description > * {
  display: inline;
  margin: 0;
  padding: 0;
}
/* Full artwork page (main description area) */
.artwork-container .artwork-description,
.artwork-details .artwork-description {
  display: block;
  -webkit-line-clamp: initial;
  -webkit-box-orient: initial;
  overflow: visible;
}
.artwork-container .artwork-description ul,
.artwork-container .artwork-description ol,
.artwork-details ul,
.artwork-details ol {
  list-style: disc outside;          /* decimal outside for <ol> if you prefer */
  padding-left: 1.25rem;             /* indent bullets/numbers */
  margin: .5rem 0;
}
.artwork-container .artwork-description li,
.artwork-details li {
  display: list-item !important;     /* override the card clamp’s inline rule */
  margin: .25rem 0;
  line-height: 1.6;
}

/* Optional: hide explicit line breaks that defeat the clamp */
.artwork-description br { display: none; }

/* Optional: soft fade at the bottom without adding height */
.artwork-description::after {
  content: "";
  position: absolute;
  right: 0; bottom: 0; left: 0;
  height: 0.4em;
  background: linear-gradient(transparent, var(--card));
  pointer-events: none;
}

/* Duration/curve tokens */
:root {
  --theme-xdur: 220ms;
  --theme-xease: cubic-bezier(.2,.8,.2,1);
}
:root.theme-dark {
  /* same durations in dark */
}

/* Only animate during an actual toggle (see JS below) */
.theme-animating .navbar,
.theme-animating .sidebar,
.theme-animating .side-panel,
.theme-animating .bottom-panel,
.theme-animating .footer,
.theme-animating .artwork-card,
.theme-animating .mapboxgl-popup-content,
.theme-animating body,
.theme-animating .content-container,
.theme-animating .sidebar-entry,
.theme-animating #filters,
.theme-animating #filters input,
.theme-animating #filters label,
.theme-animating #artistSearch,
.theme-animating #themeSearch,
.theme-animating #artistSuggestions,
.theme-animating #themeSuggestions {
  transition:
    background-color var(--theme-xdur) var(--theme-xease),
    color            var(--theme-xdur) var(--theme-xease),
    border-color     var(--theme-xdur) var(--theme-xease),
    box-shadow       var(--theme-xdur) var(--theme-xease);
}

/* Helpful utilities for icons/SVGs */
.theme-animating svg,
.theme-animating .icon,
.theme-animating [class*="fa-"] {
  transition: color var(--theme-xdur) var(--theme-xease),
              fill  var(--theme-xdur) var(--theme-xease),
              stroke var(--theme-xdur) var(--theme-xease);
}

/* EXCLUSIONS: don’t animate images or canvases */
.theme-animating img,
.theme-animating canvas,
.theme-animating .mapboxgl-canvas,
.theme-animating .static-map {
  transition: none !important;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .theme-animating * { transition: none !important; }
}

.theme-animating blockquote,
.theme-animating .modal-content,
.theme-animating .copy-url-button,
.theme-animating .return-to-map {
  transition:
    background-color var(--theme-xdur) var(--theme-xease),
    color            var(--theme-xdur) var(--theme-xease),
    border-color     var(--theme-xdur) var(--theme-xease),
    box-shadow       var(--theme-xdur) var(--theme-xease);
}

/* =========================
   HOME PAGE ONLY
   ========================= */

/* Cards grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
@media (max-width: 1200px) { .grid-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .grid-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .grid-cards { grid-template-columns: 1fr; } }

.card {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px var(--shadow);
  text-decoration: none; color: inherit;
}
.card-image { aspect-ratio: 4 / 3; overflow: hidden; }
.card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 12px; }
.card-title { font-weight: 600; margin: 0 0 4px; }
.card-meta { color: var(--muted); font-size: .9rem; }

/* Hero */
.hero {
  /* keep your image */
  background-image: url('');
  background-size: cover;
  background-position: center;
  background-blend-mode: overlay;
  animation: kenburns 10s ease-in-out;
  filter: blur(0);
  color: #fff;

  /* layout */
  position: relative;
  margin: 60px 0 0;
  height: 40vh;
  min-height: 320px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  text-align: center;
  padding: 0 20px;
}
@keyframes kenburns { 0% { background-size: 110%; } 100% { background-size: 100%; } }
.hero::before {
  content: "";
  position: absolute; inset: 0;
  /* theme-aware vignette; a touch lighter in light mode, darker in dark mode */
  background:
    radial-gradient(circle, transparent 10%, rgba(0,0,0,.55) 70%);
  z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 {
  font-size: 3rem; font-weight: 700;
  margin: 40px 0 20px;
  text-shadow: 3px 3px 5px rgba(0,0,0,.7);
}
.hero p {
  font-size: 1.2rem; font-weight: 600;
  margin-bottom: 40px; max-width: 700px;
  text-shadow: 2px 2px 4px rgba(0,0,0,.6);
}
/* Medium hero on mobile */
@media (max-width: 800px) {
  .hero {
    height: clamp(240px, 38svh, 360px); /* between desktop 40vh and mobile 22svh */
    min-height: 0;                      /* override the 320px desktop min */
    padding: 10px 16px;
  }
  .hero h1 {
    font-size: clamp(1.6rem, 5.2vw, 2.2rem);
    margin: 18px 0 10px;
  }
  .hero p {
    font-size: clamp(1rem, 3.4vw, 1.15rem);
    margin-bottom: 14px;
    max-width: 640px;
  }
}
/* Smaller hero on mobile */
@media (max-width: 600px) {
  .hero {
    /* much shorter */
    height: clamp(120px, 22svh, 200px);
    min-height: 0;           /* override the desktop 320px */
    padding: 8px 14px;
  }
  .hero h1 {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
    margin: 12px 0 8px;
  }
  .hero p {
    font-size: clamp(.9rem, 3.6vw, 1rem);
    margin-bottom: 10px;
  }
}

/* Ultra-small screens: tighten further (optional) */
@media (max-width: 380px) {
  .hero { height: clamp(110px, 18svh, 160px); }
  .hero p { display: none; } /* hide subtitle if space is too tight */
}

/* Text sections (tokenized variants) */
.text-section {
  padding: 60px 20px;
  text-align: center;
  margin: 0 auto;
  background: var(--card);
}
.text-section h2 {
  font-size: 2rem; font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.text-section p {
  font-size: 1rem; line-height: 1.6;
  color: var(--muted);
  max-width: 1200px; margin: 0 auto;
}
@media (max-width: 800px) {
  .text-section {
    padding: 40px 18px;
  }
  .text-section h2 {
    font-size: clamp(1.4rem, 4.6vw, 1.8rem);
    margin-bottom: 12px;
    text-align: center;
  }
  .text-section p {
    font-size: clamp(1rem, 3.2vw, 1.1rem);
    line-height: 1.65;
    max-width: 820px;
    margin: 0 auto;
  }
  .text-section p + p { margin-top: 0.8em; }
}
@media (max-width: 600px) {
  .text-section {
    padding: 28px 16px;
  }
  .text-section h2 {
    font-size: clamp(1.25rem, 6vw, 1.5rem);
    margin-bottom: 10px;
    text-align: center; /* keep heading centered */
  }
  .text-section p {
    font-size: clamp(.95rem, 3.8vw, 1rem);
    line-height: 1.6;
    max-width: 680px;
    margin: 0 auto;
  }
  .text-section p + p { margin-top: 0.7em; }
}
/* Variants: use utility classes instead of nth-child */
.text-section.is-muted { background: var(--bg-soft); }
.text-section.is-plain { background: var(--card); }

/* CTA buttons */
.cta-buttons {
  display: flex; gap: 20px; flex-wrap: wrap; justify-content: center;
}
.cta-buttons a {
  display: inline-block;
  padding: 12px 22px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem; font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color .2s ease, transform .1s ease;
}
.cta-buttons a:hover { background: var(--brand-strong); }
.cta-buttons a:active { transform: translateY(1px); }

/* City buttons grid */
.city-buttons-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
.city-button {
  position: relative;
  display: block;
  height: 150px;
  background-size: cover;
  background-position: center;
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  transform: translateZ(0); /* promote to its own layer for smoother hover */
}
.city-button::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);  /* overlay for legibility */
  transition: background .3s ease;
}
/* Hover effects for city tiles */
.city-button:hover {
  transform: scale(1.02);
  filter: brightness(1.12);       /* lift the image a bit */
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.city-button:hover::after {
  background: rgba(0,0,0,0.18);   /* lighten the overlay so the tile looks brighter */
}
.city-button span {
  position: absolute; left: 10px; bottom: 10px;
  font-size: 1.2rem; font-weight: 700; color: #fff;
  z-index: 1;
}

/* Social icons row */
.social-icons {
  display: flex; justify-content: center; gap: 14px; margin: 20px 0;
}
.social-icons .icon {
  width: 40px; height: auto;
  opacity: .9;
  transition: transform .2s ease, opacity .2s ease;
  /* avoid hard-coded grayscale/brightness so icons also look good on dark */
}
/* All social icons white in dark mode */
:root.theme-dark .social-icons img {
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

/* Facebook hover tint */
:root.theme-dark .social-icons img.facebook-icon:hover {
  filter: brightness(0) saturate(100%) invert(34%) sepia(99%) saturate(607%) hue-rotate(182deg) brightness(92%) contrast(94%);
}

/* Instagram hover tint (approximate gradient mid-color) */
:root.theme-dark .social-icons img.instagram-icon:hover {
  filter: brightness(0) saturate(100%) invert(30%) sepia(71%) saturate(6172%) hue-rotate(316deg) brightness(96%) contrast(89%);
}

/* Medium hover tint */
:root.theme-dark .social-icons img.medium-icon:hover {
  filter: brightness(0) invert(78%) sepia(0%) saturate(0%) hue-rotate(178deg) brightness(98%) contrast(97%);
}

/* Medium icon colour fix in dark mode */
:root.theme-dark img.medium-icon {
  filter: invert(1) hue-rotate(180deg);
}
.social-icons .icon:hover { transform: scale(1.07); opacity: 1; }
@media (max-width: 768px) { .social-icons .icon { width: 30px; } }
@media (max-width: 480px) { .social-icons .icon { width: 26px; } }

/* “Featured artworks” strip on the home page */
.artworks-section { width: 90%; max-width: 1200px; margin: 0 auto; padding: 40px 0; }
.artworks-section h2 { font-size: 1.8rem; margin-bottom: 16px; color: var(--text); }

/* Reuse the global card styling; just define the grid here */
.artworks-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 40px;
}
@media (max-width: 1024px) { .artworks-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .artworks-grid { grid-template-columns: 1fr; } }

/* Links in body copy on home (use tokens) */
.text-section a { color: var(--link); text-decoration: none; }
.text-section a:hover { color: var(--link-hover); }

/* Dropdown (tokenized) */
.dropdown-btn {
  font: 600 16px/1 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border);
  width: 100%; padding: 10px; text-align: left; cursor: pointer; margin: 6px 0;
  border-radius: 6px;
  transition: background-color .2s ease, border-color .2s ease;
}
.dropdown-btn:hover { background: color-mix(in srgb, var(--bg-soft) 90%, var(--text)); }
.dropdown-content {
  display: none;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px; margin-top: 6px;
  font-family: 'Source Sans Pro', system-ui, -apple-system, Segoe UI, Roboto, Arial;
}
.dropdown-content p { margin: 0; }

/* Utility: show dropdown when parent has .open */
.dropdown.open .dropdown-content { display: block; }

  /* Adjust this height based on how tall the widget is on load */
  .lightwidget-wrap {
	display: flex;
	justify-content: center;
    width: 100%;
	padding-inline: 16px;
    min-height: 340px; /* enough to fit the widget without shifting */
    overflow: hidden;
    border: 0;
  }
  .lightwidget-widget {
    display: block;
    width: clamp(320px, 95vw, 1080px);
	max-width: 1200px;
    border: 0;
    overflow: hidden;
  }

  /* ===========================================================
   FORMS (add / edit / submit) + DASHBOARD — THEME-INTEGRATED
   =========================================================== */

/* Typography + controls */
body,
input, textarea, select, button, label {
  font-family: 'Montserrat', sans-serif, Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.2;
  color: var(--text);
}

/* Shared containers */
.submit-container,
.content {
  max-width: 1200px;
  margin: 80px auto;
  padding: 20px;
  background: var(--card);
  border-radius: 8px;
}

/* Headings in admin/dashboard areas */
.content h1,
.submit-container h1,
.content h2,
.submit-container h2 {
  color: var(--brand);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: var(--card);
}
th, td {
  padding: 10px 15px;
  text-align: left;
  border: 1px solid var(--border);
  color: var(--text);
}
th {
  background: var(--bg-soft);
  font-weight: 700;
}

/* Buttons */
button,
.map-toggle-btn {
  background-color: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 15px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color .25s ease, transform .05s ease;
}
button:hover,
.map-toggle-btn:hover { background-color: var(--brand-strong); }
button:active,
.map-toggle-btn:active { transform: translateY(1px); }
button:disabled {
  background-color: var(--brand) !important;
  color: var(--muted);
  cursor: not-allowed;
  opacity: .7;
}

/* Inputs/selects */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  font-size: 16px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--input-text);
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

/* Readonly */
input[readonly] {
  background: var(--bg-soft);
  color: var(--muted);
  cursor: not-allowed;
}

/* Field layout helpers */
.form-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.form-table td { border: none; padding: 10px 0; vertical-align: top; }

.field-group { display: flex; align-items: center; gap: 10px; }

.single-row { display: flex; align-items: center; gap: 10px; }
.single-row label {
  flex-shrink: 0; min-width: 150px; text-align: right; font-weight: 700; color: var(--text);
}
.single-row input { flex: 1; }

.dual-row { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
.dual-row .field-group { flex: 1; }
.dual-row label {
  flex-shrink: 0; min-width: 150px; text-align: right; font-weight: 700; color: var(--text);
}
.dual-row input, .dual-row select { flex: 1; }

/* QUILL EDITOR STYLING */
#editor-container {
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: #f9f9f9;
  padding: 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  color: #333;
  min-height: 200px;
  max-height: 400px;
  overflow: hidden;
  width: 800px;
}
/* Quill toolbar icon fix for dark mode */
:root.theme-dark .ql-toolbar .ql-stroke {
  stroke: var(--text); /* use your theme's text color */
}

:root.theme-dark .ql-toolbar .ql-fill {
  fill: var(--text);
}

:root.theme-dark .ql-toolbar .ql-picker-label,
:root.theme-dark .ql-toolbar .ql-picker-item {
  color: var(--text);
}

/* Optional: lighten hover state slightly */
:root.theme-dark .ql-toolbar button:hover .ql-stroke,
:root.theme-dark .ql-toolbar button:hover .ql-fill {
  stroke: var(--link);
  fill: var(--link);
}

#editor-container .ql-toolbar {
  display: none;
  border-bottom: 1px solid #ddd;
  background-color: #fff;
  padding: 0;
}
#editor-container .ql-container {
  flex: 1;
  padding: 10px;
  background-color: #fff;
  font-size: 16px;
  line-height: 1.5;
  font-family: 'Montserrat', sans-serif;
  color: #333;
  overflow-y: auto;
}

/* Images grid (drag & drop) */
#imagesContainer {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0;
}
.thumbnail {
  position: relative;
  width: 190px; height: 128px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: move;
  background: var(--card-soft);
}
.thumbnail img { max-width: 100%; max-height: 100%; object-fit: cover; pointer-events: none; }
/* Ensure remove button has consistent look */
.remove-btn {
  position: absolute; top: 5px; right: 5px;
  background-color: rgba(0, 0, 0, 0.5); /* dark semi-transparent */
  color: #fff; /* white text/icon */
  border: none;
  border-radius: 50%;
  cursor: pointer;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.remove-btn:hover {
  opacity: 1;
}

/* In light mode, keep same look */
:root .remove-btn {
  background-color: rgba(0, 0, 0, 0.5);
}

/* In dark mode, keep same look */
:root.theme-dark .remove-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}


/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  padding: 20px; text-align: center; margin-top: 20px; cursor: pointer;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  transition: background-color .2s ease, border-color .2s ease;
}
.drop-zone.drag-over {
  background: var(--bg-soft);
  border-color: var(--text);
}

/* Map popup (used in forms) */
.map-popup {
  display: none;
  position: fixed;
  inset: 0;
  width: 500px;
  height: 420px;
  margin: auto;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 1000;
  padding: 10px;
  border: 1px solid var(--border);
}

.map-popup-content { position: relative; width: 100%; height: 100%; }

.map-popup #editMap {
  position: absolute !important;   /* defeat global #map rules */
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  left: 0 !important;
  top: 0 !important;
  border-radius: 6px;
}

.close-btn {
  position: absolute; top: 10px; right: 15px;
  font-size: 24px; cursor: pointer; color: var(--brand); font-weight: 800; z-index: 10000;
}
.close-btn:hover { color: var(--brand-strong); }
.map-popup #map {
  width: 100%;
  height: 100%;
  left: 0;
  border-radius: 6px;
}

/* =========================
   AUTH (LOGIN)
   ========================= */
.auth-wrap {
  min-height: 100vh;
  padding: 80px 16px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 6px 20px var(--shadow);
}

.auth-heading {
  margin: 0 0 12px 0;
  color: var(--brand);
  font-weight: 800;
  text-align: center;
}

.auth-card label {
  font-weight: 600;
  margin: 12px 0 6px;
  display: block;
  color: var(--text);
}

.auth-keep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: .95rem;
}

.auth-card button {
  width: 100%;
  margin-top: 8px;
}

.auth-message {
  margin-top: 10px;
  text-align: center;
  min-height: 1.2em;
}

/* ==================
   DASHBOARD elements
   ================== */

.navbar-logo a { color: var(--brand); font-weight: 700; text-decoration: none; }

.content { /* already defined above for container */ }

.dashboard-section {
  background: var(--bg-soft);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.dashboard-section ul { list-style: none; margin: 0; padding: 0; }
.dashboard-section li { margin: 6px 0; }

/* Quick grids */
.two-columns   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.three-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.four-columns  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.artwork-entry {
  display: flex; align-items: center;
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 2px 0px;
}
.artwork-entry img {
  width: 40px; height: 40px; border-radius: 4px; margin-right: 10px; object-fit: cover;
}
.artwork-entry {
  line-height: 1.2em !important;
}

/* Stats row & cards */
.stats-row { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.stat-box {
  flex: 1 1 200px;
  background: var(--brand);
  color: #fff;
  padding: 24px 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px var(--shadow);
}
.stat-box h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 8px; }
.stat-box div { font-size: 2rem; font-weight: 800; }

/* Tooltips */
.hover-tooltip { position: relative; display: inline-block; cursor: default; }
.tooltip-text {
  visibility: hidden;
  background: var(--text);
  color: var(--bg);
  text-align: left;
  padding: 6px 10px; border-radius: 6px;
  position: absolute; z-index: 1;
  top: 125%; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 14px;
  box-shadow: 0 2px 6px var(--shadow);
  min-width: 120px;
}
.hover-tooltip:hover .tooltip-text { visibility: visible; }

/* Respect your global smoothing transitions */
.submit-container,
.content,
table, th, td,
input, textarea, select, button,
.drop-zone, .thumbnail, .dashboard-section, .stat-box {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease, box-shadow .25s ease;
}

/* === Quill editor: always light (white) regardless of site theme === */
.ql-snow .ql-toolbar,
.ql-container.ql-snow,
.ql-snow .ql-editor {
  background: #ffffff !important;
  color: #111 !important;
  border-color: #ddd !important;
}

.ql-snow .ql-toolbar .ql-stroke { stroke: #111 !important; }
.ql-snow .ql-toolbar .ql-fill   { fill:   #111 !important; }
.ql-snow .ql-picker-label,
.ql-snow .ql-picker-item { color: #111 !important; }

/* Remove site-wide blockquote styling inside editor */
.ql-container .ql-editor blockquote {
  background: #ffffff !important;   /* kill the dark strip */
  color: #111 !important;
  margin: .75rem 0;
  padding-left: 1rem;
  border-left: 4px solid #e5e7eb !important;  /* subtle left rule */
  font-style: italic;
}

/* Optional: code blocks readable on white */
.ql-container .ql-editor pre,
.ql-container .ql-editor code {
  background: #f6f8fa !important;
  color: #111 !important;
  border-radius: 6px;
  padding: .5rem .75rem;
}

/* === MAP PAGE (no sidebar) — CANONICAL BLOCK === */
:root { --nav-h: 60px; --tile-ratio: 3/2; } /* adjust ratio if you like */

body.no-sidebar .sidebar { display: none !important; }
#map:not(.default-split) {
  position: fixed;
  top: var(--nav-h, 60px);
  left: 0;
  width: 100%;
  /* Multiple viewport fallbacks for widest support */
  height: calc(100vh  - var(--nav-h, 60px));
  height: calc(100dvh - var(--nav-h, 60px));
  height: calc(100svh - var(--nav-h, 60px));
  z-index: 10;
}

body.no-sidebar #map {
  position: fixed !important;
  top: var(--nav-h) !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100svh - var(--nav-h)) !important;
  z-index: 10;
}

/* Toolbar */
.map-toolbar {
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 8px;
  align-items: center;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
@media (max-width: 700px){ .map-toolbar { left: 12px; transform: none; } }

.toolbar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-weight: 700; cursor: pointer;
}
.toolbar-btn[aria-expanded="true"] {
  outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
}

/* Backdrop */
.panel-backdrop { position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(0,0,0,.28); z-index: 20; }

/* Floating panels */
.float-panel {
  position: fixed; top: calc(var(--nav-h) + 56px); left: 50%;
  transform: translateX(-50%);
  width: clamp(320px, 92vw, 760px);
  max-height: calc(100svh - var(--nav-h) - 80px);
  background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
  z-index: 40; display: flex; flex-direction: column;
}
.float-panel[hidden] { display: none; }

.float-panel__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.float-panel__header h3 { margin: 0; font-size: 1.1rem; }
.panel-close {
  background: transparent; border: 0; font-size: 22px; cursor: pointer;
  color: var(--text); width: 32px; height: 32px; line-height: 32px; text-align: center;
  border-radius: 6px;
}
.panel-close:hover { background: var(--bg-soft); }
.float-panel__body { padding: 12px; overflow: auto; }

/* Panel widths */
#filtersPanel { width: clamp(320px, 92vw, 520px); }
#artworksPanel.float-panel--wide { width: clamp(360px, 96vw, 1100px); }

@media (max-width: 480px){
  .float-panel {
    top: calc(var(--nav-h) + 48px);
    width: calc(100vw - 16px);
    left: 8px; transform: none;
    max-height: calc(100svh - var(--nav-h) - 64px);
  }
}

/* Suggestions above panel content */
#artistSuggestions, #themeSuggestions { position: relative; z-index: 2; }

/* === ARTWORKS PANEL — GRID + CARD === */
#artworksPanel .sidebar-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

#artworksPanel .artwork-card {
  overflow: visible;           /* show description below image */
  container-type: inline-size;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 10px var(--shadow);
}

/* Media area: fixed ratio; top corners rounded only */
#artworksPanel .artwork-card .artwork-media,
#artworksPanel .artwork-card > div:first-child {
  position: relative;
  aspect-ratio: var(--tile-ratio);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

/* Image fill (no letterboxing) */
#artworksPanel .artwork-card .artwork-media img,
#artworksPanel .artwork-card > div:first-child img {
  position: absolute; inset: 0;
  width: 100%; height: 100% !important;
  object-fit: cover; border-radius: 0; display: block;
}

/* Ribbons: smaller & tucked into corners */
#artworksPanel .artwork-title {
  font-size: .95rem; padding: 4px 8px;
  top: 6px; left: 6px; border-radius: 8px;
  max-width: calc(100% - 12px); z-index: 1;
}
#artworksPanel .artwork-artist {
  font-size: .85rem; padding: 4px 8px;
  right: 6px; bottom: 6px; border-radius: 8px;
  max-width: calc(100% - 12px);
}

/* Content flush with bottom */
#artworksPanel .artwork-card-content { padding: 8px 10px 0; }

/* Safari clipping quirk */
@supports (-webkit-hyphens:none) {
  #artworksPanel .artwork-card .artwork-media,
  #artworksPanel .artwork-card > div:first-child {
    -webkit-mask-image: -webkit-radial-gradient(white, black);
  }
}

/* === ARTWORK PAGE: MOBILE THUMBS UNDER MAIN IMAGE (refined) === */
.mobile-thumbs {
  display: none;
  margin-top: 0px;
  gap: 2px;
  justify-content: center; /* center the grid */
}

.mobile-thumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform .15s ease;
}
.mobile-thumbs img:hover { transform: scale(1.05); }

@media (max-width: 768px) {
  .mobile-thumbs {
    display: flex;
    flex-wrap: wrap;
  }
  .side-panel .thumbnail-container {
    display: none !important;
  }
}
