/*
 * Analysis page (`/analysis/<id>`) — rediseno 2026-08-02.
 *
 * Jerarquia de la pagina: hero (score + distribucion de veredictos + ledger de
 * stats), la ESPINA (win curve con ticks de veredicto clicables — la firma del
 * informe), key moments como enlaces, y las turn cards en dos columnas que
 * escenifican "You played | Engine best". base.css aporta las primitivas
 * (.slot-actions, .label-badge y variantes, .turn-narrative, .disclaimer...);
 * aqui va solo lo especifico del informe. Colores: tokens.css. Disciplina de
 * acento: el naranja de marca aparece en la linea de la curva y en interaccion,
 * nunca como color de datos.
 */

/* ---------- Hero (score + verdict distribution + stat ledger) ---------- */

.analysis-hero {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-6);
    padding: var(--space-5) 0 var(--space-5);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}

.hero-score { display: flex; flex-direction: column; gap: var(--space-3); min-width: 260px; flex: 1 1 320px; }

.score-row { display: flex; align-items: baseline; gap: var(--space-3); }

.score-display {
    font-family: var(--font-display);
    font-size: 4.5rem;
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: -0.03em;
}

.score-caption {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.5;
}

.score-partial-note {
    font-size: 0.78rem;
    color: var(--warning);
    max-width: 24rem;
}

.hero-score-warning {
    margin: 0;
    flex: 1 1 320px;
}

/* Distribucion de veredictos: barra proporcional + leyenda con conteos. */
.verdict-dist {
    display: flex;
    gap: 2px;
    height: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 420px;
}
.vd-seg { display: block; min-width: 6px; }
.vd-best { background: var(--label-best); }
.vd-ok { background: var(--label-ok); }
.vd-inaccuracy { background: var(--label-inaccuracy); }
.vd-mistake { background: var(--label-mistake); }
.vd-blunder { background: var(--label-blunder); }

.verdict-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.vl-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.vl-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fg);
}

/* Ledger de stats: filas etiqueta/valor con hairlines, sin cajas dentro de cajas
   (mismo device que "the deal" de la landing). */
.stat-ledger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 220px;
    margin: 0;
}
.stat-ledger-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-5);
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}
.stat-ledger-row:last-child { border-bottom: none; }
.stat-ledger dt {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--fg-muted);
}
.stat-ledger dd {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg);
    margin: 0;
}

/*
 * Accessibility: play-quality badges must NOT rely on color alone. Each label
 * class gets a distinct leading glyph (geometric shapes, not emoji) via
 * `::before`, so a colorblind reader distinguishes best/ok/inaccuracy/mistake/
 * blunder by shape + word, not just hue. Applies wherever a `.label-*` badge
 * appears (hero legend, turn cards, key moments, feedback verdicts).
 */
.label-badge::before {
    display: inline-block;
    margin-right: 0.3em;
    font-weight: 700;
}
.label-badge.label-best::before { content: "\25B2"; }          /* ▲ up triangle */
.label-badge.label-ok::before { content: "\25CF"; }            /* ● filled circle */
.label-badge.label-inaccuracy::before { content: "\25C6"; }    /* ◆ diamond */
.label-badge.label-mistake::before { content: "\25BC"; }       /* ▼ down triangle */
.label-badge.label-blunder::before { content: "\25A0"; }       /* ■ filled square */
.label-badge.label-recommendation::before { content: "\25B8"; }/* ▸ right triangle */
.label-badge.label-skipped::before { content: "\2013"; }       /* – en dash */

/* ---------- The spine: win curve + verdict ticks ---------- */

.win-curve-section { margin-bottom: var(--space-6); }
.win-curve-container { position: relative; }
.win-curve-container svg { width: 100%; height: auto; display: block; }

.wc-grid { stroke: var(--border); stroke-width: 0.5; }
.wc-axis-label,
.wc-xlabel {
    fill: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 10px;
}
.wc-lowsig {
    fill: var(--fg-muted);
    fill-opacity: 0.09;
    stroke: var(--border);
    stroke-width: 0.5;
    stroke-dasharray: 3 3;
}
.wc-lowsig-label {
    fill: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 9px;
}
.win-curve-note {
    margin-top: var(--space-2);
    color: var(--fg-muted);
    font-size: 0.8125rem;
    line-height: 1.5;
    max-width: 72ch;
}
.wc-hint {
    margin-top: var(--space-2);
    color: var(--fg-faint);
    font-size: 0.75rem;
}
.wc-area { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.wc-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.wc-point {
    fill: var(--accent);
    r: 3;
    transition: r var(--transition-fast);
}
/* Area de click generosa: el circulo invisible del grupo recibe el raton;
   el punto visible crece cuando el grupo esta en hover. */
.wc-pt { cursor: pointer; }
.wc-hit { fill: transparent; }
.wc-pt:hover .wc-point, .wc-pt.is-hot .wc-point { r: 5.5; }

/* Columna de click bajo el eje: cubre T{n} + tick. Feedback via .is-hot (JS). */
.wc-colhit { fill: transparent; cursor: pointer; }
.wc-xlabel.is-hot { fill: var(--fg); }
.wc-tick.is-hot { transform: scale(1.35); }

/* Ticks de veredicto bajo el eje: la espina. Cuadrados con el color de la
   etiqueta, clicables (analysis.js) y enfocables con teclado. */
.wc-tick { cursor: pointer; transition: transform var(--transition-fast); transform-box: fill-box; transform-origin: center; }
.wc-tick:hover, .wc-tick:focus-visible { transform: scale(1.35); outline: none; }
.wct-best { fill: var(--label-best); }
.wct-ok { fill: var(--label-ok); }
.wct-inaccuracy { fill: var(--label-inaccuracy); }
.wct-mistake { fill: var(--label-mistake); }
.wct-blunder { fill: var(--label-blunder); }

.wc-tooltip {
    position: absolute;
    transform: translate(-50%, calc(-100% - 8px));
    padding: 0.25rem 0.5rem;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg);
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

/* ---------- Key moments (links into the turn list) ---------- */

.key-moments-section { margin-bottom: var(--space-5); }
.km-list { display: flex; flex-direction: column; gap: var(--space-2); }
.key-moment {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--fg);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
a.key-moment:hover { border-color: var(--border-strong); background: var(--surface-2); }
a.key-moment:focus-visible { outline: none; box-shadow: var(--glow-accent); }
.km-turn { font-family: var(--font-mono); font-weight: 600; font-size: 0.85rem; color: var(--fg); }
.key-moment code { background: transparent; color: var(--fg-muted); padding: 0; }

/* ---------- Turn cards ---------- */

.turns-section { margin-top: var(--space-5); }

.turn-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-3);
    transition: border-color var(--transition-fast);
    scroll-margin-top: 1rem;
}
.turn-card:hover { border-color: var(--border-strong); }
.turn-card.skipped { opacity: 0.55; }

/* Aterrizaje desde la espina / key moments: resalta la card destino. */
.turn-card:target { border-color: var(--accent); }
.turn-card.flash { animation: card-flash 1.4s ease-out; }
@keyframes card-flash {
    0% { border-color: var(--accent); box-shadow: var(--glow-accent); }
    100% { border-color: var(--border); box-shadow: var(--shadow-card); }
}
@media (prefers-reduced-motion: reduce) {
    .turn-card.flash { animation: none; border-color: var(--accent); }
}

.turn-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}
.turn-number {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--fg-muted);
    min-width: 2.2rem;
}

/* Dos columnas: tu jugada | lo que dice el motor. La comparacion ES el
   producto; cada card la escenifica en vez de apilar lineas mono. */
.turn-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}
.tc-col { min-width: 0; }
.tc-engine {
    border-left: 1px solid var(--border);
    padding-left: var(--space-5);
}
.tc-col-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--fg-faint);
    margin-bottom: 0.35rem;
}

.tc-mix { margin-top: var(--space-2); }
.tc-mix summary {
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-faint);
    list-style: none;
}
.tc-mix summary::before { content: "+ "; }
.tc-mix[open] summary::before { content: "\2212 "; }
.tc-mix summary::-webkit-details-marker { display: none; }
.tc-mix summary:hover { color: var(--fg-muted); }
.tc-mix summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---------- Delta CI range bar ---------- */

.delta-ci {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--fg-faint);
}
.delta-ci-caption {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.delta-ci-track {
    position: relative;
    display: inline-block;
    width: 110px;
    height: 5px;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.delta-ci-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--fg-muted);
    border-radius: var(--radius-sm);
}
.delta-ci-range { color: var(--fg-muted); }

/* ---------- World assumption chips ---------- */

.world-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
}
.world-chip {
    padding: 0.1rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--fg-faint);
    cursor: default;
}
.world-chip:hover { border-color: var(--border-strong); color: var(--fg-muted); }

/* ---------- Flags row ---------- */

.flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-4) 0;
}
.flag-chip {
    padding: 0.1rem 0.5rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--fg-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .turn-compare { grid-template-columns: 1fr; gap: var(--space-3); }
    .tc-engine { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: var(--space-3); }
}

@media (max-width: 480px) {
    .analysis-hero {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-4);
        padding-top: var(--space-3);
    }
    .score-display { font-size: 3.25rem; }
    .stat-ledger { min-width: 0; }
    .turn-card { padding: var(--space-4); }
    .turn-card-header { flex-wrap: wrap; gap: var(--space-2); }
    .delta-ci-track { width: 80px; }
}

/* ---- Team preview card (spec 2026-07-20) ---------------------------------- */
.preview-card {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.preview-card.skipped { border-color: var(--border); border-left-color: var(--border-strong); box-shadow: none; opacity: 0.85; }
.preview-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.preview-title { font-family: var(--font-display); font-weight: 700; color: var(--fg); letter-spacing: 0.01em; }
.preview-hint {
  color: var(--fg-muted); font-size: 0.85rem; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md); padding: 8px 12px; margin-bottom: 16px;
}
.pv-compare { display: flex; flex-direction: column; gap: 6px; }
.pv-compare-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-side-label {
  min-width: 96px; color: var(--fg-faint); font-family: var(--font-mono);
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
}
.pv-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pv-chip {
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 2px 10px; font-size: 0.85rem; white-space: nowrap;
}
.pv-lead { border-color: var(--border-strong); }
.pv-lead::before { content: "◉ "; color: var(--accent); }
.pv-legend { color: var(--fg-faint); font-size: 0.72rem; margin-top: 2px; }
.pv-bars { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.pv-bar-row { display: flex; align-items: center; gap: 8px; }
.pv-bar-label {
  min-width: 96px; color: var(--fg-faint); font-family: var(--font-mono);
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
}
.pv-bar-track {
  flex: 1; height: 6px; background: var(--surface-3); border-radius: var(--radius-sm); overflow: hidden;
}
.pv-bar-fill { display: block; height: 100%; background: var(--fg-muted); border-radius: var(--radius-sm); }
.pv-bar-value { min-width: 52px; text-align: right; font-size: 0.8rem; font-family: var(--font-mono); }
.pv-mix { margin-top: 12px; }
.pv-mix summary { cursor: pointer; color: var(--fg-muted); font-size: 0.85rem; }
.pv-mix summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.pv-mix-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
