/* ==========================================================================
   Ratings and reviews — landing page.

   Material 3 shapes and states, painted with daisyUI's theme variables so the
   block follows the landing page into dark mode without its own palette.
   Role names follow M3 (surface, on-surface-variant, outline...) and map onto
   daisyUI's base/primary scale below.
   ========================================================================== */

.rv {
    --rv-primary: var(--color-primary);
    --rv-on-primary: var(--color-primary-content);
    --rv-surface: var(--color-base-100);
    --rv-on-surface: var(--color-base-content);
    --rv-on-surface-variant: color-mix(in oklab, var(--color-base-content) 68%, transparent);
    --rv-outline: color-mix(in oklab, var(--color-base-content) 38%, transparent);
    --rv-outline-variant: color-mix(in oklab, var(--color-base-content) 14%, transparent);
    --rv-track: color-mix(in oklab, var(--color-base-content) 5%, var(--color-base-100));
    --rv-secondary-container: color-mix(in oklab, var(--color-primary) 16%, var(--color-base-100));
    --rv-on-secondary-container: color-mix(in oklab, var(--color-primary) 70%, var(--color-base-content));
    --rv-state-hover: color-mix(in oklab, var(--color-base-content) 8%, transparent);
    --rv-star-empty: color-mix(in oklab, var(--color-base-content) 30%, transparent);

    color: var(--rv-on-surface);
    scroll-margin-top: 16px;
}

.rv-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Type ------------------------------------------------------------- */

.rv-title {
    font-size: 1.125rem;     /* M3 title-large, scaled to this page */
    line-height: 1.5rem;
    font-weight: 500;
}

.rv-subtitle {
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--rv-on-surface-variant);
}

.rv-label {
    font-size: 0.75rem;
    line-height: 1rem;
    color: var(--rv-on-surface-variant);
}

/* ---- Buttons ---------------------------------------------------------- */

.rv-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    overflow: hidden;
    text-decoration: none;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

/* State layer: M3 expresses hover/press as a tint over the container. */
.rv-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
.rv-btn:hover::after { opacity: 0.08; }
.rv-btn:active::after { opacity: 0.12; }
.rv-btn:focus-visible { outline: 2px solid var(--rv-primary); outline-offset: 2px; }
.rv-btn:disabled { cursor: default; opacity: 0.38; }
.rv-btn:disabled::after { opacity: 0; }

.rv-btn-filled { background: var(--rv-primary); color: var(--rv-on-primary); }
.rv-btn-filled:hover { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15); }

.rv-btn-tonal { background: var(--rv-secondary-container); color: var(--rv-on-secondary-container); }

.rv-btn-outlined {
    background: transparent;
    color: var(--rv-primary);
    box-shadow: inset 0 0 0 1px var(--rv-outline);
}

.rv-btn-text { background: transparent; color: var(--rv-primary); padding: 0 12px; }
.rv-btn-text.rv-danger { color: var(--color-error); }

/* ---- Filter chips ----------------------------------------------------- */

.rv-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 0;
}
.rv-chips::-webkit-scrollbar { display: none; }

.rv-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    height: 32px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rv-outline);
    color: var(--rv-on-surface-variant);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    overflow: hidden;
}
.rv-chip::after {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.rv-chip:hover::after { opacity: 0.08; }
.rv-chip:focus-visible { outline: 2px solid var(--rv-primary); outline-offset: 2px; }
.rv-chip svg { display: none; width: 18px; height: 18px; margin-left: -8px; }

.rv-chip[aria-pressed="true"] {
    background: var(--rv-secondary-container);
    color: var(--rv-on-secondary-container);
    box-shadow: none;
}
.rv-chip[aria-pressed="true"] svg { display: block; }

/* ---- Star input ------------------------------------------------------- */

.rv-stars-input {
    display: flex;
    justify-content: space-between;
    max-width: 320px;
    margin: 0;
    padding: 0;
    border: 0;
}

.rv-stars-input label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;     /* M3 minimum touch target */
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--rv-star-empty);
    transition: background-color 0.15s ease;
}
.rv-stars-input label:hover { background: var(--rv-state-hover); }
.rv-stars-input svg {
    width: 36px;
    height: 36px;
    fill: transparent;
    stroke: currentColor;
    stroke-width: 1.5;
    transition: fill 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.rv-stars-input input:focus-visible + label { outline: 2px solid var(--rv-primary); outline-offset: -2px; }

/* Fill every star up to the chosen one. Hover previews without committing,
   so while the pointer is over the row the checked state steps aside. */
.rv-stars-input:has(input[value="1"]:checked) label:nth-of-type(-n+1) svg,
.rv-stars-input:has(input[value="2"]:checked) label:nth-of-type(-n+2) svg,
.rv-stars-input:has(input[value="3"]:checked) label:nth-of-type(-n+3) svg,
.rv-stars-input:has(input[value="4"]:checked) label:nth-of-type(-n+4) svg,
.rv-stars-input:has(input[value="5"]:checked) label:nth-of-type(-n+5) svg {
    fill: var(--rv-primary);
    color: var(--rv-primary);
}

@media (hover: hover) {
    /* Doubled class: has to outrank the :checked fill above, which carries
       the same pseudo-classes plus an attribute selector. */
    .rv-stars-input.rv-stars-input:has(label:hover) label:nth-of-type(n) svg {
        fill: transparent;
        color: var(--rv-star-empty);
    }
    .rv-stars-input:has(label:nth-of-type(1):hover) label:nth-of-type(-n+1) svg,
    .rv-stars-input:has(label:nth-of-type(2):hover) label:nth-of-type(-n+2) svg,
    .rv-stars-input:has(label:nth-of-type(3):hover) label:nth-of-type(-n+3) svg,
    .rv-stars-input:has(label:nth-of-type(4):hover) label:nth-of-type(-n+4) svg,
    .rv-stars-input:has(label:nth-of-type(5):hover) label:nth-of-type(-n+5) svg {
        fill: var(--rv-primary);
        color: var(--rv-primary);
    }
}

.rv-stars-input input:checked + label svg { transform: scale(1.08); }

/* ---- Star display ----------------------------------------------------- */

.rv-stars {
    position: relative;
    display: inline-flex;
    line-height: 0;
    color: var(--rv-star-empty);
}
.rv-stars svg {
    flex: 0 0 auto;     /* the clipped fill row must not squeeze its stars */
    width: var(--rv-star-size, 12px);
    height: var(--rv-star-size, 12px);
    fill: currentColor;
}
.rv-stars-fill {
    position: absolute;
    inset: 0 auto 0 0;
    display: inline-flex;
    overflow: hidden;
    color: var(--rv-primary);
}

/* ---- Compose ---------------------------------------------------------- */

/* The text field waits for a star, so the first decision is a single tap. No
   script needed: a checked rating is enough to open it. */
.rv-compose { display: none; }
.rv-rate:has(input[name="rating"]:checked) .rv-compose,
.rv-rate[data-open="true"] .rv-compose {
    display: block;
    animation: rv-reveal 0.22s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes rv-reveal {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* M3 outlined text field */
.rv-field { position: relative; margin-top: 16px; }

/* Doubled class: form-controls.css gives every dark-mode textarea a filled
   ground at 0-2-1, and M3's outlined field is see-through. */
.rv-field.rv-field textarea {
    display: block;
    width: 100%;
    min-height: 128px;
    padding: 16px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rv-outline);
    color: var(--rv-on-surface);
    font: inherit;
    font-size: 1rem;
    line-height: 1.5rem;
    resize: vertical;
    outline: none;
    transition: box-shadow 0.15s ease;
}
.rv-field textarea:hover { box-shadow: inset 0 0 0 1px var(--rv-on-surface); }
.rv-field textarea:focus { box-shadow: inset 0 0 0 2px var(--rv-primary); }

.rv-field label {
    position: absolute;
    top: 16px;
    left: 12px;
    padding: 0 4px;
    background: var(--rv-surface);
    color: var(--rv-on-surface-variant);
    font-size: 1rem;
    line-height: 1.5rem;
    pointer-events: none;
    transform-origin: left top;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), color 0.15s ease;
}
.rv-field textarea:focus + label,
.rv-field textarea:not(:placeholder-shown) + label {
    transform: translateY(-28px) scale(0.75);
}
.rv-field textarea:focus + label { color: var(--rv-primary); }

.rv-field-support {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 16px 0;
    font-size: 0.75rem;
    line-height: 1rem;
    color: var(--rv-on-surface-variant);
}
.rv-field-support [data-counter] { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* ---- Summary ---------------------------------------------------------- */

.rv-summary {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 24px;
}

.rv-score { text-align: left; }
.rv-score-num { font-size: 3.5rem; line-height: 1; font-weight: 400; letter-spacing: -0.02em; }
.rv-score .rv-stars { --rv-star-size: 14px; margin: 8px 0 4px; }

.rv-bars { display: grid; gap: 6px; }
.rv-bar {
    display: grid;
    grid-template-columns: 10px 1fr;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--rv-on-surface-variant);
}
.rv-track { height: 10px; border-radius: 999px; background: var(--rv-track); overflow: hidden; }
.rv-track span { display: block; height: 100%; border-radius: 999px; background: var(--rv-primary); }

/* ---- Review item ------------------------------------------------------ */

.rv-item + .rv-item { margin-top: 24px; }

.rv-item-head { display: flex; align-items: center; gap: 12px; min-height: 32px; }

.rv-avatar {
    --rv-hue: #1a73e8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--rv-hue) 22%, var(--rv-surface));
    color: color-mix(in oklab, var(--rv-hue) 75%, var(--rv-on-surface));
    font-size: 0.875rem;
    font-weight: 500;
}
.rv-avatar[data-hue="1"] { --rv-hue: #188038; }
.rv-avatar[data-hue="2"] { --rv-hue: #e37400; }
.rv-avatar[data-hue="3"] { --rv-hue: #d93025; }
.rv-avatar[data-hue="4"] { --rv-hue: #9334e6; }
.rv-avatar[data-hue="5"] { --rv-hue: #007b83; }

.rv-name { font-size: 0.875rem; font-weight: 500; }

.rv-role {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--rv-track);
    color: var(--rv-on-surface-variant);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.rv-item-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.rv-body {
    margin-top: 8px;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--rv-on-surface-variant);
    white-space: pre-line;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
}
.rv-body[data-expanded="true"] { -webkit-line-clamp: unset; }

.rv-more {
    margin-top: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--rv-primary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

/* The signed-in user's own review sits in a tonal card, like Play's. */
.rv-own {
    padding: 16px;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--rv-outline-variant);
}

.rv-empty {
    padding: 24px 16px;
    border-radius: 12px;
    background: var(--rv-track);
    text-align: center;
    font-size: 0.875rem;
    color: var(--rv-on-surface-variant);
}

.rv-feed[aria-busy="true"] { opacity: 0.5; transition: opacity 0.2s ease; }

/* ---- Dialog (delete confirmation) ------------------------------------ */

.rv-dialog {
    width: min(312px, calc(100vw - 48px));
    padding: 24px;
    border: 0;
    border-radius: 28px;
    background: color-mix(in oklab, var(--color-primary) 6%, var(--color-base-100));
    color: var(--color-base-content);
    box-shadow: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.rv-dialog::backdrop { background: rgba(0, 0, 0, 0.32); }
.rv-dialog h2 { font-size: 1.5rem; line-height: 2rem; font-weight: 400; margin-bottom: 16px; }
.rv-dialog p { font-size: 0.875rem; line-height: 1.25rem; opacity: 0.75; }
.rv-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

@media (prefers-reduced-motion: reduce) {
    .rv *, .rv *::after { transition: none !important; animation: none !important; }
}

/* ---- Layout ----------------------------------------------------------- */
/* Local to this block so it does not depend on a Tailwind rebuild. */

.rv-section { display: flex; flex-direction: column; gap: 28px; margin: 32px 0 8px; }
.rv-head { display: flex; flex-direction: column; gap: 2px; }
.rv-stars-input { margin-top: 12px; }
.rv-stars-input a { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; color: var(--rv-star-empty); }
.rv-stars-input a:hover { background: var(--rv-state-hover); color: var(--rv-primary); }
.rv-stars-input a svg { fill: transparent; }
.rv-disclosure { margin: 12px 16px 0; }
.rv-disclosure strong { font-weight: 500; color: var(--rv-on-surface); }
.rv-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.rv-own-actions { display: flex; gap: 4px; margin: 12px 0 -8px -12px; }
.rv-items { margin-top: 28px; }
.rv-more-wrap { display: flex; justify-content: flex-start; margin-top: 24px; }
.rv-signin-hint { margin-top: 4px; }

/* ---- Institute reply -------------------------------------------------- */

.rv-reply {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--rv-track);
}
.rv-reply-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.rv-reply .rv-body { margin-top: 4px; }

.rv-reply-tools { margin: 4px 0 0 -12px; }
.rv-reply-form { margin-left: 12px; }
.rv-reply-form .rv-field textarea { min-height: 88px; }
.rv-item[aria-busy="true"] { opacity: 0.5; }
