/**
 * Frontend Styles for Year's Best Voting
 *
 * Beautiful, accessible, user-friendly design
 * Following Jakob Nielsen's usability principles
 */

/* Container */
.ybv-voting-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.ybv-voting-header {
    text-align: center;
    margin-bottom: 32px;
}

.ybv-voting-header h2 {
    color: #1a1a1a;
    font-size: 32px;
    margin-bottom: 12px;
}

.ybv-intro {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
}

/* Progress Indicator */
.ybv-progress {
    background: #f7f9fc;
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 32px;
}

.ybv-progress p {
    margin: 0 0 12px 0;
    font-weight: 600;
    color: #1a1a1a;
}

.ybv-progress-bar {
    height: 12px;
    background: #e1e8ed;
    border-radius: 6px;
    overflow: hidden;
}

.ybv-progress-fill {
    height: 100%;
    background: #278082;
    transition: width 0.4s ease;
}

/* Accordions */
.ybv-accordions {
    margin-bottom: 32px;
}

.ybv-accordion {
    border: none;
    border-radius: 12px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    background: rgba(45, 106, 79, 0.05);
}

.ybv-accordion:hover {
}

.ybv-accordion-voted {
    background: rgba(45, 106, 79, 0.05);
}

.ybv-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: none;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    text-align: left;
    transition: background 0.2s ease;
}

.ybv-accordion-header:hover {
    background-color: #eaefef;
}

.ybv-accordion-voted .ybv-accordion-header {
}

.ybv-accordion-voted .ybv-accordion-header:hover {
}

.ybv-category-name {
    flex: 1;
}

.ybv-voted-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
/*    background: #278082;*/
    color: #fff;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    margin-right: 12px;
    color: #278082;
}

.ybv-accordion-icon {
    width: 17px;
    height: 20px;
    position: relative;
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(-90deg); /* Start pointing right */
}

.ybv-accordion-icon::before,
.ybv-accordion-icon::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: #1a1a1a;
    top: 50%;
    border-radius: 1px;
}

.ybv-accordion-icon::before {
    left: 3px;
    transform: translateY(-50%) rotate(45deg);
    transform-origin: left center;
}

.ybv-accordion-icon::after {
    right: 3px;
    transform: translateY(-50%) rotate(-45deg);
    transform-origin: right center;
}

/* Rotate 90 degrees to point down when open */
.ybv-accordion-header[aria-expanded="true"] .ybv-accordion-icon {
    transform: rotate(0deg);
}

.ybv-accordion-content {
    padding: 24px 24px 24px;
    border-radius: 0 0 12px 12px;
}

/* Candidates */
.ybv-candidates {
    display: grid;
    gap: 20px;
    transition: all 0.4s ease;
}

.ybv-candidates-voted {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ybv-candidate {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #f7f7f7;
    border: 1px solid #b3bdbe;
    border-radius: 12px;
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
    position: relative;
}

.ybv-candidate:hover {
    /*background: #e9efef; changed*/
    background: #fff;
    border-color: #fff; /* new! */
}


/* Fade out animation for non-voted candidates */
.ybv-candidate-fade-out {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* Currently voted candidate styling (revoting enabled) */
.ybv-candidate-currently-voted {
    background-color: #d7e1e1 !important;
    background: rgba(45, 106, 79, 0.2);
    border: none;
    position: relative;
}

.ybv-candidate-currently-voted:hover {
    background-color: #eaefef;
}

/* Voted indicator icon */
.ybv-voted-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #2d6a4f;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(45, 106, 79, 0.15);
    border-radius: 50%;
    z-index: 10;
}

/* Voted candidate styling (old animation - keep for JS) */
.ybv-candidate-voted {
    background: rgba(45, 106, 79, 0.2);
    animation: ybv-vote-success 0.6s ease-out;
}

@keyframes ybv-vote-success {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Centered voted candidate */
.ybv-candidate-centered {
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 600px;
    width: 100%;
    padding: 32px;
    gap: 16px;
    animation: ybv-center-candidate 0.5s ease-out;
}

@keyframes ybv-center-candidate {
    from {
        opacity: 0.8;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ybv-candidate-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ybv-candidate-centered .ybv-candidate-content {
    width: 100%;
}

.ybv-candidate-name {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    transition: all 0.3s ease;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.ybv-candidate-centered .ybv-candidate-name {
    font-size: 28px;
    font-weight: 700;
    color: #22543d;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Large star icon for voted candidate (static display) */
.ybv-vote-icon-large {
    color: #2d6a4f;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.ybv-vote-icon-large svg {
    width: 64px;
    height: 64px;
}

/* Small star icon (used in JS animation) */
.ybv-vote-icon {
    color: #2d6a4f;
    animation: ybv-star-sparkle 1.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes ybv-star-sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
        opacity: 0.8;
    }
}

.ybv-candidate-description {
    color: #4a5568;
    line-height: 1.6;
    position: relative;
    margin-bottom: 16px;
}

.ybv-description-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ybv-description-text.expanded {
    -webkit-line-clamp: unset;
}

.ybv-description-text::after {
    content: '...';
    position: absolute;
    bottom: 0;
    right: 0;
    padding-left: 40px;
    background: none;
    pointer-events: none;
    font-weight: 600;
    color: #2d6a4f;
}

.ybv-description-text.expanded::after,
.ybv-description-text.no-truncation::after {
    display: none;
}

.ybv-description-text.no-truncation {
    cursor: default;
}

.ybv-candidate:hover .ybv-description-text::after {
    background: none
}

.ybv-candidate-centered .ybv-candidate-description {
    font-size: 16px;
    color: #2d3748;
    line-height: 1.8;
    max-width: 500px;
    margin: 0 auto;
}

.ybv-candidate-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    margin-top: auto;
}

.ybv-candidate-centered .ybv-candidate-actions {
    margin-top: 24px;
    justify-content: center;
    width: 100%;
}

/* Animated Checkmark */
.ybv-checkmark-circle {
    width: 80px;
    height: 80px;
    position: relative;
    display: inline-block;
}

.ybv-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: #2d6a4f;
    stroke-miterlimit: 10;
}

.ybv-checkmark-circle-path {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: #2d6a4f;
    fill: none;
}

.ybv-checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-width: 3;
    stroke: #2d6a4f;
}

/* Animate the checkmark on vote */
.ybv-checkmark-animate .ybv-checkmark-circle-path {
    animation: ybv-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.ybv-checkmark-animate .ybv-checkmark-check {
    animation: ybv-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes ybv-stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

/* Static checkmark (already voted on page load) */
.ybv-checkmark-circle:not(.ybv-checkmark-animate) .ybv-checkmark-circle-path,
.ybv-checkmark-circle:not(.ybv-checkmark-animate) .ybv-checkmark-check {
    stroke-dashoffset: 0;
}

/* "This is your vote" label */
.ybv-your-vote-label {
    margin-top: 20px;
    padding: 12px 20px;
    background: rgba(45, 106, 79, 0.15);
    border: 1px solid rgba(45, 106, 79, 0.4);
    border-radius: 8px;
    color: #1b4332;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Buttons */
.ybv-vote-button,
.ybv-button-primary {
    padding: 10px 30px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ybv-vote-button,
.ybv-button-primary {
    background: #278082;
    color: #fff;
}

.ybv-vote-button:hover,
.ybv-button-primary:hover {
    background: #428076;
}

.ybv-vote-button:active,
.ybv-button-primary:active {
    transform: translateY(0);
}

.ybv-vote-button:disabled,
.ybv-button-disabled {
    background: rgba(45, 106, 79, 0.2); /* 20% transparent for inactive */
    color: rgba(27, 67, 50, 0.6);
    cursor: not-allowed;
    opacity: 0.6;
    border: 1px solid rgba(45, 106, 79, 0.3);
}

.ybv-vote-button:disabled:hover,
.ybv-button-disabled:hover {
    transform: none;
}

/* Currently voted button (revoting enabled - lighter, more passive) */
.ybv-button-currently-voted {
    background: #85a6a7 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 24px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0.9;
    padding: 10px 20px
}

.ybv-button-currently-voted::before {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%23ffffff"><path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
}

/* Allow re-clicking voted button - subtle hover */
.ybv-button-currently-voted:hover {
    background: #85a6a7 !important;
}

.ybv-button-voted {
    background: #52b788 !important;
    color: #fff !important;
    cursor: default !important;
    opacity: 1 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    padding: 14px 32px;
}

.ybv-button-voted:hover {
    transform: none !important;
}

.ybv-candidate-centered .ybv-button-voted {
    font-size: 18px;
    padding: 16px 40px;
}


.ybv-vote-button.ybv-voting {
    background: #4299e1;
    position: relative;
}

.ybv-vote-button.ybv-voting::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 1px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: ybv-spin 0.6s linear infinite;
}

@keyframes ybv-spin {
    to { transform: rotate(360deg); }
}

/* Non-Votable Notice (for "Aasta Tegu") */
.ybv-non-votable-notice {
    padding: 10px 30px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;

    display: inline-block;
    color: #4f7f81;
    text-align: center;
    border: 1px solid #4f7f81;
}

.ybv-accordion-non-votable .ybv-accordion-header {

}

.ybv-accordion-non-votable .ybv-accordion-header:hover {
}

/* Category Footer */
.ybv-category-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e8ed;
}

.ybv-voted-message {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2d6a4f;
    font-weight: 500;
    margin: 0;
}

/* Messages */
.ybv-message {
    padding: 20px 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: center;
}

.ybv-message h3 {
    margin: 0 0 12px 0;
}

.ybv-message p {
    margin: 0 0 16px 0;
}

.ybv-message-info {
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    color: #2c5282;
}

.ybv-message-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #22543d;
}

.ybv-message-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #742a2a;
}

.ybv-message-warning {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    color: #92400e;
}

.ybv-testing-banner {
    margin-bottom: 24px;
    text-align: left;
    animation: ybv-pulse-warning 2s ease-in-out infinite;
}

.ybv-testing-banner strong {
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
    color: #b45309;
}

@keyframes ybv-pulse-warning {
    0%, 100% {
        border-color: #fbbf24;
    }
    50% {
        border-color: #f59e0b;
    }
}

.ybv-message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.ybv-toast {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
    animation: ybv-slide-in 0.3s ease;
}

@keyframes ybv-slide-in {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.ybv-toast-success {
    background: #48bb78;
    color: #fff;
}

.ybv-toast-error {
    background: #f56565;
    color: #fff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ybv-voting-container {
        padding: 16px;
    }

    .ybv-voting-header h2 {
        font-size: 24px;
    }

    .ybv-candidate {
        flex-direction: column;
        gap: 16px;
    }

    .ybv-candidate-actions {
        justify-content: flex-start;
    }

    .ybv-vote-button {
        width: 100%;
    }

    .ybv-accordion-header {
        padding: 16px;
        font-size: 16px;
    }

    .ybv-accordion-content {
        padding: 0 16px 16px;
    }

    .ybv-candidate-name {
        font-size: 18px;
        line-height: 1.4;
    }

    .ybv-message-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    /* Voted candidate responsive */
    .ybv-candidate-centered {
        padding: 24px;
    }

    .ybv-candidate-centered .ybv-candidate-name {
        font-size: 26px;
        font-weight: 700;
    }

    .ybv-vote-icon svg {
        width: 36px;
        height: 36px;
    }

    .ybv-candidate-centered .ybv-button-voted {
        font-size: 16px;
        padding: 14px 32px;
        width: 100%;
    }
}

/* Accessibility */
.ybv-accordion-header:focus {
    outline: 2px solid #2d6a4f;
    outline-offset: 2px;
}

.ybv-vote-button:focus {
    outline: 2px solid #2d6a4f;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Countdown Timer */
.ybv-countdown-container {
    background: #278082;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.ybv-countdown-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.ybv-countdown-label {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ybv-countdown-timer {
    display: flex;
    gap: 24px;
    align-items: center;
}

.ybv-countdown-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ybv-countdown-value {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px 20px;
    min-width: 70px;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ybv-countdown-unit {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-transform: lowercase;
}

.ybv-countdown-ended {
    padding: 16px;
}

.ybv-countdown-ended .ybv-countdown-label {
    font-size: 18px;
    color: #fff;
}

/* Responsive countdown */
@media (max-width: 768px) {
    .ybv-countdown-container {
        padding: 16px 20px;
    }

    .ybv-countdown-timer {
        gap: 12px;
    }

    .ybv-countdown-value {
        font-size: 24px;
        padding: 8px 12px;
        min-width: 50px;
    }

    .ybv-countdown-label {
        font-size: 14px;
    }

    .ybv-countdown-unit {
        font-size: 11px;
    }
}
