/**
 * Beer Rating widget styles.
 *
 * WCAG AAA compliant: 7:1 contrast minimum on all text.
 */

.beer-rating-widget {
    font-family: inherit;
    line-height: 1.5;

    /*
     * Themeable, and declared HERE on the widget rather than on the individual pieces, so
     * that a site setting one of these on the widget (or on any ancestor) actually wins.
     * Declared on .beer-star, the star colours could not be overridden at widget level at
     * all: the element's own declaration shadowed the inherited one, which made the override
     * documented at the foot of this file do nothing.
     *
     * Defaults are AAA on a light surface.
     */
    --beer-rating-ink: #101010;
    --beer-star-empty: #595959;
    --beer-star-filled: #7a4f00;
}

/* Star buttons (interactive mode) */
.beer-star-btn {
    display: inline-block;
    padding: 2px;
    margin: 0;
    border: none;
    background: none;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1;
}

.beer-star-btn:focus-visible {
    outline: 2px solid #124a7c;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Star colours */
.beer-star {
    color: var(--beer-star-empty, #595959);
    transition: color 0.15s ease;
}

.beer-star--filled,
.beer-star--active {
    color: var(--beer-star-filled);
}

.beer-star--half {
    color: var(--beer-star-filled);
}

.beer-star--hover {
    color: var(--beer-star-filled);
    transform: scale(1.15);
}

.beer-star-btn:hover .beer-star {
    color: var(--beer-star-filled);
    transform: scale(1.15);
}

/* Empty stars: ensure contrast on both light and dark backgrounds */
.beer-star--empty {
    color: var(--beer-star-empty);
}

/* Rating rows */
.beer-rating-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.beer-rating-stars {
    display: flex;
    align-items: center;
    gap: 2px;
}

.beer-rating-stars--interactive {
    display: flex;
    align-items: center;
    gap: 0;
}

.beer-rating-stars--small {
    display: flex;
    align-items: center;
    gap: 1px;
}

/* Text elements */
.beer-rating-value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--beer-rating-ink, #1a1a2e);
}

.beer-rating-count {
    font-size: 0.875rem;
    color: #124a7c;
}

.beer-rating-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--beer-rating-ink, #1a1a2e);
    min-width: 70px;
}

/* Compact mode */
.beer-rating-compact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.beer-rating-compact .beer-star--filled {
    color: var(--beer-star-filled);
}

.beer-rating-compact .beer-rating-value {
    font-size: 0.875rem;
}

.beer-rating-compact .beer-rating-count {
    font-size: 0.75rem;
}

/* Feedback message */
.beer-rating-feedback {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.beer-rating-feedback--success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.beer-rating-feedback--error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* User rating section */
.beer-rating-user {
    padding-top: 4px;
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
}

/* Responsive: make stars touch-friendly */
@media (max-width: 640px) {
    .beer-star-btn {
        padding: 4px;
    }
}

/* Shown in place of the stars when this visitor may not rate: logged-out on a members-only
   site, or a drink that is not currently on. Never grey, and never colour alone. */
.beer-rating-signin a {
    color: #8a1e28;
    font-weight: 700;
    text-decoration: underline;
}

.beer-rating-note {
    color: var(--beer-rating-ink, #101010);
    margin: .25rem 0 0;
}


/*
 * NO prefers-color-scheme block, deliberately.
 *
 * This stylesheet controls the widget's text but not the page behind it. On a site whose
 * pages stay light while the visitor's system is set to dark, flipping the text to a pale
 * colour puts pale text on a white page: measured at well under 3:1 on a real page, which is
 * how it was caught. The defaults above are AAA on a light surface.
 *
 * A site with genuinely dark pages sets the variables once, in its own stylesheet, where it
 * DOES know what the background is:
 *
 *   .uk-section-secondary .beer-rating-widget { --beer-rating-ink: #ffffff; }
 */
