/* /tilbakemelding: the emailed feedback form and its thank-you page. Namespaced under .fb-
   and using the site color tokens (see layout.css).

   Deliberately JavaScript-free. The page arrives from an email, usually on a phone, so the
   star picker is five radio inputs whose labels are filled in by CSS sibling selectors. */

.fb-page {
    max-width: 620px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.fb-card {
    padding: 28px;
    background: var(--white);
    border: 1px solid color-mix(in srgb, var(--action-primary) 18%, transparent);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.fb-card--done {
    text-align: center;
}

.fb-title {
    margin: 0 0 10px;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.fb-lead {
    margin: 0 0 14px;
    color: var(--foreground-secondary);
    font-size: 15px;
    line-height: 1.6;
}

.fb-secondary {
    display: inline-block;
    margin-top: 10px;
    font-size: 15px;
    font-weight: 600;
}

.fb-form {
    margin-top: 26px;
}

.fb-errors {
    margin-bottom: 22px;
    padding: 14px 16px;
    background: rgba(192, 57, 43, 0.06);
    border: 1px solid rgba(192, 57, 43, 0.35);
    border-radius: 10px;
    color: var(--foreground-primary);
    font-size: 14px;
}

.fb-errors ul {
    margin: 0;
    padding-left: 20px;
}

.fb-label {
    display: block;
    margin-bottom: 4px;
    padding: 0;
    color: var(--foreground-primary);
    font-size: 15px;
    font-weight: 600;
}

.fb-hint {
    margin: 0 0 10px;
    color: var(--foreground-tertiary);
    font-size: 13px;
}

/* ── Star picker ─────────────────────────────────────────────────── */
.fb-rating {
    margin: 0 0 26px;
    padding: 0;
    border: 0;

    --fb-star-empty: color-mix(in srgb, var(--foreground-tertiary) 35%, transparent);
    --fb-star-filled: #f0a500;
}

/* row-reverse so DOM order 5..1 renders left-to-right as 1..5. That inversion is the whole
   trick: a checked star can then reach its lower neighbours as following siblings, which is
   something CSS can express and "preceding sibling" is not. */
.fb-rating__stars {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 4px;
    margin: 8px 0 6px;
}

.fb-rating__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.fb-rating__star {
    display: block;
    padding: 2px;
    color: var(--fb-star-empty);
    cursor: pointer;
    border-radius: 6px;
    transition: color 120ms ease, transform 120ms ease;
}

.fb-rating__star svg {
    display: block;
    width: 44px;
    height: 44px;
    fill: currentColor;
}

/* The score: the checked star and every lower one. */
.fb-rating__input:checked ~ .fb-rating__star {
    color: var(--fb-star-filled);
}

/* Hover preview. The two rules below never fight over the same star, which is the point:
   this one only matches stars ABOVE the pointer (they have the hovered star as a LATER
   sibling, so a star can never match it against itself), and the next one only matches the
   pointed-at star and the ones below it. Layering them by specificity instead is what broke
   before, because the star under the pointer lost to the rule emptying the score.

   :has() is the only way to say "above the pointer" in a DOM ordered high-to-low. Where it
   is unsupported this single rule drops out, which leaves a score that no longer empties
   above the pointer during a preview: less precise, still readable, and the chosen score and
   the fill-up-to-the-pointer both keep working. */
.fb-rating__star:has(~ .fb-rating__star:hover) {
    color: var(--fb-star-empty);
}

.fb-rating__star:hover,
.fb-rating__star:hover ~ .fb-rating__star {
    color: var(--fb-star-filled);
}

.fb-rating__star:hover {
    transform: scale(1.06);
}

/* The inputs are visually hidden, so the focus ring has to be drawn on the label instead or
   keyboard users lose their place entirely. */
.fb-rating__input:focus-visible + .fb-rating__star {
    outline: 2px solid var(--action-primary);
    outline-offset: 2px;
}

.fb-rating__scale {
    display: flex;
    justify-content: space-between;
    max-width: 252px;
    color: var(--foreground-tertiary);
    font-size: 12px;
}

/* ── Comment ─────────────────────────────────────────────────────── */
.fb-field {
    margin-bottom: 24px;
}

.fb-textarea {
    width: 100%;
    padding: 14px 16px;
    font: inherit;
    font-size: 15px;
    color: var(--foreground-primary);
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 10px;
    resize: vertical;
}

.fb-textarea:focus-visible {
    outline: 2px solid var(--action-primary);
    outline-offset: 1px;
    border-color: var(--action-primary);
}

.fb-submit {
    width: 100%;
    padding: 15px 22px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    background: var(--action-primary);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.fb-submit:hover {
    background: var(--brand-ink);
}

.fb-submit:focus-visible {
    outline: 2px solid var(--foreground-primary);
    outline-offset: 2px;
}

.fb-fineprint {
    margin: 16px 0 0;
    color: var(--foreground-tertiary);
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .fb-card {
        padding: 22px 18px;
    }

    .fb-title {
        font-size: 22px;
    }

    .fb-rating__star svg {
        width: 38px;
        height: 38px;
    }

    .fb-rating__scale {
        max-width: 218px;
    }
}
