:root {
      --bg: #f5f0e8;
      --bg2: #ede8dc;
      --surface: #faf7f2;
      --surface-strong: #fffdf9;
      --ink: #1c1712;
      --ink-soft: #6b6458;
      --gold: #b8860b;
      --gold-lt: #d4a017;
      --rust: #8b3a2a;
      --green: #3a5c3a;
      --border: rgba(28, 23, 18, 0.12);
      --shadow: 0 10px 35px rgba(28, 23, 18, 0.12);
      --radius: 10px;
      --header-h: 58px;
      --filter-h: 58px;
      --panel-w: 390px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    html, body { height: 100%; }
    body {
      font-family: 'DM Sans', sans-serif;
      background: var(--bg);
      color: var(--ink);
      overflow: hidden;
      font-size: 15px;
      line-height: 1.6;
    }
    button, input { font: inherit; }
    a { color: inherit; }

    #app {
      display: flex;
      flex-direction: column;
      height: 100dvh;
      min-height: 100vh;
      overflow: hidden;
    }

    header {
      min-height: var(--header-h);
      background: var(--ink);
      color: var(--bg);
      display: flex;
      align-items: center;
      gap: 18px;
      padding: 10px 18px;
      border-bottom: 2px solid var(--gold);
      z-index: 100;
    }
.site-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

    .site-logo img {
        display: block;
        height: 60px;
        width: auto;
        max-height: none;
    }

    .logo {
      font-family: 'Cormorant Garamond', serif;
      font-size: clamp(1.2rem, 2.2vw, 1.55rem);
      font-weight: 700;
      letter-spacing: .04em;
      white-space: nowrap;
    }
    .logo span { color: var(--gold-lt); font-style: italic; }

    .header-meta {
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .header-meta small {
      font-size: 11px;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: rgba(245,240,232,.72);
    }

    .header-actions {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .header-btn {
      border: 1px solid rgba(255,255,255,.14);
      background: rgba(255,255,255,.06);
      color: var(--bg);
      border-radius: 999px;
      padding: 8px 14px;
      cursor: pointer;
      transition: .2s ease;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      white-space: nowrap;
    }
    .header-btn:hover { background: rgba(255,255,255,.12); }
    .header-btn.primary {
      background: var(--gold);
      color: #fff;
      border-color: var(--gold);
    }
    .header-btn.primary:hover { background: var(--gold-lt); }
    .header-btn.is-loading { opacity: .7; pointer-events: none; }
    .header-btn.is-active { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); }

.map-controls .header-btn {
    color: var(--ink);
    border: 1.5px solid var(--border);
}

    .filterbar {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 18px;
      flex-wrap: wrap;
      z-index: 90;
    }

    .filter-label {
      font-family: 'Cormorant Garamond', serif;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--ink-soft);
      margin-right: 2px;
    }

    .filter-group {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }

    .filter-pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 7px 14px;
      border-radius: 999px;
      border: 1.5px solid var(--border);
      background: transparent;
      font-size: 12.5px;
      font-weight: 500;
      color: var(--ink-soft);
      cursor: pointer;
      transition: .2s ease;
    }
    .filter-pill:hover {
      border-color: var(--gold);
      color: var(--gold);
    }
    .filter-pill.active {
      background: var(--ink);
      color: var(--bg);
      border-color: var(--ink);
    }
    .filter-pill .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--gold);
    }

    .search-wrap {
      margin-left: auto;
      position: relative;
      min-width: min(320px, 100%);
      max-width: 100%;
      flex: 0 1 280px;
    }
    .search-wrap input {
      width: 100%;
      padding: 10px 14px 10px 38px;
      border: 1.5px solid var(--border);
      border-radius: 999px;
      background: var(--bg2);
      color: var(--ink);
      outline: none;
      transition: border-color .2s ease;
    }
    .search-wrap input:focus { border-color: var(--gold); }
    .search-wrap input::placeholder { color: var(--ink-soft); }
    .search-wrap svg {
      position: absolute;
      left: 13px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--ink-soft);
      pointer-events: none;
    }

    .content-area {
      display: flex;
      flex: 1;
      min-height: 0;
      overflow: hidden;
      position: relative;
    }

    .side-panel {
      width: var(--panel-w);
      flex-shrink: 0;
      background: var(--surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      min-height: 0;
      z-index: 40;
      transition: transform .3s ease, width .3s ease;
    }
    .side-panel.collapsed {
      width: 0;
      border-right: none;
      overflow: hidden;
    }

    .location-list {
      overflow-y: auto;
      flex: 1;
      min-height: 0;
    }

    .loc-card {
      display: flex;
      gap: 14px;
      padding: 16px 18px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      position: relative;
      transition: background .18s ease;
    }
    .loc-card:hover, .loc-card.active { background: var(--bg2); }
    .loc-card.active::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 3px;
      background: var(--gold);
    }

    .loc-thumb {
      width: 58px;
      height: 58px;
      border-radius: 10px;
      background: linear-gradient(135deg, #d8cfbc, #e7dfd2);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      font-family: 'Cormorant Garamond', serif;
      font-size: 20px;
      color: var(--rust);
    }

    .loc-info { min-width: 0; flex: 1; }
    .loc-name {
      font-family: 'Cormorant Garamond', serif;
      font-size: 1.1rem;
      font-weight: 700;
      margin-bottom: 3px;
      line-height: 1.2;
    }
    .loc-desc {
      font-size: 13px;
      color: var(--ink-soft);
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .loc-meta {
      font-size: 11px;
      color: var(--ink-soft);
      text-transform: uppercase;
      letter-spacing: .08em;
      margin-top: 5px;
    }

    .news-card {
      padding: 16px 18px;
      border-bottom: 1px solid var(--border);
      transition: background .18s ease;
    }
    .news-card:hover { background: var(--bg2); }
    .news-date {
      font-size: 11px;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--gold);
      margin-bottom: 6px;
    }
    .news-title {
      font-family: 'Cormorant Garamond', serif;
      font-size: 1.15rem;
      font-weight: 700;
      margin-bottom: 6px;
      line-height: 1.25;
    }
    .news-snippet {
      font-size: 13px;
      color: var(--ink-soft);
    }

    .map-area {
      position: relative;
      flex: 1;
      min-width: 0;
      min-height: 0;
    }
    #map {
      width: 100%;
      height: 100%;
    }

    .toggle-panel {
      position: absolute;
      top: 50%;
      left: 0;
      transform: translateY(-50%);
      z-index: 45;
      width: 24px;
      height: 56px;
      border: 1px solid var(--border);
      border-left: none;
      border-radius: 0 10px 10px 0;
      background: var(--surface);
      box-shadow: 2px 0 10px rgba(0,0,0,.06);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }
    .toggle-panel svg { transition: transform .3s ease; }
    .toggle-panel.flipped svg { transform: rotate(180deg); }

    .map-controls {
      position: absolute;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      z-index: 35;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px;
      width: min(92vw, 720px);
      padding: 10px 14px;
      background: rgba(250,247,242,.96);
      border: 1px solid var(--border);
      border-radius: 999px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
    }
    .map-controls span {
      font-size: 12px;
      color: var(--ink-soft);
      display: inline-flex;
      align-items: center;
      gap: 7px;
      white-space: nowrap;
    }

    .detail-overlay {
      position: absolute;
      top: 16px;
      right: 16px;
      width: min(400px, calc(100vw - 32px));
      max-height: calc(100% - 32px);
      display: none;
      flex-direction: column;
      background: var(--surface-strong);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: var(--shadow);
      overflow: hidden;
      z-index: 2000;
      pointer-events: auto;
    }
    .detail-overlay.open { display: flex; }

    .location-modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(28, 23, 18, 0.58);
      backdrop-filter: blur(2px);
      z-index: 5000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .location-modal-backdrop.open {
      display: flex;
    }

    .location-modal {
      width: min(100%, 460px);
      background: var(--surface-strong);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
      overflow: hidden;
    }

    .location-modal-header {
      padding: 18px 20px 12px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .location-modal-title {
      font-family: 'Cormorant Garamond', serif;
      font-size: 28px;
      line-height: 1.05;
      color: var(--ink);
      margin: 0;
    }

    .location-modal-close {
      width: 36px;
      height: 36px;
      border: 1px solid var(--border);
      background: var(--surface);
      border-radius: 50%;
      cursor: pointer;
      font-size: 18px;
      color: var(--ink-soft);
      flex: 0 0 auto;
    }

    .location-modal-close:hover {
      color: var(--ink);
      border-color: rgba(28, 23, 18, 0.22);
    }

    .location-modal-body {
      padding: 18px 20px 8px;
    }

    .location-modal-body p {
      font-size: 14px;
      line-height: 1.7;
      color: var(--ink-soft);
      margin: 0 0 14px;
    }

    .location-modal-note {
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 14px;
      color: var(--ink);
      font-size: 13px;
    }

    .location-modal-actions {
      padding: 0 20px 20px;
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      flex-wrap: wrap;
    }

    .modal-btn {
      min-height: 44px;
      padding: 10px 18px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--ink);
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }

    .modal-btn:hover {
      border-color: rgba(28, 23, 18, 0.24);
    }

    .modal-btn.primary {
      background: var(--gold);
      border-color: var(--gold);
      color: #fff;
    }

    .modal-btn.primary:hover {
      background: var(--gold-lt);
      border-color: var(--gold-lt);
    }


    .detail-hero {
      position: relative;
      min-height: 160px;
      background:
        linear-gradient(to top, rgba(28,23,18,.72), rgba(28,23,18,.18)),
        linear-gradient(135deg, #d8cfbc, #e7dfd2);
      display: flex;
      align-items: flex-end;
      padding: 18px;
    }
    .detail-hero-title {
      font-family: 'Cormorant Garamond', serif;
      font-size: clamp(1.4rem, 3vw, 1.8rem);
      font-weight: 700;
      line-height: 1.15;
      color: white;
      padding-right: 34px;
    }
.detail-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 28px;
    line-height: 1;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.45);
    color: white;
    cursor: pointer;
}

.detail-close {
    transform: none;
}

    .detail-close::before {
        content: "×";
        display: block;
        transform: translateY(-2px);
    }

    .detail-body {
      overflow-y: auto;
      padding: 18px;
    }

    .detail-meta {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      margin-bottom: 14px;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      padding: 5px 10px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: .07em;
      text-transform: uppercase;
      background: rgba(184,134,11,.12);
      color: #7a5800;
    }

    .detail-desc {
      color: var(--ink-soft);
      margin-bottom: 18px;
    }

    .detail-section-title {
      font-family: 'Cormorant Garamond', serif;
      font-size: 14px;
      font-weight: 700;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--ink-soft);
      margin-bottom: 10px;
      padding-bottom: 6px;
      border-bottom: 1px solid var(--border);
    }

    .info-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 18px;
    }
    .info-item {
      background: var(--bg2);
      border-radius: 10px;
      padding: 10px 12px;
    }
    .info-item-label {
      font-size: 10px;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--ink-soft);
      margin-bottom: 4px;
    }
    .info-item-value {
      font-size: 13px;
      color: var(--ink);
      font-weight: 500;
    }

    .link-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .ext-link {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 14px;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      text-decoration: none;
      transition: .2s ease;
    }
    .ext-link:hover {
      border-color: var(--gold);
      color: var(--gold);
    }
    .ext-link-icon {
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: var(--bg2);
      flex-shrink: 0;
    }

    .empty-state {
      padding: 28px 18px;
      color: var(--ink-soft);
      text-align: center;
      font-style: italic;
    }

    .leaflet-popup-content-wrapper {
      border-radius: 12px;
      box-shadow: var(--shadow);
    }
    .leaflet-popup-content {
      margin: 0;
      width: 250px !important;
    }
    .popup-card {
      overflow: hidden;
      background: var(--surface);
      border-radius: 12px;
    }
    .popup-top {
      height: 110px;
      background: linear-gradient(135deg, #d8cfbc, #e7dfd2);
      display: flex;
      align-items: flex-end;
      padding: 14px;
    }
    .popup-top strong {
      font-family: 'Cormorant Garamond', serif;
      font-size: 1.2rem;
      line-height: 1.1;
      color: var(--ink);
    }
    .popup-body {
      padding: 12px 14px 14px;
    }
    .popup-desc {
      font-size: 12px;
      color: var(--ink-soft);
      margin-bottom: 10px;
    }
    .popup-btn {
      width: 100%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: none;
      border-radius: 10px;
      padding: 10px 12px;
      background: var(--ink);
      color: var(--bg);
      cursor: pointer;
      text-decoration: none;
    }

    .mobile-panel-open {
      display: none;
    }
    .panel-backdrop {
      display: none;
    }

    @media (max-width: 980px) {
      .header-meta small { display: none; }
      .search-wrap {
        margin-left: 0;
        width: 100%;
        flex-basis: 100%;
      }
    }

    @media (max-width: 768px) {
      .location-modal-backdrop {
        padding: 16px;
      }

      .location-modal {
        width: 100%;
      }

      .location-modal-header {
        padding: 16px 16px 10px;
      }

      .location-modal-title {
        font-size: 24px;
      }

      .location-modal-body {
        padding: 16px 16px 6px;
      }

      .location-modal-actions {
        padding: 0 16px 16px;
      }

      body { overflow: hidden; }
      header {
        flex-wrap: wrap;
        gap: 8px 12px;
        padding: 10px 14px;
      }
      .header-actions {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
      }
      .header-btn.desktop-only {
        display: none;
      }
      .mobile-panel-open {
        display: inline-flex;
      }

      .filterbar {
        padding: 10px 14px;
        gap: 10px;
      }
      .filter-label {
        width: 100%;
      }
      .search-wrap {
        order: 3;
      }

      .side-panel {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(88vw, 380px);
        max-width: 100%;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
      }
      .side-panel.mobile-open {
        transform: translateX(0);
      }
      .side-panel.collapsed {
        width: min(88vw, 380px);
        transform: translateX(-100%);
        border-right: 1px solid var(--border);
      }

      .panel-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,.28);
        z-index: 39;
      }
      .panel-backdrop.open {
        display: block;
      }

      .toggle-panel {
        display: none;
      }

      .detail-overlay {
        inset: auto 12px 12px 12px;
        width: auto;
        max-height: min(72vh, calc(100% - 24px));
      }

      .info-grid {
        grid-template-columns: 1fr;
      }

      .map-controls {
        bottom: 10px;
        border-radius: 16px;
        width: calc(100% - 20px);
      }
    }

    @media (max-width: 520px) {
      .logo {
        font-size: 1.1rem;
      }
      .header-btn {
        padding: 8px 12px;
        font-size: 13px;
      }
      .filter-pill {
        font-size: 12px;
        padding: 7px 12px;
      }
      .loc-card {
        padding: 14px;
      }
      .loc-thumb {
        width: 52px;
        height: 52px;
      }
      .loc-name {
        font-size: 1rem;
      }
    }

/* ===== MVC integration — keep the original map layout stable ===== */

/* Required for Leaflet: every parent of #map must have a real height. */
html,
body {
    height: 100%;
}

body.page-map,
body.page-leaflet {
    height: 100%;
    min-height: 100%;
    overflow: hidden !important;
}

/* Do not let global website CSS alter this app. */
body.page-map #app,
body.page-leaflet #app {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    width: 100% !important;
    overflow: hidden !important;
}

/* Original top header. */
body.page-map #app > header,
body.page-leaflet #app > header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    min-height: var(--header-h) !important;
    background: var(--ink) !important;
    color: var(--bg) !important;
    display: flex !important;
    align-items: center !important;
    gap: 18px !important;
    padding: 10px 18px !important;
    border-bottom: 2px solid var(--gold) !important;
    z-index: 100 !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    box-shadow: none !important;
}

body.page-map #app > .filterbar,
body.page-leaflet #app > .filterbar {
    flex: 0 0 auto !important;
}

body.page-map #app > .content-area,
body.page-leaflet #app > .content-area {
    display: flex !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: hidden !important;
    position: relative !important;
}

body.page-map .side-panel,
body.page-leaflet .side-panel {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

body.page-map .location-list,
body.page-leaflet .location-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

body.page-map .map-area,
body.page-leaflet .map-area {
    display: block !important;
    position: relative !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* This line fixes the invisible map when the flex height is not yet resolved. */
body.page-map #map,
body.page-leaflet #map {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 320px !important;
    background: #d8cfbc;
}

body.page-map .detail-overlay.open,
body.page-leaflet .detail-overlay.open {
    display: flex !important;
}

body.page-map .location-modal-backdrop.open,
body.page-leaflet .location-modal-backdrop.open {
    display: flex !important;
}

/* Leaflet tiles must remain visible above the fallback background. */
.leaflet-container {
    background: #d8cfbc;
}

.leaflet-container,
.leaflet-pane,
.leaflet-top,
.leaflet-bottom {
    z-index: 1 !important;
}

/* ===== Heritage detail page ===== */

body.page-patrimonio,
body.heritage-detail-body {
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg);
}

.heritage-detail-page {
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
}

.heritage-detail-hero {
    position: relative;
    min-height: clamp(380px, 58vh, 620px);
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    background: var(--ink);
}

.heritage-detail-hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transform: scale(1.02);
}

.heritage-detail-hero-bg-empty {
    background: radial-gradient(circle at 18% 22%, rgba(212,160,23,.35), transparent 36%), linear-gradient(135deg, #2c241b 0%, #1c1712 55%, #3b2d1e 100%);
}

.heritage-detail-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(28,23,18,.9) 0%, rgba(28,23,18,.52) 46%, rgba(28,23,18,.22) 100%), linear-gradient(to right, rgba(28,23,18,.82) 0%, rgba(28,23,18,.34) 60%, rgba(28,23,18,.16) 100%);
}

.heritage-detail-hero-content {
    position: relative;
    z-index: 2;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 52px 0 56px;
}

.heritage-back-link {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 8px 14px;
    margin-bottom: 28px;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.16);
    color: rgba(255,255,255,.86);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    backdrop-filter: blur(8px);
}

    .heritage-back-link:hover {
        background: rgba(255,255,255,.14);
        color: #fff;
    }

.heritage-detail-eyebrow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

    .heritage-detail-eyebrow span,
    .heritage-detail-meta span {
        display: inline-flex;
        align-items: center;
        min-height: 30px;
        padding: 5px 11px;
        border-radius: 999px;
        background: rgba(184,134,11,.18);
        border: 1px solid rgba(212,160,23,.28);
        color: var(--gold);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

.heritage-detail-title {
    max-width: 860px;
    margin: 0;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(42px, 7vw, 82px);
    font-weight: 700;
    line-height: .98;
    letter-spacing: -.02em;
    color: #fff;
}

.heritage-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

    .heritage-detail-meta span {
        background: rgba(255,255,255,.1);
        border-color: rgba(255,255,255,.16);
        color: rgba(255,255,255,.82);
    }

.heritage-detail-section {
    padding: 72px 0;
}

.heritage-detail-container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.heritage-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
}

.heritage-detail-main,
.heritage-detail-aside {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.heritage-detail-aside {
    position: sticky;
    top: 22px;
}

.heritage-card {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 32px rgba(28,23,18,.08);
    padding: 26px;
}

.heritage-section-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

    .heritage-section-label::before {
        content: '';
        width: 22px;
        height: 1.5px;
        background: var(--gold);
    }

.heritage-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

    .heritage-section-heading h2 {
        margin: 0;
        font-family: 'Cormorant Garamond', serif;
        font-size: clamp(28px, 3vw, 38px);
        line-height: 1.05;
    }

    .heritage-section-heading > span {
        color: var(--ink-soft);
        font-size: 13px;
        white-space: nowrap;
    }

.heritage-richtext {
    color: var(--ink-soft);
    font-size: 15.5px;
    line-height: 1.85;
}

    .heritage-richtext p,
    .heritage-richtext ul,
    .heritage-richtext ol {
        margin-bottom: 16px;
    }

    .heritage-richtext a {
        color: var(--gold);
        font-weight: 700;
    }

    .heritage-richtext ul,
    .heritage-richtext ol {
        padding-left: 0;
        margin-left: 0;
        list-style: none;
    }

    .heritage-richtext li {
        position: relative;
        margin-bottom: 9px;
        padding-left: 24px;
    }

        .heritage-richtext li:last-child {
            margin-bottom: 0;
        }

    .heritage-richtext ul li::before {
        content: "";
        position: absolute;
        top: 12px;
        left: 3px;
        width: 7px;
        height: 7px;
        border-radius: 999px;
        background: var(--gold);
        box-shadow: 0 0 0 4px rgba(180, 136, 57, 0.12);
    }

    .heritage-richtext ol {
        counter-reset: heritage-counter;
    }

        .heritage-richtext ol li {
            counter-increment: heritage-counter;
            padding-left: 34px;
        }

            .heritage-richtext ol li::before {
                content: counter(heritage-counter);
                position: absolute;
                top: 3px;
                left: 0;
                width: 23px;
                height: 23px;
                border-radius: 999px;
                background: rgba(180, 136, 57, 0.12);
                color: var(--gold);
                font-size: 12px;
                font-weight: 800;
                line-height: 23px;
                text-align: center;
            }

        .heritage-richtext ul ul,
        .heritage-richtext ol ol,
        .heritage-richtext ul ol,
        .heritage-richtext ol ul {
            margin-top: 8px;
            margin-bottom: 8px;
            padding-left: 18px;
        }

            .heritage-richtext ul ul li::before {
                width: 6px;
                height: 6px;
                background: transparent;
                border: 1.5px solid var(--gold);
                box-shadow: none;
            }

    .heritage-richtext strong,
    .heritage-richtext b {
        color: var(--ink);
        font-weight: 800;
    }

.heritage-muted {
    color: var(--ink-soft);
    font-style: italic;
}

.heritage-gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.heritage-gallery-item {
    position: relative;
    min-height: 220px;
    border-radius: 13px;
    overflow: hidden;
    background: var(--bg2);
    color: #fff;
    text-decoration: none;
}

    .heritage-gallery-item img {
        width: 100%;
        height: 100%;
        min-height: 220px;
        object-fit: cover;
        transition: transform .45s ease;
    }

    .heritage-gallery-item:hover img {
        transform: scale(1.04);
    }

    .heritage-gallery-item span {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 42px 14px 14px;
        background: linear-gradient(to top, rgba(28,23,18,.82), transparent);
    }

    .heritage-gallery-item strong {
        font-size: 13px;
    }

    .heritage-gallery-item small {
        color: rgba(255,255,255,.7);
        font-size: 12px;
    }

.heritage-info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .heritage-info-list > div {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
        gap: 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

        .heritage-info-list > div:last-child {
            border-bottom: none;
        }

    .heritage-info-list span {
        color: var(--ink-soft);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .heritage-info-list strong {
        color: var(--ink);
        font-size: 14px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

.heritage-action-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.heritage-btn-primary,
.heritage-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 18px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.heritage-btn-primary {
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #fff;
}

    .heritage-btn-primary:hover {
        background: var(--gold-lt);
        border-color: var(--gold-lt);
    }

.heritage-btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border2, rgba(28,23,18,.18));
    color: var(--ink);
}

    .heritage-btn-ghost:hover {
        border-color: var(--gold);
        color: var(--gold);
    }

.heritage-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.heritage-tag {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 11px;
    border-radius: 12px;
    background: var(--bg2);
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}

    .heritage-tag small {
        color: var(--ink-soft);
        font-size: 11px;
        font-weight: 600;
    }

.heritage-resource-list,
.heritage-media-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .heritage-resource-list.compact {
        gap: 8px;
    }

.heritage-resource-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: rgba(237,232,220,.45);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .2s ease, background .2s ease, transform .15s ease;
}

    .heritage-resource-link:hover {
        border-color: var(--gold);
        background: var(--surface);
        transform: translateY(-1px);
    }

.heritage-resource-icon {
    width: auto;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: var(--ink);
    color: var(--bg);
    font-size: 12px;
    font-weight: 900;
    padding: 15px;
}

.heritage-resource-link span:last-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.heritage-resource-link strong {
    font-size: 14px;
    line-height: 1.25;
}

.heritage-resource-link small {
    color: var(--ink-soft);
    font-size: 12px;
}

@media (max-width: 980px) {
    .heritage-detail-grid {
        grid-template-columns: 1fr;
    }

    .heritage-detail-aside {
        position: static;
    }
}

@media (max-width: 680px) {
    .heritage-detail-hero-content,
    .heritage-detail-container {
        width: min(100% - 28px, 1180px);
    }

    .heritage-detail-hero {
        min-height: 420px;
    }

    .heritage-detail-section {
        padding: 42px 0;
    }

    .heritage-card {
        padding: 20px;
        border-radius: 14px;
    }

    .heritage-gallery-grid {
        grid-template-columns: 1fr;
    }

    .heritage-info-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .heritage-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ===== Frontend image support: list, popup and detail modal ===== */
.loc-thumb {
  overflow: hidden;
}

.loc-thumb-image {
  background: var(--bg2);
}

.loc-thumb-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.popup-top {
  position: relative;
  overflow: hidden;
}

.popup-top.popup-top-image {
  background: var(--ink);
}

.popup-top.popup-top-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  z-index: 0;
}

.popup-top.popup-top-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(28,23,18,.76), rgba(28,23,18,.12));
  z-index: 1;
}

.popup-top strong {
  position: relative;
  z-index: 2;
}

.popup-top.popup-top-image strong {
  color: #fff;
}

.detail-hero.detail-hero-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.heritage-detail-hero.has-hero-image .heritage-detail-hero-bg,
.heritage-detail-hero-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}


/* Lista do mapa: thumb, título e card clicáveis para centrar marker */
.loc-thumb-btn,
.loc-name-btn {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.loc-thumb-btn {
  flex: 0 0 auto;
  border-radius: 10px;
}

.loc-thumb-btn:focus-visible,
.loc-name-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.loc-name-btn {
  display: block;
  width: 100%;
}

.loc-name-btn:hover {
  color: var(--gold);
}


/* Correção mobile: collapsed não pode esconder quando mobile-open está ativo */
@media (max-width: 768px) {
  .content-area {
    position: relative !important;
    overflow: hidden !important;
  }

  .map-area,
  #map,
  .leaflet-container {
    position: relative !important;
    z-index: 1 !important;
  }

  .side-panel {
    z-index: 3000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .side-panel.mobile-open,
  .side-panel.collapsed.mobile-open {
    transform: translateX(0) !important;
    width: min(88vw, 380px) !important;
    display: flex !important;
    border-right: 1px solid var(--border) !important;
  }

  .panel-backdrop {
    z-index: 2990 !important;
  }

  .panel-backdrop.open {
    display: block !important;
  }
}



/* Apenas ícone/thumb e título centram no marker; o card não abre */
.loc-card {
  cursor: default;
}

.loc-thumb-btn,
.loc-name-btn {
  cursor: pointer;
}


/* Filtro de tipos em select */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.filter-group-select {
  flex: 0 1 280px;
  min-width: 220px;
  max-width: 100%;
}

.filter-select {
    width: 100%;
    min-height: 38px;
    padding: 8px 42px 8px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background-color: var(--bg2);
    color: var(--ink);
    outline: none;
    cursor: pointer;
    font: inherit;
    letter-spacing: .01em;
}

.filter-select:focus {
  border-color: var(--gold);
}

@media (max-width: 768px) {
  .filter-group-select {
    flex: 1 1 100%;
    min-width: 0;
  }

  .filter-select {
    width: 100%;
  }
}

.heritage-marker span {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0d6efd;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.heritage-marker-nearby span {
    width: 36px;
    height: 36px;
    background: #ffc107;
    border: 4px solid #fff;
    box-shadow: 0 0 0 6px rgba(255,193,7,.25), 0 2px 10px rgba(0,0,0,.35);
    animation: nearbyPulse 1.4s infinite;
}

@keyframes nearbyPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255,193,7,.45), 0 2px 10px rgba(0,0,0,.35);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(255,193,7,0), 0 2px 10px rgba(0,0,0,.35);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255,193,7,0), 0 2px 10px rgba(0,0,0,.35);
    }
}

.frontend-user-menu-toggle {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.frontend-user-menu {
    position: relative;
    z-index: 99999;
}

.frontend-user-dropdown {
    position: fixed;
    top: 64px;
    right: 18px;
    min-width: 220px;
    display: none;
    flex-direction: column;
    padding: 8px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 999999;
}

    .frontend-user-dropdown.open {
        display: flex;
    }

    .frontend-user-dropdown a,
    .frontend-user-dropdown button {
        width: 100%;
        border: 0;
        background: transparent;
        color: var(--ink);
        text-align: left;
        padding: 10px 12px;
        border-radius: 8px;
        cursor: pointer;
        text-decoration: none;
        font: inherit;
        font-size: 13px;
    }

        .frontend-user-dropdown a:hover,
        .frontend-user-dropdown button:hover {
            background: var(--bg2);
        }

    .frontend-user-dropdown form {
        margin: 0;
    }

/* ===== Meus circuitos ===== */

body.page-meus-circuitos {
    overflow: hidden !important;
}

    body.page-meus-circuitos #app {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        overflow: hidden !important;
    }

        body.page-meus-circuitos #app > header {
            flex: 0 0 auto !important;
            overflow: visible !important;
            z-index: 8000 !important;
        }

    body.page-meus-circuitos .my-circuits-map {
        position: relative;
    }

        body.page-meus-circuitos .my-circuits-map .detail-overlay {
            position: absolute !important;
            top: 50% !important;
            right: 16px !important;
            bottom: auto !important;
            left: auto !important;
            transform: translateY(-50%) !important;
            max-height: calc(100% - 32px);
            z-index: 9000 !important;
        }

.my-circuits-page {
    display: grid;
    grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    background: var(--bg);
    color: var(--ink);
}

.my-circuits-list {
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.my-circuits-header {
    padding: 24px 22px 18px;
    border-bottom: 1px solid var(--border);
}

.my-circuits-back {
    display: inline-flex;
    align-items: center;
    margin-bottom: 14px;
    color: var(--gold);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

    .my-circuits-back:hover {
        color: var(--gold-lt);
    }

.my-circuits-header h1 {
    margin: 0 0 6px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 34px;
    line-height: 1.05;
}

.my-circuits-header p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.my-circuit-card {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    background: var(--surface);
    transition: background .18s ease;
    position: relative;
    margin-top: 16px;
}

    .my-circuit-card:hover,
    .my-circuit-card.active {
        background: var(--bg2);
    }

        .my-circuit-card.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: var(--gold);
        }

.my-circuit-card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.my-circuit-card h2 {
    margin: 0;
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    line-height: 1.1;
}

.my-circuit-card-top span {
    flex: 0 0 auto;
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(184,134,11,.12);
    color: #7a5800;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.my-circuit-card p {
    margin: 0 0 8px;
    color: var(--ink-soft);
    font-size: 13px;
}

.my-circuit-card small {
    display: block;
    color: var(--ink-soft);
    font-size: 11px;
    margin-bottom: 10px;
}

.my-circuit-points {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--ink-soft);
    font-size: 13px;
}

    .my-circuit-points li {
        margin-bottom: 6px;
    }

    .my-circuit-points span {
        display: block;
        color: var(--ink);
        font-weight: 700;
    }

    .my-circuit-points small {
        margin: 0;
    }

.my-circuits-map {
    min-height: 0;
    position: relative;
}

#myCircuitsMap {
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #d8cfbc;
}

.my-circuit-marker {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gold);
    border: 3px solid #fff;
    box-shadow: 0 2px 9px rgba(0,0,0,.32);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
}

.my-circuit-popup {
    padding: 10px 12px;
    min-width: 180px;
}

    .my-circuit-popup strong {
        display: block;
        font-family: 'Cormorant Garamond', serif;
        font-size: 18px;
        line-height: 1.1;
        margin-bottom: 4px;
    }

    .my-circuit-popup small {
        display: block;
        color: var(--ink-soft);
        margin-bottom: 8px;
    }

    .my-circuit-popup a {
        display: inline-flex;
        text-decoration: none;
        font-size: 12px;
        font-weight: 800;
        color: var(--gold);
    }

@media (max-width: 900px) {
    .my-circuits-page {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(280px, 42vh) minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }

    .my-circuits-map {
        order: 1;
        height: 42vh;
    }

    .my-circuits-list {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--border);
    }

    #myCircuitsMap {
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    body.page-meus-circuitos .my-circuits-map .detail-overlay {
        position: absolute !important;
        top: auto !important;
        right: 12px !important;
        bottom: 12px !important;
        left: 12px !important;
        transform: none !important;
        width: auto !important;
        max-height: min(72vh, calc(100% - 24px));
    }
}

.js-circuit-google-links {
    padding-top: 20px;
}

.my-circuit-google-link {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1.5px solid rgba(184, 134, 11, .28);
    background: linear-gradient(135deg, rgba(184, 134, 11, .14), rgba(212, 160, 23, .07)), var(--surface-strong);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 8px 22px rgba(28, 23, 18, .07);
    transition: border-color .2s ease, background .2s ease, transform .15s ease, box-shadow .2s ease;
}

    .my-circuit-google-link::before {
        content: "🧭";
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: var(--gold);
        color: #fff;
        font-size: 20px;
        line-height: 1;
        box-shadow: 0 6px 16px rgba(184, 134, 11, .24);
    }

    .my-circuit-google-link::after {
        content: "↗";
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: var(--gold);
        font-size: 18px;
        font-weight: 900;
    }

    .my-circuit-google-link:hover {
        border-color: var(--gold);
        background: linear-gradient(135deg, rgba(184, 134, 11, .2), rgba(212, 160, 23, .1)), var(--surface-strong);
        color: var(--ink);
        text-decoration: none;
        transform: translateY(-1px);
        box-shadow: 0 12px 28px rgba(28, 23, 18, .12);
    }

@media (max-width: 520px) {
    .my-circuit-google-link {
        grid-template-columns: 38px minmax(0, 1fr) auto;
        padding: 11px 12px;
        gap: 10px;
    }

        .my-circuit-google-link::before {
            width: 38px;
            height: 38px;
            border-radius: 11px;
            font-size: 18px;
        }

    .my-circuit-google-link-text strong {
        font-size: 12.5px;
    }

    .my-circuit-google-link-text small {
        font-size: 11.5px;
    }
}

button.ext-link {
    width: 100%;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

    button.ext-link.is-in-circuit {
        border-color: var(--gold);
        color: var(--gold);
    }

    button.ext-link.is-loading {
        opacity: .65;
        pointer-events: none;
    }
/* ==========================================================
   Accessibility overrides — WCAG-oriented frontend improvements
   Added after the original rules so it can be removed safely.
   ========================================================== */

:root {
    --focus-ring: #005fcc;
    --focus-ring-soft: rgba(0, 95, 204, .18);
    --accessible-gold-text: #6f4f00;
    --accessible-danger: #9f1d1d;
}

/* Improve text rendering and preserve user font-size/zoom preferences. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    text-rendering: optimizeLegibility;
}

/* Keep hidden text available to screen readers. */
.sr-only,
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Optional skip link support if added to the layout. */
.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000000;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    transform: translateY(-150%);
    transition: transform .18s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: translateY(0);
}

/* Strong visible focus for keyboard users. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible,
.leaflet-control a:focus-visible,
.leaflet-marker-icon:focus-visible {
    outline: 3px solid var(--focus-ring) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px var(--focus-ring-soft) !important;
}

/* Avoid relying only on border-color for focus in forms. */
.search-wrap input:focus,
.filter-select:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 4px var(--focus-ring-soft);
}

/* Minimum comfortable target sizes for interactive controls. */
.header-btn,
.filter-pill,
.filter-select,
.toggle-panel,
.detail-close,
.location-modal-close,
.modal-btn,
.popup-btn,
.ext-link,
.heritage-back-link,
.heritage-btn-primary,
.heritage-btn-ghost,
.heritage-resource-link,
.my-circuits-back,
.my-circuit-google-link,
.frontend-user-dropdown a,
.frontend-user-dropdown button,
.loc-thumb-btn,
.loc-name-btn,
button.ext-link {
    min-height: 44px;
}

.detail-close,
.location-modal-close,
.toggle-panel,
.loc-thumb-btn {
    min-width: 44px;
}

/* Text links inside content should be clearly identifiable, not only colored. */
.heritage-richtext a,
.detail-body a,
.location-modal-body a,
.my-circuits-header a {
    text-decoration: underline;
    text-underline-offset: .18em;
    text-decoration-thickness: 1.5px;
}

/* Keep button-like links without forced underlines. */
.ext-link,
.popup-btn,
.header-btn,
.modal-btn,
.heritage-btn-primary,
.heritage-btn-ghost,
.heritage-resource-link,
.my-circuit-google-link,
.heritage-back-link,
.frontend-user-dropdown a {
    text-decoration: none;
}

/* Improve contrast for small gold text on light backgrounds. */
.news-date,
.heritage-section-label,
.heritage-richtext a,
.ext-link:hover,
.my-circuits-back,
.my-circuit-google-link,
.my-circuit-popup a,
.loc-name-btn:hover,
.filter-pill:hover {
    color: var(--accessible-gold-text);
}

/* Preserve accessible contrast for gold-filled buttons. */
.header-btn.primary,
.modal-btn.primary,
.heritage-btn-primary {
    background: #8a6200;
    border-color: #8a6200;
    color: #fff;
}

.header-btn.primary:hover,
.modal-btn.primary:hover,
.heritage-btn-primary:hover {
    background: #735200;
    border-color: #735200;
    color: #fff;
}

/* Badges should remain readable on light backgrounds. */
.badge,
.my-circuit-card-top span,
.heritage-detail-eyebrow span {
    color: var(--gold);
}

/* Dropdown menu accessibility. */
.frontend-user-dropdown a:focus-visible,
.frontend-user-dropdown button:focus-visible {
    background: var(--bg2);
}

.frontend-user-menu-toggle {
    min-height: 44px;
}

/* Modal usability for zoom and keyboard navigation. */
.location-modal {
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
}

.location-modal-body {
    overflow-y: auto;
    min-height: 0;
}

.location-modal-backdrop {
    overflow-y: auto;
}

/* Detail overlay should remain usable at browser zoom. */
.detail-overlay {
    max-width: calc(100vw - 32px);
}

.detail-body {
    min-height: 0;
}

/* Leaflet controls are links/buttons visually; make them accessible targets. */
.leaflet-control-zoom a,
.leaflet-control-layers-toggle,
.leaflet-bar a {
    min-width: 44px !important;
    min-height: 44px !important;
    line-height: 44px !important;
}

/* Make map marker states less dependent on color alone. */
.heritage-marker-nearby span::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 2px solid rgba(28, 23, 18, .65);
}

/* Improve form readability. */
input,
select,
textarea {
    font-size: 16px;
}

input::placeholder,
textarea::placeholder {
    opacity: 1;
    color: #5f584c;
}

/* Prevent animated effects for users who request reduced motion. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

    .heritage-gallery-item:hover img,
    .heritage-resource-link:hover {
        transform: none !important;
    }

    .heritage-marker-nearby span {
        animation: none !important;
    }
}

/* Better behavior at high zoom / small screens. */
@media (max-width: 768px) {
    .header-btn,
    .filter-pill,
    .modal-btn,
    .popup-btn,
    .ext-link,
    .heritage-resource-link,
    .heritage-btn-primary,
    .heritage-btn-ghost {
        min-height: 44px;
    }

    .filterbar {
        max-height: 45dvh;
        overflow-y: auto;
    }

    .map-controls {
        max-height: 35dvh;
        overflow-y: auto;
    }

    .location-modal {
        max-height: calc(100dvh - 32px);
    }
}

/* Emergency overflow protection for long labels, emails and URLs. */
.loc-name,
.news-title,
.detail-hero-title,
.location-modal-title,
.heritage-detail-title,
.heritage-resource-link strong,
.my-circuit-card h2,
.my-circuit-points span,
.info-item-value {
    overflow-wrap: anywhere;
}

.my-circuit-form {
    display: block;
}

.my-circuit-name-edit {
    min-width: 0;
    flex: 1 1 auto;
}

.my-circuit-name-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    border-radius: 10px;
    padding: 6px 8px;
    margin-left: -8px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    line-height: 1.1;
    font-weight: 700;
}

    .my-circuit-name-input:hover,
    .my-circuit-name-input:focus {
        background: var(--surface-strong);
        border-color: var(--border);
        outline: none;
    }

.my-circuit-points-editable {
    padding-left: 0;
    list-style: none;
}

.my-circuit-point-row {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid rgba(28, 23, 18, 0.08);
}

.my-circuit-order-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.my-circuit-order-input {
    width: 64px;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-strong);
    color: var(--ink);
    padding: 6px 8px;
}

.my-circuit-point-info {
    min-width: 0;
}

.my-circuit-point-title {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

    .my-circuit-point-title:hover {
        color: var(--gold);
    }

.my-circuit-remove-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.my-circuit-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.my-circuit-save-btn {
    min-height: 38px;
    border: 1px solid var(--gold);
    border-radius: 999px;
    background: var(--gold);
    color: #fff;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

    .my-circuit-save-btn:hover {
        background: var(--gold-lt);
        border-color: var(--gold-lt);
    }

@media (max-width: 520px) {
    .my-circuit-point-row {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .my-circuit-remove-check {
        grid-column: 2;
    }
}

/* ===== Marker selecionado - mapa principal ===== */

.heritage-marker span {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gold);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.heritage-marker-selected span {
    width: 30px;
    height: 30px;
    background: var(--rust);
    border: 4px solid #fff;
    box-shadow: 0 0 0 5px rgba(139, 58, 42, .22), 0 3px 11px rgba(0,0,0,.34);
    position: relative;
}

    .heritage-marker-selected span::after {
        content: '';
        position: absolute;
        inset: 6px;
        border-radius: 50%;
        border: 2px solid rgba(255,255,255,.85);
    }

/* ===== Marker selecionado - meus circuitos ===== */

.my-circuit-marker-wrapper {
    background: transparent;
    border: 0;
}

.my-circuit-marker.is-selected {
    width: 42px;
    height: 42px;
    background: var(--rust);
    border: 5px solid #fff;
    box-shadow: 0 0 0 7px rgba(139, 58, 42, .25), 0 4px 14px rgba(0,0,0,.38);
    font-size: 15px;
}

.my-circuit-select-form {
    margin-top: 16px;
}

.my-circuit-select-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.my-circuit-select {
    width: 100%;
    min-height: 40px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--ink);
    padding: 8px 14px;
    font: inherit;
}

.my-circuit-card.read-only {
    cursor: pointer;
}

.my-circuit-readonly-title {
    margin: 0;
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    line-height: 1.1;
}

.my-circuit-order-readonly {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg2);
    color: var(--ink);
    font-size: 13px;
}

.my-circuit-readonly-note {
    margin-top: 12px;
    color: var(--ink-soft);
    font-size: 12px;
    font-style: italic;
}

.my-circuits-toolbar {
    margin-top: 16px;
}

.my-circuit-marker-available {
    width: 34px;
    height: 34px;
    background: var(--green);
    font-size: 0;
}

    .my-circuit-marker-available span {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        margin-top: -2px;
        color: #fff;
        font-family: Arial, sans-serif;
        font-size: 26px;
        line-height: 1;
        font-weight: 500;
    }

.my-circuit-point-row {
    grid-template-columns: 92px minmax(0, 1fr) auto;
}

.my-circuit-order-actions {
    display: grid;
    grid-template-columns: 28px 20px 28px;
    align-items: flex-start;
    justify-content: start;
    gap: 2px;
}

.my-circuit-order-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    justify-self: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--bg2);
    color: var(--ink);
    font-size: 16px;
    line-height: 28px;
    font-weight: 900;
    text-align: center;
    padding: 0;
    margin: 0;
}

.my-circuit-order-btn,
.my-circuit-remove-btn {
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--ink);
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.my-circuit-order-btn {
    width: 28px;
    height: 28px;
    line-height: 1;
}

.my-circuit-remove-btn {
    min-height: 34px;
    padding: 6px 12px;
    color: var(--rust);
}

    .my-circuit-order-btn:hover,
    .my-circuit-remove-btn:hover {
        border-color: var(--gold);
        color: var(--gold);
    }

    .my-circuit-order-btn:disabled,
    .my-circuit-remove-btn:disabled,
    .my-circuit-order-btn.is-loading,
    .my-circuit-remove-btn.is-loading {
        opacity: .55;
        cursor: not-allowed;
    }

@media (max-width: 520px) {
    .my-circuit-point-row {
        grid-template-columns: 92px minmax(0, 1fr);
    }

    .my-circuit-remove-btn {
        grid-column: 2;
        justify-self: flex-start;
    }
}

.my-circuit-empty-points {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: rgba(237, 232, 220, .45);
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.55;
}

.my-circuit-form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.my-circuit-delete-btn {
    min-height: 38px;
    border: 1px solid rgba(139, 58, 42, .35);
    border-radius: 999px;
    background: transparent;
    color: var(--rust);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

    .my-circuit-delete-btn:hover {
        border-color: var(--rust);
        background: rgba(139, 58, 42, .08);
        color: var(--rust);
    }

/* =========================================================
   Pins dos grupos de património
   ========================================================= */

.heritage-marker-wrapper {
    background: transparent !important;
    border: 0 !important;
}

.heritage-pin {
    position: relative;
    width: 24px;
    height: 30px;
    transform-origin: 50% 100%;
    transition: transform .18s ease, filter .18s ease;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .28));
}


/* Forma do pin */

.heritage-pin-marker {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--pin-color);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

.heritage-pin-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    color: #fff;
    text-align: center;
}

.heritage-pin.is-selected {
    transform: scale(1.28);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .38));
}

/* Próximo da localização do utilizador */
.heritage-pin.is-nearby {
    animation: heritagePinPulse 1.5s ease-in-out infinite;
}

@keyframes heritagePinPulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

/* =========================================================
   Legenda dos grupos de património
   ========================================================= */

.map-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.map-legend-label {
    font-size: 12px;
    line-height: 1.2;
    color: var(--ink-soft);
}


/* =========================================================
   Legenda dos grupos de património
   ========================================================= */

.map-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.map-legend-label {
    font-size: 12px;
    line-height: 1.2;
    color: var(--ink-soft);
}

/* Pin pequeno da legenda */

.map-legend-pin {
    width: 15px;
    height: 18px;
    flex: 0 0 15px;
}

.map-legend-pin-marker {
    width: 15px;
    height: 15px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--pin-color);
    border: 1px solid #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-legend-pin-icon {
    transform: rotate(45deg);
    font-size: 7px;
    line-height: 1;
    color: #fff;
}