/* /css/ratings.css */
:root {
    --bg: #0c0c0e;
    --bg-card: #141417;
    --bg-raised: #1a1a1f;
    --bg-hover: #1f1f26;
    --border: rgba(255,255,255,0.07);
    --border-light: rgba(255,255,255,0.12);
    --accent: #c8ff3e;
    --accent-dim: rgba(200,255,62,0.12);
    --accent-glow: rgba(200,255,62,0.25);
    --danger: #ff5c5c;
    --danger-dim: rgba(255,92,92,0.12);
    --danger-glow: rgba(255,92,92,0.28);
    --safe: #4dd68c;
    --safe-dim: rgba(77,214,140,0.12);
    --safe-glow: rgba(77,214,140,0.25);
    --text-1: #f2f2f4;
    --text-2: #9898a6;
    --text-3: #5a5a6a;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow-card: 0px 2px 12px rgba(0,0,0,0.5), 0px 1px 3px rgba(0,0,0,0.4);
    --shadow-lift: 0px 16px 48px rgba(0,0,0,0.6), 0px 4px 16px rgba(0,0,0,0.4);
    --transition: 0.22s cubic-bezier(0.4,0,0.2,1);

    /* Ratings module: always dark, thread-style */
    --rating-bg: #0e1113;
    --rating-surface: #15191c;
    --rating-surface-hover: #1c2125;
    --rating-border: #2a3236;
    --rating-line: #343d42;
    --rating-line-hover: #5c6a72;
    --rating-text: #d7dadc;
    --rating-text-strong: #f2f4f5;
    --rating-text-muted: #8b9498;
    --rating-star: #ffb000;
    --rating-star-off: #3a4349;
    --rating-primary: #ff5a1f;
    --rating-primary-hover: #ff7340;
    --rating-link: #6aa8ff;
    --rating-danger: #ff6b6b;
    --rating-font: system-ui, -apple-system, "Segoe UI", Roboto, Inter,
        "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Panels ---------- */
.track-rating,
.track-ratings {
    box-sizing: border-box;
    font-family: var(--rating-font);
    font-size: 14px;
    line-height: 21px;
    color: var(--rating-text);
    background: var(--rating-bg);
    border: 1px solid var(--rating-border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    color-scheme: dark;
}

.track-rating *,
.track-ratings * {
    box-sizing: border-box;
}

.track-ratings {
    display: flex;
    flex-direction: column;
}

/* ---------- Composer ---------- */
.rating-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rating-form-title {
    margin: 0;
    font-size: 16px;
    line-height: 22px;
    font-weight: 600;
    color: var(--rating-text-strong);
}

.star-input {
    display: flex;
    align-items: center;
    gap: 2px;
    width: fit-content;
    max-width: 100%;
    margin-left: -6px;
}

.star {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 4px 6px;
    font: inherit;
    font-size: 26px;
    line-height: 1;
    color: var(--rating-star-off);
    cursor: pointer;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}

.star.filled {
    color: var(--rating-star);
}

.star:focus-visible {
    outline: 2px solid var(--rating-link);
    outline-offset: 1px;
}

.rating-form-comment {
    display: block;
    width: 100%;
    min-height: 88px;
    font: inherit;
    color: var(--rating-text-strong);
    background: var(--rating-bg);
    border: 1px solid var(--rating-border);
    border-radius: 8px;
    padding: 10px 12px;
    resize: vertical;
}

.rating-form-comment:hover {
    border-color: var(--rating-line-hover);
}

.rating-form-comment:focus {
    outline: none;
    border-color: var(--rating-text-strong);
}

.rating-form-comment::placeholder {
    color: var(--rating-text-muted);
}

.rating-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.rating-form-status {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--rating-text-muted);
}

.rating-form-status.error {
    color: var(--rating-danger);
}

.rating-form-submit {
    flex: 0 0 auto;
    appearance: none;
    border: 0;
    background: var(--rating-primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    line-height: 20px;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
}

.rating-form-submit:hover:not(:disabled) {
    background: var(--rating-primary-hover);
}

.rating-form-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.rating-form-submit:focus-visible,
.ratings-load-more:focus-visible,
.rating-toggle:focus-visible,
.rating-thread:focus-visible {
    outline: 2px solid var(--rating-link);
    outline-offset: 2px;
}

/* ---------- Thread ---------- */
.rating {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 12px 0;
}

.rating + .rating {
    border-top: 1px solid var(--rating-border);
}

.rating-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 28px;
    width: 28px;
}

.rating-user-avatar {
    display: block;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--rating-surface);
}

/* Reddit-style thread line: wide click target, thin visible line */
.rating-thread {
    appearance: none;
    position: relative;
    flex: 1 1 auto;
    width: 28px;
    min-height: 12px;
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.rating-thread::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    border-radius: 1px;
    background: var(--rating-line);
}

.rating-thread:hover::after {
    background: var(--rating-line-hover);
}

.rating-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rating-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
}

.rating-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 6px;
    min-width: 0;
    font-size: 12px;
    line-height: 18px;
    color: var(--rating-text-muted);
}

.rating-user-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--rating-text-strong);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rating-time {
    white-space: nowrap;
}

.rating-toggle {
    appearance: none;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--rating-text-muted);
    font: inherit;
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.rating-toggle:hover {
    background: var(--rating-surface-hover);
    color: var(--rating-text-strong);
}

.user-rating {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.rating-stars {
    display: flex;
    gap: 2px;
    font-size: 15px;
    line-height: 1;
}

.rating-stars .star {
    padding: 0;
    font-size: inherit;
    cursor: default;
    color: var(--rating-star-off);
}

.rating-stars .star.filled {
    color: var(--rating-star);
}

.user-rating-comment {
    margin: 0;
    max-width: 100%;
    font-size: 14px;
    line-height: 21px;
    color: var(--rating-text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Collapsed rating: header only */
.rating.collapsed {
    padding: 8px 0;
}

.rating.collapsed .user-rating,
.rating.collapsed .rating-thread {
    display: none;
}

.ratings-empty {
    margin: 0;
    padding: 20px 0;
    text-align: center;
    font-size: 14px;
    color: var(--rating-text-muted);
}

/* ---------- Load more ---------- */
.ratings-load-more-wrap {
    display: flex;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid var(--rating-border);
}

.rating + .ratings-load-more-wrap {
    margin-top: 0;
}

.ratings-load-more {
    appearance: none;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    line-height: 20px;
    color: var(--rating-text-strong);
    background: transparent;
    border: 1px solid var(--rating-line-hover);
    border-radius: 999px;
    padding: 7px 18px;
    cursor: pointer;
}

.ratings-load-more:hover:not(:disabled) {
    background: var(--rating-surface-hover);
}

.ratings-load-more:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .track-rating,
    .track-ratings {
        padding: 10px 12px;
        border-radius: 6px;
    }

    .rating {
        gap: 8px;
    }

    .rating-rail,
    .rating-thread {
        flex-basis: 24px;
        width: 24px;
    }

    .rating-user-avatar {
        width: 24px;
        height: 24px;
    }

    .rating-header {
        min-height: 24px;
    }

    .star {
        font-size: 28px;
        padding: 4px 7px;
    }

    .rating-stars .star {
        padding: 0;
        font-size: inherit;
    }

    .rating-form-comment {
        font-size: 16px; /* stops iOS zoom-on-focus */
    }

    .ratings-load-more {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .rating-form-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .rating-form-submit {
        width: 100%;
    }
}

