/*
 * The viewer rating block of the live page (PHPDS-69).
 * Follows the theme of the event page: it only uses the platform variables (live2.css) and the optional card variables
 * (--card-bg, --card-border) an operation's CSS may define, with neutral fallbacks. Buttons carry the class "button" so the
 * operation's own button rule (e.g. "#panels BUTTON.button") styles them like the rest of the page.
 * Star colour / size: --rt-star / --rt-size, set by live-rating.js from the settings (empty colour: the theme's --star, else gold).
 */
#rating_panel {
    --rt-size: 32px;
    display: none;
    box-sizing: border-box;
    margin: 26px 0 0 0;
    text-align: left;
    color: var(--maintext-accent, inherit);
    background: var(--card-bg, var(--background-accent, transparent));
    border: var(--card-border, 1px solid var(--frame-accent, slategray));
    border-radius: var(--main-radius, 0);
    overflow: hidden;
}

/* independent of the panels: only its switch (and the optional "panels" setting) shows it */
#rating_panel.rating-on {
    display: block;
}

#rating_panel .rt-box {
    padding: 28px 34px 30px 34px;
}

#rating_panel .rt-title {
    margin: 0 0 12px 0;
    font-family: var(--title-font, inherit);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--title-text-accent, inherit);
    text-transform: none;
}

/* small kicker above the title, like the other cards of the page */
#rating_panel .rt-box::before {
    content: attr(data-kicker);
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--star, var(--alttext-accent, inherit));
}

#rating_panel .rt-box:not([data-kicker])::before {
    content: none;
}

#rating_panel .rt-intro, #rating_panel .rt-thanks {
    margin: 0 0 14px 0;
    color: var(--alttext-accent, inherit);
}

#rating_panel .rt-thanks {
    font-family: var(--title-font, inherit);
    font-size: 20px;
    font-weight: 700;
    color: var(--title-text-accent, inherit);
}

/* one row per question: the title on the left, the stars centred in the right column; stacked on narrow screens */
#rating_panel .rt-q {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    column-gap: 24px;
    margin: 0;
    padding: 14px 0;
    border-top: 1px solid var(--frame-accent, rgba(128, 128, 128, .25));
}

#rating_panel .rt-q:first-child {
    border-top: 0;
}

/* layout "columns": one column per question, title / stars / captions stacked and centred */
#rating_panel .rt-columns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 28px;
}

#rating_panel .rt-columns .rt-q {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 200px;
    max-width: 100%;
    padding: 10px 0;
    border-top: 0;
    text-align: center;
}

#rating_panel .rt-columns .rt-label {
    margin-bottom: 8px;
}

#rating_panel .rt-label {
    font-weight: 700;
    color: var(--maintext-accent, inherit);
    overflow-wrap: anywhere;
}

#rating_panel .rt-stars {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

#rating_panel .rt-star {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0 2px;
    border: 0;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: var(--rt-size);
    line-height: 1.1;
    color: var(--alttext-accent, #888);
    opacity: .45;
    transition: transform .12s, opacity .12s, color .12s;
}

#rating_panel .rt-star.on {
    color: var(--rt-star, var(--star, #f5b301));
    opacity: 1;
}

#rating_panel .rt-star:hover {
    transform: translateY(-2px) scale(1.08);
}

#rating_panel .rt-star:focus-visible, #rating_panel .rt-send:focus-visible, #rating_panel textarea:focus-visible {
    outline: 3px solid var(--nebula, var(--rt-star, #f5b301));
    outline-offset: 2px;
}

#rating_panel .rt-scale {
    justify-self: center;
    max-width: 100%;
}

#rating_panel .rt-caps {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
    padding: 0 2px;
    font-size: 13px;
    color: var(--alttext-accent, inherit);
}

#rating_panel .rt-clabel {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--alttext-accent, inherit);
}

/* the page's own field rule (class qfield: "#ask_question_panel TEXTAREA", ".qfield"...) styles the comment; these are only the lowest-specificity defaults */
:where(#rating_panel) .rt-comment textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 18px;
    border: 1px solid var(--frame-accent, #dfdfeb);
    border-radius: 14px;
    background: var(--altbackground-accent, transparent);
    color: var(--inputtext-accent, inherit);
    font: inherit;
    font-size: 16px;
    resize: vertical;
}

#rating_panel .rt-comment textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}

#rating_panel .rt-error {
    margin: 10px 0 0 0;
    color: var(--flame, #ff8a4c);
}

#rating_panel .rt-send {
    display: block;
    margin: 18px auto 0 auto;
    cursor: pointer;
}

/* a button with no visible edge or colour of its own (the platform default is white on white) gets an outline in the theme's action frame */
#rating_panel .rt-send.rt-outlined {
    border: 1px solid currentColor;
    border-color: var(--action-frame, currentColor); /* ignored when the theme gives a full shorthand instead of a colour */
    border-radius: var(--input-radius, 30px);
}

/* the field of a theme without a visible frame colour: a soft edge made of the text colour */
#rating_panel .rt-comment textarea.rt-outlined {
    border: 1px solid rgba(128, 128, 128, .55);
    border-color: color-mix(in srgb, var(--maintext-accent, currentColor) 35%, transparent);
}

#rating_panel .rt-send:disabled {
    opacity: .6;
    cursor: default;
}

/* fallback when the operation has no .button rule: :where() keeps it at the lowest specificity, so the operation's own rule always wins */
:where(#rating_panel) .rt-send {
    background: var(--actionbk-accent, #eee);
    color: var(--action-accent, #111);
    border: 0;
    border-radius: 30px;
    padding: 12px 28px;
    font-weight: 700;
    font-size: 16px;
}

/* layout "lines" on wide screens: the labels and the scales form two aligned columns (the label column is as wide as the longest label,
   at most 40%), the whole block centred; each label is centred on the row of stars, not on stars + captions.
   --rt-row-h is the height of the row of stars (a theme CSS that changes the buttons, e.g. round numbers, sets it). Without subgrid, each row keeps its own grid. */
#rating_panel {
    --rt-row-h: calc(var(--rt-size, 32px) * 1.2);
}

@media (min-width: 561px) {
    #rating_panel .rt-lines {
        display: grid;
        grid-template-columns: fit-content(40%) auto;
        justify-content: center;
        column-gap: clamp(28px, 4vw, 56px);
    }

    #rating_panel .rt-lines .rt-q {
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        column-gap: clamp(28px, 4vw, 56px);
        align-items: start;
    }

    #rating_panel .rt-lines .rt-label {
        display: flex;
        align-items: center;
        min-height: var(--rt-row-h);
    }

    #rating_panel .rt-lines .rt-scale {
        justify-self: start;
    }
}

@media (max-width: 560px) {
    #rating_panel .rt-q {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 8px;
        text-align: center;
    }

    #rating_panel .rt-box {
        padding: 22px 18px 24px 18px;
    }
}
