/* Wikiclash — composants de base (README §4). Uniquement des variables de tokens.css. */

/* ---------- structure : plein écran, sans scroll de page ---------- */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 900ms ease; pointer-events: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
body[style*="zoom"] #app, body[style*="zoom"] #bg { position: absolute; }
.wc-screen {
  position: absolute; inset: 0; display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr) var(--foot-h); grid-template-columns: minmax(0, 1fr);
  opacity: 0; transition: opacity 500ms ease; user-select: none; -webkit-user-select: none; cursor: default;
}
.wc-screen.in { opacity: 1; }
.wc-main { min-height: 0; overflow: hidden; padding: var(--pad-y) var(--pad-x); }
.scroll-y { overflow-y: auto; scrollbar-width: none; }
.scroll-y::-webkit-scrollbar { display: none; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wc-fatal { grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: 15px; color: var(--err); }

/* ---------- logo ---------- */
.wc-logo { display: block; flex: none; height: auto; overflow: visible; }
.wc-logo .lg-w { stroke: var(--ink); }
.wc-logo .lg-ink { fill: var(--ink); stroke: var(--ink); }
.wc-logo .lg-mid { fill: var(--bg); stroke: var(--ink); }
.wc-logo .lg-end, .wc-logo .lg-ring { fill: var(--link); stroke: var(--link); }
.wc-logo .lg-ring { fill: none; }
.wc-word { font-family: var(--serif); line-height: 1; letter-spacing: .06em; font-variant: small-caps; color: var(--ink); }
.wc-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wc-stack .wc-word { font-size: calc(var(--u) * .8); }

/* ---------- barre haute (64 px) ---------- */
.wc-top {
  display: flex; align-items: center; gap: 28px; padding: 0 var(--pad-x); border-bottom: 1px solid var(--bg3);
  background: var(--bg); min-width: 0; position: relative; z-index: 5;
}
.crumbs { display: flex; align-items: baseline; gap: 8px; font-size: 13px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--ln); }
.crumbs .cur { color: var(--ink); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 28px; flex: none; }
.tb-bal, .tb-user { display: flex; align-items: baseline; gap: 8px; }
.tb-bal b, .tb-user b { font-family: var(--serif); font-weight: 400; font-size: 19px; color: var(--ink); }
.tb-bal span, .tb-user span { font-size: 13px; color: var(--mut); }
.tb-bal b { display: inline-block; transform-origin: right center; }
.tb-bal.up b { color: var(--ok); transition: color 400ms ease; }
.tb-bal .tb-pz { width: 16px; height: 16px; color: var(--link) !important; margin: 0 -3px 0 -2px; }
.tb-sound { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; font-size: 13px; color: var(--link); cursor: pointer; min-width: 120px; justify-content: flex-end; }
.tb-sound .cap { color: var(--mut); font-style: italic; opacity: 0; transition: opacity 400ms ease; white-space: nowrap; }
.tb-sound .cap.on { opacity: 1; }
.tb-sound:hover span { text-decoration: underline; }
.tb-sound:focus-visible, .crumbs a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------- pied de page clavier (56 px) ---------- */
.wc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 var(--pad-x);
  border-top: 1px solid var(--bg3); background: rgba(var(--ovr), .9); min-width: 0; position: relative; z-index: 5;
}
.wc-foot .keys { display: flex; align-items: center; gap: 22px; font-size: 13px; color: var(--sub); white-space: nowrap; flex: none; }
.wc-foot .kb { display: flex; align-items: center; gap: 6px; }
.wc-foot .help { font-size: 12px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wc-key { display: inline-block; border: 1px solid var(--ln2); border-bottom-width: 2px; border-radius: var(--radius-key); padding: 0 6px; background: var(--bg2); font-family: var(--sans); font-size: 12px; line-height: 18px; color: var(--sub); font-weight: 400; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: var(--radius-btn); cursor: pointer;
  font-weight: 700; font-size: 14px; padding: 7px 16px; border: 1px solid transparent; white-space: nowrap; text-decoration: none !important;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.btn-p { background: var(--link); color: var(--on); border-color: var(--link); }
.btn-p:hover { background: var(--link2); border-color: var(--link2); color: var(--on); }
.btn-s { background: var(--bg2); color: var(--ink); border-color: var(--ln); }
.btn-s:hover { border-color: var(--link); color: var(--ink); }
.btn-d { background: var(--bg); color: var(--err); border-color: var(--err); }
.btn-d:hover { background: var(--err); color: var(--on); }
.btn-l { background: none; border-color: transparent; color: var(--link); padding-left: 8px; padding-right: 8px; }
.btn-l:hover { text-decoration: underline !important; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--bg3); color: var(--mut); border-color: var(--ln2); cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.btn .wc-key { font-weight: 400; }
.btn-p .wc-key { background: transparent; color: var(--on); border-color: rgba(var(--ovr), .5); }
.seg { display: inline-flex; border: 1px solid var(--ln); border-radius: var(--radius-btn); overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--ln); }
.seg button.on { background: var(--ink); color: var(--on); }
.seg button:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }

/* champs */
.wc-input { border: 1px solid var(--ln); border-radius: var(--radius-btn); background: var(--bg); padding: 7px 10px; font-size: 14px; color: var(--ink); min-width: 0; }
.wc-input::placeholder { color: var(--mut); }
.wc-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); }

/* ---------- carte de jeu (5 × 7) ---------- */
.gcard {
  --rc: var(--ln); position: relative; aspect-ratio: 5 / 7; background: var(--bg); border: 1px solid var(--ln); border-top: 5px solid var(--rc);
  padding: clamp(5px, .8vw, 10px); display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow: hidden; container-type: size;
  transition: transform 160ms var(--ease-out), box-shadow 160ms ease, outline-color 160ms ease, opacity 200ms ease;
  outline: 2px solid transparent; outline-offset: 2px;
}
.gcard[tabindex], .gcard.hoverable { cursor: pointer; }
.gcard.hoverable:hover, .gcard:focus-visible, .gcard.focus { transform: translateY(-3px); box-shadow: var(--shadow-card); outline-color: var(--link); }
.gcard.k-no { opacity: .5; }
.gcard.k-used { opacity: .35; border-style: dashed; }
.gcard.missing { border-style: dashed; }
.gcard.missing .gc-title { color: var(--err); }
.gc-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.gc-prox { font-family: var(--serif); font-weight: 400; font-size: clamp(16px, 22cqh, 30px); line-height: 1; color: var(--ink); }
.gc-tag { font-size: 11px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-ok .gc-tag { color: var(--ok); }
.k-used .gc-tag { color: var(--link); }
.gc-direct { margin-left: auto; color: var(--link); font-size: 14px; }
.gc-meta { display: flex; justify-content: space-between; gap: 6px; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); white-space: nowrap; min-width: 0; }
.gc-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.gc-rar { display: inline-flex; align-items: center; gap: 4px; color: var(--rc); font-weight: 600; }
.gc-rar i, .rar-dot { display: inline-block; width: 6px; height: 6px; background: var(--rc); flex: none; }
.gc-title { font-family: var(--serif); font-size: clamp(12px, 11cqh, 20px); line-height: 1.1; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gc-img { flex: 1; min-height: 0; border: 1px solid var(--bg3); background-size: cover; background-position: 50% 20%; }
@container (max-height: 120px) { .gc-img { display: none; } }
.gc-common { font-family: var(--serif); font-style: italic; font-size: 11px; color: var(--link); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- infobox ---------- */
.wc-infobox { border-collapse: collapse; border: 1px solid var(--ln); background: var(--bg2); font-size: 13px; width: 100%; }
.wc-infobox caption { font-family: var(--serif); font-size: 17px; text-align: left; padding: 0 0 6px; color: var(--ink); }
.wc-infobox th { background: var(--bg3); font-weight: 700; font-size: 12px; text-align: left; padding: 5px 10px; vertical-align: top; white-space: nowrap; }
.wc-infobox td { background: var(--bg); padding: 5px 10px; color: var(--ink); }
.wc-infobox tr + tr th, .wc-infobox tr + tr td { border-top: 1px solid var(--bg2); }

/* ---------- onglets façon Wikipédia ---------- */
.wc-tabs { display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--ln); }
.wc-tabs button { border: 1px solid transparent; border-bottom: 0; background: none; padding: 6px 14px; margin-bottom: -1px; font-size: 13px; color: var(--link); cursor: pointer; }
.wc-tabs button:hover { text-decoration: underline; }
.wc-tabs button.on { border-color: var(--ln); background: var(--bg); color: var(--ink); text-decoration: none; cursor: default; }
.wc-tabs button:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }

/* ---------- overlay / fenêtre ---------- */
.wc-ovl {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(var(--ovr), .9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 300ms ease;
}
.wc-ovl.in { opacity: 1; }
.wc-box {
  background: var(--bg); border: 1px solid var(--ln); box-shadow: var(--shadow-modal); padding: 24px 28px; max-width: min(560px, 100%); max-height: calc(100% - 16px);
  overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: 14px; transform: translateY(16px); transition: transform 400ms var(--ease-out);
}
.wc-ovl.in .wc-box { transform: none; }
.wc-box h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 4vh, 32px); line-height: 1.1; border-bottom: 1px solid var(--ln); padding-bottom: 8px; }
.wc-box p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--sub); }
.wc-box .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- toast ---------- */
.wc-toast { font-size: 13px; opacity: 0; transition: opacity 240ms ease; min-height: 18px; }
.wc-toast.on { opacity: 1; }
.wc-toast.ok { color: var(--ok); }
.wc-toast.err { color: var(--err); }

/* ---------- fiche de survol (264 px) ---------- */
.wc-sheet {
  position: fixed; z-index: 40; width: 264px; max-height: calc(100vh - 16px); overflow: hidden; background: var(--bg); border: 1px solid var(--ln);
  border-top: 5px solid var(--rc, var(--ln)); box-shadow: var(--shadow-float); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; opacity: 0; transform: scale(.97); transition: opacity 160ms ease, transform 200ms var(--ease-out);
}
.wc-sheet.on { opacity: 1; transform: none; }
.wc-sheet .sh-title { font-family: var(--serif); font-size: 20px; line-height: 1.1; color: var(--ink); }
.wc-sheet .sh-img { height: 110px; background-size: cover; background-position: 50% 20%; border: 1px solid var(--bg3); }
@media (max-height: 700px) { .wc-sheet .sh-img { display: none; } }
.wc-sheet .sh-meta { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.wc-sheet .sh-links { display: flex; flex-wrap: wrap; gap: 4px; }
.wc-sheet .sh-links span { font-family: var(--serif); font-size: 12px; color: var(--sub); border: 1px solid var(--bg3); padding: 0 5px; }
.wc-sheet .sh-links span.t { color: var(--link); font-weight: 600; }
.wc-sheet .sh-links span.v { color: var(--vis); font-weight: 600; }
.wc-sheet .sh-links span.n { border-color: var(--link); background: var(--sel); }
.wc-sheet .sh-state { font-size: 12px; color: var(--mut); }

/* ---------- écran de chargement ---------- */
#loader { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 450ms ease; }
#loader.on { opacity: 1; pointer-events: auto; }
.ld-box { width: min(560px, 80vw); display: flex; flex-direction: column; gap: 28px; background: rgba(var(--ovr), .92); padding: 32px; }
.ld-head { display: flex; flex-direction: column; gap: 10px; }
.ld-status { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); }
.ld-title { font-family: var(--serif); font-size: 48px; line-height: 1.05; color: var(--ink); }
.ld-bar { height: 2px; background: var(--bg3); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0; background: var(--link); transition: width 1300ms cubic-bezier(.4,.1,.3,1); }
.ld-fact { border: 1px solid var(--ln); background: var(--bg2); padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; }
.ld-fact .h { font-family: var(--serif); font-size: 17px; color: var(--ink); border-bottom: 1px solid var(--ln2); padding-bottom: 6px; }
.ld-fact p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink); }
.ld-esc { font-size: 13px; color: var(--link); opacity: 0; transition: opacity 400ms ease; }
.ld-esc.on { opacity: 1; }

/* ---------- titres ---------- */
.wc-h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(26px, 4.6vh, 40px); line-height: 1.1; color: var(--ink); border-bottom: 1px solid var(--ln); padding-bottom: 6px; }
.wc-h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(20px, 3.4vh, 26px); line-height: 1.15; color: var(--ink); }

/* ---------- mouvements réduits ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* liens d'un article (fiche de collection, ouverture de booster) */
.wc-lkbox { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.wc-lkbox .hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); border-bottom: 1px solid var(--bg3); padding-bottom: 4px; white-space: nowrap; }
.wc-lkbox .hd span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wc-lkbox .hd span + span { letter-spacing: 0; text-transform: none; font-size: 12px; color: var(--vis); }
.wc-lk { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 1px 12px; overflow-y: auto; min-height: 0; scrollbar-width: thin; padding-right: 4px; }
.wc-lk a { font-family: var(--serif); font-size: 15px; line-height: 1.4; color: var(--link); }
.wc-lk a.sh { color: var(--vis); }
.wc-lk sup { font-family: var(--sans); font-size: 9px; font-weight: 700; margin-left: 2px; color: var(--vis); }
.wc-lk a:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.wc-lk-none { margin: 0; font-size: 12px; color: var(--mut); font-style: italic; }
.wc-lk-none button { border: 0; background: none; padding: 0; font: inherit; font-style: normal; color: var(--link); cursor: pointer; }
/* liens v2 : étiquettes séparées, groupes repliables, filtre */
.wc-lk { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
.wc-lk .ch { display: flex; flex-wrap: wrap; gap: 4px; }
.wc-lk .ch a { display: inline-flex; align-items: baseline; gap: 2px; max-width: 100%; border: 1px solid var(--bg3); background: var(--bg2); padding: 1px 7px; font-size: 13px; line-height: 1.45; color: var(--link); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-lk .ch a:hover { border-color: var(--link); background: var(--sel); }
.wc-lk .ch a.sh { border-color: color-mix(in srgb, var(--vis) 55%, transparent); background: color-mix(in srgb, var(--vis) 10%, var(--bg)); color: var(--vis); }
.wc-lk .ch a[hidden] { display: none; }
.wc-lk details.gr { border-top: 1px solid var(--bg3); padding-top: 4px; }
.wc-lk details.gr[hidden] { display: none; }
.wc-lk details.gr:first-child { border-top: 0; padding-top: 0; }
.wc-lk summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--sub); padding: 2px 0 4px; user-select: none; }
.wc-lk summary::-webkit-details-marker { display: none; }
.wc-lk summary span::before { content: '▸'; display: inline-block; width: 12px; color: var(--mut); transition: transform 160ms ease; }
.wc-lk details[open] > summary span::before { transform: rotate(90deg); }
.wc-lk summary em { font-style: normal; letter-spacing: 0; color: var(--mut); }
.wc-lk details.g-shared summary { color: var(--vis); }
.wc-lk summary:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.wc-lkq { width: 100%; padding: 4px 8px; font-size: 13px; flex: none; }
.wc-lk .nf[hidden] { display: none; }
/* bouton de thème (barre haute) : pastille mi-claire mi-sombre */
.tb-theme { display: flex; align-items: center; gap: 7px; border: 0; background: none; padding: 0; font-size: 13px; color: var(--link); cursor: pointer; white-space: nowrap; }
.tb-theme i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--ink); background: linear-gradient(90deg, var(--ink) 50%, var(--bg) 50%); flex: none; transition: transform 300ms var(--ease-soft); }
:root[data-theme="dark"] .tb-theme i { transform: rotate(180deg); }
.tb-theme:hover span { text-decoration: underline; }
.tb-theme:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.pt-right .tb-theme { margin-right: -6px; }
/* pied de page rendu dans un conteneur (éditeur de deck, partie) : il occupe toute sa rangée, contenu centré */
[data-foot] { display: contents; }
