/* =============================================================================
   Tyre Score Badge & Modal Styles
   ============================================================================= */

:root {
    --score-excellent: #28a745;
    --score-good: #0db1e7;
    --score-average: #fd7e14;
    --score-poor: #dc3545;
    --perf-excellent: #28a745;
    --perf-strong: #0db1e7;
    --perf-good: #17a2b8;
    --perf-average: #fd7e14;
    --perf-below-average: #dc3545;
}

/* =============================================================================
   Score Bar (horizontal, inside .tyre-header-info)
   ============================================================================= */

.tyre-score-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.tyre-score-bar:hover {
    background: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tyre-score-bar:focus {
    outline: 2px solid var(--score-good);
    outline-offset: 2px;
}

/* Score circle — logo with overlaid score */
.tyre-score-bar-circle {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tyre-score-bar-logo {
    width: 100%;
    height: 100%;
    display: block;
}

.tyre-score-bar-value {
    position: absolute;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.tyre-score-bar-max {
    position: absolute;
    font-size: 0.55rem;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    bottom: 10px;
}

/* Info text block */
.tyre-score-bar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.tyre-score-bar-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #333;
}

.tyre-score-bar-source {
    font-size: 0.72rem;
    color: #777;
}

/* Right side: confidence pill + CTA */
.tyre-score-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.tyre-score-bar-confidence {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tyre-score-confidence-high { background: #d4edda; color: #155724; }
.tyre-score-confidence-medium { background: #fff3cd; color: #856404; }
.tyre-score-confidence-limited { background: #e9ecef; color: #6c757d; }

.tyre-score-bar-cta {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--tyre-reviews-blue, #0db1e7);
    white-space: nowrap;
}

.tyre-score-bar-cta i {
    margin-right: 3px;
}

/* Mobile: shrink circle, hide CTA text */
@media (max-width: 768px) {
    .tyre-score-bar {
        gap: 10px;
        padding: 8px 12px;
    }

    .tyre-score-bar-circle {
        width: 50px;
        height: 50px;
    }

    .tyre-score-bar-value {
        font-size: 1.05rem;
    }

    .tyre-score-bar-max {
        font-size: 0.5rem;
        bottom: 8px;
    }

    .tyre-score-bar-cta {
        display: none;
    }
}

/* =============================================================================
   Modal Overlay & Container
   ============================================================================= */

.tyre-score-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.tyre-score-modal-overlay.show {
    display: flex;
}

.tyre-score-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: scoreModalIn 0.25s ease-out;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

@keyframes scoreModalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =============================================================================
   Modal Header — Image + Tyre Info + Score Circle
   ============================================================================= */

.score-modal-header {
    padding: 24px 24px 20px;
    border-bottom: 1px solid #334155;
    background-color: #1e293b;
    border-radius: 16px 16px 0 0;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.score-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #334155;
    border: 1px solid #475569;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}

.score-modal-close:hover {
    background: #475569;
    color: #ffffff;
}

/* Left: image */
.score-modal-tyre-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 10px;
    background: #ffffff;
    padding: 4px;
    flex-shrink: 0;
}

.score-modal-tyre-img-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #64748b;
    font-size: 1.5rem;
}

/* Centre: tyre name + badges */
.score-modal-tyre-info {
    flex: 1;
    min-width: 0;
    padding-right: 40px; /* space for close button */
}

.score-modal-tyre-name {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #ffffff;
    line-height: 1.3;
}

.score-modal-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.score-modal-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.score-modal-badge-season { background: #e7f5ff; color: #1971c2; }
.score-modal-badge-tier { background: #f3f0ff; color: #6741d9; }

/* Right: score circle */
.score-modal-score-block {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.score-modal-circle {
    position: relative;
    width: 88px;
    height: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-modal-circle-logo {
    width: 100%;
    height: 100%;
    display: block;
}

.score-modal-circle-value {
    position: absolute;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.score-modal-circle-max {
    position: absolute;
    font-size: 0.6rem;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    bottom: 15px;
}

.score-modal-beta-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e7f5ff;
    color: #1971c2;
    white-space: nowrap;
}

/* Score meta below the header */
.score-modal-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    background: #fafbfc;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.78rem;
    color: #666;
}

.score-modal-confidence-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    text-transform: uppercase;
}

.score-modal-confidence-badge.conf-high { background: #d4edda; color: #155724; }
.score-modal-confidence-badge.conf-medium { background: #fff3cd; color: #856404; }
.score-modal-confidence-badge.conf-limited { background: #e9ecef; color: #6c757d; }

.score-modal-meta-sep {
    color: #ddd;
}

/* About / Technical Description */
.score-modal-about {
    margin: 16px 24px 0;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.score-modal-about p {
    font-size: 0.82rem;
    color: #555;
    line-height: 1.6;
    margin: 0 0 8px;
}

.score-modal-about-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--tyre-reviews-blue, #0db1e7);
    text-decoration: none;
}

.score-modal-about-link:hover {
    text-decoration: underline;
}

.score-modal-about-link i {
    font-size: 0.68rem;
    margin-left: 3px;
}

/* Section description text */
.score-modal-section-desc {
    font-size: 0.78rem;
    color: #888;
    line-height: 1.5;
    margin: -4px 0 12px;
}

/* =============================================================================
   Categories
   ============================================================================= */

.score-modal-categories {
    padding: 20px 24px 0;
}

.score-modal-section-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 12px;
}

.score-modal-category {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.score-modal-cat-name {
    width: 80px;
    flex-shrink: 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: #444;
    text-align: right;
}

.score-modal-cat-bar-wrap {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-modal-cat-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.score-modal-cat-bar.perf-excellent { background: var(--perf-excellent); }
.score-modal-cat-bar.perf-strong { background: var(--perf-strong); }
.score-modal-cat-bar.perf-good { background: var(--perf-good); }
.score-modal-cat-bar.perf-average { background: var(--perf-average); }
.score-modal-cat-bar.perf-below-average { background: var(--perf-below-average); }

.score-modal-cat-score {
    width: 40px;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    text-align: right;
}

.score-modal-cat-tests {
    width: 80px;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: #aaa;
    white-space: nowrap;
}

/* =============================================================================
   Collapsible Sections
   ============================================================================= */

.score-modal-section {
    border-top: 1px solid #f0f0f0;
    margin-top: 16px;
}

.score-modal-section:first-of-type {
    margin-top: 20px;
}

.score-modal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.score-modal-section-header:hover {
    background: #fafafa;
}

.score-modal-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.score-modal-section-chevron {
    font-size: 0.75rem;
    color: #bbb;
    transition: transform 0.25s ease;
}

.score-modal-section.open .score-modal-section-chevron {
    transform: rotate(180deg);
}

.score-modal-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.score-modal-section.open .score-modal-section-body {
    max-height: 2000px;
}

.score-modal-section-content {
    padding: 0 24px 20px;
}

/* =============================================================================
   Score Components
   ============================================================================= */

.score-modal-components {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.score-modal-component-card {
    flex: 1;
    min-width: 170px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px;
    border: 1px solid #eee;
}

.score-modal-component-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 2px;
}

.score-modal-component-weight {
    font-size: 0.72rem;
    color: #999;
    margin-bottom: 8px;
}

.score-modal-component-desc {
    font-size: 0.78rem;
    color: #555;
    line-height: 1.45;
    margin-bottom: 8px;
}

.score-modal-component-detail {
    font-size: 0.76rem;
    color: #666;
    line-height: 1.5;
}

.score-modal-component-detail div {
    padding: 1px 0;
}

.score-modal-component-detail strong {
    color: #333;
}

/* =============================================================================
   Data Sources Table
   ============================================================================= */

.score-modal-sources-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.score-modal-sources-table th {
    text-align: left;
    padding: 8px 10px;
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

.score-modal-sources-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    vertical-align: top;
}

.score-modal-sources-table a {
    color: var(--tyre-reviews-blue, #0db1e7);
    text-decoration: none;
}

.score-modal-sources-table a:hover {
    text-decoration: underline;
}

.score-modal-position-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: #e9ecef;
    color: #333;
}

.score-modal-position-badge.pos-top3 {
    background: #d4edda;
    color: #155724;
}

/* =============================================================================
   Methodology
   ============================================================================= */

.score-modal-methodology-summary {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.65;
    margin-bottom: 14px;
}

.score-modal-methodology-subtitle {
    font-size: 0.82rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    margin-top: 16px;
}

.score-modal-methodology-subtitle:first-child {
    margin-top: 0;
}

.score-modal-methodology-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
    counter-reset: steps;
}

.score-modal-methodology-steps li {
    font-size: 0.82rem;
    color: #555;
    padding: 8px 0 8px 36px;
    line-height: 1.5;
    position: relative;
    border-bottom: 1px solid #f5f5f5;
    counter-increment: steps;
}

.score-modal-methodology-steps li:last-child {
    border-bottom: none;
}

.score-modal-methodology-steps li::before {
    content: counter(steps);
    position: absolute;
    left: 0;
    top: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tyre-reviews-blue, #0db1e7);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-modal-methodology-note {
    font-size: 0.82rem;
    color: #666;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 12px 14px;
    border-radius: 8px;
    margin-top: 14px;
    line-height: 1.55;
}

.score-modal-methodology-note i {
    color: #d97706;
}

/* Weight bars */
.score-modal-methodology-weights {
    margin-bottom: 14px;
}

.score-modal-weight-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.score-modal-weight-label {
    width: 100px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: #555;
    text-align: right;
}

.score-modal-weight-bar-wrap {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-modal-weight-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--tyre-reviews-blue, #0db1e7);
    transition: width 0.4s ease;
}

.score-modal-weight-pct {
    width: 36px;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
}

/* Parameters table */
.score-modal-params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 8px;
}

.score-modal-params-table th {
    text-align: left;
    padding: 6px 10px;
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.score-modal-params-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
}

/* =============================================================================
   Methodology Config Table (full parameters)
   ============================================================================= */

.score-modal-config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-top: 8px;
}

.score-modal-config-table th {
    text-align: left;
    padding: 6px 10px;
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e9ecef;
}

.score-modal-config-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    vertical-align: top;
}

.score-modal-config-table code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.74rem;
    color: #333;
    white-space: nowrap;
}

.score-modal-config-desc-col {
    color: #888;
    font-size: 0.74rem;
}

/* =============================================================================
   Loading & Error States
   ============================================================================= */

.score-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.score-modal-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e9ecef;
    border-top-color: var(--tyre-reviews-blue, #0db1e7);
    border-radius: 50%;
    animation: scoreSpinner 0.7s linear infinite;
    margin-bottom: 12px;
}

@keyframes scoreSpinner {
    to { transform: rotate(360deg); }
}

.score-modal-loading-text {
    font-size: 0.85rem;
}

.score-modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.score-modal-error-icon {
    font-size: 2.5rem;
    color: #ddd;
    margin-bottom: 14px;
}

.score-modal-error-message {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 18px;
    max-width: 320px;
}

.score-modal-error-close {
    display: inline-block;
    padding: 8px 24px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: background 0.15s;
}

.score-modal-error-close:hover {
    background: #e0e0e0;
}

/* =============================================================================
   Mobile (<=768px)
   ============================================================================= */

@media (max-width: 768px) {
    .tyre-score-modal-overlay {
        padding: 10px;
    }

    .tyre-score-modal {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    }

    .score-modal-header {
        padding: 16px;
        flex-wrap: wrap;
        border-radius: 12px 12px 0 0;
    }

    .score-modal-tyre-info {
        padding-right: 32px;
    }

    .score-modal-score-block {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-top: 4px;
    }

    .score-modal-meta {
        padding: 8px 16px;
    }

    .score-modal-narrative {
        margin: 16px 16px 0;
    }

    .score-modal-categories {
        padding: 16px 16px 0;
    }

    .score-modal-cat-name {
        width: 60px;
        font-size: 0.75rem;
    }

    .score-modal-section-header {
        padding: 12px 16px;
    }

    .score-modal-section-content {
        padding: 0 16px 16px;
    }

    .score-modal-components {
        flex-direction: column;
    }

    .score-modal-component-card {
        min-width: auto;
    }

    .score-modal-sources-table {
        font-size: 0.72rem;
    }

    .score-modal-weight-label {
        width: 80px;
    }

    .score-modal-config-desc-col {
        display: none;
    }

    .score-modal-config-table {
        font-size: 0.72rem;
    }

    .score-modal-about {
        margin: 12px 16px 0;
        padding: 12px 14px;
    }

    .score-modal-circle {
        width: 72px;
        height: 72px;
    }

    .score-modal-circle-value {
        font-size: 1.5rem;
    }

    .score-modal-circle-max {
        font-size: 0.55rem;
        bottom: 12px;
    }
}

/* =============================================================================
   Alternative Tyres - Inline Score
   ============================================================================= */

.alt-tyre-score-inline {
    display: inline-flex;
    align-items: baseline;
    gap: 1px;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
    margin-top: 2px;
}

.alt-tyre-score-inline-value {
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
}

.alt-tyre-score-inline-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

.alt-tyre-score-inline-excellent {
    background: var(--score-excellent);
}

.alt-tyre-score-inline-good {
    background: var(--score-good);
}

.alt-tyre-score-inline-average {
    background: var(--score-average);
}

.alt-tyre-score-inline-poor {
    background: var(--score-poor);
}
