/* Страница «Рейтинг» */
.rating-section {
    /* Верхний отступ равен отступу до линии футера (2rem), чтобы воздух
       над первой карточкой и под последней был одинаковым. */
    padding-top: 2rem;
    padding-bottom: 0;
}

.rating-section > .text-content-block {
    margin-bottom: 1.5rem;
}

/* В свёрнутом виде показываем только первый абзац: заголовки разделов
   не должны попадать в видимую область при любой длине перевода. */
.rating-section .text-content-block .content-text .intro-lead {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rating-section .text-content-block .content-text .intro-rest {
    display: none;
}

.rating-section .text-content-block .content-text:not(.is-collapsed) .intro-lead {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.rating-section .text-content-block .content-text:not(.is-collapsed) .intro-rest {
    display: block;
}

.rating-section .text-content-toggle {
    display: block;
    width: fit-content;
    margin: 0.6rem 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--accent-primary-glow);
    border-radius: 6px;
    padding: 0.35rem 1.1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.3s;
}

.rating-section .text-content-toggle:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.rating-section .text-content-toggle[hidden] {
    display: none;
}

.rating-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.rating-card {
    scroll-margin-top: 110px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 1.35rem;
    position: relative;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.rating-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.rating-card:target {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35), 0 10px 28px rgba(0, 0, 0, 0.35);
}

.rating-rank {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    height: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0 0.7rem;
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 55%, #f97316 100%);
    color: #1a100a;
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
    font-weight: 900;
    font-size: 1.5rem;
    line-height: 1;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
    border-bottom: 2px solid rgba(120, 50, 0, 0.35);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(120, 50, 0, 0.2);
}

.rating-rank-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    box-sizing: border-box;
    border-radius: 50%;
    background: #140d08;
    border: 2px solid rgba(251, 191, 36, 0.9);
    color: var(--accent-gold);
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.rating-rank-label {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    opacity: 0.85;
}

.rating-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2px;
    background: linear-gradient(135deg, #1f1410 0%, #0f0a08 100%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
    isolation: isolate;
}

.rating-cover::after {
    content: '';
    position: absolute;
    inset: -18px;
    background-image: var(--cover);
    background-size: cover;
    background-position: center;
    filter: blur(18px);
    opacity: 0.55;
    z-index: -1;
}

.rating-cover-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.rating-cover-link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.rating-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rating-title {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.2rem;
}

.rating-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.rating-title a:hover {
    color: var(--accent-primary-glow);
}

.rating-year {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.55rem;
}

.rating-meta-sep {
    color: var(--text-muted);
    margin: 0 0.25rem;
}

.rating-desc {
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.9rem;
}

.rating-desc-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
}

.rating-desc.is-open .rating-desc-text {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.rating-desc-prefix {
    display: block;
}

.rating-desc-lastline {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.rating-desc-last {
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    overflow: hidden;
}

.rating-desc.is-open .rating-desc-last {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.rating-panel {
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
}

.rating-overall-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* Сетка как у параметров: вертикальная черта попадает на то же место */
.rating-overall-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
    align-items: center;
    width: 100%;
}

.rating-overall-row::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--border-hover);
}

.rating-votes {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.35rem;
    white-space: nowrap;
}

.rating-overall-stars {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.05rem;
    padding-left: 0.65rem;
    font-size: 2rem;
    line-height: 1;
}

.rating-overall-star {
    color: rgba(255, 255, 255, 0.18);
    background: linear-gradient(90deg, var(--accent-gold) var(--fill, 0%), rgba(255, 255, 255, 0.18) var(--fill, 0%));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rating-votes::before {
    content: '·';
    margin-right: 0.35rem;
}

.rating-overall {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding-right: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rating-overall-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

.rating-overall-hint[hidden] {
    display: none;
}

.rating-overall-hint.is-done {
    color: var(--accent-gold);
}

.rating-overall-value {
    color: var(--accent-gold);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
}

.rating-overall-max {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.rating-criteria {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, auto);
    grid-auto-flow: column;
    column-gap: 1.5rem;
    row-gap: 0.4rem;
    position: relative;
}

/* Вертикальная разделительная черта между колонками параметров */
.rating-criteria::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--border-hover) 15%, var(--border-hover) 85%, transparent);
}

.rating-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

.rating-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

/* Маркер: ○ — параметр ещё не оценён, ✓ — оценён */
.rating-label::before {
    content: '○';
    color: var(--text-muted);
    font-size: 0.85em;
    line-height: 1;
}

.rating-row.is-rated .rating-label {
    color: var(--text-primary);
}

.rating-row.is-rated .rating-label::before {
    content: '✓';
    color: var(--accent-gold);
    font-weight: 700;
}

.rating-stars-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.rating-avg {
    min-width: 2.2em;
    text-align: right;
    color: var(--accent-gold);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    line-height: 1;
}

.rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
}

.rating-star {
    border: 0;
    background: none;
    padding: 0 0.05rem;
    margin: 0;
    line-height: 1;
    font-size: 1.02rem;
    color: rgba(255, 255, 255, 0.22);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.15s ease;
}

.rating-star:hover {
    transform: scale(1.15);
}

.rating-star.active,
.rating-star.hover {
    color: var(--accent-gold);
}

/* При наведении показываем предполагаемую оценку, а не только сохранённую */
.rating-row.previewing .rating-star.active:not(.hover) {
    color: rgba(255, 255, 255, 0.22);
}

.rating-star:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* После учёта голоса звёзды заблокированы (защита от повторной накрутки) */
.rating-card.is-locked .rating-star {
    cursor: default;
}

.rating-card.is-locked .rating-star:hover {
    transform: none;
}

.rating-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.25rem;
}

.rating-share {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.rating-share-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.rating-share .share-btn {
    width: 32px;
    height: 32px;
}

.rating-share .share-btn svg {
    width: 15px;
    height: 15px;
}

.rating-buy {
    width: auto;
    min-width: 200px;
    justify-content: center;
}

.rating-actions .rating-buy--alt {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid var(--border-hover);
    color: var(--accent-gold);
}

.rating-actions .rating-buy--alt:hover {
    background: rgba(251, 191, 36, 0.16);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

/* Сортировка над списком */
#rating-sort {
    scroll-margin-top: 100px;
}

.rating-sort {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    /* Сверху отступ задаёт text-content-block (1.5rem); снизу — такой же,
       чтобы блок сортировки стоял по центру между текстом и карточками. */
    margin: 0 0 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rating-sort-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sort-switch {
    position: relative;
    display: inline-flex;
}

.rating-sort-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 11rem;
    max-width: min(70vw, 22rem);
    padding: 0.5rem 0.8rem;
    background: rgba(25, 18, 12, 0.88);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    list-style: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.rating-sort-toggle::-webkit-details-marker {
    display: none;
}

.rating-sort-toggle::marker {
    content: '';
}

.rating-sort-toggle:hover {
    border-color: var(--border-hover);
}

.sort-switch[open] .rating-sort-toggle,
.rating-sort-toggle:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.18);
}

.rating-sort-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rating-sort-chevron {
    flex: none;
    width: 0.45rem;
    height: 0.45rem;
    margin-inline-start: auto;
    border-right: 1.5px solid var(--accent-gold);
    border-bottom: 1.5px solid var(--accent-gold);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.sort-switch[open] .rating-sort-chevron {
    transform: rotate(225deg);
}

.sort-menu {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 180px;
    max-width: min(90vw, 22rem);
}

.sort-switch[open] .sort-menu {
    display: block;
}

.sort-menu-link {
    display: block;
    width: 100%;
    text-align: start;
    white-space: normal;
    overflow-wrap: anywhere;
    background: none;
    border: 0;
    font-family: inherit;
    cursor: pointer;
}

html[dir="rtl"] .sort-menu {
    left: auto;
    right: 0;
}

@media (max-width: 1340px) {
    .rating-criteria {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-flow: row;
    }
    /* В одну колонку место есть — увеличиваем область нажатия звёзд */
    .rating-star {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 24px;
        min-height: 24px;
        padding: 0;
    }
    .rating-criteria::before {
        display: none;
    }
    .rating-overall-row {
        grid-template-columns: 1fr;
    }
    .rating-overall-row::after {
        display: none;
    }
    .rating-overall {
        justify-content: center;
        padding-right: 0;
    }
    .rating-overall-stars {
        justify-content: center;
        padding-left: 0;
        font-size: 1.7rem;
    }
}

@media (max-width: 520px) {
    .rating-overall-stars {
        font-size: 1.5rem;
    }
}

@media (max-width: 950px) {
    /* Узкие экраны: подпись и звёзды в две строки, чтобы ряды не прыгали */
    .rating-row {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 0.35rem;
    }
    .rating-stars-wrap {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 1100px) {
    .rating-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .rating-share {
        justify-content: center;
    }
    .rating-buy {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .rating-card {
        grid-template-columns: 180px minmax(0, 1fr);
        gap: 1rem;
        padding: 1rem;
    }
    .rating-panel {
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }
    .rating-buy {
        width: 100%;
        min-width: 0;
    }

    .rating-stars {
        gap: 0;
    }
    .rating-stars-wrap {
        gap: 0.3rem;
    }
    .rating-avg {
        min-width: 2em;
    }
    .rating-star {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 24px;
        min-height: 32px;
        padding: 0.2rem 0.06rem;
        font-size: 1.2rem;
    }
}

@media (max-width: 520px) {
    .rating-share-label {
        flex-basis: 100%;
        text-align: center;
    }
    .rating-media {
        position: static;
        top: auto;
    }
    .rating-shots {
        align-self: center;
        width: 100%;
        max-width: 260px;
        margin: 0.55rem auto 0;
    }
    .rating-actions {
        flex-direction: column;
    }
    .rating-card {
        grid-template-columns: 1fr;
    }
    .rating-cover {
        max-width: 260px;
        margin: 0 auto;
    }

    .rating-rank {
        height: 2.3rem;
        font-size: 1.3rem;
    }
}

.rating-empty {
    margin: 1.5rem auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Раскрывающийся список: пункты вставляются перед ссылкой, ссылка уезжает вниз */
.rating-more-toggle {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--accent-primary-glow);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.rating-more-toggle[hidden] {
    display: none;
}

.rating-more-toggle:hover {
    border-color: var(--border-hover);
    background: rgba(249, 115, 22, 0.08);
    color: var(--text-primary);
}

/* Скриншоты под обложкой — в ряд */
.rating-media {
    display: flex;
    flex-direction: column;
    align-self: start;
    position: sticky;
    top: 90px;
    min-width: 0;
}

.rating-shots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    margin: 0.55rem 0 0;
}

.rating-shot {
    display: block;
    min-width: 48px;
    min-height: 48px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(251, 191, 36, 0.08);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
    transition: border-color 0.25s, box-shadow 0.25s;
}

.rating-shot:hover {
    border-color: var(--border-hover);
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.2);
}

.rating-shot img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 3px;
    transition: transform 0.3s;
}

.rating-shot:hover img {
    transform: scale(1.04);
}

/* Просмотр скриншота крупно */
.rating-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.9);
}

.rating-lightbox.open {
    display: flex;
}

.rating-lightbox img {
    max-width: min(1200px, 92vw);
    max-height: 86vh;
    width: auto;
    height: auto;
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.rating-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-hover);
    border-radius: 50%;
    background: rgba(25, 18, 12, 0.9);
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.rating-lightbox-prev,
.rating-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border: 1px solid var(--border-hover);
    border-radius: 50%;
    background: rgba(25, 18, 12, 0.9);
    color: var(--text-primary);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.rating-lightbox-prev {
    left: 1rem;
}

.rating-lightbox-next {
    right: 1rem;
}

.rating-lightbox-prev:hover,
.rating-lightbox-next:hover,
.rating-lightbox-close:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.rating-lightbox-counter {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

body.rating-lightbox-open {
    overflow: hidden;
}

.rating-lightbox.single .rating-lightbox-prev,
.rating-lightbox.single .rating-lightbox-next,
.rating-lightbox.single .rating-lightbox-counter {
    display: none;
}

@media (max-width: 600px) {
    .rating-lightbox {
        padding: 1rem;
    }
    .rating-lightbox-prev,
    .rating-lightbox-next {
        width: 38px;
        height: 38px;
        font-size: 1.5rem;
    }
    .rating-lightbox-prev {
        left: 0.4rem;
    }
    .rating-lightbox-next {
        right: 0.4rem;
    }
}

@media (max-width: 520px) {
    /* В одноколоночной карточке липкая обложка не нужна */
    .rating-card .rating-media {
        position: static;
        top: auto;
        align-self: stretch;
    }
}

/* В RTL-языках сами звёзды и шкала остаются слева направо */
html[dir="rtl"] .rating-stars,
html[dir="rtl"] .rating-overall-stars {
    direction: ltr;
}
