/* =====================================================================================================
   ARBRE DES NAVIRES par familles (2026-10-21, point 18 de la revue de Simon) — js/arbre-navires.js.
   Habillage « cité engloutie » (marbre ivoire, liseré doré, titres Cinzel) repris des jetons --gc-* de
   css/cite-engloutie.css ; valeurs de repli en dur si la feuille n'est pas posée (?lang, UI_STYLE autre).
   Scopé #gallery-panel.av-on : la roue de repli (atelier inactif) et le banc d'essai gardent leur style.
   Chargée TOUT EN DERNIER. Contrastes : encre #2f2619 sur plaque #fbf7ee 14:1 ; blanc sur #154a42 10:1,
   blanc sur #9a3a1c 7:1, #ffe9a8 sur #3a2f22 10:1, blanc sur #5a2d82 9:1 — tous ≥ AA.
   Aucune animation (prefers-reduced-motion respecté d'office), aucune ombre portée mouvante.
   ===================================================================================================== */

html body #gallery-panel.av-on {
  --av-ink: var(--gc-text, #2f2619);
  --av-dim: var(--gc-text-dim, #5a4a36);
  --av-card: var(--gc-card, #fbf7ee);
  --av-card2: var(--gc-card-2, #efe5cf);
  --av-gold: var(--gc-gold, #c9b07a);
  --av-bronze: #154a42;
  --av-fam: #6b4226;
  inset: 0 !important; width: 100% !important; height: 100dvh !important; max-width: none !important; max-height: none !important;
  padding: 0 !important; margin: 0 !important; gap: 0 !important;
  display: flex !important; flex-direction: column !important; align-items: stretch !important; justify-content: flex-start !important;
  overflow: hidden !important; box-sizing: border-box !important;
  background: var(--gc-polish, linear-gradient(175deg, #fbf8f0 0%, #f2ebdb 50%, #e8dcc3 100%)) !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  text-align: left; color: var(--av-ink);
}
html body #gallery-panel.av-on.hidden { display: none !important; }
html body #gallery-panel.av-on #gallery-box {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100% !important; max-width: none !important; height: auto !important; max-height: none !important;
  overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior: contain;
  padding: max(20px, env(safe-area-inset-top)) max(16px, calc((100% - 1180px) / 2)) max(20px, env(safe-area-inset-bottom)) !important;
  align-items: stretch !important; justify-content: flex-start !important; gap: 0 !important;
  background: none !important; border: 0 !important; box-shadow: none !important; animation: none !important;
}
html body #gallery-panel.av-on #gallery-box > h2,
html body #gallery-panel.av-on #gallery-box > .gallery-lead,
html body #gallery-panel.av-on #gallery-box > #gallery-legend,
html body #gallery-panel.av-on #gallery-box > .gallery-foot,
html body #gallery-panel.av-on #gallery-codex { display: none !important; }
html body #gallery-panel.av-on #gallery-box #gallery-cards { display: block; width: 100%; max-width: none; }
html body #gallery-panel.av-on.gallery-in, html body #gallery-panel.av-on.closing { animation: none !important; }
html body #gallery-panel.av-on.closing #gallery-box { animation: none !important; }
/* croix : même gabarit que les autres panneaux pleine largeur, calée sur le bord de la colonne */
html body #gallery-panel.av-on > .panel-x {
  position: absolute !important; top: max(14px, env(safe-area-inset-top)); right: max(16px, calc((100% - 1180px) / 2)); z-index: 5;
  width: 44px; height: 44px; font-size: 24px; line-height: 1; border-radius: 2px !important; transform: none !important;
  background: #9a3b2c !important; color: #fff !important; border: 2px solid var(--gc-ink, #3a2f22) !important; box-shadow: 0 3px 0 #4a160c !important;
}
html body #gallery-panel.av-on > .panel-x:hover { background: #b34a39 !important; transform: none !important; }

/* ---------- en-tête ---------- */
.av-root { display: block; width: 100%; }
.av-head { padding-right: 56px; }
.av-title {
  margin: 0 0 6px; font: 800 clamp(22px, 3.4vw, 30px)/1.15 var(--gc-title, "Cinzel", Georgia, serif); letter-spacing: 2px; text-transform: uppercase;
  color: var(--av-ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
}
.av-lead { margin: 0 0 14px; max-width: 760px; font-size: 14px; line-height: 1.5; color: var(--av-dim); }

/* ---------- onglets de famille ---------- */
.av-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.av-tab {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; text-align: left; cursor: pointer;
  font: inherit; color: var(--av-ink); background: var(--av-card2); border: 2px solid var(--av-gold); border-bottom-width: 4px; border-radius: 4px;
}
.av-tab-ic { font-size: 24px; line-height: 1; flex: 0 0 auto; }
.av-tab-tx { display: flex; flex-direction: column; min-width: 0; }
.av-tab-name { font: 800 15px/1.2 var(--gc-title, "Cinzel", Georgia, serif); letter-spacing: .5px; }
.av-tab-sub { font-size: 12px; line-height: 1.3; color: var(--av-dim); }
.av-tab-mine {
  position: absolute; top: -9px; right: 8px; padding: 1px 7px; font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: #fff; background: var(--av-bronze); border-radius: 2px;
}
.av-tab.is-on { background: var(--av-card); border-color: var(--av-fam); border-bottom-color: var(--av-fam); box-shadow: inset 0 -5px 0 var(--av-fam); }
.av-tab:hover { background: var(--av-card); }
.av-tab:focus-visible, .av-card:focus-visible, html body #gallery-panel.av-on > .panel-x:focus-visible {
  outline: 3px solid var(--av-bronze); outline-offset: 2px; box-shadow: 0 0 0 5px #fff;
}

/* ---------- grille : frise (gauche) + fiche (droite, collante) ---------- */
.av-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.av-stage { min-width: 0; }
.av-tiers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; counter-reset: av; }
.av-tier {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px 6px 10px; min-width: 0;
  background: rgba(255, 252, 244, .55); border: 1px solid var(--av-gold); border-radius: 4px;
}
.av-tier + .av-tier::before { /* chevron de progression entre deux paliers */
  content: "\203A"; position: absolute; left: -11px; top: 14px; width: 12px; text-align: center; font: 700 20px/1 serif; color: var(--av-dim);
}
.av-tier.is-next { background: #fff7e0; border: 2px solid #9a3a1c; }
.av-tier-h { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 36px; text-align: center; }
.av-tier-lv { font: 800 12.5px/1.2 var(--gc-title, "Cinzel", Georgia, serif); letter-spacing: 1px; color: var(--av-ink); }
.av-tier-next { font-size: 10.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #9a3a1c; }
.av-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.av-cell { margin: 0; padding: 0; }

/* ---------- carte de coque ---------- */
.av-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; min-height: 44px; padding: 6px 4px 7px; cursor: pointer; font: inherit; text-align: center;
  color: var(--av-ink); background: var(--av-card); border: 2px solid var(--av-gold); border-radius: 4px;
}
.av-card:hover, .av-card.is-sel { border-color: var(--av-fam); background: #fff; }
.av-card.is-sel { box-shadow: inset 0 0 0 2px var(--av-fam); }
.av-card.is-current { border-color: var(--av-bronze); background: #e3f1ee; box-shadow: inset 0 0 0 2px var(--av-bronze); }
.av-card.is-next { border-color: #9a3a1c; background: #fff; }
.av-card.is-past:not(.is-current) { background: var(--av-card2); border-style: dashed; }
.av-cv { display: block; width: 100%; max-width: 124px; height: auto; aspect-ratio: 156 / 120; }
.av-name { font-size: 13.5px; font-weight: 800; line-height: 1.2; }
.av-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.av-tag {
  display: inline-block; padding: 1px 6px; font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .4px; line-height: 1.5; border-radius: 2px;
  color: #fff; background: var(--av-bronze); white-space: nowrap;
}
.av-tag--next { background: #9a3a1c; }
.av-tag--legendary, .av-tag--secret { color: #ffe9a8; background: #3a2f22; }
.av-tag--epic { background: #5a2d82; }
.av-tag--rare { background: #1d5a8f; }
.av-tag--seen { color: var(--av-ink); background: transparent; border: 1px solid var(--av-gold); font-weight: 700; }
.av-note { margin: 12px 2px 0; font-size: 13px; line-height: 1.45; color: var(--av-dim); }

/* ---------- fiche détaillée ---------- */
.av-detail {
  position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: var(--av-card); border: 2px solid var(--av-gold); border-radius: 4px; box-shadow: var(--gc-carved, inset 0 0 0 2px #e6d6b0);
}
.av-fig { margin: 0; display: flex; justify-content: center; padding: 6px; background: linear-gradient(180deg, #d8ecea, #bfdad6); border-radius: 3px; border: 1px solid var(--av-gold); }
.av-fig-cv { display: block; width: 100%; max-width: 240px; height: auto; aspect-ratio: 240 / 184; }
.av-d-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.av-d-name { margin: 0; font: 800 20px/1.15 var(--gc-title, "Cinzel", Georgia, serif); letter-spacing: .5px; }
.av-d-lv { margin: 0; font-size: 13px; font-weight: 800; color: #9a3a1c; }
.av-d-role, .av-d-power { margin: 0; font-size: 13.5px; line-height: 1.45; }
.av-d-role { font-style: italic; color: var(--av-dim); }
.av-stats { display: flex; flex-direction: column; gap: 5px; }
.av-stat { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; }
.av-stat-bar { display: block; height: 9px; background: #e6dcc4; border: 1px solid var(--av-gold); border-radius: 2px; overflow: hidden; }
.av-stat-bar b { display: block; height: 100%; background: var(--av-fam); }
.av-d-status { margin: 2px 0 0; padding: 7px 9px; font-size: 13px; font-weight: 800; line-height: 1.35; color: var(--av-ink); background: var(--av-card2); border-radius: 3px; }
.av-d-status.is-you { color: #fff; background: var(--av-bronze); }
.av-d-status.is-next { color: #fff; background: #9a3a1c; }

/* ---------- écrans moyens : fiche sous la frise ---------- */
@media (max-width: 1100px) {
  .av-main { grid-template-columns: minmax(0, 1fr); }
  .av-detail {
    position: sticky; top: auto; bottom: 0; z-index: 3; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px;
    margin-bottom: 0;
  }
  .av-fig { flex: 0 0 150px; }
  .av-d-head, .av-d-lv, .av-d-role, .av-d-power, .av-stats, .av-d-status { flex: 1 1 280px; }
}
/* ---------- téléphone / fenêtre étroite : un palier par RANGÉE ---------- */
@media (max-width: 860px) {
  .av-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .av-tiers { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .av-tier + .av-tier::before { content: none; }
  .av-tier { padding: 8px 8px 10px; }
  .av-tier-h { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 0; }
  .av-cards { flex-direction: row; flex-wrap: wrap; }
  .av-cell { flex: 1 1 calc(33.333% - 6px); min-width: 108px; max-width: 220px; }
  .av-main { display: flex; flex-direction: column; }
  .av-detail { position: sticky; bottom: 0; order: 2; margin: 10px -4px 0; box-shadow: 0 -6px 14px rgba(47, 38, 25, .18); }
  /* barre de fiche COMPACTE (ne couvre pas la frise) : silhouette, nom, niveau, rôle, état — pouvoir et jauges restent sur PC */
  .av-detail { flex-direction: row; flex-wrap: wrap; gap: 2px 12px; padding: 8px 10px; max-height: 30dvh; overflow: hidden; }
  .av-fig { flex: 0 0 72px; padding: 2px; align-self: center; }
  .av-d-head, .av-d-lv, .av-d-role, .av-d-status { flex: 1 1 calc(100% - 90px); min-width: 0; }
  .av-d-role { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.35; }
  .av-d-power, .av-stats { display: none; }
  .av-d-status { padding: 4px 8px; font-size: 12.5px; }
  .av-d-name { font-size: 16px; }
  .av-lead { font-size: 13px; }
}
@media (max-width: 420px) {
  .av-tab { padding: 6px 8px; gap: 6px; }
  .av-tab-sub { display: none; }
  .av-tab-name { font-size: 13px; letter-spacing: 0; overflow-wrap: anywhere; }
  .av-tab-ic { font-size: 20px; }
  .av-cell { flex-basis: calc(50% - 4px); }
}
@media (prefers-reduced-motion: no-preference) {
  .av-card, .av-tab { transition: background-color .12s linear, border-color .12s linear; }
}
