/* =========================
   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);
  --spinner-track: rgba(0, 0, 0, 0.1);
  --backdrop: rgba(0,0,0,0.45);

  /* Theme animation */
  --theme-xdur: 220ms;
  --theme-xease: cubic-bezier(.2,.8,.2,1);

  /* Nav */
  --nav-h: 60px;
  --tile-ratio: 3/2;
}

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

  --brand: #D7153A;
  --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);
  --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; }

/* Browse dropdown */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-btn {
  background: none; border: none;
  color: var(--brand); font-weight: 600;
  font-size: inherit; font-family: inherit;
  cursor: pointer; padding: 0; margin-right: 30px;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .3s;
}
.nav-dropdown-btn:hover { color: var(--brand-strong); background: none; }
.nav-chevron { font-size: 0.7rem; transition: transform 0.2s ease; }
.nav-dropdown.open .nav-chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none;
  position: absolute; top: calc(100% + 10px); left: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  min-width: 140px; z-index: 1001; overflow: hidden;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 10px 16px;
  color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 0.9rem;
  margin-right: 0; transition: background 0.15s;
}
.nav-dropdown-menu a:hover { background: var(--bg-soft); color: var(--brand); }

.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 {
    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; }
  .nav-dropdown { display: contents; }
  .nav-dropdown-btn { display: none; }
  .nav-dropdown-menu {
    display: contents; position: static;
    background: none; border: none;
    box-shadow: none; min-width: auto;
  }
  .nav-dropdown-menu a { padding: 0; font-size: 14px; margin-right: 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.02em;
}

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0;
  display: flex; justify-content: center; align-items: center;
  background: var(--overlay-bg);
  z-index: 1000;
  opacity: 0;
  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;
}
.loading-overlay.fade-on-show { opacity: 0; }
.loading-overlay.fade-on-show.is-visible {
  transition: opacity .35s ease;
  opacity: 1;
}

.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 (bottom sheet) */
.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: var(--brand); 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; } }

/* Status pill */
.status-pill {
  padding: 6px 16px; border-radius: 999px;
  border: 2px solid var(--border); background: var(--card) !important;
  color: var(--text); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.status-pill.active { background: var(--brand) !important; color: #fff; border-color: var(--brand); }
.status-pill:hover:not(.active) { border-color: var(--brand); color: var(--brand); background: var(--card) !important; }

/* 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); }

/* Truncation / description fade */
.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; }

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

/* Login page — dot matrix background, light/dark mode aware */
body[data-page="login"] {
  background-color: var(--bg);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--muted) 30%, transparent) 1px, transparent 1px);
  background-size: 14px 14px;
}

.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; 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; }

/* =========================
   THEME ANIMATION
   ========================= */
.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);
}
.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);
}
.theme-animating img,
.theme-animating canvas,
.theme-animating .mapboxgl-canvas,
.theme-animating .static-map { transition: none !important; }
@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);
}