/* ============================================================
   FedSmith Polls — Frontend Widget Styles
   Loaded only when fs_render_poll_widget() is called.
   Uses theme CSS custom properties — no hardcoded colors.
   ============================================================ */

/* -------------------------------------------------------------------------
   Widget container
   Mirrors .widget--bordered from theme.css so the poll card is consistent
   with other sidebar widgets without depending on theme class names.
   ------------------------------------------------------------------------- */
.poll-widget {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}

.poll-widget__heading {
    background: var(--brand-navy);
    color: var(--text-on-navy);
    font-family: "Outfit", sans-serif;
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 12px 16px;
    margin: 0;
    border-bottom: none;
}

/* -------------------------------------------------------------------------
   Widget body — JS-controlled content area
   ------------------------------------------------------------------------- */
#fs-poll-widget {
    padding: 14px 16px;
}

/* -------------------------------------------------------------------------
   Shared status messages (loading, no-poll, error)
   ------------------------------------------------------------------------- */
.poll-loading,
.poll-no-active,
.poll-error-msg {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 0;
}

/* -------------------------------------------------------------------------
   Poll question — shared by form and results states
   ------------------------------------------------------------------------- */
.poll-question {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.45;
    margin: 0 0 12px;
}

/* -------------------------------------------------------------------------
   Form: radio option list
   ------------------------------------------------------------------------- */
.poll-options {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.poll-option__label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-body);
    line-height: 1.4;
}

.poll-option__radio {
    accent-color: var(--brand-navy);
    flex-shrink: 0;
    margin-top: 0.125rem;
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.poll-option__radio:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Form: actions row (Vote button + View Results link)
   ------------------------------------------------------------------------- */
.poll-form__actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* -------------------------------------------------------------------------
   Vote button
   ------------------------------------------------------------------------- */
.poll-vote-btn {
    background: var(--brand-navy);
    color: var(--text-on-navy);
    border: none;
    border-radius: var(--r);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 8px 18px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.poll-vote-btn:hover {
    background: var(--brand-deep-navy);
}

.poll-vote-btn:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
}

.poll-vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* -------------------------------------------------------------------------
   "View Results" and "Cast Your Vote" links
   ------------------------------------------------------------------------- */
.poll-view-results,
.poll-cast-vote {
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--link);
    text-decoration: none;
}

.poll-view-results:hover,
.poll-cast-vote:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.poll-view-results:focus-visible,
.poll-cast-vote:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
    border-radius: 2px;
}

/* -------------------------------------------------------------------------
   Inline form error
   Uses :empty to suppress display without toggling classes or hidden attr.
   ------------------------------------------------------------------------- */
.poll-form__error {
    font-size: 0.8125rem;
    color: var(--brand-red);
    margin: 8px 0 0;
}

.poll-form__error:empty {
    display: none;
}

/* -------------------------------------------------------------------------
   Results: bar chart
   ------------------------------------------------------------------------- */
.poll-bars {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.poll-bar__label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.poll-bar__text {
    font-size: 0.8125rem;
    color: var(--text-body);
    line-height: 1.3;
    flex: 1 1 auto;
}

.poll-bar--voted .poll-bar__text {
    font-weight: 600;
}

.poll-bar__pct {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
    flex-shrink: 0;
}

.poll-bar__track {
    background: var(--bg-light-navy);
    border-radius: var(--r-sm);
    height: 8px;
    overflow: hidden;
    margin-bottom: 3px;
}

.poll-bar__fill {
    height: 100%;
    background: var(--link);
    border-radius: var(--r-sm);
    transition: width 0.4s ease;
    min-width: 0;
}

/* Winning option gets the red accent fill */
.poll-bar--winner .poll-bar__fill {
    background: var(--brand-red);
}

.poll-bar__meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* -------------------------------------------------------------------------
   Results footer
   ------------------------------------------------------------------------- */
.poll-total {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 4px 0 10px;
    text-align: right;
}

.poll-voted-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

/* -------------------------------------------------------------------------
   Closed poll state
   ------------------------------------------------------------------------- */
.poll-closed-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0 0 6px;
    font-style: italic;
}

/* -------------------------------------------------------------------------
   Widget archive footer link — persistent across all non-transient states.
   Top border separates it from the poll content above.
   ------------------------------------------------------------------------- */
.poll-archive-footer-link {
    display: block;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-decoration: none;
    text-align: center;
}

.poll-archive-footer-link:hover {
    color: var(--link);
    text-decoration: underline;
}

.poll-archive-footer-link:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
    border-radius: 2px;
}

/* =========================================================================
   Archive page — intro paragraph
   ========================================================================= */
.polls-archive-intro {
    font-size: 0.9375rem;
    color: var(--text-body);
    margin: -4px 0 20px;
    line-height: 1.55;
}

/* =========================================================================
   Archive page — year filter tabs
   ========================================================================= */
.polls-year-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 20px;
}

.polls-year-tab {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text-body);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 5px 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.polls-year-tab:hover {
    border-color: var(--link);
    color: var(--link);
}

.polls-year-tab:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
}

.polls-year-tab.is-active {
    background: var(--brand-navy);
    border-color: var(--brand-navy);
    color: var(--text-on-navy);
}

/* =========================================================================
   Archive page — search field
   ========================================================================= */
.polls-search {
    margin: 0 0 20px;
}

.polls-search__input {
    display: block;
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text-body);
    font-family: inherit;
    font-size: 0.9375rem;
    padding: 8px 12px;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.polls-search__input::placeholder {
    color: var(--text-muted);
}

.polls-search__input:focus {
    outline: none;
}

.polls-search__input:focus-visible {
    border-color: var(--brand-navy);
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
}

/* =========================================================================
   Archive page — status / empty messages
   ========================================================================= */
.polls-archive-status {
    min-height: 1.4em;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.polls-archive-empty {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin: 24px 0;
    text-align: center;
}

/* =========================================================================
   Archive page — poll card grid
   3 columns desktop → 2 columns tablet → 1 column mobile
   ========================================================================= */
.polls-archive-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 0 0 32px;
}

@media (max-width: 900px) {
    .polls-archive-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .polls-archive-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   Archive card
   ========================================================================= */
.arc-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.arc-card__question {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.4;
    margin: 0;
}

.arc-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
}

.arc-card__dates {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.arc-card__votes {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* =========================================================================
   Archive card — mini bar chart
   Compact version of the widget's poll-bar pattern.
   ========================================================================= */
.arc-bars {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.arc-bar__label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 3px;
}

.arc-bar__text {
    font-size: 0.75rem;
    color: var(--text-body);
    line-height: 1.3;
    flex: 1 1 auto;
}

/* Winning option text is bolded */
.arc-bar--winner .arc-bar__text {
    font-weight: 600;
    color: var(--text-heading);
}

.arc-bar__pct {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.arc-bar__track {
    background: var(--bg-light-navy);
    border-radius: var(--r-sm);
    height: 5px;
    overflow: hidden;
}

.arc-bar__fill {
    height: 100%;
    background: var(--link);
    border-radius: var(--r-sm);
    transition: width 0.4s ease;
    min-width: 0;
}

/* Winning option gets the red accent fill */
.arc-bar--winner .arc-bar__fill {
    background: var(--brand-red);
}

/* =========================================================================
   Archive page — pagination
   ========================================================================= */
.polls-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 32px;
    justify-content: center;
}

.polls-page-btn {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text-body);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 2.25rem;
    padding: 5px 10px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.polls-page-btn:hover {
    border-color: var(--link);
    color: var(--link);
}

.polls-page-btn:focus-visible {
    outline: 2px solid var(--brand-navy);
    outline-offset: 2px;
}

.polls-page-btn.is-current {
    background: var(--brand-navy);
    border-color: var(--brand-navy);
    color: var(--text-on-navy);
    cursor: default;
}

/* -------------------------------------------------------------------------
   prefers-reduced-motion — must remain at end of file (WCAG 2.3.3)
   !important is justified: this override must win against all individual
   transition declarations in this file.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
