/*
 * Reviews plugin storefront + admin styles.
 *
 * Served through shop_route('plugin.asset') -> Beike\Plugin\Asset, which only recognises the
 * extensions in its CONTENT_TYPES map (css, js, webp, webm, ...) and returns an empty 200 body for
 * anything else, so this file has to be reachable as .css and cannot @import a preprocessor.
 *
 * Everything is namespaced under .rv-* and deliberately avoids the theme's own class names. The
 * section is injected through @hook('product.detail.content.after'), i.e. inside the theme's
 * .product-container right under the description tabs, so a generic selector here would reach the
 * gallery, the description and the related-products swiper below it.
 *
 * Layout is Bootstrap 5 (the shop theme loads it), but the flex/grid rules below are written by
 * hand rather than composed from bs utilities: the pane is one fragment, and utility classes in
 * Blade markup cannot be re-styled later without editing the views again.
 */

/* ---------- stars ---------- */

.rv-stars {
    position: relative;
    display: inline-block;
    line-height: 1;
    letter-spacing: .06em;
    white-space: nowrap;
    vertical-align: middle;
    font-family: Arial, "Helvetica Neue", sans-serif;
}

.rv-stars-sm { font-size: 13px; }
.rv-stars-md { font-size: 18px; }
.rv-stars-lg { font-size: 26px; }

.rv-stars-row { display: block; }

.rv-stars-bg { color: #dfdcd5; }

/* The foreground row is clipped by an inline width percentage, so a 4.6 average paints four and
   a bit of gold stars instead of rounding to 5. */
.rv-stars-fg {
    position: absolute;
    inset: 0 auto 0 0;
    overflow: hidden;
    color: var(--rv-star, #f0a500);
}

/* ---------- price-area summary ---------- */

.rv-price-summary {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: .35rem;
    text-decoration: none;
    color: inherit;
}

.rv-price-summary:hover .rv-price-count { text-decoration: underline; }

.rv-price-avg { font-weight: 600; }

.rv-price-count { color: var(--bs-secondary-color, #6c757d); font-size: .9em; }

.rv-tab-count { color: var(--bs-secondary-color, #6c757d); font-weight: 400; font-size: .8em; }

/* ---------- section shell ---------- */

/* Own block on the page now, not a .tab-pane inside the theme's tab strip: it gets its own heading
   and a rule above it, and scroll-margin so the anchor jump from the tab link or the price summary
   does not park the heading under the sticky header. */
.rv-pane {
    margin-top: 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid #eceae5;
    scroll-margin-top: 5rem;
}

.rv-heading {
    display: flex;
    align-items: baseline;
    gap: .45rem;
    margin: 0 0 1.1rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.rv-heading-n {
    color: var(--bs-secondary-color, #6c757d);
    font-size: .95rem;
    font-weight: 500;
}

/* The tab link and the price summary are plain in-page anchors, so the only thing that makes them
   feel like navigation rather than a reload is a smooth scroll. Reduced-motion users keep the cut. */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

.rv-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.rv-side {
    flex: 0 0 232px;
    position: sticky;
    top: 1rem;
}

.rv-main { flex: 1 1 auto; min-width: 0; }

@media (max-width: 767.98px) {
    .rv-layout { flex-direction: column; gap: 1.25rem; }
    .rv-side { position: static; flex: none; width: 100%; }
}

/* ---------- summary rail ---------- */

.rv-big { display: flex; align-items: baseline; gap: .3rem; }

.rv-big-num { font-size: 2.4rem; font-weight: 600; line-height: 1; }

.rv-big-of { color: var(--bs-secondary-color, #6c757d); font-size: .9rem; }

.rv-total { margin: .35rem 0 .9rem; color: var(--bs-secondary-color, #6c757d); font-size: .9rem; }

.rv-dist { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .3rem; }

.rv-dist-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr 2rem;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .15rem 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: inherit;
    text-decoration: none;
    cursor: pointer;
}

/* :not(.is-empty) because the zero rows are plain spans now, not disabled buttons -- a hover rule
   keyed off :disabled alone stopped applying to them and the bar looked dead. */
.rv-dist-row:hover:not(:disabled):not(.is-empty) .rv-dist-star { text-decoration: underline; }

/* The rail and the chip row are two ways to ask for the same filter, so the rail has to show which
   one is on -- otherwise filtering to 2★ leaves the only visible indicator off-screen on mobile,
   where the rail sits above the chips and stops being sticky. */
.rv-dist-row.is-active .rv-dist-star {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rv-dist-row.is-active .rv-dist-n { font-weight: 600; }

.rv-dist-row:disabled,
.rv-dist-row.is-empty { cursor: default; opacity: .45; }

.rv-dist-star { font-size: .85rem; white-space: nowrap; }

.rv-dist-bar { height: 6px; background: #eceae5; border-radius: 3px; overflow: hidden; }

.rv-dist-bar i { display: block; height: 100%; background: var(--rv-star, #f0a500); border-radius: 3px; }

.rv-dist-n { font-size: .8rem; color: var(--bs-secondary-color, #6c757d); text-align: right; }

.rv-write-btn {
    display: block;
    width: 100%;
    padding: .6rem 1rem;
    background: none;
    border: 1px solid currentColor;
    border-radius: 2px;
    font-weight: 600;
    cursor: pointer;
}

.rv-write-hint {
    margin: 0;
    font-size: .82rem;
    line-height: 1.5;
    color: var(--bs-secondary-color, #6c757d);
}

/* ---------- filter chips ---------- */

.rv-filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }

.rv-chip {
    display: inline-block;
    padding: .25rem .7rem;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .88rem;
    text-decoration: none;
    cursor: pointer;
}

/* Selected state is a colour change plus an underline, not a filled pill -- a background chip
   inside a product tab reads as a button rather than a filter. */
.rv-chip.is-active {
    color: inherit;
    font-weight: 600;
    border-bottom-color: currentColor;
}

/* ---------- masonry ---------- */

/* CSS columns rather than a JS masonry: review cards have no predictable height (one line, or
   three paragraphs under four photos), and measuring them after lazy image loads needs a resize
   observer plus a reflow per image. column-count balances the column heights on its own.
   The trade-off is that cards read top-to-bottom per column instead of newest-first across the
   row, which is right for a cloud of opinions and is what Temu's grid does as well. */
.rv-grid {
    column-count: 2;
    column-gap: 1rem;
}

@media (min-width: 1200px) { .rv-grid { column-count: 3; } }

@media (max-width: 767.98px) { .rv-grid { column-count: 1; } }

.rv-card {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: inline-block;
    width: 100%;
    margin: 0 0 1rem;
    padding: 1rem;
    border: 1px solid #eceae5;
    border-radius: 4px;
    background: #fff;
}

.rv-card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .55rem; }

.rv-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #f1efe9;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.rv-who { display: flex; flex-direction: column; min-width: 0; }

.rv-author { font-weight: 600; font-size: .9rem; }

.rv-when { font-size: .78rem; color: var(--bs-secondary-color, #6c757d); }

.rv-card-rating { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }

.rv-title { font-weight: 600; font-size: .95rem; }

.rv-body {
    margin: 0 0 .7rem;
    font-size: .9rem;
    line-height: 1.65;
    color: #3d3b36;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* ---------- media strip ---------- */

.rv-media { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }

.rv-video { width: 100%; max-height: 320px; border-radius: 3px; background: #000; }

.rv-thumb {
    width: 68px;
    height: 68px;
    padding: 0;
    border: 1px solid #eceae5;
    border-radius: 3px;
    background: none;
    overflow: hidden;
    cursor: zoom-in;
}

.rv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- footer / helpful ---------- */

.rv-card-foot { display: flex; align-items: center; gap: .8rem; }

.rv-helpful {
    padding: .2rem 0;
    background: none;
    border: 0;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .82rem;
    cursor: pointer;
}

.rv-helpful:hover:not(:disabled) { text-decoration: underline; }

.rv-helpful:disabled { cursor: default; opacity: .6; }

.rv-helpful-n { margin-left: .15rem; }

/* ---------- load more ---------- */

/* ---------- pager ---------- */

/* Numbered paging replaced the "show more" button. The list is a section of its own now rather than
   a tab body, so a control that keeps appending cards would grow an unbounded column under a fold
   the reader has already passed; a page number says how much is left before the click, and gives
   every page a URL worth pasting. */
.rv-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eceae5;
}

.rv-page {
    padding: .2rem .5rem;
    border-bottom: 2px solid transparent;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .88rem;
    text-decoration: none;
    cursor: pointer;
}

/* Selected and hover are a colour change plus an underline, never a filled pill -- the same rule
   the filter chips follow, and the reason the pager does not compete with the buy button above it. */
.rv-page:hover:not(.is-active):not(.is-off) {
    color: inherit;
    border-bottom-color: currentColor;
}

.rv-page.is-active {
    color: inherit;
    font-weight: 600;
    border-bottom-color: currentColor;
    cursor: default;
}

.rv-page.is-off { opacity: .4; cursor: default; }

.rv-pager-dots { padding: 0 .2rem; color: var(--bs-secondary-color, #6c757d); }

.rv-pager-note {
    margin-left: .5rem;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .8rem;
}

/* Only reachable by typing ?reviews_rating=N for a band nobody left feedback on; the chips and the
   rail rows both hide empty bands, so this is the honest note rather than a blank rectangle. */
.rv-empty {
    margin: 0;
    padding: 1rem 0;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .9rem;
}

/* ---------- write form ---------- */

.rv-form-shell {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eceae5;
}

.rv-form { display: grid; gap: 1rem; max-width: 640px; }

.rv-form-rate { display: flex; align-items: center; gap: .7rem; }

.rv-form-label { font-size: .9rem; font-weight: 600; }

.rv-picker { display: inline-flex; gap: .15rem; }

.rv-picker-star { cursor: pointer; }

.rv-picker-star input { position: absolute; opacity: 0; pointer-events: none; }

.rv-picker-star span[aria-hidden] {
    display: block;
    font-size: 1.5rem;
    line-height: 1;
    color: #dfdcd5;
}

.rv-picker-star:hover span[aria-hidden] { color: var(--rv-star, #f0a500); }

/* Checked state covers this star and its predecessors; the sibling combinator only reaches
   forward, so :has() drives the reverse fill. Without :has the picked star still lights up,
   which degrades rather than breaks on older browsers. */
.rv-picker-star input:checked ~ span[aria-hidden],
.rv-picker-star:has(input:checked) span[aria-hidden] { color: var(--rv-star, #f0a500); }

.rv-picker-star:has(input:focus-visible) span[aria-hidden] { outline: 2px solid currentColor; outline-offset: 2px; }

.rv-field { display: grid; gap: .35rem; }

.rv-field label { font-size: .9rem; font-weight: 600; }

.rv-field input[type=text],
.rv-field textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid #dcd9d3;
    border-radius: 2px;
    font: inherit;
    font-size: .92rem;
}

.rv-field textarea { resize: vertical; }

.rv-field input[type=file] { font-size: .88rem; }

.rv-counter,
.rv-upload-note { font-size: .78rem; color: var(--bs-secondary-color, #6c757d); }

.rv-form-error {
    padding: .5rem .7rem;
    border-left: 3px solid #c0392b;
    background: #fbf1ef;
    color: #8e2b21;
    font-size: .88rem;
}

.rv-submit {
    justify-self: start;
    padding: .55rem 1.8rem;
    background: #1c1b18;
    border: 1px solid #1c1b18;
    border-radius: 2px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.rv-submit:disabled { opacity: .55; cursor: default; }

/* ---------- lightbox ---------- */

.rv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 2rem;
    background: rgba(18, 17, 15, .88);
    cursor: zoom-out;
}

.rv-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 2px;
}

.rv-lightbox[hidden] { display: none; }

/* ---------- admin list ---------- */

.rv-admin-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 3px; border: 1px solid #eceae5; }

/* Bootstrap 5 renamed sr-only; the theme may ship either name, and the picker radios need a
   visually-hidden label either way, so define it here instead of depending on the theme. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
