/* =========================================
   REVIEWS PAGE (reviews.html)
   page-header/breadcrumbs/page-title are intentionally redefined here
   rather than shared, matching the existing per-page convention (see
   css/account.css, css/product.css, css/blog-page.css, css/about.css,
   css/delivery.css). main.section-padding (not plain .section-padding)
   is deliberate — see the identical note in those files: it out-specifies
   css/responsive.css's mobile ".section-padding { padding-top: 50px }" so
   this page stays tight under the header on mobile too.
   ========================================= */
main.section-padding { padding-top: 10px; padding-bottom: 60px; }

.page-header { margin-bottom: 40px; }
.breadcrumbs {
    flex-wrap: wrap;
}
.page-title { font-size: clamp(22px, 1.2vw + 17.7px, 32px); font-weight: 600; text-transform: uppercase; letter-spacing: 2px; color: var(--text-main); }
.page-subtitle { color: var(--text-secondary); font-size: 15px; margin-top: 15px; max-width: 600px; line-height: 1.5; }

/* ---- Summary bar: avg rating + the write-a-review form beside it ---- */
/* Plain, no card/background behind it (removed on purpose) - metric on
   the left, form on the right, moved together as one row. */
.reviews-summary {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 40px; margin-bottom: 40px;
}
.rs-left { display: flex; align-items: center; flex-shrink: 0; }
.rs-rating-box { display: flex; flex-direction: column; }
.rs-rating-label { color: var(--text-secondary); font-size: 13px; margin-bottom: 10px; }
.rs-rating-value-row { display: flex; align-items: center; gap: 20px; }
.rs-rating { font-size: 64px; font-weight: 200; color: var(--text-main); line-height: 1; }
.rs-details { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.rs-stars { color: var(--warning); font-size: 20px; letter-spacing: 2px; }
.rs-text { color: var(--text-secondary); font-size: 11px; text-transform: lowercase; letter-spacing: 1px; }

/* ---- Reviews one at a time under the rating (desktop only) ---- */
/* Fills the empty space beside the form. On a tablet it would squeeze the
   form, on a phone push it down — so below 1024px (iPad in landscape and
   desktops keep it) it isn't shown. The thin
   line fills while a review is shown and moves on when it's full
   (animationend), so hovering pauses both the line and the change. */
/* Lined up with the form beside it: the card wears the form fields' own
   look (soft fill, 1px border) and spans from the top of the name field to
   the bottom of the message field (the rating block is held at 55px, +30px
   = the form's title row and gap), and the arrows sit level with
   «Відправити». The card stays put; only the review inside it changes. */
.rs-spotlight { display: none; margin-top: 30px; }
.rs-spot-card { background: var(--bg-soft); border: 1px solid var(--border-strong); border-radius: 4px; padding: 17px 26px; overflow: hidden; }
/* Faint outline of «ByMax» behind the whole block, standing on the
   «Всього відгуків» bar: the bottoms of the letters run on behind the bar
   and behind the review cards, showing in the gaps between them.
   reviews.js eases it down a touch as the page scrolls (--wm-y). Its own
   clipping layer, so nothing in the form gets cut off; the bar and the
   cards are lifted above it. The word is sized to the block's width
   (30.4cqw ≈ edge to edge) and stands on the same spot at every width:
   its baseline 10px above the bottom of the block (the arrows row). */
.rs-watermark { display: none; }
@media (min-width: 1024px) {
    .reviews-summary { position: relative; isolation: isolate; container-type: inline-size; }
    .reviews-summary ~ .catalog-topbar, .reviews-summary ~ .reviews-grid { position: relative; }
    .rs-watermark { display: block; position: absolute; left: 0; right: 0; top: -20px; bottom: -260px; z-index: -1; overflow: hidden; pointer-events: none; }
    .rs-watermark span {
        --wm-fs: 30.4cqw;
        position: absolute; left: 0; right: 0; bottom: calc(270px - 0.1175 * var(--wm-fs)); text-align: center;
        font-size: var(--wm-fs); font-weight: 800; letter-spacing: -0.03em; line-height: 1;
        color: transparent; -webkit-text-stroke: 2px var(--accent); opacity: 0.1;
        transform: translateY(var(--wm-y, 0px)); will-change: transform;
    }
}
@media (min-width: 1024px) {
    .reviews-summary .rs-left { flex-direction: column; align-items: stretch; flex: 1 1 0; min-width: 0; }
    .reviews-summary .rs-rating { font-size: 52px; }
    .reviews-summary .rs-rating-box { height: 55px; }
    .rs-spotlight:not([hidden]) { display: block; }
}
/* iPad in landscape / small laptops: a narrower review card, so the form
   keeps room for the name field and the Google/Facebook buttons */
@media (min-width: 1024px) and (max-width: 1279px) {
    .reviews-summary .rs-left { max-width: 380px; }
}
/* wider screens: the card reaches toward the form, always 100px apart */
@media (min-width: 1280px) {
    .reviews-summary { gap: 100px; }
}
.rs-spot-slide { transition: opacity 0.3s ease, transform 0.3s ease; }
.rs-spot-slide.is-leaving { opacity: 0; transform: translateX(calc(var(--spot-dir, 1) * -14px)); }
.rs-spot-slide.is-entering { opacity: 0; transform: translateX(calc(var(--spot-dir, 1) * 14px)); transition: none; }
.rs-spot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rs-spot-stars { color: var(--warning); font-size: 13px; letter-spacing: 2px; }
.rs-spot-date { color: var(--text-muted); font-size: 12px; }
/* room for 4 lines and «Читати повністю», so a short review doesn't move the arrows */
.rs-spot-body { min-height: calc(16px * 1.6 * 4 + 29px); }
.rs-spot-text { font-size: 16px; line-height: 1.6; color: var(--text-main); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.rs-spot-text.is-open { display: block; overflow: visible; }
.rs-spot-more { background: none; border: 0; padding: 0; margin-top: 8px; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.rs-spot-author { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.rs-spot-author .rc-avatar { background: var(--bg-card); }
.rs-spot-name { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: var(--text-main); }
.rs-spot-nav { display: flex; align-items: center; gap: 10px; margin-top: 33px; }
/* the site's round white arrows (as .tv-arrow / the blog rail) */
.rs-spot-arrow {
    width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border-light); background: #fff;
    color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px;
    box-shadow: 0 6px 18px rgba(27, 49, 82, 0.16); cursor: pointer; transition: background 0.2s ease;
}
@media (hover: hover) and (pointer: fine) {
    .rs-spot-arrow:hover { background: var(--accent-soft); }
}
.rs-spot-count { min-width: 52px; text-align: center; font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rs-spot-progress { flex: 1; height: 2px; margin-left: 8px; background: var(--border-light); border-radius: 1px; overflow: hidden; }
.rs-spot-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.rs-spot-progress span.is-running { animation: rs-spot-fill 7s linear forwards; }
.rs-spotlight.is-paused .rs-spot-progress span, .rs-spotlight.is-held .rs-spot-progress span { animation-play-state: paused; }
@keyframes rs-spot-fill { to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
    .rs-spot-progress { visibility: hidden; }
    .rs-spot-slide { transition: none; }
}

.btn-primary {
    background: var(--accent-gold); color: #fff; padding: 16px 40px; font-weight: 500; text-transform: uppercase;
    letter-spacing: 1px; font-size: 13px; border-radius: 4px; transition: 0.3s; cursor: pointer;
    display: inline-block; border: none; outline: none;
}
@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover { background: var(--accent-hover); }
}
.btn-primary:active { transform: scale(0.97); }

.rf-group { display: flex; flex-direction: column; align-items: flex-start; width: 100%; }
.rf-label { color: var(--text-secondary); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; font-weight: 500; }
.rf-input, .rf-textarea {
    width: 100%; background: var(--bg-soft); border: 1px solid var(--border-strong); padding: 15px 20px; color: var(--text-main);
    border-radius: 4px; outline: none; font-size: 15px; font-family: inherit; transition: 0.3s;
}
.rf-textarea { resize: vertical; min-height: 120px; }
.rf-input:focus, .rf-textarea:focus { border-color: var(--accent-gold); background: var(--bg-soft); }
.rf-input--locked { color: var(--accent-gold); border-color: rgba(5, 83, 156, 0.35); cursor: default; }
.rf-input.rf-input--invalid, .rf-textarea.rf-input--invalid { border-color: var(--danger) !important; background: rgba(229, 72, 77, 0.08); }
.rf-input.rf-input--invalid:focus, .rf-textarea.rf-input--invalid:focus { border-color: var(--danger); }

/* #formStars isn't an input — no red box/tint for the missing-rating
   case, just a quick one-at-a-time pop through the stars (see
   bounceRatingStars() in product.js). */
@keyframes rf-star-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.4); }
    65% { transform: scale(0.92); }
    100% { transform: scale(1); }
}
.rf-star-pop { display: inline-block; animation: rf-star-pop 0.32s ease; }

@keyframes rf-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}
.rf-shake { animation: rf-shake 0.5s; }
.rf-hint { font-size: 12px; color: var(--text-secondary); margin-top: 8px; line-height: 1.4; }
.rf-rating-select { display: flex; gap: 12px; cursor: pointer; }
.rf-rating-select i { font-size: 24px; color: var(--border-strong); transition: 0.2s; }
.rf-rating-select i.active { color: var(--warning); }
@media (hover: hover) and (pointer: fine) {
    .rf-rating-select i:hover, .rf-rating-select i:hover ~ i { color: var(--warning); }
}
.rf-submit-wrap { margin-top: 10px; text-align: center; }
.rf-submit-wrap .btn-primary { width: 100%; padding: 16px; font-size: 14px; }

/* ---- Toolbar: results count + sort + grid/list toggle ---- */
.catalog-topbar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 4px; padding: 15px 25px; flex-wrap: wrap; gap: 20px;
}
.catalog-results-count { color: var(--text-secondary); font-size: 13px; }
.catalog-results-count span { color: var(--text-main); font-weight: 500; }
.catalog-controls { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.sort-group { display: flex; align-items: center; gap: 15px; }
.sort-label { color: var(--text-secondary); font-size: 13px; }
.sort-buttons { display: flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; background: var(--bg-soft); }
.sort-btn { background: transparent; border: none; border-right: 1px solid var(--border-strong); color: var(--text-secondary); padding: 8px 15px; font-size: 13px; cursor: pointer; transition: 0.3s; }
.sort-btn:last-child { border-right: none; }
.sort-btn.active { color: var(--accent-gold); background: var(--bg-soft); }
@media (hover: hover) and (pointer: fine) {
    .sort-btn:hover { color: var(--accent-gold); background: var(--bg-soft); }
}
.view-toggles { display: flex; gap: 5px; background: var(--bg-card); padding: 4px; border-radius: 4px; border: 1px solid var(--border-light); }
.view-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); background: transparent; border: none; border-radius: 4px; transition: 0.3s; font-size: 14px; cursor: pointer; }
.view-btn.active { background: var(--bg-soft); color: var(--accent-gold); }
@media (hover: hover) and (pointer: fine) {
    .view-btn:hover { background: var(--bg-soft); color: var(--accent-gold); }
}
.mobile-sort-btn { display: none; background: transparent; border: none; color: var(--accent-gold); font-size: 14px; font-weight: 500; cursor: pointer; align-items: center; gap: 8px; outline: none; }

/* ---- Reviews grid / list ---- */
.reviews-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; transition: opacity 0.3s ease; }
.reviews-grid.fading { opacity: 0; }

.review-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 4px; padding: 30px; transition: 0.3s; display: flex; flex-direction: column; }
@media (hover: hover) and (pointer: fine) {
    .review-card:hover { border-color: var(--border-light); transform: translateY(-5px); }
}
.rc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.rc-user { display: flex; align-items: center; gap: 15px; }
.rc-avatar { width: 45px; height: 45px; background: var(--bg-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 500; color: var(--accent-gold); border: 1px solid var(--border-light); overflow: hidden; flex-shrink: 0; }
.rc-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.rc-user-info { display: flex; flex-direction: column; }
.rc-name { color: var(--text-main); font-weight: 500; font-size: 15px; }
.rc-date { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.rc-stars { color: var(--warning); font-size: 12px; }
.rc-body { display: flex; flex-direction: column; flex-grow: 1; }
.rc-text { color: var(--text-secondary); font-size: 15px; line-height: 1.7; flex-grow: 1; }
.rc-text.collapsed { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.read-more-btn { background: transparent; border: none; color: var(--accent-gold); font-size: 12px; font-weight: 500; cursor: pointer; padding: 5px 0 0 0; text-align: left; transition: 0.3s; display: inline-block; margin-top: 5px; }
@media (hover: hover) and (pointer: fine) {
    .read-more-btn:hover { color: var(--text-main); }
}
.rc-product { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-light); font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.rc-product i { color: var(--accent-green); }

.reviews-grid.list-view { grid-template-columns: 1fr; gap: 0; }
.reviews-grid.list-view .review-card { flex-direction: column; position: relative; padding: 30px 0 30px 75px; gap: 10px; background: transparent; border: none; border-bottom: 1px solid var(--border-light); border-radius: 0; }
.reviews-grid.list-view .review-card:last-child { border-bottom: none; }
@media (hover: hover) and (pointer: fine) {
    .reviews-grid.list-view .review-card:hover { transform: none; border-color: var(--border-light); }
}
.reviews-grid.list-view .rc-header { flex-direction: row; justify-content: flex-start; align-items: center; margin-bottom: 5px; gap: 15px; width: 100%; }
.reviews-grid.list-view .rc-user { gap: 0; }
.reviews-grid.list-view .rc-avatar { position: absolute; left: 0; top: 30px; width: 50px; height: 50px; }
.reviews-grid.list-view .rc-user-info { flex-direction: row; align-items: baseline; gap: 12px; }
.reviews-grid.list-view .rc-name { font-size: 16px; }
.reviews-grid.list-view .rc-date { font-size: 13px; margin-top: 0; }
.reviews-grid.list-view .rc-stars { margin-left: 5px; }
.reviews-grid.list-view .rc-body { flex-grow: 1; }
.reviews-grid.list-view .rc-product { border-top: none; padding-top: 10px; margin-top: 10px; }

/* ---- Pagination ---- */
.pagination-wrapper { display: flex; justify-content: center; margin-top: 40px; margin-bottom: 20px; }

/* Inline "write a review" section - reuses js/pages/product.js's own
   .pr-review-form component (see css/product.css) instead of the old
   modal popup or a toggle button. Sits right in .reviews-summary,
   beside the rating metric - no card/background of its own. */
.pr-reviews-write-section { flex: 1; min-width: 0; max-width: 640px; }
.pr-reviews-write-section .pr-review-form { margin-bottom: 0; }
.pagination {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: 4px; padding: 6px; overflow: visible;
}
.page-btn {
    background: transparent; border: none; border-radius: 4px; color: var(--text-secondary);
    width: 38px; height: 38px; padding: 0; font-size: 14px; font-family: inherit;
    cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;
    position: relative;
}
.page-btn:has(.page-text) { width: auto; padding: 0 14px; }
@media (hover: hover) and (pointer: fine) {
    .page-btn:hover:not(.disabled):not(.dots):not(.active) { color: var(--text-main); background: var(--bg-soft); }
}
.page-btn.active { color: var(--accent-gold); font-weight: 500; background: transparent; }
.page-btn.active::after {
    content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
    width: 16px; height: 2px; background: var(--accent-gold); border-radius: 2px;
}
.page-btn.disabled { color: var(--border-strong); cursor: not-allowed; }
.page-btn.dots { cursor: default; pointer-events: none; color: var(--text-muted); width: auto; padding: 0 4px; }

/* ---- Mobile sort bottom sheet ---- */
/* Апдейт 113: backdrop fade timing matched to the cart's (0.3s -> 0.5s
   ease) — see the matching comment on catalog.css's copy of this block.
   The sheet's own slide-up keeps its 0.3s cubic-bezier. */
/* Апдейт 119: darkness matched to .cart-overlay (0.7, was 0.8), and the
   -webkit- prefix (missing here, present on the catalog.css copy of this
   same overlay) added for Safari — see the longer explanation in
   css/overlays.css. */
.mobile-sort-overlay {
    position: fixed; inset: 0; background: rgba(27, 49, 82, 0.45); -webkit-backdrop-filter: var(--blur-overlay); backdrop-filter: var(--blur-overlay);
    z-index: 7000; display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; visibility: hidden; pointer-events: none; transition: 0.5s ease;
    touch-action: none; overscroll-behavior: none;
}
.mobile-sort-overlay.active { opacity: 1; visibility: visible; pointer-events: all; }
.mobile-sort-sheet {
    width: 100%; background: var(--bg-card); border-radius: 16px 16px 0 0; transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); padding-bottom: 20px; border-top: 1px solid var(--border-light);
}
.mobile-sort-overlay.active .mobile-sort-sheet { transform: translateY(0); }
.ms-header { text-align: center; color: var(--text-main); font-size: 16px; font-weight: 500; padding: 20px; border-bottom: 1px solid var(--border-light); }
.ms-option { width: 100%; text-align: left; background: transparent; border: none; padding: 20px 25px; color: var(--text-main); font-size: 15px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: 0.2s; }
.ms-option:active { background: var(--bg-soft); }
.ms-option.active { color: var(--accent-gold); }
.ms-option.active::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; }

@media (max-width: 1024px) {
    .reviews-grid { grid-template-columns: repeat(2, 1fr); }
    .reviews-grid.list-view .review-card { padding: 25px 0 25px 65px; }
    .reviews-grid.list-view .rc-avatar { left: 0; top: 25px; width: 45px; height: 45px; }
}

@media (max-width: 600px) {

    .reviews-summary { flex-direction: column; align-items: stretch; gap: 25px; }
    .rs-left { flex-direction: column; align-items: flex-start; gap: 25px; width: 100%; }
    .pr-reviews-write-section { max-width: none; }

    .reviews-grid { grid-template-columns: 1fr; gap: 0; }
    .review-card { background: transparent; border: none; border-bottom: 1px solid var(--border-light); border-radius: 0; padding: 25px 0; }
    .review-card:last-child { border-bottom: none; }
    @media (hover: hover) and (pointer: fine) {
        .review-card:hover { transform: none; border-color: var(--border-light); }
    }

    .reviews-grid.list-view .review-card { padding: 25px 0 25px 60px; }
    .reviews-grid.list-view .rc-avatar { left: 0; top: 25px; width: 45px; height: 45px; }
    .reviews-grid.list-view .rc-header { flex-wrap: wrap; gap: 8px; }

    .catalog-topbar { flex-direction: row; align-items: center; justify-content: space-between; }
    .catalog-controls { display: none !important; }
    .mobile-sort-btn { display: flex; }

    .pagination { flex-wrap: nowrap; justify-content: center; padding: 6px; gap: 2px; }
    .page-btn { width: 34px; height: 34px; font-size: 13px; margin-bottom: 0; }
    .page-btn:has(.page-text) { padding: 0 12px; }
    .page-text { display: none; }
}
