/* ===========================================================
   BlindTest — historique, statistiques et fenêtre de détail
   Uniquement les tokens et composants du design system partagé.
   =========================================================== */

.bt-page {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vw, 20px);
    max-width: 960px;
    margin: 0 auto;
}
.bt-page .bt-auth__title { margin: 0; }
.bt-page .bt-play__status { margin: 0; }

/* ------------------- Statistiques du reveal ------------------- */

.bt-reveal-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 10px 12px;
    border: 1px solid var(--md-outline-soft);
    border-radius: var(--radius-sm);
    background: var(--md-surface-1);
}
.bt-reveal-stats[hidden] { display: none; }

.bt-reveal-stats__icon { color: var(--md-primary); }

.bt-reveal-stats__lines {
    display: flex;
    flex: 1 1 220px;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bt-reveal-stats__line {
    margin: 0;
    color: var(--md-on-surface-variant);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.bt-reveal-stats__line:first-child { color: var(--md-on-surface); }

/* ------------------- Fenêtre de détail ------------------- */

.bt-dialog {
    width: min(760px, calc(100% - 32px));
    max-height: min(88vh, 900px);
    padding: 0;
    border: 1px solid var(--md-outline-soft);
    border-radius: var(--radius-md);
    background: var(--md-surface-2);
    color: var(--md-on-surface);
    box-shadow: var(--shadow-lg);
}
.bt-dialog::backdrop {
    background: color-mix(in srgb, var(--md-background) 72%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.bt-dialog[open] { animation: bt-dialog-in var(--duration-medium) var(--ease-emphasized-decel); }

@keyframes bt-dialog-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.bt-dialog__panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: clamp(16px, 3vw, 24px);
}

.bt-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.bt-dialog__head .bt-section__title { margin: 0; }

.bt-dialog__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.bt-dialog__body[hidden] { display: none; }

.bt-stats-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(12px, 2vw, 20px);
    align-items: start;
}

.bt-stats-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.bt-stats-block__title {
    margin: 0;
    color: var(--md-primary);
    font-size: 15px;
    font-weight: 800;
}

.bt-stats-block__content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ------------------- Tableaux de répartition ------------------- */

.bt-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.bt-stats-table__caption {
    padding: 0 0 6px;
    color: var(--md-on-surface-variant);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}

.bt-stats-table th,
.bt-stats-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--md-outline-soft);
    text-align: left;
    vertical-align: middle;
}
.bt-stats-table thead th {
    color: var(--md-on-surface-muted);
    font-size: 12px;
    font-weight: 600;
}
.bt-stats-table tbody th {
    font-weight: 600;
    overflow-wrap: anywhere;
}
.bt-stats-table tr:last-child > * { border-bottom: 0; }

.bt-stats-table__count { white-space: nowrap; }

.bt-rate {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
}

.bt-rate__value {
    min-width: 42px;
    font-weight: 700;
    white-space: nowrap;
}

.bt-meter {
    position: relative;
    flex: 1;
    height: 6px;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--md-surface-3);
}

.bt-meter__fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--md-primary), var(--accent-magenta));
    transition: width var(--duration-medium) var(--ease-emphasized);
}

.bt-stats-kpi__rate {
    color: var(--md-primary);
    font-size: 15px;
}

/* ------------------- Historique ------------------- */

.bt-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.bt-history[hidden] { display: none; }

.bt-history__link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--duration-short) var(--ease-emphasized);
}
.bt-history__link:hover { background: var(--md-surface-2); }

.bt-history__main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.bt-history__date {
    margin: 0;
    font-weight: 800;
}

.bt-history__summary {
    margin: 0;
    color: var(--md-on-surface-variant);
    font-size: 14px;
}

.bt-history__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
}

.bt-history__item[data-status="abandoned"] .bt-history__status {
    border-color: color-mix(in srgb, var(--md-error) 45%, transparent);
    color: var(--md-error);
}

.bt-history__score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    text-align: right;
}

.bt-history__points {
    color: var(--md-primary);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bt-history__rounds,
.bt-history__rank {
    color: var(--md-on-surface-muted);
    font-size: 13px;
}

.bt-history__chevron { color: var(--md-on-surface-muted); }

.bt-history__more {
    display: flex;
    justify-content: center;
}

.bt-history__back { margin: 0; }
.bt-history__back .btn { padding-left: 4px; }

.bt-history-detail {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vw, 20px);
}
.bt-history-detail[hidden] { display: none; }
.bt-history-detail .bt-facts { margin: 0; }

.bt-history-round { align-items: start; }

.bt-history-round__meta {
    margin: 2px 0 0;
    color: var(--md-on-surface-muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.bt-history-round__answers { margin-top: 10px; }

.bt-history-round__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .bt-dialog[open] { animation: none; }
    .bt-meter__fill,
    .bt-history__link { transition: none; }
}

@media (max-width: 640px) {
    .bt-stats-columns { grid-template-columns: minmax(0, 1fr); }
    .bt-history__link { grid-template-columns: minmax(0, 1fr) auto; }
    .bt-history__chevron { display: none; }
    .bt-history-round { grid-template-columns: auto minmax(0, 1fr); }
    .bt-history-round__side {
        grid-column: 2;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .bt-rate { min-width: 80px; }
}
