/*
 * BFH Community Polls (polls.css)
 *
 * Per-perfume poll grid. Colours resolve from the theme tokens so a poll on a
 * dark single-perfume page and one dropped into a light Elementor section both
 * read correctly without per-placement overrides.
 */

.bfh-polls {
    --bfh-poll-accent: var(--bfh-color-primary, #18B7B0);
    --bfh-poll-accent-soft: var(--bfh-color-primary-transparent, rgba(24, 183, 176, 0.15));
    --bfh-poll-surface: var(--bfh-surface, #1A1A1A);
    --bfh-poll-border: var(--bfh-border, #333333);
    --bfh-poll-text: var(--bfh-text-primary, #FFFFFF);
    --bfh-poll-muted: var(--bfh-text-secondary, #A0A0A0);
    --bfh-poll-track: rgba(127, 127, 127, 0.18);
    --bfh-poll-radius: var(--bfh-radius-xl, 16px);

    font-family: var(--bfh-font-sans, 'Inter', system-ui, sans-serif);
    color: var(--bfh-poll-text);
}

/* -------------------- Section header -------------------- */

.bfh-polls__header {
    margin-bottom: var(--bfh-space-6, 2rem);
}

.bfh-polls__title {
    margin: 0 0 var(--bfh-space-2, 0.5rem);
    font-family: var(--bfh-font-serif, 'Playfair Display', Georgia, serif);
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: var(--bfh-font-weight-semibold, 600);
    line-height: 1.2;
    color: var(--bfh-poll-text);
}

.bfh-polls__subtitle {
    margin: 0;
    max-width: 60ch;
    font-size: var(--bfh-text-sm, 0.875rem);
    line-height: 1.6;
    color: var(--bfh-poll-muted);
}

/* -------------------- Grid -------------------- */

.bfh-polls-grid {
    display: grid;
    grid-template-columns: repeat(var(--bfh-poll-columns, 2), minmax(0, 1fr));
    gap: var(--bfh-space-5, 1.5rem);
}

@media (max-width: 1024px) {
    .bfh-polls-grid {
        grid-template-columns: repeat(min(var(--bfh-poll-columns, 2), 2), minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .bfh-polls-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* -------------------- Card -------------------- */

.bfh-poll-card {
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-4, 1rem);
    padding: var(--bfh-space-5, 1.5rem);
    background: var(--bfh-poll-surface);
    border: var(--bfh-border-width, 1px) solid var(--bfh-poll-border);
    border-radius: var(--bfh-poll-radius);
    transition: border-color var(--bfh-anim-normal, 250ms ease-in-out),
                transform var(--bfh-anim-normal, 250ms ease-in-out),
                box-shadow var(--bfh-anim-normal, 250ms ease-in-out);
}

.bfh-poll-card:hover {
    border-color: var(--bfh-border-hover, #444444);
    box-shadow: var(--bfh-shadow-1, 0 4px 6px rgba(0, 0, 0, 0.3));
}

.bfh-poll-card:focus-within {
    border-color: var(--bfh-poll-accent);
}

.bfh-poll-card.is-busy {
    opacity: 0.75;
    pointer-events: none;
}

.bfh-poll-card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--bfh-space-3, 0.75rem);
}

.bfh-poll-card__title {
    margin: 0;
    font-size: var(--bfh-text-lg, 1.125rem);
    font-weight: var(--bfh-font-weight-semibold, 600);
    line-height: 1.3;
    color: var(--bfh-poll-text);
}

.bfh-poll-card__votes {
    flex-shrink: 0;
    font-size: var(--bfh-text-xs, 0.75rem);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--bfh-poll-muted);
}

/* -------------------- Option rows -------------------- */

.bfh-poll-card__options {
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-3, 0.75rem);
}

.bfh-poll-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-2, 0.5rem);
    padding: var(--bfh-space-2, 0.5rem) var(--bfh-space-3, 0.75rem);
    border-radius: var(--bfh-radius-md, 8px);
    transition: background-color var(--bfh-anim-fast, 150ms ease-in-out);
}

.bfh-poll-option:hover {
    background: var(--bfh-surface-hover, rgba(127, 127, 127, 0.08));
}

/* The native radio stays in the accessibility tree but the label is the
   visible control, so the whole row is clickable. */
.bfh-poll-option__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.bfh-poll-option__input:focus-visible + .bfh-poll-option__label {
    outline: 2px solid var(--bfh-poll-accent);
    outline-offset: 3px;
    border-radius: var(--bfh-radius-sm, 4px);
}

.bfh-poll-option__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bfh-space-3, 0.75rem);
    cursor: pointer;
    font-size: var(--bfh-text-sm, 0.875rem);
    line-height: 1.4;
}

.bfh-poll-card.has-voted .bfh-poll-option__label,
.bfh-poll-card.is-results .bfh-poll-option__label {
    cursor: default;
}

.bfh-poll-option__text {
    color: var(--bfh-poll-text);
    transition: color var(--bfh-anim-fast, 150ms ease-in-out);
}

.bfh-poll-option__percent {
    flex-shrink: 0;
    font-weight: var(--bfh-font-weight-semibold, 600);
    font-variant-numeric: tabular-nums;
    color: var(--bfh-poll-muted);
    transition: color var(--bfh-anim-fast, 150ms ease-in-out);
}

/* -------------------- Result bars -------------------- */

.bfh-poll-option__track {
    position: relative;
    width: 100%;
    height: 8px;
    overflow: hidden;
    background: var(--bfh-poll-track);
    border-radius: var(--bfh-radius-pill, 9999px);
}

.bfh-poll-option__bar {
    display: block;
    width: 0;
    height: 100%;
    background: var(--bfh-poll-accent);
    border-radius: inherit;
    transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* The highest-voted row carries the accent treatment from the design. */
.bfh-poll-option.is-leading .bfh-poll-option__text,
.bfh-poll-option.is-leading .bfh-poll-option__percent {
    color: var(--bfh-poll-accent);
}

.bfh-poll-option.is-selected {
    background: var(--bfh-poll-accent-soft);
}

.bfh-poll-option.is-selected .bfh-poll-option__text {
    font-weight: var(--bfh-font-weight-semibold, 600);
}

.bfh-poll-option.is-selected .bfh-poll-option__bar {
    background: var(--bfh-poll-accent);
    box-shadow: 0 0 12px var(--bfh-poll-accent-soft);
}

/* Bars hold at zero until the card scrolls in, then run to width. */
.bfh-animate-bars-yes .bfh-poll-card:not(.is-visible) .bfh-poll-option__bar {
    width: 0 !important;
}

/* -------------------- Footer -------------------- */

.bfh-poll-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bfh-space-3, 0.75rem);
    margin-top: auto;
    padding-top: var(--bfh-space-2, 0.5rem);
}

.bfh-poll-card__submit {
    flex-shrink: 0;
    padding: 0.625rem 1.5rem;
    font-family: inherit;
    font-size: var(--bfh-text-sm, 0.875rem);
    font-weight: var(--bfh-font-weight-semibold, 600);
    color: var(--bfh-text-inverse, #121212);
    background: var(--bfh-poll-accent);
    border: none;
    border-radius: var(--bfh-radius-pill, 9999px);
    cursor: pointer;
    transition: background-color var(--bfh-anim-fast, 150ms ease-in-out),
                transform var(--bfh-anim-fast, 150ms ease-in-out),
                opacity var(--bfh-anim-fast, 150ms ease-in-out);
}

.bfh-poll-card__submit:hover:not(:disabled) {
    background: var(--bfh-color-primary-hover, #02C3AE);
    transform: translateY(-1px);
}

.bfh-poll-card__submit:active:not(:disabled) {
    transform: translateY(0);
}

.bfh-poll-card__submit:focus-visible {
    outline: 2px solid var(--bfh-poll-accent);
    outline-offset: 3px;
}

.bfh-poll-card__submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.bfh-poll-card__message {
    margin: 0;
    font-size: var(--bfh-text-xs, 0.75rem);
    line-height: 1.4;
    color: var(--bfh-poll-muted);
}

.bfh-poll-card__message.is-success {
    color: var(--bfh-success, #28A745);
}

.bfh-poll-card__message.is-error {
    color: var(--bfh-danger, #DC3545);
}

/* -------------------- Empty state -------------------- */

.bfh-polls-empty {
    padding: var(--bfh-space-8, 3rem) var(--bfh-space-5, 1.5rem);
    text-align: center;
    color: var(--bfh-poll-muted);
    background: var(--bfh-poll-surface);
    border: 1px dashed var(--bfh-poll-border);
    border-radius: var(--bfh-poll-radius);
}

.bfh-polls-empty p {
    margin: 0;
    font-size: var(--bfh-text-sm, 0.875rem);
}

/* -------------------- Motion preferences -------------------- */

@media (prefers-reduced-motion: reduce) {
    .bfh-poll-card,
    .bfh-poll-option,
    .bfh-poll-option__bar,
    .bfh-poll-card__submit {
        transition-duration: 1ms;
    }

    .bfh-poll-card__submit:hover:not(:disabled) {
        transform: none;
    }
}
