/* Modern, clean CSS for responsive design */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&display=swap');
/* Arboria isn't on Google Fonts; use a local stack with Arboria if available, otherwise fall back to a clean sans */
body {
    font-family: 'Arboria', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
}

/* (rest of the original styles.css content copied verbatim) */

header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    display: flex;
    align-items: center;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
    min-height: 150px; /* ensure enough vertical space for larger photo */
}

/* Candidate-specific header that matches the index header dimensions */
.candidate-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    min-height: 150px;
}

.candidate-header .nav-link {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    color: white;
    text-decoration: none;
    font-weight: bold;
}

.candidate-header .centered-image {
    max-height: 80px;
    flex: 1;
    object-fit: contain;
    border: 2px solid white;
    box-sizing: border-box;
}

.candidate-header .header-content {
    flex-shrink: 0;
    text-align: right;
}

header img {
    display: block;
    border: 3px solid white;
}

.logo {
    width: 480px;
    height: auto;
    fill: white;
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1;
}

.logo-link:hover {
    background-color: transparent !important;
}

.header-content {
    flex: 1;
    text-align: center;
    margin-left: 0; /* left column occupies space naturally */
}

/* Name section: place photo and name on the same row and vertically center them */
.name-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.name-section h1 {
    margin: 0;
    text-align: left; /* keep name left-aligned relative to itself */
    font-size: 2rem;
}

/* Candidate page: small photo and action area on the right of the header */
/* Left column for logo + candidate photo (candidate pages) */
.left-column {
    /* place the left column in the header flow so its contents remain inside the top bar */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 1;
    width: 260px; /* fixed column width so header-content centers properly */
    padding-left: 1rem;
    padding-right: 1rem;
}

/* When a candidate page uses the left-column, make the logo flow naturally inside it */
.left-column .logo {
    position: static;
    width: 200px; /* smaller so candidate photo fits nicely below */
    margin-bottom: 0.25rem;
}

.candidate-photo {
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-height: 220px; /* limit height so both image and button fit */
}

.candidate-photo img {
    /* fall back styling for pages that don't use the framed layout */
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* New consistent photo frame so the visible box precisely matches the image
   - Use a square frame by default, center the image and cover the frame
   - Prevents mismatched white boxes and ensures consistent borders */
.photo-frame {
    width: 200px;
    height: 200px;
    background: transparent; /* let header background show through */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* crop any overflowing image cleanly */
    border-radius: 10px;
    /* border removed so the photo sits flush with the header background */
    box-sizing: border-box;
}

.photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* fill the frame without distortion */
    display: block;
}

/* Ensure any image with the centered-image class inside a photo-frame
   ignores the candidate-header max-height constraint and fills the frame. */
.photo-frame .centered-image {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    object-fit: cover !important;
    display: block;
}

.candidate-photo .nav-link {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.45rem 0.8rem;
}

/* Image modal / lightbox */
.image-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    padding: 0; /* we'll handle spacing inside the modal-content to guarantee containment */
}

.image-modal.open {
    display: flex;
}

.image-modal .modal-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* ensure content always stays inside the viewport with a small margin */
    box-sizing: border-box;
    padding: 12px; /* comfortable inner padding without pushing image off-screen */
    max-width: calc(100vw - 32px);
    /* Limit modal to 90% of viewport height to avoid oversized modals */
    max-height: calc(90vh - 32px);
    background: transparent; /* keep backdrop visible */
    transform-origin: center center;
    transition: opacity 180ms ease, transform 180ms ease;
    opacity: 0;
    transform: scale(0.96);
}

.image-modal img {
    display: block;
    max-width: 100%;
    /* ensure image never exceeds 90% of viewport height */
    max-height: calc(90vh - 32px);
    width: auto;
    height: auto;
    object-fit: contain; /* ensure full image is visible without cropping */
    border-radius: 6px;
}

.image-modal .close-btn {
    position: absolute;
    /* place the close button inside the modal content so it doesn't push the image out */
    top: 8px;
    right: 8px;
    background: #fff;
    color: #333;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 2; /* keep it above the image */
}

/* If the modal contains large images, ensure the image is never positioned outside the visible area
   by forcing the modal-content to use constrained dimensions and centering */
.image-modal.open .modal-content {
    /* same constraints when open (helps some older browsers/layout engines) */
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    opacity: 1;
    transform: scale(1);
}

/* Header text: use an elegant serif for a city look */
.header-content h1,
.header-content p {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 300;
}

header p {
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

/* Header link styling should only affect navigation buttons, not the logo */
.nav-link {
    color: #ffeb3b;
    text-decoration: none;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border: 2px solid #ffeb3b;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background-color: #ffeb3b;
    color: #007bff;
}

.logo-link {
    display: inline-block; /* shrink-wrap to the SVG */
    padding: 0; /* no extra hit area unless desired */
    border: none;
    background: transparent;
}

.logo-link:hover,
.logo-link:focus,
.logo-link:active {
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

.logo-link .logo {
    display: block;
    pointer-events: none; /* allow the anchor to receive clicks, not the inner SVG */
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

section {
    background: white;
    margin: 1rem 0;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

h2 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

ul {
    padding-left: 1.5rem;
}

li {
    margin: 0.5rem 0;
}

a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

ol {
    list-style-position: outside;
    padding-left: 2rem;
}

li {
    margin: 0.5rem 0;
    list-style-type: "•";
    list-style-position: outside;
    padding-left: 0.5rem;
}

/* Restore box styling for rankings on index page */
#rankings li {
    background: white;
    margin: 1rem 0;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    list-style-type: none;
    padding-left: 0;
}

li a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

#rankings li a:hover {
    background-color: #f8f9fa;
    text-decoration: none;
}

#rankings li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Compact ranking list items: keep layout consistent with smaller images and less padding */
#rankings li > a > div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
}

#rankings li > a img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    flex: 0 0 72px;
    border: 2px solid #eef3fb;
}

/* Text block: ensure name/summary stacks neatly */
#rankings li > a > div > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Force the rankings row to stay on a single line and avoid wrapping the score */
#rankings li > a > div {
    flex-wrap: nowrap;
    /* ensure the main text column can shrink if needed but not force the score down */
}

/* Keep the score together (number + percent) on one line */
#rankings li > a > div > div:last-child {
    margin-left: auto;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    #rankings li > a img {
        width: 56px;
        height: 56px;
        flex: 0 0 56px;
    }
    #rankings li > a > div {
        gap: 0.5rem;
        padding: 0.45rem 0.5rem;
    }
}

footer {
    text-align: center;
    padding: 1rem;
    background: #333;
    color: white;
    margin-top: 2rem;
}

footer a {
    color: #ffeb3b;
}

footer a:hover {
    color: #fff;
}

/* Responsive design */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }
}

/* Ensure candidate header stacks on smaller screens so action buttons don't overlap photos */
@media (max-width: 768px) {
    .candidate-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        min-height: auto;
    }

    .candidate-header .nav-link {
        /* remove absolute positioning and let it flow above the content */
        position: static;
        align-self: flex-start;
        margin: 0 0 0.75rem 0;
        z-index: 5; /* keep it above minor decorations but below modal */
    }

    .candidate-header .header-content {
        text-align: center;
        margin-left: 0;
    }

    .candidate-header .centered-image {
        max-height: 120px;
        max-width: 120px;
        margin: 0 auto;
    }

    /* Prevent cropping at tablet widths: allow the photo frame to shrink and the
       image to scale proportionally (contain) instead of filling/cropping the box. */
    .photo-frame {
        width: 120px;
        height: auto; /* let the image determine the height on narrow screens */
        overflow: visible; /* avoid hard cropping on mobile */
        border-radius: 8px;
    }

    .photo-frame img,
    .photo-frame .centered-image {
        width: 100%;
        height: auto !important;
        object-fit: contain !important; /* show the whole image rather than cropping */
        max-height: none !important;
    }

    /* allow candidate-photo to grow naturally on mobile so buttons don't force cropping */
    .candidate-photo {
        max-height: none;
    }
}

/* Mobile adjustments appended from original file */

main {
    padding: 0 0.5rem;
}

section {
    padding: 1rem;
}

li {
    margin: 0.5rem 0;
    padding: 0;
}

li a {
    padding: 0.75rem;
}

/* Mobile-specific adjustments for index page */
/* Stack photo and name only on narrow screens; the global rule below was forcing all rows
   to become column-layout and caused the percent to drop to a new line. Move this into
   a mobile media query so desktop/tablet rows remain horizontal. */

li a div img {
    width: 100px;
    height: 100px;
}

/* Stack photo and name on narrow screens */
@media (max-width: 480px) {
    .name-section {
        flex-direction: column;
        gap: 0.4rem;
        align-items: center;
    }
    .name-section h1 {
        font-size: 1.2rem;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .logo {
        width: 150px;
    }

    .header-content {
        margin-left: 170px;
    }

    h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 0.75rem;
    }

    .logo {
        width: 100px;
        top: 0.5rem;
        left: 0.5rem;
    }

    .header-content {
        margin-left: 120px;
    }

    h1 {
        font-size: 1.2rem;
    }

    header p {
        font-size: 0.9rem;
    }

    main {
        padding: 0 0.25rem;
    }

    section {
        padding: 0.75rem;
    }

    li a {
        padding: 0.5rem;
    }

    li a div {
        gap: 8px;
    }

    li a div img {
        width: 80px;
        height: 80px;
    }

    /* Ensure images on individual pages are responsive */
    header img {
        max-width: 100%;
        height: auto;
        width: 150px;
    }

    /* Make charts responsive */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Single chart rule: cap chart and its wrapper to 600px regardless of screen size */
/* Single unified rule for the chart: fixed 600px width regardless of screen size */
#ratingsChart,
.chart-wrap-hidden {
    width: 600px !important;
    max-width: 600px !important;
    margin: 0 auto 1rem;
    display: flex;
    justify-content: center;
    overflow: hidden; /* keep canvas contained if Chart.js draws outside */
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}    /* Improve text readability on small screens */
    body {
        font-size: 16px;
        line-height: 1.5;
    }

    /* Better button/link spacing on mobile */
    a {
        display: inline-block;
        margin: 0.25rem 0;
    }

    /* Stronger override for very small screens to ensure nav button is not overlapping */
    .candidate-header {
        padding-top: 0.75rem;
    }

    .candidate-header .nav-link {
        position: static !important;
        display: inline-block;
        margin-bottom: 0.6rem !important;
        order: -1; /* render before the name/photo block */
    }

    .candidate-header .centered-image {
        max-height: 96px !important;
        max-width: 96px !important;
    }
}

@media (max-width: 480px) {
    .name-section {
        flex-direction: column;
        gap: 0.4rem;
        align-items: center;
    }
    .name-section h1 {
        font-size: 1.2rem;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .logo {
        width: 150px;
    }

    .header-content {
        margin-left: 170px;
    }

    h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 0.75rem;
    }

    .logo {
        width: 100px;
        top: 0.5rem;
        left: 0.5rem;
    }

    .header-content {
        margin-left: 120px;
    }

    h1 {
        font-size: 1.2rem;
    }

    header p {
        font-size: 0.9rem;
    }

    main {
        padding: 0 0.25rem;
    }

    section {
        padding: 0.75rem;
    }

    li a {
        padding: 0.5rem;
    }

    li a div {
        gap: 8px;
    }

    li a div img {
        width: 80px;
        height: 80px;
    }

    /* Ensure images on individual pages are responsive */
    header img {
        max-width: 100%;
        height: auto;
        width: 150px;
    }

    /* Make charts responsive */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Improve text readability on small screens */
    body {
        font-size: 16px;
        line-height: 1.5;
    }

    /* Better button/link spacing on mobile */
    a {
        display: inline-block;
        margin: 0.25rem 0;
    }
}

/* Expandable ratings styling */
details {
    margin: 1rem 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
}

details summary {
    cursor: pointer;
    padding: 0.75rem;
    font-weight: bold;
    background-color: #e9ecef;
    border-radius: 4px;
    list-style: none;
}

details summary:hover {
    background-color: #dee2e6;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::after {
    content: " ▶";
    float: right;
    font-size: 1.2em;
    transition: transform 0.2s;
}

details[open] summary::after {
    content: " ▼";
    transform: rotate(0deg);
}

details p {
    margin: 0;
    padding: 0.75rem;
    background-color: white;
    border-radius: 0 0 4px 4px;
}
