/* ==========================================================================
   Test Results Cards
   Modern card layout for {results} token in tyre test articles
   ========================================================================== */

/* --- Container --- */
.test-results {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- Card --- */
.test-card {
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background-color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.1),
                0 10px 20px -2px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    padding: 0;
}

.test-card--reference {
    border: 2px dashed #ffc107;
}

/* --- Header (dark, matching tyre page hero callout) --- */
.test-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background-color: #1e293b;
    color: #f8fafc;
}

.test-card__position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 4px 12px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    color: #94a3b8;
    background: #334155;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.test-card__position sup {
    font-size: 0.65em;
    vertical-align: super;
    line-height: 0;
    margin-left: -1px;
}

.test-card__position--gold {
    background: #f59e0b;
    color: #fff;
}

.test-card__position--silver {
    background: #94a3b8;
    color: #fff;
}

.test-card__position--bronze {
    background: #b45309;
    color: #fff;
}

.test-card__position--reference {
    background: rgba(255, 193, 7, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(255, 193, 7, 0.3);
    font-size: 0.78rem;
}

.test-card__position svg {
    width: 0.9em;
    height: 0.9em;
    flex-shrink: 0;
}

/* Title: target via parent because article TOC strips class from h2 */
.test-card__header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    line-height: 1.3;
}

.test-card__header h2 a,
.test-card__header h2 a:link,
.test-card__header h2 a:visited,
.test-card__header h2 a:active {
    color: #f8fafc;
    text-decoration: none;
}

.test-card__header h2 a:hover {
    color: var(--tyre-reviews-blue, #0db1e7);
    text-decoration: none;
}

.test-card__size {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Body --- */
.test-card__body {
    display: flex;
    padding: 20px;
    gap: 24px;
}

/* --- Sidebar --- */
.test-card__sidebar {
    flex-shrink: 0;
    width: 140px;
}

.test-card__image {
    text-align: center;
    margin-bottom: 12px;
}

.test-card__image img {
    max-width: 100px;
    height: auto;
}

.test-card__details {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    color: #475569;
}

.test-card__details li {
    padding: 3px 0;
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.4;
}

.test-card__details li:last-child {
    border-bottom: none;
}

.test-card__detail-label {
    font-weight: 600;
    color: #334155;
}

/* --- Content --- */
.test-card__content {
    flex: 1;
    min-width: 0;
}

/* --- Feedback (text breakdowns) --- */
.test-card__feedback {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.test-card__feedback-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.test-card__feedback-item--positive {
    background: #f0fdf4;
    border-left: 4px solid #16a34a;
    color: #15803d;
}

.test-card__feedback-item--negative {
    background: #fdf2f8;
    border-left: 4px solid #ec4899;
    color: #be185d;
}

.test-card__feedback-item--overall {
    background: #f8fafc;
    border-left: 4px solid #64748b;
    color: #475569;
}

.test-card__feedback-item--other {
    background: #f8fafc;
    border-left: 4px solid #94a3b8;
    color: #475569;
}

.test-card__feedback-icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* --- Scores (Data mode - Accordion) --- */
.test-card__scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.test-card__category {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
}

.test-card__category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(to right, #f1f5f9, #e8ecf1);
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background-color 0.15s;
}

.test-card__category-header:hover {
    background: linear-gradient(to right, #e8ecf1, #e2e8f0);
}

.test-card__category-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    min-width: 80px;
    flex-shrink: 0;
}

.test-card__category-bar {
    flex: 1;
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.test-card__category-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

/* Animation initial state */
.test-card__category-bar-fill--animate {
    width: 0 !important;
}

/* Rating colors - higher thresholds for test data (clusters near 100%) */
.test-card__category-bar-fill--excellent {
    background: linear-gradient(90deg, #16a34a, #22c55e);
    box-shadow: 0 1px 2px rgba(22, 163, 74, 0.3);
}

.test-card__category-bar-fill--good {
    background: linear-gradient(90deg, #ca8a04, #eab308);
    box-shadow: 0 1px 2px rgba(202, 138, 4, 0.3);
}

.test-card__category-bar-fill--poor {
    background: linear-gradient(90deg, #dc2626, #ef4444);
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.3);
}

.test-card__category-value {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 42px;
    text-align: right;
    flex-shrink: 0;
}

.test-card__category-value--excellent { color: #16a34a; }
.test-card__category-value--good { color: #ca8a04; }
.test-card__category-value--poor { color: #dc2626; }

.test-card__category-chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: #94a3b8;
}

.test-card__category.open .test-card__category-chevron {
    transform: rotate(180deg);
}

/* --- Category breakdown table --- */
.test-card__category-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.test-card__category.open .test-card__category-body {
    max-height: 500px;
}

.test-card__breakdown {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.test-card__breakdown th {
    background: #334155;
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.test-card__breakdown td {
    padding: 6px 10px;
    border-top: 1px solid #f1f5f9;
    color: #334155;
}

.test-card__breakdown tr:first-child td {
    border-top: none;
}

.test-card__breakdown-rank {
    font-weight: 700;
}

.test-card__breakdown-first {
    color: #16a34a;
    font-weight: 700;
}

.test-card__breakdown-pct {
    font-style: italic;
    color: #64748b;
}

/* --- Scores (Magazine mode - Grid) --- */
.test-card__scores-magazine {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.test-card__score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.85rem;
}

.test-card__score-name {
    color: #475569;
}

.test-card__score-value {
    font-weight: 700;
    color: #1e293b;
}

.test-card__total-score {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #0db1e7, #0a9bcc);
    color: #fff;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
}

/* --- Award --- */
.test-card__award {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.test-card__award .svg-badge-object {
    max-width: 350px;
}

/* --- Footer (matching tyre-header-stats bar) --- */
.test-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(to right, #f1f5f9, #e2e8f0);
    border-top: 2px solid #cbd5e1;
}

.test-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.test-card__btn--primary,
.test-card__btn--primary:link,
.test-card__btn--primary:visited {
    background: var(--tyre-reviews-blue, #0db1e7);
    color: #fff;
}

.test-card__btn--primary:hover {
    background: var(--tyre-reviews-blue-dark, #0a9bcc);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(13, 177, 231, 0.3);
}

.test-card__btn--buy,
.test-card__btn--buy:link,
.test-card__btn--buy:visited {
    background: #16a34a;
    color: #fff;
}

.test-card__btn--buy:hover {
    background: #15803d;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.3);
}

.test-card__btn--outline,
.test-card__btn--outline:link,
.test-card__btn--outline:visited {
    background: #fff;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.test-card__btn--outline:hover {
    background: #f8fafc;
    color: #1e293b;
    text-decoration: none;
}

.test-card__btn--dark,
.test-card__btn--dark:link,
.test-card__btn--dark:visited {
    background: #1e293b;
    color: #f8fafc;
    border-left: 3px solid var(--tyre-reviews-blue, #0db1e7);
}

.test-card__btn--dark:hover {
    background: #334155;
    color: #f8fafc;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.3);
}

.test-card__btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==========================================================================
   Responsive - Mobile (<=768px)
   ========================================================================== */
@media (max-width: 768px) {
    .test-card__header {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 8px;
    }

    .test-card__header h2 {
        font-size: 1.1rem;
        order: 1;
        flex-basis: calc(100% - 80px);
    }

    .test-card__position {
        order: 0;
    }

    .test-card__size {
        order: 2;
        margin-left: 0;
        font-size: 0.8rem;
        color: #94a3b8;
    }

    .test-card__body {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    .test-card__sidebar {
        width: 100%;
        display: flex;
        align-items: flex-start;
        gap: 16px;
    }

    .test-card__image {
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .test-card__image img {
        max-width: 80px;
    }

    .test-card__details {
        flex: 1;
    }

    .test-card__category-name {
        min-width: 60px;
        font-size: 0.82rem;
    }

    /* Hide Best/Diff columns in breakdown table on mobile */
    .test-card__breakdown .d-hide-mobile {
        display: none;
    }

    .test-card__scores-magazine {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .test-card__footer {
        padding: 10px 16px;
        gap: 6px;
    }

    .test-card__btn {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .test-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .test-card__category-body {
        max-height: none !important;
        overflow: visible;
    }

    .test-card__category-bar-fill {
        transition: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .test-card__footer {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
