/* Parliament Results Display Styles */

#toplist-table {
    display: none;
    width: clamp(200px, 90vw, 1200px);
    margin: 0em auto 1.5em auto;
    position: relative;
}

#toplist-table .toplist-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
    width: var(--toplist-item-width, 80px);
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none;
}

#toplist-table .toplist-item.visible {
    opacity: 1;
    pointer-events: auto;
}

#toplist-table .toplist-score {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.1em, 2.4vw, 1.5em);
    font-weight: bold;
    text-align: center;
    color: #00ff66; /* Neon green to match original palette look and style theme */
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
    background: rgba(10, 11, 18, 0.9); /* Dark glass background matching site theme */
    border: 1px solid rgba(0, 255, 102, 0.35); /* Subtle neon green border accent */
    border-radius: 6px;
    padding: 3px 12px;
    margin-bottom: -10px; /* Overlaps the badge beautifully on the top border of the image */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), inset 0 0 6px rgba(0, 255, 102, 0.15);
    display: inline-block;
    z-index: 2;
}

#toplist-table .toplist-image {
    text-align: center;
    margin-bottom: 0px;
    width: 100%;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Only apply hover scaling and blue glow on devices that support hover (e.g., mouse pointer) */
@media (hover: hover) and (pointer: fine) {
    #toplist-table .toplist-image:hover {
        transform: scale(1.05);
        border-color: #00e5ff;
        box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
    }

    #toplist-table .toplist-image:hover .audio-play-button {
        display: flex !important;
    }
}

@media (hover: none), (pointer: coarse) {
    #toplist-table .toplist-item:not(.audio-active) .toplist-image:hover,
    #toplist-table .toplist-item:not(.audio-active) .toplist-image:focus,
    #toplist-table .toplist-item:not(.audio-active) .toplist-image:focus-within {
        transform: none !important;
        border-color: transparent !important;
        box-shadow: none !important;
        outline: none !important;
    }
}

/* Glow indicators for active playing MP (applies to both touch and mouse devices) */
#toplist-table .toplist-item.audio-active .toplist-image {
    border-color: #39ff14; /* Neon green */
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.6);
    transform: scale(1.05);
}

#toplist-table .toplist-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    background: transparent !important;
}

#toplist-table .toplist-name {
    font-size: clamp(0.85em, 1.5vw, 1em);
    font-weight: bold;
    text-align: center;
    white-space: pre-line;
    margin-top: -2px; /* Pulls the name closer up towards the badge */
    line-height: 1.1; /* Tighter line wrapping for wrapped names */
}

/* Styled party badges (generic base styles, used everywhere) */
.party-badge {
    display: inline-block;
    font-size: 0.7em;
    padding: 0.15em 0.55em;
    border-radius: 4px;
    font-weight: 900;
    text-transform: uppercase;
    background-color: #333333;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); /* Nice floating shadow */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Specific positioning adjustments when inside #toplist-table */
#toplist-table .party-badge {
    margin-top: 0;
    transform: translateY(-30%); /* Shifted so its center aligns perfectly with the visual bottom border edge */
    z-index: 2; /* Ensures it renders above the image */
}

/* Specific styling overrides for party badges inside video titles to make them clear and crisp */
.video-title .party-badge {
    vertical-align: middle;
    transform: translateY(-5%); /* Small vertical adjustment to align with Orbitron font baseline */
    font-family: system-ui, -apple-system, sans-serif; /* Clean readable font */
    letter-spacing: 0;
    text-shadow: none; /* Strip out parent text-shadow (glow) for high legibility */
    -webkit-text-stroke: 0px; /* Strip out parent outline stroke for crispness */
}

/* Party specific brand colors (generic class names match both display modes) */
.party-kok { background-color: #006288; color: #ffffff; } /* Kansallinen Kokoomus */
.party-sdp { background-color: #e11932; color: #ffffff; } /* SDP */
.party-ps { background-color: #ffd500; color: #111111; }  /* Perussuomalaiset */
.party-kesk { background-color: #01954b; color: #ffffff; } /* Keskusta */
.party-vihr { background-color: #61bf1a; color: #ffffff; } /* Vihreät */
.party-vas { background-color: #bf0000; color: #ffffff; }  /* Vasemmistoliitto */
.party-rkp { background-color: #005ea2; color: #ffffff; }  /* RKP */
.party-kd { background-color: #173d7a; color: #ffffff; }   /* Kristillisdemokraatit */
.party-liik { background-color: #ff5000; color: #ffffff; } /* Liike Nyt */

#toplist-table .audio-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: calc(var(--toplist-item-width, 100px) * 0.28); /* Proportional to item size (28% of item width) */
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: parliament-pulse 1.5s ease-in-out infinite;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

@keyframes parliament-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
}
