/* Carte d'identité d'un cheval (clic sur son nom dans un tableau de stats) */
.tpg-hc {
    --hc-ink: #0A1522;
    --hc-navy: #101E33;
    --hc-navy-2: #16283F;
    --hc-gold: #E3C27E;
    --hc-gold-deep: #C4A15A;
    --hc-text: #EDE6D6;
    --hc-dim: rgba(237, 230, 214, .68);
    --hc-line: rgba(196, 161, 90, .22);
    --hc-display: var(--font-display, 'Cormorant Garamond', Georgia, serif);
    --hc-mono: var(--font-mono, 'Space Mono', 'Courier New', monospace);
    position: fixed;
    inset: 0;
    z-index: 100010;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: var(--font-body, 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif);
    color: var(--hc-text);
}
.tpg-hc[hidden] { display: none; }

.tpg-hc__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 11, 19, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .3s ease;
}
.tpg-hc__card {
    position: relative;
    width: min(880px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    padding: 2px;
    background: linear-gradient(135deg, var(--hc-gold), var(--hc-gold-deep) 45%, #6B4F1E);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
    opacity: 0;
    transform: translateY(18px) scale(.965);
    transition: opacity .32s ease, transform .42s cubic-bezier(.2, .8, .2, 1);
    scrollbar-width: thin;
}
.tpg-hc.is-open .tpg-hc__backdrop { opacity: 1; }
.tpg-hc.is-open .tpg-hc__card { opacity: 1; transform: none; }

.tpg-hc__content,
.tpg-hc__nav { background: linear-gradient(160deg, var(--hc-navy-2), var(--hc-ink)); }
.tpg-hc__content {
    position: relative;
    border-radius: 20px 20px 0 0;
    padding: 28px 30px 18px;
    overflow: hidden;
}
.tpg-hc__content::before {
    content: '';
    position: absolute;
    top: -160px;
    right: -120px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(196, 161, 90, .22), transparent 70%);
    pointer-events: none;
}

.tpg-hc__close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: 1px solid var(--hc-line);
    border-radius: 50%;
    background: rgba(10, 21, 34, .6);
    color: var(--hc-gold);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, transform .2s ease;
}
.tpg-hc__close:hover { background: rgba(227, 194, 126, .15); transform: rotate(90deg); }
.tpg-hc__close:focus-visible,
.tpg-hc__navbtn:focus-visible { outline: 2px solid var(--hc-gold); outline-offset: 2px; }

/* En-tête */
.tpg-hc__head { position: relative; display: flex; gap: 18px; align-items: center; padding-right: 40px; }
.tpg-hc__num {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border: 2px solid var(--hc-gold-deep);
    border-radius: 50%;
    font-family: var(--hc-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hc-gold);
    box-shadow: 0 0 0 6px rgba(196, 161, 90, .08), inset 0 0 18px rgba(196, 161, 90, .15);
}
.tpg-hc__eyebrow {
    margin: 0 0 4px;
    font-family: var(--hc-mono);
    font-size: .66rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--hc-gold);
}
.tpg-hc__name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-family: var(--hc-display);
    font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem);
    font-weight: 600;
    line-height: 1.1;
    color: var(--hc-text);
}
.tpg-hc__rank {
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(227, 194, 126, .14);
    color: var(--hc-gold);
    font-family: var(--hc-mono);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.tpg-hc__rank--fav { background: linear-gradient(180deg, var(--hc-gold), var(--hc-gold-deep)); color: #201705; }
.tpg-hc__meta { margin: 6px 0 0; font-size: .86rem; color: var(--hc-dim); }
.tpg-hc__meta i { margin: 0 8px; font-style: normal; color: var(--hc-gold-deep); }

/* Pastilles d'identité */
.tpg-hc__chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.tpg-hc__chip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    padding: 6px 11px;
    border: 1px solid var(--hc-line);
    border-radius: 10px;
    background: rgba(10, 21, 34, .55);
    font-size: .82rem;
    font-weight: 600;
}
.tpg-hc__chip em {
    font-style: normal;
    font-family: var(--hc-mono);
    font-size: .6rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--hc-dim);
}
.tpg-hc__chip--good { border-color: rgba(34, 197, 94, .45); color: #86EFAC; }
.tpg-hc__chip--warn { border-color: rgba(245, 158, 11, .6); color: #FCD34D; }
.tpg-hc__chip--musique b {
    display: inline-flex;
    align-items: baseline;
    font-family: var(--hc-mono);
    font-size: .82rem;
    color: var(--hc-text);
}
.tpg-hc__chip--musique b + b { margin-left: 3px; }
.tpg-hc__chip--musique b small { font-size: .62em; color: var(--hc-dim); }
.tpg-hc__chip--musique b.top { color: var(--hc-gold); }
.tpg-hc__chip--musique b.faute { color: #FF8A80; }

/* Radar + axes */
.tpg-hc__body {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    margin-top: 10px;
}
.tpg-hc__radar { position: relative; }
.tpg-hc__radar::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(227, 194, 126, .12), transparent 70%);
    pointer-events: none;
}
.tpg-hc__svg { position: relative; display: block; width: 100%; height: auto; overflow: visible; }
.tpg-hc__ring {
    fill: none;
    stroke: rgba(196, 161, 90, .2);
    stroke-width: 1;
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
    animation: tpg-hc-draw 1.1s ease forwards;
    animation-delay: calc(var(--k) * .08s);
}
.tpg-hc__ring:last-of-type { stroke: rgba(196, 161, 90, .38); }
.tpg-hc__spoke { stroke: rgba(196, 161, 90, .16); stroke-width: 1; }
.tpg-hc__axis {
    fill: var(--hc-dim);
    font-family: var(--hc-mono);
    font-size: 10.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: 0;
    animation: tpg-hc-fade .5s ease forwards;
    animation-delay: calc(.25s + var(--i) * .05s);
}
.tpg-hc__avg {
    fill: rgba(237, 230, 214, .05);
    stroke: rgba(237, 230, 214, .45);
    stroke-width: 1.2;
    stroke-dasharray: 4 4;
}
.tpg-hc__shape {
    fill: url(#tpg-hc-fill);
    stroke: var(--hc-gold);
    stroke-width: 2;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 10px rgba(227, 194, 126, .35));
}
.tpg-hc__dot { fill: var(--hc-ink); stroke: var(--hc-gold); stroke-width: 2; }
@keyframes tpg-hc-draw { to { stroke-dashoffset: 0; } }
@keyframes tpg-hc-fade { to { opacity: 1; } }

.tpg-hc__legend { display: flex; justify-content: center; gap: 18px; margin-top: 4px; font-size: .74rem; color: var(--hc-dim); }
.tpg-hc__legend span::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 0;
    margin-right: 6px;
    vertical-align: middle;
    border-top: 2px solid var(--hc-gold);
}
.tpg-hc__legend .is-avg::before { border-top: 1.5px dashed rgba(237, 230, 214, .55); }

.tpg-hc__axes { margin: 0; padding: 0; list-style: none; display: grid; gap: 11px; }
.tpg-hc__axes li {
    opacity: 0;
    transform: translateX(10px);
    animation: tpg-hc-in .45s ease forwards;
    animation-delay: calc(.15s + var(--i) * .06s);
}
.tpg-hc__axhead { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; font-weight: 600; }
.tpg-hc__axhead b { font-family: var(--hc-mono); font-size: .8rem; color: var(--hc-gold); }
.tpg-hc__bar { position: relative; height: 6px; margin: 5px 0 4px; border-radius: 999px; background: rgba(237, 230, 214, .08); }
.tpg-hc__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, hsl(var(--hue) 70% 42%), hsl(var(--hue) 80% 62%));
    transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.tpg-hc__fill.is-on { width: calc(var(--v) * 1%); }
.tpg-hc__avgmark {
    position: absolute;
    top: -3px;
    left: calc(var(--v) * 1%);
    width: 2px;
    height: 12px;
    margin-left: -1px;
    border-radius: 1px;
    background: rgba(237, 230, 214, .7);
    opacity: 0;
    transition: opacity .4s ease .5s;
}
.tpg-hc__avgmark.is-on { opacity: 1; }
.tpg-hc__axes p { margin: 0; font-size: .74rem; line-height: 1.4; color: var(--hc-dim); }
@keyframes tpg-hc-in { to { opacity: 1; transform: none; } }

.tpg-hc__verdict { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--hc-line); }
.tpg-hc__verdict p { margin: 0; font-size: .86rem; }
.tpg-hc__verdict span {
    margin-right: 8px;
    font-family: var(--hc-mono);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--hc-dim);
}
.tpg-hc__verdict .is-plus { color: #86EFAC; }
.tpg-hc__verdict .is-minus { color: #FF8A80; }
.tpg-hc__empty { margin: 22px 0 8px; color: var(--hc-dim); font-style: italic; }

/* Entrée du contenu (ouverture et changement de cheval) */
.tpg-hc__content.is-in .tpg-hc__head,
.tpg-hc__content.is-in .tpg-hc__chips,
.tpg-hc__content.is-in .tpg-hc__verdict { animation: tpg-hc-rise .45s ease both; }
.tpg-hc__content.is-in .tpg-hc__chips { animation-delay: .06s; }
.tpg-hc__content.is-in .tpg-hc__verdict { animation-delay: .4s; }
@keyframes tpg-hc-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Navigation entre les chevaux */
.tpg-hc__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 10px 16px 16px;
    border-radius: 0 0 20px 20px;
    border-top: 1px solid var(--hc-line);
}
.tpg-hc__navbtn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--hc-line);
    border-radius: 50%;
    background: transparent;
    color: var(--hc-gold);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.tpg-hc__navbtn:hover { background: rgba(227, 194, 126, .12); }
.tpg-hc__navbtn[data-step="-1"]:hover { transform: translateX(-2px); }
.tpg-hc__navbtn[data-step="1"]:hover { transform: translateX(2px); }
.tpg-hc__pos { min-width: 60px; text-align: center; font-family: var(--hc-mono); font-size: .76rem; color: var(--hc-dim); }

/* Nom du cheval cliquable dans les tableaux */
.tpg-fs .tpg-fs-horse-btn {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.tpg-fs .tpg-fs-horse-btn:hover .tpg-fs-name { color: var(--gold-bright, #E3C27E); }
.tpg-fs .tpg-fs-horse-btn:hover .tpg-fs-num { background: rgba(227, 194, 126, .15); }
.tpg-fs .tpg-fs-horse-btn:focus-visible { outline: 2px solid var(--gold-bright, #E3C27E); outline-offset: 3px; border-radius: 6px; }

@media (max-width: 700px) {
    .tpg-hc { padding: 0; align-items: flex-end; }
    .tpg-hc__card { width: 100%; max-height: 94vh; border-radius: 22px 22px 0 0; transform: translateY(40px); }
    .tpg-hc__content { padding: 22px 18px 14px; }
    .tpg-hc__nav { border-radius: 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .tpg-hc__num { width: 48px; height: 48px; font-size: 1.1rem; }
    .tpg-hc__body { grid-template-columns: 1fr; gap: 10px; }
    .tpg-hc__radar { max-width: 340px; margin: 0 auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .tpg-hc__card, .tpg-hc__backdrop, .tpg-hc__fill { transition: none; }
    .tpg-hc__ring, .tpg-hc__axis, .tpg-hc__axes li, .tpg-hc__content.is-in * { animation: none !important; opacity: 1; transform: none; stroke-dashoffset: 0; }
}

/* Non-partant : pastille « np » dans le nom de la carte */
.tpg-hc__np {
    padding: 3px 8px;
    border: 1px solid rgba(239, 68, 68, .5);
    border-radius: 6px;
    background: rgba(239, 68, 68, .14);
    color: #FF8A80;
    font-family: var(--hc-mono);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .05em;
}
