/*
 * Salle de garde, la scène (docs/REFONTE-GARDE-METIERS-PLAN.md, RG2 ; maquette docs/pages-demo/salle-de-garde-maquette.html).
 * Fond peint et lueurs : salles-fonds.css et shared/salle-fond.js (fond « garde »), composants des Ateliers
 * (ateliers-scene.css : .ws-enseigne, .ws-chip, .ws-plaque). Ici : l'enseigne de la compagnie, le mur nu, le panneau
 * d'affichage qui ouvre le recrutement, et la tablée des fiches illustrées.
 * Couleurs du décor hors thèmes : variables --sg-* (docs/THEMES.md § 3). Pas de style en ligne (CSP) : largeurs par
 * data-w (shared/inline-style.js), couleurs par classes et attributs data-s / data-k.
 * Les thèmes stylent les boutons avec une forte spécificité : d'où les :root:root:root:root devant ce qui en est un.
 */
:root {
  --sg-braise: #d9622b; --sg-foyer: rgba(255, 120, 40, .30);
  --sg-lice: #b8392c; --sg-infirm: #c9c2b4; --sg-infirm-croix: #a8261b; --sg-repos: #4a6aa8; --sg-pret: #4f8a3a; --sg-libre: #6d6a64;
  --sg-liege: #6b4a2c; --sg-liege-2: #523620; --sg-cire: #9e1f1a; --sg-cire-hi: #d8483c;
  --sg-dalle: url("/skins/base/tile/flagstone_3.png"); --sg-plancher: url("/skins/base/tile/planks_5.png");
}
:root[data-theme="dark"] { --sg-infirm: #a9a294; --sg-liege: #553a22; --sg-liege-2: #3f2918; }

/* ---------- La scène ---------- */
:root:root:root:root .ws-scene.sg-scene {
  --metier: var(--sg-braise); container-type: inline-size;
  > * { image-rendering: auto; }
  canvas { image-rendering: pixelated; }
  h2::before, h2::after, h3::before, h3::after { content: none; }
}
:root [data-s="map"] { --c: var(--sg-lice); }
:root [data-s="healing"] { --c: var(--sg-infirm-croix); }
:root [data-s="resting"] { --c: var(--sg-repos); }
:root [data-s="ready"] { --c: var(--sg-pret); }
:root [data-s="libre"] { --c: var(--ws-laiton); }

/* Mur nu : laisse voir la cheminée et le panneau d'affichage. Hauteur = part de l'image (y 0–106 sur 180), moins
   l'enseigne ; le fond couvre aussi la marge de la scène (14 px de chaque côté). */
:root:root:root:root .sg-scene .sg-mur {
  height: max(120px, calc((100cqw + 28px) * 106 / 320 - var(--mur-off, 150px))); margin-top: -14px; pointer-events: none; z-index: 0;
}
/* Le panneau d'affichage peint (x 226–304, y 36–106 du fond) : il ouvre le recrutement. */
:root:root:root:root .sg-scene .sg-avis {
  position: absolute !important; z-index: 2 !important; pointer-events: auto;   /* salles-fonds.css met les enfants en relatif */
  left: calc((100cqw + 28px) * 226 / 320 - 14px); top: calc((100cqw + 28px) * 36 / 320 - 14px);
  width: calc((100cqw + 28px) * 78 / 320); height: calc((100cqw + 28px) * 70 / 320);
  border: 0; padding: 0; margin: 0; background: none; box-shadow: none; cursor: pointer; border-radius: 3px; outline-offset: 3px; clip-path: none;
  &::before { content: none; }
  &::after { content: ""; position: absolute; inset: 0; border-radius: 3px; box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .15s; }
  &:hover::after, &:focus-visible::after { box-shadow: inset 0 0 0 2px var(--ws-laiton-hi), 0 0 24px rgba(255, 200, 110, .45); }
}
.sg-avis-tag { position: absolute; left: 50%; bottom: -12px; translate: -50% 0; white-space: nowrap; padding: 4px 12px 5px;
  font: 700 13px 'Cinzel', serif; letter-spacing: .05em; color: #2a1405; border-radius: 2px;
  background: linear-gradient(180deg, var(--ws-laiton-hi), var(--ws-laiton) 60%, var(--ws-laiton-lo)); box-shadow: 0 3px 8px rgba(0, 0, 0, .6); }
.sg-avis-tag small { font: 600 12px 'Alegreya', serif; letter-spacing: 0; opacity: .8; }
.sg-avis[data-plein] .sg-avis-tag { background: linear-gradient(180deg, var(--ws-fer-hi), var(--ws-fer-2)); color: var(--ws-parch-2); }

/* ---------- L'enseigne de la compagnie ---------- */
:root:root:root:root .sg-scene .ws-enseigne { grid-template-columns: auto minmax(0, 1fr) auto; }
.sg-blason { width: 64px; height: 74px; display: grid; place-items: center; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .6)); }
.sg-blason svg { width: 64px; height: 74px; stroke: none; }
.sg-titre { display: grid; gap: 4px; min-width: 0; }
:root:root:root:root .sg-scene .sg-titre h1 { margin: 0; font-size: clamp(22px, 3.2vw, 32px); color: var(--ws-laiton-hi); text-shadow: 0 2px 0 #000, 0 0 18px var(--sg-foyer); }
.sg-titre .ws-sub { margin: 0; }
.sg-titre .ws-sub b { color: var(--ws-parch); }
/* État synthétique : dix places, une pastille chacune (couleur de l'état), et la légende. */
.sg-places { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 2px; }
.sg-pips { display: flex; gap: 3px; }
.sg-pip { width: 14px; height: 18px; border-radius: 2px 2px 7px 7px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .25); }
.sg-pip[data-s="libre"], .sg-legende [data-s="libre"] i { background: transparent; box-shadow: inset 0 0 0 1px var(--ws-fer-hi); }
.sg-legende { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 14px; color: var(--ws-parch-2); }
.sg-legende span { display: inline-flex; align-items: center; gap: 5px; }
.sg-legende i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
.sg-lices { margin: 0; font-size: 14px; color: var(--ws-parch-2); }
.sg-bourse { display: grid; gap: 6px; justify-items: end; }
:root:root:root:root .sg-scene .sg-bourse .ws-chip { font-size: 15px; }
.sg-bourse .ws-chip b { color: var(--ws-laiton-hi); }
.sg-boutons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.sg-or-form { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.sg-or-form input { width: 9em; }

/* Boutons de la salle (plaques de fer), primaire en laiton chauffé ; lien discret pour les testeurs. */
:root:root:root:root .sg-scene .sg-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; margin: 0; border-radius: 3px; cursor: pointer; text-decoration: none;
  font: 600 14px 'Alegreya', serif; color: var(--ws-parch); background: linear-gradient(180deg, var(--ws-fer-2), var(--ws-fer));
  border: 1px solid #0b0b0c; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 2px 0 #0b0b0c; clip-path: none; text-transform: none; letter-spacing: 0;
  &:hover { background: linear-gradient(180deg, var(--ws-fer-hi), var(--ws-fer-2)); }
  &:active { translate: 0 1px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1); }
  &[data-primaire] { color: #2a1405; font-weight: 700; background: linear-gradient(180deg, #ffe0a0, var(--ws-laiton) 50%, var(--ws-laiton-lo)); }
  &:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .55; translate: none; }
  svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
}
:root:root:root:root .sg-scene .sg-lien {
  padding: 0; margin: 0; border: 0; background: none; box-shadow: none; clip-path: none; cursor: pointer;
  font: 600 13px 'Alegreya', serif; color: var(--ws-laiton-hi); text-decoration: underline; text-underline-offset: 2px;
  &::before, &::after { content: none; }
}

/* ---------- Corps : la tablée (les mercenaires) | la fiche ---------- */
.sg-corps { display: grid; grid-template-columns: minmax(340px, 30%) minmax(0, 1fr); gap: 16px; align-items: start; }
:root:root:root:root .sg-scene .garde-flash:empty { display: none; }
.sg-banc { padding: 10px; border-radius: 4px; background: linear-gradient(180deg, rgba(20, 12, 8, .55), rgba(20, 12, 8, .72));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6), inset 0 2px 10px rgba(0, 0, 0, .45); }
.sg-tri { display: flex; gap: 4px; margin: 0 0 10px; flex-wrap: wrap; }
:root:root:root:root .sg-scene .sg-tri button {
  padding: 3px 10px; margin: 0; font: 600 13px 'Alegreya', serif; color: var(--ws-parch-2); cursor: pointer; text-transform: none; letter-spacing: 0;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--ws-laiton-lo); border-radius: 999px; box-shadow: none; clip-path: none;
  &::before, &::after { content: none; }
  &[aria-pressed="true"] { color: #2a1405; background: var(--ws-laiton-hi); border-color: var(--ws-laiton); }
  &:disabled { opacity: .45; cursor: default; }
}
:root:root:root:root .sg-scene .sg-groupe {
  display: flex; align-items: center; gap: 8px; margin: 12px 2px 6px; padding: 0; border: 0; background: none;
  font: 700 12px 'Alegreya SC', serif; letter-spacing: .06em; color: var(--ws-parch-2); text-transform: none;
  &:first-of-type { margin-top: 0; }
  i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); }
  &::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--ws-laiton-lo), transparent); }
  small { font: 400 12px 'Alegreya', serif; opacity: .8; }
}
.sg-cartes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Une fiche illustrée : le portrait sur sa dalle, le nom, l'état en ruban, trois jauges. */
:root:root:root:root .sg-scene .sg-carte {
  position: relative; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 4px 8px; align-items: start; align-content: start;
  width: 100%; height: 100%; margin: 0; padding: 7px 7px 8px; text-align: left; cursor: pointer; border: 0; border-radius: 3px;
  color: var(--ws-encre); font: 400 13px/1.25 'Alegreya', serif; text-transform: none; letter-spacing: 0; clip-path: none;
  background: var(--ws-grain), linear-gradient(180deg, var(--ws-parch), var(--ws-parch-2));
  box-shadow: inset 0 3px 0 var(--c), inset 0 0 0 1px rgba(60, 35, 10, .45), 0 2px 4px rgba(0, 0, 0, .5);
  transition: transform .14s ease, box-shadow .14s ease;
  &::before { content: none; }
  &:hover { transform: translateY(-2px); box-shadow: inset 0 3px 0 var(--c), inset 0 0 0 1px rgba(60, 35, 10, .45), 0 6px 10px rgba(0, 0, 0, .55); }
  &[aria-pressed="true"] {
    transform: translateY(-2px);
    background: var(--ws-grain), radial-gradient(120% 90% at 50% 0%, #fff1d0, var(--ws-parch) 60%, var(--ws-parch-2));
    box-shadow: inset 0 3px 0 var(--c), inset 0 0 0 2px var(--ws-laiton), 0 0 0 2px var(--sg-braise), 0 0 18px var(--sg-foyer), 0 8px 14px rgba(0, 0, 0, .6);
  }
  &[aria-pressed="true"]::after {   /* la flèche vers la fiche */
    content: ""; position: absolute; right: -10px; top: 26px; border: 8px solid transparent; border-left-color: var(--sg-braise); filter: drop-shadow(0 0 4px var(--sg-foyer)); }
}
.sg-carte[data-s="healing"] .sg-portrait canvas { filter: saturate(.5) brightness(.9); }
.sg-portrait { position: relative; grid-row: span 3; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 3px;
  background: var(--sg-dalle) center / 58px; box-shadow: inset 0 0 0 2px #0b0b0c, inset 0 0 0 3px var(--ws-fer-hi), inset 0 0 14px rgba(0, 0, 0, .6); }
.sg-carte[data-hero] .sg-portrait { background-image: var(--sg-plancher); box-shadow: inset 0 0 0 2px #0b0b0c, inset 0 0 0 3px var(--ws-laiton), inset 0 0 14px rgba(0, 0, 0, .6); }
.sg-portrait canvas { width: 52px; height: 52px; }
.sg-xp { position: absolute; left: 50%; bottom: -7px; translate: -50% 0; white-space: nowrap; padding: 0 5px; border-radius: 2px;
  font: 700 11px 'Alegreya', serif; color: #2a1405; background: var(--ws-laiton-hi); box-shadow: 0 0 0 1px #0b0b0c, 0 0 8px var(--sg-foyer); }
.sg-nom { display: flex; align-items: baseline; gap: 6px; min-width: 0; font: 700 15px/1.15 'Cinzel', serif; letter-spacing: .02em; }
.sg-nom span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-chef { font-style: normal; color: var(--ws-laiton-lo); }
.sg-qui { color: var(--ws-encre-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-ruban { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sg-etat { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px 0 4px; border-radius: 2px; font: 700 11px/17px 'Alegreya SC', serif;
  color: #fff7e6; background: var(--c); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.sg-carte[data-s="healing"] .sg-etat { color: var(--ws-encre); background: var(--sg-infirm); box-shadow: inset 2px 0 0 var(--sg-infirm-croix); }
.sg-etat svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sg-metier { display: inline-flex; align-items: center; gap: 3px; font: 600 11px 'Alegreya', serif; color: var(--ws-encre-2); }
.sg-metier svg { width: 14px; height: 14px; stroke-width: 2; }
.sg-jauges { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr auto; gap: 1px 6px; align-items: center; margin-top: 4px;
  font: 600 11px 'Alegreya', serif; color: var(--ws-encre-2); }
.sg-jauges b { font-weight: 700; color: var(--ws-encre); text-align: right; font-variant-numeric: tabular-nums; }
.sg-j { --jc: var(--hp); height: 6px; border-radius: 3px; background: rgba(60, 35, 10, .22); overflow: hidden; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .3); }
.sg-j[data-k="ap"] { --jc: var(--ap); }
.sg-j[data-k="ep"] { --jc: var(--ep); }
.sg-j i { display: block; height: 100%; width: 0; background: var(--jc); border-radius: 3px; }
.sg-j[data-bas] i { background: repeating-linear-gradient(135deg, var(--jc) 0 4px, color-mix(in srgb, var(--jc) 70%, #000) 4px 8px); }
.sg-jauges .sg-off { grid-column: 2 / -1; font-style: italic; font-weight: 400; }
/* Place libre : une fiche vierge épinglée, à recruter. */
:root:root:root:root .sg-scene .sg-carte.sg-vide {
  grid-template-columns: 1fr; justify-items: center; align-content: center; gap: 2px; min-height: 104px; text-align: center; color: var(--ws-parch-2);
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03) 0 8px, transparent 8px 16px), rgba(0, 0, 0, .25);
  box-shadow: inset 0 0 0 1px var(--ws-laiton-lo); outline: 1px dashed var(--ws-laiton); outline-offset: -6px;
  &:hover { color: var(--ws-parch); box-shadow: inset 0 0 0 1px var(--ws-laiton), 0 0 14px var(--sg-foyer); }
  b { font: 700 15px 'Cinzel', serif; }
  .sg-plus { font: 400 28px/1 'Cinzel', serif; color: var(--ws-laiton-hi); }
  &[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
}
.sg-banc-vide { display: grid; gap: 8px; justify-items: center; padding: 22px 12px; margin: 0; text-align: center; color: var(--ws-parch-2); font-size: 15px; }
.sg-banc-vide svg { width: 54px; height: 54px; stroke: currentColor; fill: none; stroke-width: 1.6; color: var(--ws-laiton); }
.sg-banc-vide p { margin: 0; }

/* ---------- Petits écrans ---------- */
.sg-mobile-recrue { display: none !important; }
@media (max-width: 900px) {
  .sg-corps { grid-template-columns: minmax(0, 1fr); }
  :root:root:root:root .sg-scene .sg-carte[aria-pressed="true"]::after { content: none; }
  /* la tablée devient un bandeau qu'on fait défiler : la fiche reste juste dessous */
  .sg-cartes { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(200px, 62%); overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; }
  .sg-carte { scroll-snap-align: start; }
  :root:root:root:root .sg-scene .sg-groupe, .sg-banc .sg-tri { display: none; }
}
@media (max-width: 760px) {
  :root:root:root:root .ws-scene.sg-scene[data-fond] {
    background-size: auto 340px, auto; background-position: 50% calc(var(--mur-off, 300px) - 104px), 0 0; padding: 10px;
    .ws-lueurs { display: none; }
    .sg-mur { height: 150px; margin-top: 0; }
    .sg-avis { display: none; }
    .ws-enseigne { grid-template-columns: auto minmax(0, 1fr); }
  }
  .sg-blason, .sg-blason svg { width: 44px; height: 52px; }
  :root:root:root:root .sg-scene .sg-titre h1 { font-size: 22px; }
  .sg-bourse { grid-column: 1 / -1; justify-items: start; }
  .sg-boutons { justify-content: flex-start; }
  :root .sg-mobile-recrue { display: inline-flex !important; }
}

/* Fiche : Partir au front, Voir au front, Quitter le front (anciens boutons des tuiles). */
.sheet-front { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* =====================================================================================================================
 * La fiche du mercenaire (RG3) : un grand parchemin cloué (.ws-fiche des Ateliers). En-tête : tapis et pion orientable,
 * identité, insignes, barre d'XP, état physique, quatre caractéristiques ; puis les signets et le volet ouvert.
 * ===================================================================================================================== */
:root:root:root:root .sg-scene :is(.sg-fiche, .sg-contrat) {
  /* Les volets gardent leur code (sheet-*.js) et lisent les variables de thème : sur le parchemin, elles prennent ses
     encres et ses filets (les --text, --muted… du :root sont déjà résolus : on les redéfinit aussi). */
  --ink: var(--ws-encre); --ink-soft: var(--ws-encre-2); --text: var(--ws-encre); --muted: var(--ws-encre-2);
  --line: rgba(90, 60, 25, .35); --line-strong: var(--ws-encre-2); --border: rgba(90, 60, 25, .35);
  --paper: rgba(255, 250, 235, .35); --paper-2: rgba(255, 250, 235, .55); --paper-3: rgba(90, 60, 25, .12);
  --surface: rgba(255, 250, 235, .45); --bg: rgba(90, 60, 25, .1); --accent: #8c2a1c; --sur-accent: #fff4d8;
  min-width: 0; color: var(--ws-encre); font: 400 15px/1.4 'Alegreya', serif;
  a:not(.sg-btn) { color: #8c2a1c; }
  h2, h3, h4 { color: var(--ws-encre); }
}
.sg-fiche-haut { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(220px, 300px); gap: 18px; align-items: start; }
.sg-tapis { position: relative; width: 132px; height: 132px; display: grid; place-items: center; border-radius: 50%;
  background: var(--sg-dalle) center / 66px; box-shadow: 0 0 0 3px #0b0b0c, 0 0 0 5px var(--ws-laiton), 0 0 0 7px #0b0b0c, inset 0 0 26px rgba(0, 0, 0, .7), 0 8px 18px rgba(0, 0, 0, .45); }
.sg-fiche[data-hero] .sg-tapis { background-image: var(--sg-plancher); }
.sg-tapis canvas { width: 104px; height: 104px; image-rendering: pixelated; }
.sg-tourner { position: absolute; bottom: -10px; left: 50%; translate: -50% 0; display: flex; gap: 2px; }
:root:root:root:root .sg-scene .sg-tourner button {
  width: 26px; height: 22px; padding: 0; margin: 0; cursor: pointer; border-radius: 3px; color: var(--ws-parch); clip-path: none; box-shadow: none;
  font: 700 13px/1 'Alegreya', serif; background: var(--ws-fer); border: 1px solid #0b0b0c;
  &::before, &::after { content: none; }
  &:hover { background: var(--ws-fer-hi); }
}
.sg-nom-l { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
:root:root:root:root .sg-scene .sg-id h2 { font: 700 clamp(24px, 2.8vw, 32px)/1.05 'Cinzel', serif; color: var(--ws-encre); margin: 2px 0 4px; }
.sg-liens { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
:root:root:root:root .sg-scene .sg-fiche .sg-lien { color: #8c2a1c; }
.sg-vers-liste { display: none; }
.sg-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; font-size: 14px; }
.sg-form input { min-width: 0; width: 12em; }
.sg-id .sg-qui { font-size: 16px; white-space: normal; }
.sg-insignes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.sg-insigne { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 2px; font: 700 13px 'Alegreya SC', serif;
  background: rgba(90, 60, 25, .14); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .35); color: var(--ws-encre); }
.sg-insigne svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sg-insigne .trade-emblem { width: 15px; height: 15px; }
.sg-insigne[data-grade] { background: linear-gradient(180deg, var(--ws-laiton-hi), var(--ws-laiton)); box-shadow: inset 0 0 0 1px var(--ws-laiton-lo); color: #2a1405; }
.sg-insigne.sg-etat { color: #fff7e6; background: var(--c); }
.sg-fiche[data-s="healing"] .sg-insigne.sg-etat { color: var(--ws-encre); background: var(--sg-infirm); }
.sg-xpbar { display: grid; gap: 3px; max-width: 520px; }
.sg-xpbar-l { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ws-encre-2); }
.sg-xpbar-l b { color: var(--ws-encre); }
.sg-xptrack { position: relative; height: 10px; border-radius: 5px; background: rgba(60, 35, 10, .25); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); overflow: hidden; }
.sg-xptrack i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 5px; background: linear-gradient(90deg, var(--ws-laiton-lo), var(--ws-laiton-hi)); }
.sg-xptrack s { position: absolute; inset: 0 auto 0 0; width: 0; background: repeating-linear-gradient(135deg, rgba(255, 240, 200, .45) 0 3px, transparent 3px 6px); }
.sg-depense { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; font-size: 15px; }
.sg-depense strong { font: 700 17px 'Cinzel', serif; color: var(--sg-braise); }
.sg-note { margin: 0; font-size: 13px; color: var(--ws-encre-2); }

/* État physique : trois grandes jauges, le mot de la santé, les ordres de front. */
.sg-corps-etat { display: grid; gap: 9px; padding: 12px 14px; border-radius: 3px; background: rgba(90, 60, 25, .1); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .3); }
:root:root:root:root .sg-scene .sg-corps-etat h3 { margin: 0; font: 700 13px 'Alegreya SC', serif; letter-spacing: .08em; color: var(--ws-encre-2); }
.sg-g { display: grid; gap: 3px; }
.sg-g-l { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 14px; }
.sg-g-l b { font: 700 15px 'Alegreya', serif; font-variant-numeric: tabular-nums; }
.sg-g-l small { color: var(--ws-encre-2); }
.sg-g .sg-j { height: 10px; border-radius: 5px; }
.sg-sante { font: italic 600 15px 'Alegreya', serif; }
:root:root:root:root .sg-scene .sg-sante.hp-state { padding: 0; background: none; box-shadow: none; }
.sheet-front { margin-top: 2px; }

/* Caractéristiques : quatre médaillons gravés, valeur, plafond du grade, barre. */
.sg-caracs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.sg-carac { --k: #8a6a2a; position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 10px; align-items: center; padding: 8px 10px;
  border-radius: 3px; background: linear-gradient(180deg, rgba(255, 250, 235, .55), rgba(255, 250, 235, .15)); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .3); }
.sg-carac[data-k="str"] { --k: #a8261b; } .sg-carac[data-k="dex"] { --k: #3d72b8; } .sg-carac[data-k="agi"] { --k: #4f7f2c; }
.sg-carac-ico { grid-row: span 2; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ws-laiton-hi);
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--k) 55%, #000), #120c08 78%); box-shadow: 0 0 0 2px var(--ws-laiton), 0 0 0 3px #0b0b0c; }
.sg-carac-ico svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sg-carac-n { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font: 700 12px 'Alegreya SC', serif; letter-spacing: .04em; color: var(--ws-encre-2); }
.sg-carac-v { font: 700 26px/1 'Cinzel', serif; color: var(--ws-encre); }
.sg-carac-v small { font: 600 13px 'Alegreya', serif; color: var(--ws-ok); }
.sg-carac .sg-j { --jc: var(--k); grid-column: 1 / -1; height: 5px; margin-top: 4px; }

/* Signets : des rubans de tissu cousus au haut du volet. */
.sg-signets { display: flex; flex-wrap: wrap; gap: 4px; margin: 22px 0 0; padding: 0 6px; border-bottom: 2px solid var(--ws-encre-2); }
:root:root:root:root .sg-scene .sg-signet {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px 6px; margin: 0; cursor: pointer; clip-path: none;
  font: 700 13px 'Cinzel', serif; letter-spacing: .03em; text-transform: none; color: var(--ws-encre-2); border: 0; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(90, 60, 25, .16), rgba(90, 60, 25, .28)); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .3);
  &::before, &::after { content: none; }
  &:hover { color: var(--ws-encre); background: rgba(90, 60, 25, .1); }
  &[aria-selected="true"] { color: #fff4d8; background: linear-gradient(180deg, #8c2a1c, #5e1810); box-shadow: inset 0 0 0 1px #3a0d07, 0 -2px 8px rgba(160, 40, 20, .35); }
  svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .ws-dot { width: 7px; height: 7px; }
}

/* Le volet ouvert : les modules existants (sheet-*.js), rhabillés sur le parchemin. */
:root:root:root:root .sg-scene .sg-volet {
  padding: 16px 4px 0; min-height: 220px;
  &.sg-neuf { animation: sg-apparait .18s ease; }   /* au changement de signet seulement, pas au rafraîchissement */
  h3 { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font: 700 15px 'Cinzel', serif; letter-spacing: .06em; color: var(--ws-encre); }
  h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(90, 60, 25, .5), transparent); }
  h3:first-child { margin-top: 0; }
  h4 { margin: 12px 0 6px; font: 700 13px 'Alegreya SC', serif; letter-spacing: .05em; color: var(--ws-encre-2); }
  .small, .muted { color: var(--ws-encre-2); }
  table { width: 100%; border-collapse: collapse; font-size: 14px; background: none; }
  th { text-align: left; font: 700 12px 'Alegreya SC', serif; letter-spacing: .04em; color: var(--ws-encre-2); padding: 4px 8px; border: 0; border-bottom: 1px solid rgba(90, 60, 25, .4); background: none; }
  td { padding: 5px 8px; border: 0; border-bottom: 1px dotted rgba(90, 60, 25, .3); font-variant-numeric: tabular-nums; background: none; }
  .gauge { height: 6px; border-radius: 3px; background: rgba(60, 35, 10, .22); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .3); }
  .gauge i { border-radius: 3px; background: var(--ws-laiton-lo); }
  .train-line { padding: 6px 8px; margin-bottom: 6px; border-radius: 3px; background: rgba(90, 60, 25, .08); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .22); }
  .derived { gap: 8px; }
  .derived > div { padding: 7px 10px; border-radius: 3px; background: rgba(90, 60, 25, .1); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .25); border: 0; }
  .derived b { font: 700 20px 'Cinzel', serif; color: var(--ws-encre); }
  .slot { border-radius: 3px; background: rgba(90, 60, 25, .1); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .25); border: 0; }
  .reports { max-height: 420px; overflow-y: auto; padding-right: 6px; font-size: 14px; }
  .reports li { border-radius: 0; margin: 0; padding: 5px 8px; background: none; border-bottom: 1px dotted rgba(90, 60, 25, .3); }
  .reports li.day { padding: 10px 0 4px; border: 0; background: none; font: 700 13px 'Alegreya SC', serif; letter-spacing: .05em; color: var(--ws-encre-2); }
  .tabs { gap: 0; width: fit-content; max-width: 100%; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--ws-encre-2); border: 0; padding: 0; }
  .tabs button { margin: 0; border: 0; border-radius: 0; border-right: 1px solid rgba(90, 60, 25, .4); clip-path: none; box-shadow: none;
    padding: 6px 14px; font: 700 14px 'Alegreya', serif; text-transform: none; letter-spacing: 0; color: var(--ws-encre); background: rgba(255, 250, 235, .4); }
  .tabs button:last-child { border-right: 0; }
  .tabs button:is([aria-pressed="true"], [aria-selected="true"]) { color: #fff4d8; background: linear-gradient(180deg, #8c2a1c, #5e1810); }
  input:not([type="checkbox"], [type="radio"], [type="range"]), select { color: var(--ws-encre); background: rgba(255, 250, 235, .7); border: 1px solid rgba(90, 60, 25, .45); }
  input[type="range"] { accent-color: var(--sg-braise); }
  input[type="checkbox"] { accent-color: var(--ws-ok); }
}
@keyframes sg-apparait { from { opacity: 0; translate: 0 4px; } }
@media (prefers-reduced-motion: reduce) { :root:root:root:root .sg-scene .sg-volet { animation: none; } }

@media (max-width: 1100px) {
  .sg-fiche-haut { grid-template-columns: auto minmax(0, 1fr); }
  .sg-corps-etat { grid-column: 1 / -1; }
  .sg-caracs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sg-vers-liste { display: inline; }
}
@media (max-width: 760px) {
  :root:root:root:root .sg-scene .sg-fiche { padding: 14px 12px 16px; margin: 6px 4px; }
  .sg-fiche-haut { grid-template-columns: minmax(0, 1fr); }
  .sg-tapis { justify-self: center; }
  .sg-carac-n { flex-direction: column; align-items: flex-start; gap: 0; }
  .sg-caracs { gap: 6px; }
  .sg-carac { grid-template-columns: 34px minmax(0, 1fr); padding: 6px 8px; }
  .sg-carac-ico { width: 34px; height: 34px; }
  .sg-carac-v { font-size: 22px; }
  .sg-signets { gap: 3px; padding: 0; }
  :root:root:root:root .sg-scene .sg-signet { padding: 7px 8px 6px; }
  .sg-signet span.sg-long { display: none; }
  .sg-signet[aria-selected="true"] span.sg-long { display: inline; }
  .train-line { grid-template-columns: minmax(0, 1fr) auto; }
  .train-line .train-level { grid-column: 1 / -1; grid-row: 2; }
}

/* =====================================================================================================================
 * Le tableau des engagements (RG4, garde/recruit.js) : le liège et ses affiches de race, puis le contrat.
 * ===================================================================================================================== */
#recrue[hidden], #salle[hidden] { display: none; }
.sg-recrue { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 16px; align-items: start; }
.sg-liege { padding: 14px; margin: 8px; border-radius: 4px; background: var(--ws-grain), radial-gradient(130% 100% at 50% 0%, var(--sg-liege), var(--sg-liege-2));
  box-shadow: 0 0 0 3px #0b0b0c, 0 0 0 6px var(--ws-bois-3), 0 0 0 8px #0b0b0c, inset 0 0 40px rgba(0, 0, 0, .55); }
.sg-liege-tete { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
:root:root:root:root .sg-scene .sg-liege-tete h2 { margin: 0; font: 700 22px 'Cinzel', serif; color: var(--ws-laiton-hi); text-shadow: 0 2px 0 #000; }
.sg-liege-tete p { margin: 0; color: var(--ws-parch-2); font-size: 14px; }
.sg-affiches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; }
:root:root:root:root .sg-scene .sg-affiche {
  --r: 0deg; position: relative; display: grid; justify-items: center; align-content: start; gap: 4px; padding: 16px 8px 10px; margin: 0; cursor: pointer;
  border: 0; border-radius: 1px; clip-path: none; text-transform: none; letter-spacing: 0;
  color: var(--ws-encre); font: 400 13px/1.25 'Alegreya', serif; background: var(--ws-grain), linear-gradient(180deg, var(--ws-parch), var(--ws-parch-2));
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .35), 0 6px 10px rgba(0, 0, 0, .35); rotate: var(--r); transition: rotate .15s, transform .15s, box-shadow .15s;
  &:nth-child(3n) { --r: 1.2deg; } &:nth-child(3n+1) { --r: -1deg; } &:nth-child(4n+2) { --r: .6deg; }
  &::before { content: ""; position: absolute; top: -6px; left: 50%; translate: -50% 0; width: 16px; height: 16px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--sg-cire-hi), var(--sg-cire) 60%, #4a0c08); box-shadow: 0 2px 3px rgba(0, 0, 0, .6); }
  &::after { content: none; }
  &:hover { rotate: 0deg; transform: translateY(-3px); }
  &[aria-pressed="true"] { rotate: 0deg; transform: translateY(-3px) scale(1.03); box-shadow: 0 0 0 2px var(--ws-laiton-hi), 0 0 18px rgba(255, 200, 110, .45), 0 10px 16px rgba(0, 0, 0, .45); }
  h3 { margin: 0; font: 700 16px 'Cinzel', serif; letter-spacing: .03em; color: var(--ws-encre); }
  .sg-portrait { grid-row: auto; width: 72px; height: 72px; background-size: 72px; }
  .sg-portrait canvas { width: 64px; height: 64px; }
  small { color: var(--ws-encre-2); font-style: italic; text-align: center; }
}
.sg-bonus { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.sg-bonus span { font: 700 11px 'Alegreya', serif; padding: 0 5px; border-radius: 2px; background: rgba(90, 60, 25, .14); }
.sg-bonus span.plus { color: var(--ws-ok); } .sg-bonus span.minus { color: var(--ws-ko); }
:root:root:root:root .sg-scene .sg-contrat {
  h2 { margin: 0 0 4px; font: 700 24px 'Cinzel', serif; color: var(--ws-encre); }
  h3 { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px; font: 700 14px 'Cinzel', serif; letter-spacing: .05em; color: var(--ws-encre); }
  h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(90, 60, 25, .5), transparent); }
  .derived { gap: 6px; }
  .derived > div { padding: 6px 8px; border-radius: 3px; background: rgba(90, 60, 25, .1); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .25); border: 0; font-size: 13px; }
  .derived b { font: 700 18px 'Cinzel', serif; color: var(--ws-encre); }
}
.sg-apercu { display: flex; justify-content: center; align-items: flex-end; gap: 10px; min-height: 110px; margin: 10px 0 4px; padding: 8px;
  border-radius: 3px; background: var(--sg-dalle) center / 48px; box-shadow: inset 0 0 0 2px #0b0b0c, inset 0 0 22px rgba(0, 0, 0, .65); }
.sg-apercu canvas { image-rendering: pixelated; }
.sg-lignees { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
:root:root:root:root .sg-scene .sg-lignee {
  display: grid; justify-items: center; gap: 4px; padding: 8px; margin: 0; cursor: pointer; border: 0; border-radius: 3px; clip-path: none; text-transform: none;
  font: 700 13px 'Alegreya', serif; letter-spacing: 0; color: var(--ws-encre); background: rgba(90, 60, 25, .1); box-shadow: inset 0 0 0 1px rgba(90, 60, 25, .3);
  &::before, &::after { content: none; }
  &[aria-pressed="true"] { background: rgba(255, 250, 235, .7); box-shadow: inset 0 0 0 2px var(--ws-laiton), 0 0 10px rgba(200, 140, 40, .35); }
  .sg-portrait { grid-row: auto; }
}
.sg-nomligne { display: flex; gap: 6px; align-items: center; margin: 8px 0; }
:root:root:root:root .sg-scene .sg-nomligne input { flex: 1; min-width: 0; padding: 6px 10px; font: 700 18px 'Cinzel', serif; color: var(--ws-encre);
  background: rgba(255, 250, 235, .6); border: 0; border-bottom: 2px solid var(--ws-encre-2); border-radius: 2px 2px 0 0; }
.sg-points { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 6px; font-size: 14px; }
.sg-points b { font: 700 18px 'Cinzel', serif; }
.sg-points[data-reste] b { color: var(--ws-ko); }
.sg-repart { display: grid; gap: 6px; }
.sg-repart-l { display: grid; grid-template-columns: 30px 1fr auto auto auto; gap: 8px; align-items: center; }
.sg-repart-l .sg-carac-ico { --k: #8a6a2a; width: 30px; height: 30px; grid-row: auto; }
.sg-repart-l .sg-carac-ico[data-k="str"] { --k: #a8261b; } .sg-repart-l .sg-carac-ico[data-k="dex"] { --k: #3d72b8; } .sg-repart-l .sg-carac-ico[data-k="agi"] { --k: #4f7f2c; }
.sg-repart-l .sg-carac-ico svg { width: 17px; height: 17px; }
.sg-repart-l small { color: var(--ws-encre-2); font-size: 12px; }
.sg-repart-l b { font: 700 18px 'Cinzel', serif; min-width: 2ch; text-align: center; }
:root:root:root:root .sg-scene .sg-pm {
  width: 28px; height: 28px; padding: 0; margin: 0; cursor: pointer; border-radius: 50%; clip-path: none; box-shadow: none;
  font: 700 16px/1 'Alegreya', serif; color: var(--ws-parch); background: var(--ws-fer); border: 1px solid #0b0b0c;
  &::before, &::after { content: none; }
  &:hover:not(:disabled) { background: var(--ws-fer-hi); }
  &:disabled { opacity: .35; cursor: not-allowed; }
}
.sg-signature { display: grid; justify-items: center; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(90, 60, 25, .35); }
.sg-signature .ws-frapper { min-width: min(100%, 300px); }
.sg-signature p { margin: 0; font-size: 13px; color: var(--ws-encre-2); text-align: center; }
/* Page /recrutement : pas d'enseigne au-dessus du mur. */
:root:root:root:root body[data-page="recruit"] .sg-scene { --mur-off: 0px; }
@media (max-width: 900px) { .sg-recrue { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .sg-affiches { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .sg-liege { margin: 6px 2px; padding: 10px; }
  :root:root:root:root .sg-scene .sg-contrat { margin: 6px 2px; padding: 14px 12px 16px; }
}
