/* Frontend Map Styles for EE Candidates Map */

/* Base and hover colors */
.ee-cm-map svg path { 
    transition: fill 0.15s ease;
}

/* All counties should be blue by default */
.ee-cm-map svg path[id] { 
    fill: var(--ee-base, #2c2d8a); 
}

/* Hover state for all counties */
.ee-cm-map svg path.is-hover { 
    fill: var(--ee-hover, #ff2b8a) !important; 
}

.ee-cm-wrap { 
    position: relative;
    width: 100%;
    max-width: 1116px; /* Original SVG width */
    margin: 0 auto; /* Center the wrapper */
    padding: 20px 0; /* Add some vertical spacing */
}

.ee-cm-map { 
    position: relative; 
    display: block; /* Changed from inline-block for better centering */
    width: 100%; 
    height: auto; /* Maintain aspect ratio */
}

/* Ensure the SVG scales properly */
.ee-cm-map > svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .ee-cm-wrap {
        max-width: 100%;
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .ee-cm-wrap {
        padding: 10px;
    }
}

.ee-cm-overlay { 
    position: absolute; 
    inset: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
}

#tallinn-dot { 
    pointer-events: all; 
    fill: #ffffff; 
    stroke: none; 
    cursor: pointer; 
    transition: fill 0.15s ease;
}

#tallinn-dot:hover,
#tallinn-dot.is-hover { 
    fill: var(--ee-hover, #ff2b8a);
}

#tallinn-label {
    pointer-events: all;
    fill: #ffffff;
    cursor: pointer;
    transition: fill 0.15s ease;
    user-select: none;
}

#tallinn-label:hover,
#tallinn-label.is-hover {
    fill: var(--ee-hover, #ff2b8a);
}

/* Additional city points (non-clickable) */
.city-point {
    pointer-events: none;
    fill: #ffffff;
    stroke: var(--ee-base, #2c2d8a);
    stroke-width: 2;
    opacity: 0.9;
}

.city-label {
    pointer-events: none;
    fill: #ffffff;
    user-select: none;
    opacity: 0.9;
    font-size: 24px!important;
}

/* Modal */
.ee-cm-modal {
    display: none;
}

.ee-cm-modal.open {
    display: block !important;
}

/* Lock background scroll when popup is open */
.ee-cm-no-scroll {
    overflow: hidden !important;
}

.ee-cm-modal .ee-cm-backdrop { 
    position: fixed; 
    inset: 0; 
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
}

.ee-cm-modal .ee-cm-dialog {
    position: fixed; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    width: min(90vw, 1300px); 
    background: #fff; 
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); 
    max-height: 90vh; 
    overflow-y: auto; 
    color: #333;
    z-index: 99999;
}

/* The previous county-level title is no longer rendered; keep class for backwards safety */
.ee-cm-title { display: none; }

.ee-cm-close { 
    position: absolute; 
    top: 25px; 
    right: 30px; 
    background: transparent !important; 
    border: 0; 
    font-size: 36px; 
    cursor: pointer;
    color: var(--e-global-color-29a1ef7, #2f2a95);
    line-height: 1;
    padding: 0;
    width: 36px;
    height: 36px;
    z-index: 100001;
    pointer-events: auto;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.ee-cm-close:hover, 
.ee-cm-close:focus,
.ee-cm-close:active {
    color: var(--e-global-color-09d8f56, #EB268E);
    background: transparent !important;
    box-shadow: none !important;
}

/* Manager Section */
.ee-cm-manager-section {
    padding: 40px 40px 30px 40px;
    display: flex;
    justify-content: center; /* center the main candidate block */
}

.cand-head {
    display: flex;
    gap: 48px;
    align-items: center !important; /* center text vertically next to image */
    max-width: 980px;
    width: auto;
    margin: 0 auto; /* explicit centering */
}

.cand-head img {
    width: 240px; /* 25% smaller than previous 320px */
    height: 240px;
    object-fit: contain; /* ensure the full image is visible */
    object-position: center center;
    background: #fff; /* avoid transparent edges showing */
    border-radius: 12px;
    flex: 0 0 240px;
}

.cand-head .cand-placeholder {
    width: 240px;
    height: 240px;
    background: #f0f0f0;
    border-radius: 12px;
    flex: 0 0 240px;
}

.cand-head .cand-content {
    flex: 1;
    padding-top: 0;
    max-width: 468px; /* 10% shorter than previous 520px to center visually */
    display: flex;
    flex-direction: column;
    justify-content: center; /* vertically center name + text inside the column */
}

.cand-head .cand-name {
    margin: 0 0 15px 0;
    font-family: var(--e-global-typography-84a53ed-font-family, inherit);
    font-size: 50px; /* Desktop H2 */
    font-weight: var(--e-global-typography-84a53ed-font-weight, 700);
    letter-spacing: var(--e-global-typography-84a53ed-letter-spacing, 0);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

.cand-head .cand-bio {
    font-family: var(--e-global-typography-bae4a59-font-family, inherit);
    font-size: 18px; /* Desktop Body */
    font-weight: var(--e-global-typography-bae4a59-font-weight, 400);
    letter-spacing: var(--e-global-typography-bae4a59-letter-spacing, -0.1px);
    line-height: var(--e-global-typography-bae4a59-line-height, 1.5em);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

/* Members Section */
.ee-cm-members-section {
    padding: 20px 40px 40px 40px;
}

.members-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px 50px;
}

.cand {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.cand img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
}

.cand .cand-placeholder {
    width: 160px;
    height: 160px;
    background: #f0f0f0;
    border-radius: 12px;
    flex-shrink: 0;
}

/* Ensure district head uses larger portrait despite generic .cand sizing */
.cand.cand-head img,
.cand.cand-head .cand-placeholder {
    width: 240px;
    height: 240px;
}

.cand-content {
    flex: 1;
    padding-top: 8px;
}

.cand-name {
    margin: 0 0 10px 0;
    font-family: var(--e-global-typography-84a53ed-font-family, inherit);
    font-size: 38px; /* Desktop H3 */
    font-weight: var(--e-global-typography-84a53ed-font-weight, 700);
    letter-spacing: var(--e-global-typography-84a53ed-letter-spacing, -0.1px);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

.cand-bio {
    font-family: var(--e-global-typography-bae4a59-font-family, inherit);
    font-size: 18px; /* Desktop Body */
    font-weight: var(--e-global-typography-bae4a59-font-weight, 400);
    letter-spacing: var(--e-global-typography-bae4a59-letter-spacing, -0.1px);
    line-height: var(--e-global-typography-bae4a59-line-height, 1.5em);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

/* Program Section */
.ee-cm-program-section {
    background: #fff;
    padding: 30px; /* governs the intended content width */
}

.program-title {
    margin: 0 0 40px 0;
    padding: 30px;
    font-family: var(--e-global-typography-937ae86-font-family, inherit);
    font-size: 50px; /* Desktop H2 */
    font-weight: var(--e-global-typography-937ae86-font-weight, 400);
    letter-spacing: var(--e-global-typography-937ae86-letter-spacing, 0);
    color: var(--e-global-color-5525c8e, #ffffff);
    text-align: center;
    background: var(--e-global-color-09d8f56, #ec4899);
    border-radius: 8px 8px 0 0;
}

.program-items {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.prog-item {
    color: #333;
    padding: 30px;
    margin: 0; /* keep the same inner width as the header */
}

/* Alternating background for prog items */
.prog-item:nth-child(even) {
    background: var(--e-global-color-4cc2c21, rgba(235, 38, 142, 0.06));
}

.prog-item.prog-hidden {
    display: none;
}

.ee-cm-program-section.show-all .prog-item.prog-hidden {
    display: block;
}

.prog-heading {
    margin: 0 0 15px 0;
    font-family: var(--e-global-typography-84a53ed-font-family, inherit);
    font-size: 38px; /* Desktop H3 */
    font-weight: var(--e-global-typography-84a53ed-font-weight, 700);
    letter-spacing: var(--e-global-typography-84a53ed-letter-spacing, -0.1px);
    color: var(--e-global-color-29a1ef7, #3730a3);
}

.prog-content {
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

.prog-text {
    font-family: var(--e-global-typography-bae4a59-font-family, inherit);
    font-size: 18px; /* Desktop Body */
    font-weight: var(--e-global-typography-bae4a59-font-weight, 400);
    letter-spacing: var(--e-global-typography-bae4a59-letter-spacing, -0.1px);
    line-height: var(--e-global-typography-bae4a59-line-height, 1.5em);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

/* Default paragraph styling inside popup */
.ee-cm-dialog p {
    font-family: var(--e-global-typography-bae4a59-font-family, inherit);
    font-size: 18px; /* Desktop Body */
    font-weight: 400;
    letter-spacing: var(--e-global-typography-bae4a59-letter-spacing, -0.1px);
    line-height: var(--e-global-typography-bae4a59-line-height, 1.5em);
    color: var(--e-global-color-29a1ef7, #2f2a95);
}

/* See more button */
.prog-show-more {
    margin: 30px 0 0 0;
    padding: 0;
    padding-bottom: 10px;
    background: transparent !important;
    border: none;
    border-radius: 0 !important;
    box-shadow: none !important;
    appearance: none;
    color: var(--e-global-color-29a1ef7, #2f2a95);
    font-family: var(--e-global-typography-bae4a59-font-family, inherit);
    font-size: 18px; /* Desktop Body */
    font-weight: var(--e-global-typography-bae4a59-font-weight, 400);
    letter-spacing: var(--e-global-typography-bae4a59-letter-spacing, -0.1px);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-block;
    text-align: left;
}

.prog-show-more:hover,
.prog-show-more:focus,
.prog-show-more:active {
    color: var(--e-global-color-09d8f56, #EB268E);
    background: transparent !important;
    box-shadow: none !important;
}

/* Tablet responsive styles */
@media (max-width: 1024px) and (min-width: 769px) {
    .ee-cm-district-title {
        font-size: 4.5rem; /* Tablet H1 (~72px) */
    }
    
    .program-title {
        font-size: 2.5rem; /* Tablet H2 (~40px) */
    }
    
    .cand-head .cand-name {
        font-size: 2.5rem; /* Tablet H2 (~40px) */
    }
    
    .prog-heading,
    .cand-name {
        font-size: 1.875rem; /* Tablet H3 (~30px) */
    }
}

/* Responsive styles for modal */
@media (max-width: 768px) {
    /* Make city labels larger on mobile */
    .ee-cm-overlay text.city-label,
    .ee-cm-overlay text#tallinn-label,
    .ee-cm-overlay text#parnu-label,
    .ee-cm-overlay text#tartu-label,
    .ee-cm-overlay text#viljandi-label,
    .ee-cm-overlay text#rakvere-label,
    .ee-cm-overlay text#polva-label {
        font-size: 28px !important;
    }
    
    .ee-cm-dialog {
        width: 100vw !important;
        height: 100vh;
        max-height: 100vh !important;
        border-radius: 0 !important;
        top: 0 !important;
        transform: translate(-50%, 0) !important;
        padding-bottom: 80px!important; /* Extra padding for Safari mobile bottom bar */
    }
    
    .ee-cm-title {
        font-size: 24px;
        padding: 15px 20px;
    }
    
    .ee-cm-manager-section {
        padding: 20px 20px 15px 20px;
    }
    
    .ee-cm-members-section {
        padding: 0 20px 20px 20px;
    }
    
    .ee-cm-program-section {
        padding: 20px 20px 40px 20px; /* Extra bottom padding for Safari mobile bar */
    }
    
    .program-title {
        font-size: 2rem; /* Mobile H2 (~32px) */
        padding: 20px;
        margin-bottom: 25px;
    }
    
    .program-items {
        padding: 0;
        gap: 0;
    }
    
    .prog-item {
        padding: 20px;
        margin: 0; /* keep aligned with header on mobile as well */
    }
    
    .prog-heading {
        font-size: 1.5rem; /* Mobile H3 (~24px) */
    }
    
    .prog-text {
        font-size: 18px; /* Mobile Body - keeping consistent with desktop */
    }
    
    .prog-show-more {
        margin: 20px 0 0 0;
        font-size: 18px; /* Mobile Body - keeping consistent with desktop */
    }
    
    .cand-head {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }
    
    .cand-head img,
    .cand-head .cand-placeholder {
        width: 150px;
        height: 150px;
    }
    
    .cand-head .cand-content {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .cand-head .cand-name {
        font-size: 2rem; /* Mobile H2 (~32px) */
        margin-bottom: 10px;
    }
    
    .cand-head .cand-bio {
        font-size: 18px; /* Mobile Body - keeping consistent with desktop */
    }
    
    .members-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .cand {
        gap: 20px;
    }
    
    .cand img,
    .cand .cand-placeholder {
        width: 120px;
        height: 120px;
    }
    
    .cand-name {
        font-size: 1.5rem; /* Mobile H3 (~24px) */
    }
    
    .cand-bio {
        font-size: 18px; /* Mobile Body - keeping consistent with desktop */
    }
}

/* Districts section */
.ee-cm-district {
    margin-top: 40px; /* 40px above the separator */
    padding-top: 40px; /* 40px below the separator */
    position: relative;
}

/* 1px separator that matches the program header width (accounts for 30px program padding) */
.ee-cm-district:not(.ee-cm-district-first)::before {
    content: "";
    position: absolute;
    top: 0;
    left: 30px;
    width: calc(100% - 60px);
    height: 1px;
    background: var(--e-global-color-09d8f56, #EB268E);
}

/* First district doesn't need top border/margin since there's no county content */
.ee-cm-district-first {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.ee-cm-district-title {
    margin: 0;
    padding: 30px 40px; /* sit where the old main title was */
    font-family: var(--e-global-typography-937ae86-font-family, inherit);
    font-size: 100px; /* Desktop H1 */
    font-weight: var(--e-global-typography-937ae86-font-weight, 400);
    letter-spacing: var(--e-global-typography-937ae86-letter-spacing, 0);
    color: var(--e-global-color-29a1ef7, #2c2d8a);
}

/* No content message */
.ee-cm-no-content {
    padding: 40px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

.ee-cm-district .ee-cm-manager-section {
    padding-top: 30px;
}

.ee-cm-district .ee-cm-members-section {
    padding-top: 20px;
}

.ee-cm-district .ee-cm-program-section {
    padding-top: 20px;
}

/* Districts responsive adjustments */
@media (max-width: 768px) {
    .ee-cm-district {
        margin-top: 30px;
        padding-top: 30px;
    }
    
    .ee-cm-district-first {
        margin-top: 0;
        padding-top: 0;
    }
    
    .ee-cm-district-title {
        padding: 15px 20px;
        font-size: 3.5rem; /* Mobile H1 (~56px) */
    }
    
    .ee-cm-no-content {
        padding: 30px 20px;
    }
}
