/* ==============================
   Benning Construction — Map & Public Page Styles
   Map, Popups, Modal, List View, Filters
   ============================== */

/* ===== Hero Section ===== */
.hero-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 5rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.hero-logo {
    padding: 14px 22px;
    border-radius: 14px;
    margin-bottom: 1.5rem;
}

.hero-logo img {
    height: 52px;
    width: auto;
}

.hero-section h1 {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.hero-section h1 i {
    color: var(--accent);
}

.hero-tagline {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 2rem;
    font-weight: 400;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: var(--accent-on);
    padding: 0.85rem 2rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: var(--transition);
    font-family: var(--font-heading);
}

.hero-btn:hover {
    background: var(--accent-hover);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(218, 170, 0, 0.4);
}

/* ===== Control Bar ===== */
/* Service-area note above the control bar */
.map-intro {
    background: var(--brand-grey);
    border-bottom: 1px solid var(--border);
}

.map-intro-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--primary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.map-intro-inner i {
    color: var(--primary);
    flex-shrink: 0;
}

.map-intro-inner p {
    margin: 0;
}

.control-bar {
    background: var(--bg-white);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 64px;
    z-index: 900;
}

.control-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    background: var(--bg-light);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.view-toggle-btn.active {
    background: var(--primary);
    color: #fff;
}

.view-toggle-btn:hover:not(.active) {
    background: var(--border);
    color: var(--text-dark);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    flex-wrap: wrap;
}

.filter-controls select,
.filter-controls input[type="date"] {
    padding: 0.45rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font-body);
    background: var(--bg-white);
    color: var(--text-dark);
    min-width: 140px;
    transition: var(--transition);
}

.filter-controls select:focus,
.filter-controls input:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-clear {
    padding: 0.45rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    transition: var(--transition);
}

.filter-clear:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.results-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: auto;
    white-space: nowrap;
}

/* ===== Map Section ===== */
.map-section {
    position: relative;
}

#projectMap {
    height: 70vh;
    min-height: 500px;
    width: 100%;
    z-index: 1;
}

/* ===== Leaflet Custom Popup ===== */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    /* Breathing room for the plain-text pin popups (project name). Extra right
       padding keeps long names clear of Leaflet's close (×) button. */
    margin: 0 !important;
    padding: 0.6rem 1.6rem 0.6rem 0.95rem !important;
    min-width: 200px;
}

.map-popup {
    padding: 1rem;
}

.map-popup h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.map-popup .popup-type {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent-ink);
    margin-bottom: 0.5rem;
}

.map-popup .popup-location {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.map-popup .popup-location i {
    width: 14px;
    color: var(--accent);
}

.map-popup .popup-dates {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.map-popup .popup-dates i {
    width: 14px;
    color: var(--text-light);
}

.popup-detail-btn {
    display: block;
    width: 100%;
    padding: 0.45rem;
    text-align: center;
    background: var(--accent);
    color: var(--accent-on);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    font-family: var(--font-body);
    transition: var(--transition);
}

.popup-detail-btn:hover {
    background: var(--accent-hover);
}

/* ===== List View ===== */
.list-section {
    display: none;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.list-section.active {
    display: block;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.sort-controls label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sort-controls select {
    padding: 0.4rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font-body);
    background: var(--bg-white);
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

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

.card-image {
    height: 180px;
    overflow: hidden;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.project-card:hover .card-image img {
    transform: scale(1.05);
}

.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 3rem;
}

.card-body {
    padding: 1.25rem;
}

.card-body h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.card-type-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent-ink);
    margin-bottom: 0.5rem;
}

.card-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.card-meta i {
    width: 14px;
    color: var(--accent);
    margin-right: 0.2rem;
}

.card-btn {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    text-align: center;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    font-family: var(--font-body);
    transition: var(--transition);
}

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

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.no-results i {
    font-size: 3rem;
    color: var(--border);
    display: block;
    margin-bottom: 1rem;
}

/* ===== Detail Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.modal-image {
    width: 100%;
    height: 300px;
    overflow: hidden;
}

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

.modal-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: rgba(255, 255, 255, 0.2);
    font-size: 5rem;
}

.modal-thumbs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 2rem 0;
}

.modal-thumb {
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
    transition: border-color 0.18s;
}

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

.modal-thumb.active,
.modal-thumb:hover {
    border-color: var(--accent);
}

.modal-body {
    padding: 2rem;
}

.modal-body h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.modal-type-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent-ink);
    margin-bottom: 1rem;
}

.modal-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.modal-meta-item i {
    color: var(--accent);
    margin-top: 0.2rem;
    width: 16px;
    flex-shrink: 0;
}

.modal-meta-item span {
    font-size: 0.9rem;
    color: var(--text-dark);
}

.modal-meta-item small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-description {
    margin-bottom: 1.5rem;
}

.modal-description h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.modal-description p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-dark);
}

.modal-map {
    height: 250px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 1rem;
}

.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
}

.modal-loading i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .project-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-meta {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 1.5rem;
    }

    .hero-section h1 {
        font-size: 2rem;
    }

    .hero-tagline {
        font-size: 1rem;
    }

    .control-bar {
        top: 64px;
    }

    .control-bar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .view-toggle {
        align-self: flex-start;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-controls select,
    .filter-controls input[type="date"] {
        min-width: 100%;
    }

    .results-count {
        margin-left: 0;
    }

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

    #projectMap {
        height: 50vh;
        min-height: 350px;
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-image {
        height: 200px;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-body h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.6rem;
    }

    .sort-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==============================
   Map Legend / Project-Type Key
   Rendered as a Leaflet bottom-right control by addMapLegend() in map.js.
   ============================== */
.map-legend {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    font-family: var(--font-body);
    max-width: 220px;
}

.map-legend-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--primary);
    color: #fff;
    border: 0;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.map-legend-toggle i {
    color: var(--accent);
}

.map-legend-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0.75rem 0.6rem;
}

.map-legend.collapsed .map-legend-list {
    display: none;
}

.map-legend-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.76rem;
    line-height: 1.6;
    color: var(--text-dark);
    white-space: nowrap;
}

.map-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}
