/* style.css */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #eef1f5; /* Light grayish blue */
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

header {
    width: 100%;
    max-width: 1200px; /* Max width for content consistency */
    background-color: #002D72; /* Mets Blue */
    color: #FC5924; /* Mets Orange */
    padding: 1.5em 0;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

header h1 {
    margin: 0;
    font-size: 2em;
    font-weight: 700;
}

/* Default styles for wider screens */
.content-and-poll-container {
    display: flex;
    flex-direction: row; /* Side-by-side by default */
    justify-content: center;
    align-items: flex-start;
    gap: 25px;
    width: 100%;
    max-width: 1200px;
}

.main-content-box {
    flex-grow: 1;
    flex-basis: 50%; /* Suggests it takes about 50% of the space initially */
    max-width: 700px; /* Max width for the main content */
    min-width: 0; 
    background-color: #fff;
    padding: 25px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    text-align: center;
    /* Default order for wide screens, assuming HTML is poll-no, main, poll-yes */
    order: 2;
}

.poll-option {
    flex-basis: 220px; 
    flex-shrink: 0;  
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.poll-no {
    background-color: #ffebee; /* Light Red */
    border: 1px solid #e57373;
    order: 1; /* Appears first on wide screens */
}

.poll-yes {
    background-color: #e3f2fd; /* Light Blue */
    border: 1px solid #64b5f6;
    order: 3; /* Appears last on wide screens */
}


/* Styles for content inside main-content-box */
.counter-section { margin-bottom: 30px; }
.counter-label { font-size: 1.1em; color: #555; margin-bottom: 8px; }
.hr-display { font-size: 4.5em; font-weight: 700; color: #FC5924; line-height: 1.2; margin-bottom: 8px; }
.target-note { font-size: 1em; color: #777; }
.projections-section h2 { font-size: 1.6em; color: #002D72; margin-bottom: 15px; border-bottom: 2px solid #e0e0e0; padding-bottom: 10px; font-weight: 700; }
.projection-item { background-color: #f8f9fa; border: 1px solid #dee2e6; padding: 15px; margin-bottom: 12px; border-radius: 8px; text-align: left; }
.projection-item p { margin: 5px 0; font-size: 0.95em; }
.projection-item strong { color: #004085; }
.projection-item .notes { font-size: 0.85em; color: #6c757d; font-style: italic; }
.loading-text, .error-text { font-style: italic; color: #6c757d; padding: 20px 0; }

/* Styles for content inside poll-option */
.poll-label { font-size: 2.8em; font-weight: bold; margin-bottom: 10px; }
.poll-no .poll-label { color: #c62828; }
.poll-yes .poll-label { color: #1565c0; }
.poll-percentage { font-size: 2em; margin-bottom: 15px; font-weight: 500; }
.vote-button { padding: 12px 20px; font-size: 1.1em; border: none; border-radius: 5px; cursor: pointer; color: white; transition: background-color 0.2s, opacity 0.2s; width: 80%; margin-bottom: 10px; }
.poll-no .vote-button { background-color: #d32f2f; }
.poll-yes .vote-button { background-color: #1976d2; }
.vote-button:hover:not(:disabled) { opacity: 0.85; }
.vote-button:disabled { background-color: #bdbdbd; color: #757575; cursor: not-allowed; opacity: 0.7; }
.vote-message { font-size: 0.9em; color: #424242; margin-top: 10px; min-height: 1.2em; }

footer {
    width: 100%;
    max-width: 1200px;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #777;
}

/* --- Responsive adjustments for narrower screens --- */

/* For tablets and larger phones (e.g., 900px down to where polls need to stack, approx 501px) */
/* Layout: Main content first (full width), polls below it AND side-by-side with each other */
@media (max-width: 900px) {
    .content-and-poll-container {
        flex-direction: row; /* Keep as row to allow flex-wrap to work as intended */
        flex-wrap: wrap;     /* This is key to allow items to go to next line */
        justify-content: center; /* Center items on their new lines */
        gap: 20px; 
    }

    .main-content-box {
        order: 1; /* Main content box appears FIRST */
        flex-basis: 100%; /* Takes full width, forcing polls to wrap below */
        max-width: 600px; /* Max width for main content on smaller screens */
        margin-bottom: 20px; /* Space between main box and the poll row below it */
        padding: 20px; 
    }
    .main-content-box .hr-display { font-size: 3.5em; }
    .main-content-box .projections-section h2 { font-size: 1.4em; }

    /* Poll options will wrap onto the next line and attempt to sit side-by-side */
    .poll-option {
        order: 2; /* Common order for the poll row items */
        flex-grow: 1;   /* Allow them to grow and share the space on their row */
        flex-shrink: 1; /* Allow them to shrink */
        flex-basis: calc(50% - 10px); /* Attempt 50/50 split for a 20px gap between them */
                                      /* (10px is half the gap) */
        max-width: 280px; /* Prevent individual poll boxes from getting too wide */
        min-width: 140px; /* Crucial: Minimum width before they consider stacking due to lack of space. 
                             Adjust this value. If 2 * min-width + gap > screen_width, they will stack. */
        
        padding: 15px; 
        margin-bottom: 0; /* No bottom margin when they are successfully side-by-side */
    }
    .poll-no { 
        order: 2; /* Explicit order for the 'no' poll on the second line (left) */
    }
    .poll-yes { 
        order: 3; /* Explicit order for the 'yes' poll on the second line (right) */
    }
    
    .poll-option .poll-label { font-size: 2.0em; margin-bottom: 8px; }
    .poll-option .poll-percentage { font-size: 1.6em; margin-bottom: 12px; }
    .poll-option .vote-button { font-size: 0.9em; padding: 8px 12px; width: 90%; }
    .vote-message { font-size: 0.85em; margin-top: 8px; }
}

/* For small mobile screens (e.g., 500px and below, or when side-by-side polls are too cramped) */
/* Layout: Main content first (full width), polls below it AND STACKED VERTICALLY */
@media (max-width: 500px) { /* Adjust this breakpoint as needed */
    header h1 { font-size: 1.6em; }
    
    .content-and-poll-container {
        gap: 15px; /* Reduce overall gap between main box and first poll */
    }

    .main-content-box {
        /* order: 1; already set from previous media query */
        /* flex-basis: 100%; already set */
        max-width: 100%; /* Allow it to use full available width */
        padding: 15px 10px; 
        margin-bottom: 15px; /* Space before the now STACKED polls */
    }
    .main-content-box .hr-display { font-size: 2.8em; }
    .main-content-box .projections-section h2 { font-size: 1.2em; }
    
    .poll-option {
        /* Override previous flex settings to stack them vertically */
        flex-grow: 0; /* Don't grow, rely on flex-basis/max-width */
        flex-shrink: 1;
        flex-basis: 100%;   /* Each poll option takes full width of the container */
        max-width: 320px;   /* But don't let them get wider than this on small screens */
        min-width: unset;   /* Remove min-width when they are stacked */
        margin-left: auto;  /* Center the stacked poll boxes */
        margin-right: auto; /* Center the stacked poll boxes */
        margin-bottom: 15px; /* Space between stacked poll boxes */
        padding: 10px;
    }
    /* .poll-no { order: 2; } /* Order is inherited */
    /* .poll-yes { order: 3; } /* Order is inherited */
    .poll-yes {
        margin-bottom: 0; /* No bottom margin on the last stacked item */
    }

    .poll-option .poll-label { font-size: 1.8em; }
    .poll-option .poll-percentage { font-size: 1.4em; }
    .poll-option .vote-button { font-size: 0.9em; width: 80%; padding: 8px 10px; }
    .vote-message { font-size: 0.8em; }
}

/* Add these styles to your existing style.css */

.poll-option {
    position: relative; /* For positioning the absolute popup */
    /* ... your existing .poll-option styles ... */
}

.expand-analytics-button {
    display: none; /* Hidden by default, shown on mobile via media query */
    padding: 6px 10px;
    font-size: 0.8em;
    background-color: #78909c; /* Neutral color */
    color: white;
    border: none;
    border-radius: 4px;
    margin-top: 10px;
    cursor: pointer;
}
.expand-analytics-button:hover {
    background-color: #546e7a;
}

.analytics-popup {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Position below the poll option */
    left: 50%;
    transform: translateX(-50%);
    width: 280px; /* Or a percentage, or auto */
    min-width: 200px;
    background-color: #ffffff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 6px;
    padding: 15px;
    z-index: 100; /* Ensure it's above other content */
    text-align: left;
    font-size: 0.9em;
    color: #333;
}
.poll-no .analytics-popup { /* Adjust if it overflows on left */
    /* left: 0; transform: translateX(0); */
}
.poll-yes .analytics-popup { /* Adjust if it overflows on right */
    /* right: 0; left: auto; transform: translateX(0); */
}


.analytics-popup h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #002D72; /* Mets Blue for headings */
}

.analytics-popup p {
    margin: 5px 0;
}

.country-breakdown-list ul {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    max-height: 150px; /* Scroll if too many countries */
    overflow-y: auto;
}
.country-breakdown-list li {
    padding: 3px 0;
    border-bottom: 1px dashed #eee;
}
.country-breakdown-list li:last-child {
    border-bottom: none;
}

/* Media query to show expand button on mobile and adjust popup if needed */
@media (max-width: 768px) { /* Or your preferred mobile breakpoint */
    .expand-analytics-button {
        display: inline-block; /* Show on mobile */
    }
    .analytics-popup {
        /* For mobile, you might want it to be fixed or cover more of the screen,
           or just ensure it doesn't go off-screen.
           The absolute positioning might need tweaking here. */
        width: 90%; /* Example: make it wider on mobile */
        max-width: 300px;
        top: calc(100% + 5px); /* Ensure a small gap */
    }
}