:root {
    --ink: #17211c;
    --muted: #68736c;
    --paper: #ffffff;
    --soft: #f4f5ef;
    --line: #dfe4dc;
    --accent: #1f6f50;
    --accent-dark: #17573e;
    --warm: #b86a32;
    --shadow: 0 14px 40px rgba(30, 48, 38, .09);
    --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(223, 228, 220, .9);
}

.header-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--accent);
    color: white;
    font-family: Georgia, serif;
    font-size: 24px;
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
    margin-top: -2px;
}

.main-nav {
    display: flex;
    gap: 24px;
    font-weight: 650;
}

.main-nav a:hover { color: var(--accent); }

.hero {
    padding: 72px 0 28px;
    background:
        radial-gradient(circle at 82% 15%, rgba(31, 111, 80, .12), transparent 31%),
        linear-gradient(180deg, #fbfcf9 0%, #fff 100%);
}

.hero-copy {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 34px;
}

.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px;
    font-weight: 800;
}

h1, h2, h3 {
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.04;
    margin-top: 0;
}

h1 {
    font-size: clamp(44px, 7vw, 92px);
    max-width: 900px;
    margin: 10px 0 20px;
    letter-spacing: -.045em;
}

h2 {
    font-size: clamp(34px, 4vw, 54px);
    margin: 8px 0 12px;
    letter-spacing: -.035em;
}

h3 { font-size: 26px; }

.hero-copy p {
    max-width: 720px;
    font-size: 20px;
    color: var(--muted);
    margin: 0;
}

.hero-stat {
    min-width: 160px;
    padding: 18px 20px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.hero-stat strong {
    display: block;
    font-size: 38px;
    line-height: 1;
    color: var(--accent);
}

.hero-stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.filters {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.period-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.pill {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    border-radius: 999px;
    padding: 9px 14px;
    font-weight: 700;
    cursor: pointer;
}

.pill.active,
.pill:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr auto;
    gap: 12px;
    align-items: end;
}

.filter-grid label span {
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 0 0 6px 2px;
}

input, select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 13px 14px;
    min-height: 48px;
    color: var(--ink);
    font: inherit;
}

input:focus, select:focus {
    outline: 3px solid rgba(31, 111, 80, .15);
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 800;
    cursor: pointer;
    font: inherit;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
    background: white;
    color: var(--ink);
    border-color: var(--line);
}

.map-section {
    padding: 28px 0 70px;
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(290px, .8fr);
    gap: 24px;
    align-items: stretch;
}

.map-shell {
    position: relative;
    min-height: 620px;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

#events-map {
    width: 100%;
    height: 620px;
}

.map-legend {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 500;
    background: rgba(255,255,255,.95);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
}

.map-side {
    padding: 36px;
    border-radius: 28px;
    background: var(--soft);
    border: 1px solid var(--line);
}

.map-side p {
    color: var(--muted);
    font-size: 17px;
}

.province-list {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.province-list span {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    font-weight: 750;
}

.map-popup {
    display: grid;
    gap: 4px;
    min-width: 180px;
}

.map-popup strong { font-size: 15px; }
.map-popup span { color: #68736c; font-size: 13px; }
.map-popup a { color: var(--accent); font-weight: 800; margin-top: 4px; }

.section { padding: 76px 0; }
.section-soft { background: var(--soft); }

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

.event-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.event-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    min-width: 0;
    transition: transform .2s ease, box-shadow .2s ease;
}

.event-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.event-card-media {
    position: relative;
    display: block;
    aspect-ratio: 16/10;
    background: #e9ede7;
    overflow: hidden;
}

.event-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(31,111,80,.12), rgba(184,106,50,.12)),
        #eff2ec;
    color: var(--accent);
    font-weight: 800;
}

.featured-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    color: var(--warm);
    font-size: 12px;
    font-weight: 850;
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
}

.featured-badge.static {
    position: static;
    display: inline-flex;
    box-shadow: none;
    border: 1px solid var(--line);
}

.event-card-body { padding: 20px; }

.event-meta {
    display: flex;
    gap: 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.event-card h3 {
    margin: 8px 0 8px;
}

.event-card p {
    color: var(--muted);
    margin: 8px 0;
}

.event-location {
    font-weight: 750;
    color: var(--ink) !important;
}

.text-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--accent);
    font-weight: 850;
}

.empty-state {
    padding: 48px;
    border: 1px dashed #bcc6bb;
    border-radius: 20px;
    text-align: center;
    background: white;
}

.page-header {
    padding: 64px 0 30px;
    background: var(--soft);
}

.page-header h1 {
    font-size: clamp(44px, 6vw, 76px);
}

.page-header > .container > p {
    color: var(--muted);
    font-size: 18px;
    margin-bottom: 30px;
}

.event-detail-hero { padding: 54px 0 80px; }

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
    gap: 48px;
    align-items: start;
}

.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--muted);
    font-weight: 700;
}

.detail-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.category-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 7px 11px;
    background: var(--soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 850;
}

.detail-main h1 {
    font-size: clamp(48px, 7vw, 92px);
}

.detail-location {
    font-size: 21px;
    color: var(--muted);
    margin-top: -10px;
}

.fact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 32px 0;
}

.fact {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
}

.fact span {
    display: block;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    font-weight: 800;
    font-size: 11px;
    margin-bottom: 7px;
}

.fact strong {
    display: block;
    font-size: 15px;
}

.lead {
    font-size: 22px;
    line-height: 1.5;
    margin: 32px 0;
}

.rich-copy {
    font-size: 17px;
    color: #38443d;
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 32px;
}

.detail-aside {
    display: grid;
    gap: 20px;
}

.flyer-card,
.mini-map-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.flyer-card img {
    width: 100%;
    max-height: 680px;
    object-fit: contain;
    background: #f0f1ed;
}

.flyer-card span {
    display: block;
    padding: 13px 16px;
    color: var(--accent);
    font-weight: 800;
    text-align: center;
}

#event-map {
    height: 300px;
    width: 100%;
}

.mini-map-footer {
    padding: 14px 16px;
}

.mini-map-footer strong,
.mini-map-footer span {
    display: block;
}

.mini-map-footer span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.site-footer {
    padding: 38px 0;
    border-top: 1px solid var(--line);
    background: #15211a;
    color: white;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    align-items: center;
}

.site-footer p,
.footer-note {
    color: rgba(255,255,255,.68);
    margin: 4px 0 0;
}

.footer-note {
    max-width: 520px;
    text-align: right;
    font-size: 13px;
}

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

    .event-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-side { order: -1; }
    .map-shell, #events-map { min-height: 520px; height: 520px; }
    .fact-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    .container {
        width: min(100% - 24px, 1380px);
    }

    .header-inner { min-height: 68px; }
    .brand small { display: none; }
    .main-nav { gap: 14px; font-size: 14px; }

    .hero { padding-top: 42px; }
    .hero-copy { display: block; }
    .hero-stat { margin-top: 24px; }
    .hero-copy p { font-size: 17px; }

    .filter-grid { gap: 10px; }
    .filter-submit { width: 100%; }

    .map-section { padding-top: 16px; }
    .map-shell, #events-map { min-height: 480px; height: 480px; border-radius: 20px; }
    .map-side { padding: 24px; border-radius: 20px; }

    .section { padding: 52px 0; }
    .section-heading { align-items: start; flex-direction: column; }

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

    .detail-main h1 { font-size: 48px; }
    .fact-grid { grid-template-columns: 1fr; }

    .footer-inner {
        flex-direction: column;
        align-items: start;
    }
    .footer-note { text-align: left; }
}

/* Compact map layers menu, matching the Casal dei Fichi style */
.map-shell,
.mini-map-shell {
    position: relative;
}

.map-layers-menu {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 760;
}

.map-layers-trigger {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(205, 214, 207, .95);
    border-radius: 7px;
    background: rgba(255, 255, 255, .97);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}

.map-layers-trigger:hover,
.map-layers-menu.is-open .map-layers-trigger {
    background: #fff;
}

.map-layers-trigger:focus-visible {
    outline: 3px solid rgba(31, 111, 80, .18);
    outline-offset: 2px;
}

/* CSS-built layers icon, so no external icon package is needed */
.layers-symbol {
    position: relative;
    width: 24px;
    height: 22px;
    display: block;
}

.layers-symbol span {
    position: absolute;
    left: 50%;
    width: 18px;
    height: 11px;
    border: 1px solid #919b95;
    background: #dfe4e1;
    transform: translateX(-50%) rotate(0deg) skewY(-28deg);
    border-radius: 1px;
}

.layers-symbol span:nth-child(1) {
    top: 1px;
    background: #eef1ef;
}

.layers-symbol span:nth-child(2) {
    top: 5px;
    background: #dfe4e1;
}

.layers-symbol span:nth-child(3) {
    top: 9px;
    background: #cdd4d0;
}

.map-layers-panel {
    position: absolute;
    top: 0;
    right: 50px;
    width: 142px;
    display: none;
    padding: 9px 10px;
    border: 1px solid rgba(205, 214, 207, .98);
    border-radius: 8px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
    backdrop-filter: blur(8px);
}

.map-layers-menu.is-open .map-layers-panel,
.map-layers-menu:hover .map-layers-panel {
    display: block;
}

.map-layers-panel label {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 27px;
    margin: 0;
    color: #27322c;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.map-layers-panel input {
    width: auto !important;
    min-height: 0 !important;
    margin: 0;
    padding: 0;
    accent-color: var(--accent);
}

.map-layers-divider {
    height: 1px;
    margin: 6px 0;
    background: #e3e7e4;
}

.map-layers-menu-small {
    top: 10px;
    right: 10px;
}

.map-layers-menu-small .map-layers-trigger {
    width: 38px;
    height: 38px;
}

.map-layers-menu-small .map-layers-panel {
    right: 46px;
}

@media (max-width: 680px) {
    .map-layers-menu {
        top: 10px;
        right: 10px;
    }

    .map-layers-trigger {
        width: 38px;
        height: 38px;
    }

    .map-layers-panel {
        right: 45px;
        width: 132px;
    }

    .map-layers-panel label {
        font-size: 11px;
    }
}

/* =========================================================
   MAP-FIRST HOMEPAGE REDESIGN
   ========================================================= */

.map-first-intro {
    padding: 42px 0 20px;
    background:
        radial-gradient(circle at 78% 15%, rgba(31, 111, 80, .10), transparent 30%),
        linear-gradient(180deg, #fbfcf9 0%, #fff 100%);
}

.map-first-intro-inner {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 34px;
}

.map-first-intro h1 {
    margin: 7px 0 12px;
    max-width: 920px;
    font-size: clamp(42px, 5.5vw, 74px);
}

.map-first-intro p {
    max-width: 790px;
    margin: 0;
    color: var(--muted);
    font-size: 18px;
}

.map-event-count {
    flex: 0 0 auto;
    min-width: 170px;
    padding: 17px 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}

.map-event-count strong {
    display: block;
    color: var(--accent);
    font-size: 36px;
    line-height: 1;
}

.map-event-count span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.map-home {
    padding: 18px 0 58px;
}

.map-home .container {
    width: min(1580px, calc(100% - 28px));
}

.home-map-shell {
    min-height: 800px;
    height: 800px;
    border-radius: 26px;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: 0 18px 55px rgba(23, 42, 31, .13);
}

.home-map-shell #events-map {
    width: 100%;
    height: 800px;
    min-height: 800px;
}

.map-filter-panel {
    position: absolute;
    z-index: 740;
    left: 18px;
    right: 18px;
    bottom: 18px;
    padding: 13px;
    border: 1px solid rgba(218, 226, 218, .95);
    border-radius: 17px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 13px 34px rgba(0, 0, 0, .18);
    backdrop-filter: blur(14px);
}

.map-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 10px;
}

.map-period-pill {
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.map-period-pill:hover,
.map-period-pill.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.map-filter-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.45fr auto auto;
    gap: 9px;
    align-items: end;
}

.map-filter-fields label > span {
    display: block;
    margin: 0 0 5px 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.map-filter-fields select,
.map-filter-fields input {
    min-height: 44px;
    padding: 10px 11px;
    border-radius: 11px;
    background: rgba(255,255,255,.98);
    font-size: 14px;
}

.map-filter-submit {
    min-height: 44px;
    white-space: nowrap;
}

.map-filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 11px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.map-filter-clear:hover {
    color: var(--accent);
}

.map-filters-trigger {
    display: none;
    position: absolute;
    top: 86px;
    left: 12px;
    z-index: 750;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid rgba(205, 214, 207, .95);
    border-radius: 8px;
    background: rgba(255,255,255,.97);
    color: var(--ink);
    box-shadow: 0 4px 16px rgba(0,0,0,.16);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.filter-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--warm);
}

/* Category marker pins */
.event-map-icon {
    background: transparent !important;
    border: 0 !important;
}

.event-marker-pin {
    position: relative;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 0;
    color: #fff;
    box-shadow:
        0 4px 14px rgba(0,0,0,.35),
        0 0 0 1px rgba(0,0,0,.12);
    transform: rotate(-45deg);
}

.event-marker-pin span {
    display: block;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    transform: rotate(45deg);
}

.event-marker-food-wine { background: #a65a2e; }
.event-marker-festa-sagra { background: #7b4fa3; }
.event-marker-music { background: #3d6292; }
.event-marker-market { background: #587c41; }
.event-marker-culture { background: #a26c3f; }
.event-marker-sport { background: #26756e; }
.event-marker-family { background: #b38719; }
.event-marker-other { background: #52635a; }

/* Rich popup */
.event-rich-popup .leaflet-popup-content-wrapper {
    overflow: hidden;
    padding: 0;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0,0,0,.22);
}

.event-rich-popup .leaflet-popup-content {
    width: 320px !important;
    margin: 0;
}

.event-rich-popup .leaflet-popup-tip {
    box-shadow: none;
}

.event-popup-card {
    overflow: hidden;
    background: #fff;
}

.event-popup-image {
    display: block;
    width: 100%;
    height: 165px;
    overflow: hidden;
    background: #eef0eb;
}

.event-popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-popup-body {
    padding: 14px;
}

.event-popup-category {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: #edf2ed;
    color: var(--accent);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.event-popup-category-food-wine { background: #f6eee3; color: #94592f; }
.event-popup-category-festa-sagra { background: #efe9f8; color: #72539a; }
.event-popup-category-music { background: #e8eef8; color: #46638d; }
.event-popup-category-market { background: #edf5e7; color: #527744; }
.event-popup-category-culture { background: #f6eadf; color: #8d5b39; }
.event-popup-category-sport { background: #e5f2f1; color: #36736d; }
.event-popup-category-family { background: #fff3d9; color: #8f6c1e; }

.event-popup-card h3 {
    margin: 9px 0 7px;
    color: var(--ink);
    font-size: 23px;
    line-height: 1.08;
}

.event-popup-meta {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.event-popup-card p {
    margin: 10px 0 0;
    color: #4f5a53;
    font-size: 13px;
    line-height: 1.45;
}

.event-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 13px;
}

.event-popup-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 850;
}

.popup-primary {
    background: var(--accent);
    color: #fff !important;
}

.popup-secondary {
    border: 1px solid var(--line);
    color: var(--ink) !important;
    background: #fff;
}

/* Modern event cards */
.event-card-modern .event-card-media {
    aspect-ratio: 16 / 10.5;
}

.event-card-category {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 999px;
    background: rgba(255,255,255,.94);
    color: var(--accent);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
}

.event-card-category-food-wine { color: #94592f; }
.event-card-category-festa-sagra { color: #72539a; }
.event-card-category-music { color: #46638d; }
.event-card-category-market { color: #527744; }
.event-card-category-culture { color: #8d5b39; }
.event-card-category-sport { color: #36736d; }
.event-card-category-family { color: #8f6c1e; }

.event-card-description {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.event-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 10px;
}

.event-card-actions .text-link {
    margin-top: 0;
}

.directions-link {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.directions-link:hover {
    color: var(--accent);
}

/* Event detail: route integration */
.route-card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        radial-gradient(circle at 90% 5%, rgba(31,111,80,.11), transparent 36%),
        #fff;
    box-shadow: var(--shadow);
}

.route-card h3 {
    margin: 6px 0 9px;
    font-size: 28px;
}

.route-card p {
    margin: 0;
    color: var(--muted);
}

.route-button {
    width: 100%;
    margin-top: 16px;
}

.route-unavailable {
    margin-top: 12px !important;
    font-size: 13px;
}

.category-badge-food-wine { background: #f6eee3; color: #94592f; }
.category-badge-festa-sagra { background: #efe9f8; color: #72539a; }
.category-badge-music { background: #e8eef8; color: #46638d; }
.category-badge-market { background: #edf5e7; color: #527744; }
.category-badge-culture { background: #f6eadf; color: #8d5b39; }
.category-badge-sport { background: #e5f2f1; color: #36736d; }
.category-badge-family { background: #fff3d9; color: #8f6c1e; }

/* Event list */
.events-page-title-row {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 28px;
}

.events-result-count {
    flex: 0 0 auto;
    min-width: 130px;
    padding: 14px 17px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
}

.events-result-count strong,
.events-result-count span {
    display: block;
}

.events-result-count strong {
    color: var(--accent);
    font-size: 28px;
    line-height: 1;
}

.events-result-count span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.filter-grid-wide {
    grid-template-columns: 1fr 1fr 1fr 1.45fr auto;
}

.filters-clear-row {
    padding-top: 11px;
    text-align: right;
}

.filters-clear-row a {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.filters-clear-row a:hover {
    color: var(--accent);
}

/* Keep the layers menu above all map content */
.map-layers-menu {
    z-index: 790;
}

@media (max-width: 1100px) {
    .map-filter-fields {
        grid-template-columns: 1fr 1fr 1fr 1.2fr;
    }

    .map-filter-submit {
        grid-column: span 2;
    }

    .map-filter-clear {
        grid-column: span 2;
    }

    .filter-grid-wide {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .map-first-intro-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .map-event-count {
        min-width: 145px;
    }

    .home-map-shell,
    .home-map-shell #events-map {
        height: 720px;
        min-height: 720px;
    }

    .map-filters-trigger {
        display: inline-flex;
    }

    .map-filter-panel {
        top: 132px;
        right: 12px;
        bottom: auto;
        left: 12px;
        display: none;
        max-height: 500px;
        overflow-y: auto;
    }

    .map-filter-panel.is-open {
        display: block;
    }

    .map-filter-fields {
        grid-template-columns: 1fr 1fr;
    }

    .map-filter-submit,
    .map-filter-clear {
        grid-column: auto;
    }

    .events-page-title-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 680px) {
    .map-first-intro {
        padding-top: 28px;
    }

    .map-first-intro h1 {
        font-size: 42px;
    }

    .map-first-intro p {
        font-size: 16px;
    }

    .map-home {
        padding-top: 8px;
    }

    .map-home .container {
        width: calc(100% - 16px);
    }

    .home-map-shell,
    .home-map-shell #events-map {
        height: 670px;
        min-height: 670px;
        border-radius: 18px;
    }

    .map-filter-fields,
    .filter-grid-wide {
        grid-template-columns: 1fr;
    }

    .map-filter-submit,
    .map-filter-clear {
        grid-column: auto;
    }

    .map-periods {
        gap: 5px;
    }

    .map-period-pill {
        padding: 6px 9px;
        font-size: 11px;
    }

    .event-rich-popup .leaflet-popup-content {
        width: 270px !important;
    }

    .event-popup-image {
        height: 135px;
    }

    .event-card-actions {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .events-result-count {
        min-width: 115px;
    }
}

/* =========================================================
   CUSTOM DATE RANGE FILTERS
   ========================================================= */

.map-filter-fields {
    grid-template-columns:
        minmax(130px, .9fr)
        minmax(130px, .9fr)
        minmax(130px, .9fr)
        minmax(135px, .8fr)
        minmax(135px, .8fr)
        minmax(190px, 1.3fr)
        auto
        auto;
}

.map-date-field input[type="date"] {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.map-date-field input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

.filter-grid-wide {
    grid-template-columns:
        minmax(130px, 1fr)
        minmax(130px, 1fr)
        minmax(130px, 1fr)
        minmax(145px, 1fr)
        minmax(145px, 1fr)
        minmax(190px, 1.35fr)
        auto;
}

@media (max-width: 1350px) {
    .map-filter-fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .map-search-field {
        grid-column: span 2;
    }

    .map-filter-submit {
        grid-column: auto;
    }

    .map-filter-clear {
        grid-column: auto;
    }

    .filter-grid-wide {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .filter-grid-wide .search-field {
        grid-column: span 2;
    }
}

@media (max-width: 900px) {
    .map-filter-fields {
        grid-template-columns: 1fr 1fr;
    }

    .map-search-field {
        grid-column: span 2;
    }

    .filter-grid-wide {
        grid-template-columns: 1fr 1fr;
    }

    .filter-grid-wide .search-field {
        grid-column: span 2;
    }
}

@media (max-width: 680px) {
    .map-filter-fields,
    .filter-grid-wide {
        grid-template-columns: 1fr;
    }

    .map-search-field,
    .filter-grid-wide .search-field {
        grid-column: auto;
    }
}

/* =========================================================
   MAP SEARCH / FILTER BAR AT TOP
   ========================================================= */

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

.map-filter-panel.map-filter-panel-top {
    top: 18px;
    right: 76px;
    bottom: auto;
    left: 18px;
    padding: 13px;
}

.map-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
}

.map-search-field-primary input {
    min-height: 50px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
}

.map-search-submit {
    min-height: 50px;
    min-width: 106px;
}

.map-filter-panel-top .map-filters-trigger {
    display: none;
    position: static;
    min-height: 50px;
    box-shadow: none;
}

.map-filter-icon {
    font-size: 15px;
    line-height: 1;
}

.map-advanced-filters {
    display: block;
    padding-top: 10px;
}

.map-filter-panel-top .map-periods {
    margin-bottom: 9px;
}

.map-filter-panel-top .map-filter-fields {
    grid-template-columns:
        minmax(120px, 1fr)
        minmax(120px, 1fr)
        minmax(120px, 1fr)
        minmax(130px, .85fr)
        minmax(130px, .85fr)
        auto
        auto;
}

.map-filter-panel-top .map-filter-fields select,
.map-filter-panel-top .map-filter-fields input {
    min-height: 42px;
}

.map-filter-panel-top .map-filter-submit {
    min-height: 42px;
}

.map-filter-panel-top .map-filter-clear {
    min-height: 42px;
}

/* Keep map-layer button visually separate from the search panel. */
.home-map-shell .map-layers-menu {
    top: 18px;
    right: 18px;
}

/* Zoom is intentionally bottom-left now. */
.home-map-shell .leaflet-bottom.leaflet-left {
    bottom: 12px;
    left: 12px;
}

.home-map-shell .leaflet-control-zoom {
    margin: 0 !important;
}

/* Give popups room below the search panel. */
.home-map-shell .leaflet-popup {
    margin-bottom: 8px;
}

@media (max-width: 1250px) {
    .map-filter-panel-top .map-filter-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .map-filter-panel-top .map-filter-submit,
    .map-filter-panel-top .map-filter-clear {
        grid-column: auto;
    }
}

@media (max-width: 900px) {
    .map-filter-panel.map-filter-panel-top {
        top: 10px;
        right: 58px;
        bottom: auto;
        left: 10px;
        display: block;
        max-height: none;
        overflow: visible;
        padding: 9px;
    }

    .map-search-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .map-search-submit {
        display: none;
    }

    .map-filter-panel-top .map-filters-trigger {
        display: inline-flex;
        min-width: auto;
    }

    .map-search-field-primary input {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    .map-advanced-filters {
        display: none;
        max-height: 475px;
        overflow-y: auto;
        padding-top: 9px;
    }

    .map-advanced-filters.is-open {
        display: block;
    }

    .map-filter-panel-top .map-filter-fields {
        grid-template-columns: 1fr 1fr;
    }

    .map-filter-panel-top .map-filter-submit {
        display: inline-flex;
    }

    .home-map-shell .map-layers-menu {
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 680px) {
    .map-filter-panel.map-filter-panel-top {
        right: 54px;
        left: 8px;
    }

    .map-filter-panel-top .map-filter-fields {
        grid-template-columns: 1fr;
    }

    .map-search-row {
        gap: 6px;
    }

    .map-filter-panel-top .map-filters-trigger {
        min-height: 44px;
        padding: 8px 10px;
    }

    .map-filter-panel-top .map-periods {
        gap: 5px;
    }
}
