/*
 * Thème « Tapisserie du seigneur » : la tenture qui raconte les exploits de la compagnie. Trame discrète de
 * fils croisés, doubles bordures brodées, frises répétées, petites fleurs ; un médaillon à quatre pétales
 * désigne la sélection, les jauges sont des points de tissage. Teintures sourdes, pas de pixel ni de plomb.
 * Polices : IM Fell English (titres, noms), Alegreya Sans (texte), Bitter (chiffres, libellés).
 */
:root[data-ui="tapisserie"] {
  --paper: #e7dcc4; --paper-2: #efe6d2; --paper-3: #d9c9aa;
  --ink: #382b25; --ink-soft: #6c5944; --line: #b29b75; --line-strong: #76573d;
  --btn-top: #efe6d2; --btn-bot: #efe6d2; --icon: #382b25;
  --garance: #a34538; --gaude: #a17b32;
  --grid: #aa9879; --tile: #d0c1a3; --blocked: #62513d; --rough: #a37b4e;
  --player: #496a50; --bot: #a34538; --front: rgba(73, 106, 80, .18); --back: rgba(163, 69, 56, .14);
  --hp: #a34538; --ap: #496a50; --ep: #a17b32; --accent: #a34538;
  --title: "IM Fell English", Georgia, serif; --body: "Alegreya Sans", system-ui, sans-serif;
  --num: "Bitter", Georgia, serif;
}
:root[data-ui="tapisserie"][data-theme="dark"] {
    --paper: #29251f; --paper-2: #383027; --paper-3: #201c17;
    --ink: #e8dcc4; --ink-soft: #bca98c; --line: #6b5944; --line-strong: #b2966c; --icon: #e8dcc4;
    --btn-top: #383027; --btn-bot: #383027;
    --garance: #d77e6c; --gaude: #dfbd72;
    --grid: #655b45; --tile: #4b4434; --blocked: #211e19; --rough: #776044;
    --player: #8eb58b; --bot: #d77e6c; --front: rgba(142, 181, 139, .16); --back: rgba(215, 126, 108, .14);
    --hp: #e47d6c; --ap: #8eb58b; --ep: #dfbd72; --accent: #d77e6c;
    color-scheme: dark;
}

:root[data-ui="tapisserie"] {
  --act: var(--choix, var(--garance)); --on-act: var(--sur-choix, #f6efe0);
  --trame: repeating-linear-gradient(0deg, color-mix(in srgb, var(--line) 22%, transparent) 0 1px, transparent 1px 3px),
           repeating-linear-gradient(90deg, color-mix(in srgb, var(--line) 15%, transparent) 0 1px, transparent 1px 3px);
  --medaillon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 1a5 5 0 0 1 4.6 7A5 5 0 0 1 16 16a5 5 0 0 1-8 0A5 5 0 0 1 7.4 8 5 5 0 0 1 12 1zm0 8.6a2.4 2.4 0 1 0 0 4.8 2.4 2.4 0 1 0 0-4.8z'/%3E%3C/svg%3E");
  --frise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='M0 6h4l8-5 8 5h4M4 6l8 5 8-5' stroke='%23927452' fill='none'/%3E%3Ccircle cx='12' cy='6' r='1.8' fill='%23a34538'/%3E%3C/svg%3E") left center / 24px 12px repeat-x;
  --points: radial-gradient(circle, #000 0 2.4px, transparent 2.9px) 0 0 / 7px 7px;

  body { background: var(--paper); font-size: 15px; }
  h1, h2, .title { font-family: var(--title); font-weight: 400; }
  h1 { font-size: 30px; }
  h2 { font-size: 22px; }
  h3 { font: 400 17px var(--title); font-variant: small-caps; letter-spacing: .06em; color: var(--ink); }
  h3::after { border-top: 0; height: 12px; background: var(--frise); }
  a { color: var(--ink); text-decoration-color: var(--act); text-underline-offset: 3px; }
  .muted { color: var(--muted); }
  .small { font-size: 13px; color: var(--muted); }
  :focus-visible { outline: 2px dotted var(--act); outline-offset: 2px; }

  /* Boutons : pièces brodées à double bordure. */
  button, select, input { background: var(--paper-2); border: 3px double var(--line-strong); border-radius: 0; }
  button { background: var(--paper-3); color: var(--ink); font: 400 16px var(--title); }
  button:hover:not(:disabled) { background: var(--paper-2); }
  button:active:not(:disabled) { translate: 0 1px; }
  button:disabled { opacity: .45; }
  button.primary, a.btn.primary { background: var(--act); color: var(--on-act); border-color: var(--on-act); box-shadow: 0 0 0 2px var(--act); }
  button.danger { background: var(--paper-2); color: var(--garance); border-color: var(--garance); }
  select, input[type="text"], input[type="email"], input[type="number"] { color: var(--ink); font-family: var(--body); }
  input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--act); border: 0; }
  a.btn { background: var(--paper-3); color: var(--ink); border: 3px double var(--line-strong); font: 400 16px var(--title); }
  button.link { background: none; border: 0; box-shadow: none; color: var(--ink); text-decoration: underline 1px var(--act); font: inherit; }
  button.mini, .small-btn { font-size: 14px; }

  .ibtn { background: none; color: var(--icon); border: 3px double transparent; box-shadow: none; }
  .ibtn:hover:not(:disabled) { border-color: var(--line); }
  .ibtn[aria-current="page"] { border-color: var(--act); color: var(--act); }

  .pills { gap: 0; }
  .pill { border-left: 1px solid var(--line); font: 500 13.5px var(--num); padding: 2px 9px; }
  .pill:first-child { border-left: 0; }
  .pill small { font: 400 12px var(--title); font-variant: small-caps; opacity: .85; }
  .pill.warm, .pill.alert { color: var(--act); }

  /* Panneaux : toile tissée bordée d'une double broderie. */
  .paper, .panel, .log, .card-pane { background: var(--paper-2); background-image: var(--trame); border: 4px double var(--line-strong); }
  .notice.quiet { border: 0; }

  .topbar { background: var(--paper-3); background-image: var(--trame); border-bottom: 4px double var(--line-strong); }
  .topbar .muted, .topbar .small { color: var(--muted); }
  .avatar { background: var(--paper-2); color: var(--ink); border: 3px double var(--line-strong); font: 400 26px var(--title); }
  .hero-name { font: 400 22px/1 var(--title); }
  .hero-sub { font: 400 13px var(--title); font-variant: small-caps; letter-spacing: .06em; }
  .where .title { font-size: 19px; }
  .live { color: var(--act); }
  .settings-body { background: var(--paper-2); color: var(--ink); border: 4px double var(--line-strong); }
  .settings-body label { font: 400 14px var(--title); font-variant: small-caps; color: var(--muted); }
  .settings-body select { color: var(--text); }
  .rail { border-right: 4px double var(--line-strong); background: var(--paper-3); background-image: var(--trame); }
  .rail hr { border: 0; height: 12px; background: var(--frise); }
  @media (max-width: 760px) { .rail { border-right: 0; border-bottom: 4px double var(--line-strong); } }

  .board { background: var(--paper-2); background-image: var(--trame); border: 6px double var(--line-strong); padding: 16px; }
  @media (max-width: 760px) { .board { padding: 8px; } }
  .hint { color: var(--muted); font-size: 13px; font-style: italic; }
  .flash { color: var(--garance); font-style: italic; }
  .flash.ok { color: var(--ap); }

  .minimap { border: 4px double var(--line-strong); }
  .mm-pulse { border: 2px solid var(--act); border-radius: 50%; }
  .portrait canvas, canvas.skin { background: var(--paper-2); border: 4px double var(--line-strong); }
  .portrait-name .title { font-size: 34px; }
  .quote { font-style: italic; border-left: 3px double var(--line-strong); font-size: 14px; }
  .message .block + .block { border-top: 1px solid var(--line); }
  .message .block div:first-child { font-weight: 700; }

  /* Onglets : une lisière ; l'actif porte une petite fleur. */
  .side-tabs, .tabs { gap: 2px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); padding: 2px 0;
    background: repeating-linear-gradient(90deg, transparent 0 6px, color-mix(in srgb, var(--line) 30%, transparent) 6px 7px); }
  .side-tabs button, .tabs button, .look { background: none; border: 0; box-shadow: none; color: var(--muted); font: 400 16px var(--title); }
  .side-tabs button:active, .tabs button:active, .look:active { translate: none; }
  .side-tabs button[aria-pressed="true"], .tabs button[aria-pressed="true"], .look[aria-pressed="true"] { color: var(--act); background: var(--paper-2); }
  .side-tabs button[aria-pressed="true"]::before, .tabs button[aria-pressed="true"]::before, .look[aria-pressed="true"]::before { content: "❀ "; }
  .side-tabs { margin-bottom: 8px; }

  .who strong { font: 400 26px var(--title); }
  .tag { font: 500 12px var(--num); color: #fff; }

  /* Jauges : rangées de points de tissage. */
  .bar .label { font: 400 14px var(--title); font-variant: small-caps; }
  .bar .track { background: radial-gradient(circle, var(--line) 0 2px, transparent 2.5px) 0 0 / 7px 7px; height: 14px; }
  .bar .fill { -webkit-mask: var(--points); mask: var(--points); }
  .gauge, .wear { background: var(--paper-3); border: 1px solid var(--line); height: 7px; }
  .gauge i { background: var(--line-strong); }
  .wear i { background: var(--line-strong); }
  .wear i.low { background: var(--garance); }

  .stats { gap: 6px; }
  .stats div, .derived div { border: 3px double var(--line); font: 400 13px var(--title); font-variant: small-caps; color: var(--muted); }
  .stats b, .derived b { font: 700 26px/1.05 var(--num); color: var(--ink); }
  .derived b { font-size: 19px; }
  .derived b.over { color: var(--garance); }

  .log li, .reports li { border-left: 3px double var(--line); }
  .log li.system { border-color: var(--act); color: var(--muted); font-style: italic; }
  .log li.attack, .reports li.attack { border-color: var(--ink); }
  .log li.defense, .reports li.defense { border-color: var(--garance); }
  .log li.move, .log li.energy, .log li.info, .reports li.move, .reports li.energy, .reports li.info { color: var(--muted); }
  .log details { font-size: 13px; color: var(--muted); }
  .log summary { color: var(--text); font-size: 14px; }
  .log .t { font: 500 11.5px var(--num); color: var(--muted); }
  .reports { font-size: 14px; }

  .roster.faded { opacity: .75; }
  .chip { background: var(--paper-2); color: var(--ink); border: 3px double var(--line); box-shadow: none; font: 400 16px var(--title); }
  .chip:active { translate: none; }
  .chip small { font: 400 12px var(--title); font-variant: small-caps; color: var(--muted); }
  .chip.on { border-color: var(--act); background: var(--paper-3); }
  .chip.healing small { color: var(--garance); }
  .chip.map small { color: var(--ap); }
  table.train { font-size: 14px; }
  table.train td { border-bottom: 1px solid var(--line); }
  table.train td:nth-child(2), table.train tr.muted td { color: var(--muted); }

  .arena-head strong { font: 400 24px var(--title); }
  .companies li { border: 3px double var(--line); }
  .companies li.mine { border-color: var(--act); background: var(--paper-3); }
  .companies small { color: var(--muted); }
  .dot { background: var(--act); }

  .banner { background: var(--paper-3); background-image: var(--trame); border-bottom: 4px double var(--line-strong); }
  .banner .small, .banner .muted { color: var(--muted); }
  .banner-name { font: 400 36px/1 var(--title); }
  .gold-pill { font: 700 22px var(--num); color: var(--ink); }

  /* Mercenaires : panneaux brodés ; le choisi prend le médaillon. */
  .tile { background: var(--paper-2); background-image: var(--trame); color: var(--ink); border: 4px double var(--line); box-shadow: none; font: inherit; letter-spacing: 0; text-align: left; }
  .tile:hover:not(:disabled) { border-color: var(--line-strong); }
  .tile:active:not(:disabled) { translate: none; }
  .tile.on { border-color: var(--act); }
  .tile.on .tile-portrait::after { content: ""; position: absolute; left: 4px; top: 4px; width: 20px; height: 20px;
    background: var(--act); -webkit-mask: var(--medaillon) center/contain no-repeat; mask: var(--medaillon) center/contain no-repeat; }
  .tile-portrait { background: var(--paper); border: 1px solid var(--line); }
  .tile canvas.skin { border: 0; background: none; }
  .xp-badge { background: var(--act); color: var(--on-act); font: 500 11.5px var(--num); }
  .tile-name { font: 400 23px/1.05 var(--title); }
  .tile-row { font-size: 13px; color: var(--muted); }
  .tile-row b { color: var(--text); font: 500 13px var(--num); }
  .tile-empty { background: none; border-style: dashed; color: var(--muted); }
  .tile-plus { font: 400 38px var(--title); }

  .sheet-name { font: 400 42px/1 var(--title); }
  .train-line { border-bottom: 1px solid var(--line); }
  .stat-line { font-size: 14px; }
  .stat-line > span:nth-child(3) { font: 700 16px var(--num); }
  .trait { font-size: 14px; }
  .trait.plus b { color: var(--ap); }
  .trait.minus b { color: var(--garance); }
  .trait.zero { color: var(--muted); }
  .slot { background: var(--paper-2); border: 3px double var(--line); }
  .slot-empty, .slot-taken { border-style: dashed; border-width: 1px; background: none; }

  .status { font: 400 13px var(--title); font-variant: small-caps; color: var(--muted); }
  .status.map { color: var(--player); }
  .status.ready { color: var(--ap); }
  .status.resting { color: var(--gaude); }
  .status.healing { color: var(--garance); }
  .warn { color: var(--garance); font-size: 13px; font-style: italic; }
  .gold { font-family: var(--num); font-weight: 700; }
  .worn { font-size: 14px; }
  .worn th, .worn td { border-bottom: 1px solid var(--line); }
  .worn thead th { font: 400 14px var(--title); font-variant: small-caps; color: var(--ink); border-bottom: 3px double var(--line-strong); }
  .item { border-bottom: 1px solid var(--line); }
  .item:last-child { border-bottom: 0; }

  .brand .title { font: 400 54px/1 var(--title); color: var(--ink); }
  .brand .small { font-style: italic; font-size: 15px; }
  .page .card { background: var(--paper-2); background-image: var(--trame); border: 6px double var(--line-strong); }
  .page .error { color: var(--garance); font-style: italic; }
  .page .ok { color: var(--ap); }
  .page dt { color: var(--muted); font: 400 14px var(--title); font-variant: small-caps; }
  .page footer { font-size: 13px; color: var(--muted); }
  .skip { border-top: 1px solid var(--line); }
  .nav { font: 400 16px var(--title); }
  .nav a { color: var(--muted); text-decoration: none; }
  .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline 2px var(--act); }
}
