/* ==========================================================================
   Carnet des Songes — le plateau de combat partagé (SongePlateau)
   Liste des combats, visionneuse pas à pas (plateau isométrique, initiative,
   lecture, tour en cours, journal) : combats.html et le carnet (direct et
   onglet Combats). Reprend les variables et composants de styles.css.
   ========================================================================== */

:root {
  --tile-a: #332c64;
  --tile-b: #3a3370;
  --tile-line: rgba(180, 165, 255, 0.3);
  --hole: rgba(160, 140, 255, 0.025);
  --hole-line: rgba(160, 140, 255, 0.06);
  --block-top: #4b4478;
  --block-left: #2f2a55;
  --block-right: #3a3466;
  --camp-nous: #2ee6d6;
  --camp-ennemi: #ff6b6b;
  --lance: #ffc94d;
  --hp: #34e0a1;
  --hp-low: #ff6b6b;
  --shield: #9ad7ff;
  --zone-nous: rgba(255, 201, 77, 0.42);
  --zone-ennemi: rgba(255, 107, 107, 0.42);
  --token-bg: #1a1730;
}

:root[data-theme="clair"] {
  --tile-a: #ffffff;
  --tile-b: #f1eeff;
  --tile-line: #c9c0ff;
  --hole: rgba(80, 60, 200, 0.02);
  --hole-line: rgba(80, 60, 200, 0.06);
  --block-top: #b3a8e8;
  --block-left: #8f84cc;
  --block-right: #a197db;
  --camp-nous: #0891b2;
  --camp-ennemi: #e11d48;
  --lance: #d97706;
  --hp: #059669;
  --hp-low: #e11d48;
  --shield: #3b82f6;
  --zone-nous: rgba(245, 158, 11, 0.4);
  --zone-ennemi: rgba(225, 29, 72, 0.3);
  --token-bg: #ffffff;
}


/* ------------------------------------------------------------- liste -- */

.cb-filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.cb-filters select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 6px 10px; min-width: 150px;
}
.cb-fav-filter { padding: 6px 12px; }
.cb-fav-filter[aria-pressed="true"] { color: var(--gold); border-color: color-mix(in srgb, var(--gold-mark) 45%, transparent); background: var(--gold-wash); }
.cb-count { margin-left: auto; font-size: 12.5px; color: var(--ink-muted); align-self: center; }

.cb-list { display: grid; gap: 8px; margin-top: 12px; }
.cb-empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); }

.cb-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1.6fr) minmax(0, 1fr) auto auto;
  gap: 6px 16px; align-items: center;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none; cursor: pointer;
  transition: border-color 0.16s ease, transform 0.12s ease;
}
.cb-row:hover { border-color: var(--line-strong); }
.cb-row:focus-visible { outline: 2px solid var(--paradoxe); outline-offset: 2px; }
.cb-row-issue { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.cb-row-main { min-width: 0; }
.cb-row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-row-sub { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-row-team { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.cb-row-team .cb-vs { font-size: 12px; color: var(--ink-muted); margin-left: 6px; white-space: nowrap; }
.cb-row-stats { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.cb-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.cb-stat b { font-size: 14px; }
.cb-stat span { font-size: 10.5px; color: var(--ink-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.cb-row-end { display: flex; align-items: center; gap: 8px; }
.chip.limit { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.chip.kind { color: var(--ink-2); }
.chip.ver { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--ink-2); }

.cb-star {
  appearance: none; border: 1px solid transparent; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; width: 36px; height: 36px; border-radius: 9px;
  color: var(--ink-muted); opacity: 0.55;
}
.cb-star:hover { opacity: 1; border-color: var(--line); }
.cb-star[aria-pressed="true"] { color: var(--gold-mark); opacity: 1; }
.cb-more { display: flex; justify-content: center; margin-top: 12px; }

/* Petits jetons (liste, barre d'initiative) */
.cb-tok {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; overflow: hidden;
  font-size: 10px; font-weight: 800; color: #fff;
  background: var(--token-bg); border: 2px solid var(--camp-nous);
}
.cb-tok.ennemi { border-color: var(--camp-ennemi); }
.cb-tok img { width: 100%; height: 100%; object-fit: cover; }
.cb-tok.lance { border-radius: 3px; transform: rotate(45deg) scale(0.72); background: var(--lance); border-color: var(--lance); }

@media (max-width: 900px) {
  .cb-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cb-row-issue { flex-direction: row; grid-column: 1 / -1; order: -1; }
  .cb-row-team { grid-column: 1 / 3; }
  .cb-row-stats { grid-column: 1 / 3; justify-content: flex-start; }
  .cb-stat { align-items: flex-start; }
  .cb-row-end { grid-column: 3; grid-row: 2 / 5; align-self: start; }
  .cb-row-main { grid-column: 1 / 3; }
}

/* ------------------------------------------------------- visionneuse -- */

.cb-head { display: flex; align-items: center; gap: 12px; padding: 18px 0 12px; }
.cb-head > a.btn { text-decoration: none; flex: none; }
.cb-head-title { flex: 1; min-width: 0; }
.cb-head h1 {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(19px, 2.6vw, 26px); letter-spacing: -0.01em; line-height: 1.2;
  font-variation-settings: "SOFT" 24, "WONK" 1;
}
.cb-head-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

.cb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.cb-layout .card + .card { margin-top: 0; }
.cb-side { display: grid; gap: 14px; }
@media (max-width: 1040px) {
  .cb-layout { grid-template-columns: minmax(0, 1fr); }
}

.cb-stage { padding: 12px; }

/* Barre d'initiative */
.cb-initiative {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.cb-ini {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 40px; padding: 4px 0 3px; border-radius: 9px; border: 1px solid transparent;
  transition: opacity 0.3s ease, background 0.2s ease, border-color 0.2s ease;
}
.cb-ini .cb-tok { width: 30px; height: 30px; }
.cb-ini-hp { width: 30px; height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.cb-ini-hp i { display: block; height: 100%; background: var(--hp); }
.cb-ini.is-current { background: var(--surface-2); border-color: var(--line-strong); box-shadow: var(--glow-violet); }
.cb-ini.is-dead { opacity: 0.32; filter: grayscale(1); }
.cb-ini.is-summon .cb-tok { width: 24px; height: 24px; }

/* Plateau */
.cb-board-wrap {
  overflow: auto; border-radius: var(--radius-sm);
  background:
    radial-gradient(90% 70% at 50% 40%, color-mix(in srgb, var(--paradoxe) 7%, transparent), transparent 75%),
    var(--surface-2);
  border: 1px solid var(--line);
  touch-action: pan-x pan-y;
}
.cb-board { display: block; width: 100%; height: auto; user-select: none; }
.cb-board .t-sol, .cb-legend .t-sol { fill: var(--tile-a); stroke: var(--tile-line); stroke-width: 0.6; }
.cb-board .t-sol.t-alt { fill: var(--tile-b); }
.cb-board .t-trou, .cb-legend .t-trou { fill: var(--hole); stroke: var(--hole-line); stroke-width: 0.5; }
.cb-board .b-top, .cb-legend .b-top { fill: var(--block-top); }
.cb-board .b-left, .cb-legend .b-left { fill: var(--block-left); }
.cb-board .b-right, .cb-legend .b-right { fill: var(--block-right); }
.cb-board .z-cell { fill: var(--zone-nous); stroke: color-mix(in srgb, var(--gold-mark) 70%, transparent); stroke-width: 0.8; }
.cb-board .z-cell.ennemi { fill: var(--zone-ennemi); stroke: color-mix(in srgb, var(--camp-ennemi) 70%, transparent); }
.cb-board .z-target { fill: none; stroke: var(--gold-mark); stroke-width: 1.8; }
.cb-board .z-target.ennemi { stroke: var(--camp-ennemi); }
.cb-board .z-path { fill: none; stroke: var(--camp-nous); stroke-width: 1.6; stroke-dasharray: 3 3; stroke-linecap: round; opacity: 0.8; }
.cb-board .z-path.ennemi { stroke: var(--camp-ennemi); }
.cb-board .z-cast { stroke: var(--gold-mark); stroke-width: 1.8; stroke-linecap: round; fill: none; }
.cb-board .z-cast.ennemi { stroke: var(--camp-ennemi); }
.cb-board .z-push { stroke: var(--ink-2); stroke-width: 1.4; fill: none; stroke-dasharray: 2 2; }

.cb-board .ent { transition: opacity 0.6s ease; }
.cb-board .ent.is-dead { opacity: 0; }
.cb-board .ent.is-absent { opacity: 0; }
.cb-board .ent-shadow { fill: rgba(0, 0, 0, 0.35); }
:root[data-theme="clair"] .cb-board .ent-shadow { fill: rgba(40, 20, 120, 0.18); }
.cb-board .ent-ring { fill: none; stroke: var(--camp-nous); stroke-width: 2.2; }
.cb-board .ennemi .ent-ring { stroke: var(--camp-ennemi); }
.cb-board .ent-bg { fill: var(--token-bg); }
.cb-board .ent-txt { font: 800 8px var(--font-ui); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.cb-board .ent-hp-bg { fill: rgba(0, 0, 0, 0.55); }
:root[data-theme="clair"] .cb-board .ent-hp-bg { fill: rgba(40, 20, 120, 0.22); }
.cb-board .ent-hp { fill: var(--hp); }
.cb-board .ent-hp.is-low { fill: var(--hp-low); }
.cb-board .ent-sh { fill: var(--shield); }
.cb-board .ent-halo { fill: none; stroke: var(--ink); stroke-width: 1.2; opacity: 0; }
.cb-board .ent.is-current .ent-halo { opacity: 0.9; animation: cb-pulse 1.3s ease-in-out infinite; }
.cb-board .lance-mark { fill: var(--lance); stroke: var(--ground); stroke-width: 1; }
.cb-board .ent.lance .ent-ring { display: none; }

.cb-board .fx-num {
  font: 800 11px var(--font-ui); text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--ground); stroke-width: 3px; stroke-linejoin: round;
  fill: var(--critical);
  animation: cb-float 1.4s ease-out forwards;
}
.cb-board .fx-num.heal { fill: var(--good); }
.cb-board .fx-num.still { animation: none; }
.cb-board .fx-skull { font: 700 12px var(--font-ui); text-anchor: middle; fill: var(--ink); animation: cb-float 1.4s ease-out forwards; }

@keyframes cb-float {
  0% { opacity: 0; transform: translateY(4px); }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}
@keyframes cb-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .cb-board .fx-num, .cb-board .fx-skull { animation: none; }
  .cb-board .ent.is-current .ent-halo { animation: none; }
}

.cb-now {
  margin-top: 10px; padding: 9px 12px; min-height: 42px;
  border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.cb-now small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-muted); letter-spacing: 0.06em; text-transform: uppercase; }

.cb-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 10px; }
.cb-buttons { display: flex; gap: 6px; align-items: center; }
.cb-buttons .icon-btn { font-size: 13px; }
.cb-play { min-width: 112px; justify-content: center; }
.cb-zoom { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.cb-zoom .icon-btn { font-size: 16px; font-weight: 700; }

.cb-timeline { position: relative; margin-top: 12px; padding-top: 16px; }
.cb-timeline input[type="range"] { width: 100%; accent-color: var(--paradoxe); margin: 0; }
.cb-ticks { position: absolute; left: 8px; right: 8px; top: 0; height: 16px; }
.cb-ticks b {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 800; color: var(--ink-muted); cursor: pointer; pointer-events: auto;
}
.cb-ticks b::after { content: ""; position: absolute; left: 50%; top: 12px; width: 1px; height: 8px; background: var(--axis); }
.cb-ticks i { position: absolute; top: 9px; width: 4px; height: 4px; border-radius: 50%; background: var(--critical); transform: translateX(-50%); opacity: 0.8; }
.cb-pos { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* Journal */
.cb-log-card { padding: 14px 10px 10px 14px; }
.cb-log {
  list-style: none; margin: 8px 0 0; padding: 0 4px 0 0;
  max-height: 340px; overflow-y: auto; font-size: 12.5px; scrollbar-width: thin;
}
.cb-log li { padding: 3px 7px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.cb-log li:hover { background: var(--surface-2); color: var(--ink); }
.cb-log li.t-tour { color: var(--ink); font-weight: 700; margin-top: 6px; }
.cb-log li.t-fin { color: var(--ink-muted); font-size: 11.5px; }
.cb-log li.t-mort { color: var(--critical); font-weight: 600; }
.cb-log li.is-future { opacity: 0.5; }
.cb-log li.is-current { background: color-mix(in srgb, var(--paradoxe) 18%, transparent); color: var(--ink); opacity: 1; }
@media (max-width: 1040px) { .cb-log { max-height: 240px; } }

.cb-dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 10px 0 0; font-size: 13px; }
.cb-dl dt { color: var(--ink-muted); }
.cb-dl dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.cb-legend ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.cb-legend li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cb-legend svg { width: 26px; height: 16px; flex: none; }
.cb-leg-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--camp-nous); }
.cb-leg-dot.ennemi { border-color: var(--camp-ennemi); }
.cb-leg-lance { display: inline-block; width: 8px; height: 8px; background: var(--lance); transform: rotate(45deg); }


@media (max-width: 560px) {
  .cb-stage { padding: 8px; }
  .cb-zoom { margin-left: 0; }
  .cb-controls { justify-content: space-between; }
  .cb-count { margin-left: 0; flex: 1 1 100%; }
  /* La base s'applique au champ (largeur), pas au menu : dans la colonne du champ elle en ferait la hauteur. */
  .cb-filters .field { flex: 1 1 140px; min-width: 0; }
  .cb-filters select { min-width: 0; width: 100%; }
}

/* ---------------------------------------------- combat3 : système, pilotage, conseil -- */
.cb-systeme .cb-n { opacity: 0.6; font-variant-numeric: tabular-nums; font-size: 0.9em; }
.chip.ver.is-archive { opacity: 0.65; }
.chip.par-pilote { color: var(--camp-nous); border-color: color-mix(in srgb, var(--camp-nous) 45%, transparent); }
.chip.par-joueur { color: var(--ink-2); }
.cb-par {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.02em; vertical-align: 1px; border: 1px solid currentColor; opacity: 0.9; white-space: nowrap;
}
.cb-par.par-pilote { color: var(--camp-nous); }
.cb-par.par-mixte { color: var(--lance); }
.cb-par.par-joueur { color: var(--ink-muted); }
.cb-turn dd { text-align: left; font-weight: 500; }
.cb-board .z-conseil { fill: none; stroke: var(--camp-nous); stroke-width: 1.6; stroke-dasharray: 3 2.5; }

/* ------------------------------------------- liste : intertitres -- */
.cb-list-h {
  margin: 10px 2px 0; font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-muted);
}
.cb-list-h:first-child { margin-top: 0; }

/* ------------------------------------------------ direct : historique -- */
/* Le combat en cours : bouton « Direct », retard quand on revoit un coup passé. */
.cb-live-btn { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.cb-live-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); }
.cb-live-btn.is-on { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.cb-live-btn.is-on i { background: var(--critical); animation: cb-pulse 1.3s ease-in-out infinite; }
.cb-retard {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 7px 10px; border-radius: var(--radius-xs);
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  font-size: 13.5px; font-weight: 700; color: var(--ink);
}
.cb-retard[hidden] { display: none; }
.cb-viewer.is-late .cb-board-wrap { outline: 2px dashed color-mix(in srgb, var(--warning) 55%, transparent); outline-offset: -2px; }
.cb-leg-direct { font-size: 11.5px; color: var(--ink-muted); }
.cb-legend .z-conseil { fill: none; stroke: var(--camp-nous); stroke-width: 1.6; stroke-dasharray: 3 2.5; }
.cb-side > * { min-width: 0; }
.cb-viewer.is-direct .cb-log { max-height: 260px; }
@media (prefers-reduced-motion: reduce) { .cb-live-btn.is-on i { animation: none; } }
@media (max-width: 560px) {
  .cb-buttons { flex-wrap: wrap; }
  .cb-play { min-width: 96px; }
}
