/* Ferme : interface par-dessus le monde (HUD, bulle, carte, registre, carte du monde).
   Tout est préfixé .ferme / .fe- pour cohabiter avec la feuille de style du jeu.
   Cadres pixel en box-shadow, comme le reste de la DA (voir docs/da/pixel-ui.md). */
.ferme {
  --u: 2px;
  --cream: #F8EED6; --paper: #F1E3C2; --paper-2: #E8D6AF; --paper-3: #D9C49A; --paper-edge: #B89C70;
  --wood-0: #24150C; --wood-1: #3E2716; --wood-2: #5A3A22; --wood-3: #6E4A2C; --wood-4: #845A36;
  --inkc: #2B1D14; --ink-muted: #6E5A44;
  --t0: #C4BBA8; --t1: #7CC25A; --t2: #E8B640; --t3: #F08A3C;
  --font: "Jersey 10", "Arial Narrow", system-ui, sans-serif;
  --font-s: "Silkscreen", "Jersey 10", monospace;
  --font-r: "Nunito", system-ui, -apple-system, sans-serif;
  --pxo: var(--wood-0); --pxbg: var(--paper); --pxhl: var(--cream); --pxsh: var(--paper-3); --pxdrop: rgba(20,10,4,.45); --dn: 3;
  position: relative; overflow: hidden; background: #2E5A22; color: var(--inkc);
  font-family: var(--font); font-size-adjust: 0.5; -webkit-font-smoothing: auto;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
.ferme * { box-sizing: border-box; }
.ferme [hidden] { display: none !important; }
.ferme button { font: inherit; color: inherit; border: 0; cursor: pointer; font-size-adjust: inherit; }
.ferme .fe-cv { position: absolute; inset: 0; display: block; image-rendering: pixelated; touch-action: none; }
.ferme :is(.fe-btn, .fe-title, .fe-bubble, .fe-toast, .fe-sheet, .fe-close, .fe-chip, .fe-rar, .fe-tier, .fe-force, .fe-maplab, .fe-help) {
  background-color: var(--pxbg); border-radius: 0;
  box-shadow: 0 calc(-1 * var(--u)) 0 0 var(--pxo), 0 var(--u) 0 0 var(--pxo), calc(-1 * var(--u)) 0 0 0 var(--pxo), var(--u) 0 0 0 var(--pxo),
    0 calc(var(--dn) * var(--u)) 0 calc(-1 * var(--u)) var(--pxdrop), inset 0 var(--u) 0 0 var(--pxhl), inset 0 calc(-2 * var(--u)) 0 0 var(--pxsh);
}
.ferme :is(.fe-rar, .fe-tier, .fe-force, .fe-chip) { --u: 1px; --dn: 2; }

/* ---------- HUD ---------- */
.ferme .fe-hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 0; pointer-events: none; z-index: 3; }
.ferme .fe-hud > * { pointer-events: auto; }
.ferme .fe-btn { width: 44px; height: 40px; display: grid; place-items: center; --pxbg: var(--wood-3); --pxhl: var(--wood-4); --pxsh: var(--wood-1); color: var(--cream); flex: 0 0 auto; }
.ferme .fe-btn:active { transform: translateY(var(--u)); --dn: 1; }
.ferme .fe-btn svg { width: 22px; height: 20px; fill: currentColor; }
.ferme .fe-title { flex: 0 1 440px; margin-right: auto; min-width: 0; height: 40px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; align-items: center; column-gap: 8px; padding: 3px 10px 5px; }
.ferme .fe-title b { font-weight: 400; font-size: 22px; line-height: 1; }
.ferme .fe-count { justify-self: end; font-size: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ferme .fe-prog { grid-column: 1 / -1; height: 4px; background: var(--paper-3); box-shadow: inset 0 1px 0 rgba(0,0,0,.15); }
.ferme .fe-prog i { display: block; height: 100%; background: #4E9A3A; }

/* ---------- aide, toast ---------- */
.ferme .fe-help { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 6px 12px 8px; font-size: 17px; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; z-index: 2; pointer-events: none; --pxbg: var(--cream); opacity: .92; }
.ferme .fe-toast { position: absolute; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 6px 14px 8px; z-index: 3; text-align: center; pointer-events: none; display: grid; gap: 0; max-width: calc(100% - 32px); --pxbg: var(--cream); }
.ferme .fe-toast b { font-weight: 400; font-size: 24px; line-height: 1.05; }
.ferme .fe-toast span { font-size: 17px; color: var(--ink-muted); line-height: 1.1; }
.ferme .fe-toast.on { animation: fe-toast 2.2s steps(12) both; }
@keyframes fe-toast { 0% { opacity: 0; transform: translate(-50%, -6px); } 10%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 0); } }

/* ---------- bulle d'un mot ---------- */
.ferme .fe-bubble { position: absolute; left: 0; top: 0; z-index: 2; padding: 6px 10px 7px; min-width: 132px; max-width: 230px; display: grid; gap: 1px; --pxbg: var(--cream); cursor: pointer; will-change: transform; }
.ferme .fe-bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 8px; height: 6px; margin-left: -4px; background: var(--wood-0);
  clip-path: polygon(0 0, 100% 0, 50% 100%); }
.ferme .fe-bubble.r-legendaire { --pxbg: #FBF0C8; --pxo: #6A4210; }
.ferme .fe-b-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.ferme .fe-b-head b { font-weight: 400; font-size: 24px; line-height: 1; letter-spacing: .02em; }
.ferme .fe-b-head b.fe-mask { letter-spacing: .08em; }
.ferme .fe-b-sub { font-size: 16px; color: var(--ink-muted); line-height: 1.1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ferme .fe-b-stats { display: flex; gap: 10px; font-size: 16px; line-height: 1.1; color: var(--ink-muted); }
.ferme .fe-b-stats b { font-weight: 400; color: var(--inkc); }
.ferme .fe-b-foot { font-size: 15px; color: var(--ink-muted); line-height: 1.1; }
.ferme .fe-b-foot u { text-decoration: none; color: #2A4FBF; }

/* raretés et paliers */
.ferme .fe-rar { font-family: var(--font-s); font-size-adjust: none; font-size: 9px; padding: 2px 5px 3px; white-space: nowrap; --pxbg: #E8DECA; color: #5A4A3A; }
.ferme .fe-rar.r-rare { --pxbg: #C8D6F6; color: #16255E; }
.ferme .fe-rar.r-tres-rare { --pxbg: #DCCCF6; color: #3E2470; }
.ferme .fe-rar.r-legendaire { --pxbg: #F6DC86; --pxhl: #FFF2B8; --pxsh: #C89A38; color: #4A2A08; }
.ferme .fe-tier { font-family: var(--font-s); font-size-adjust: none; font-size: 9px; padding: 2px 4px 3px; color: var(--inkc); --pxbg: var(--tc); --pxhl: rgba(255,255,255,.4); --pxsh: rgba(0,0,0,.15); }
.ferme .t0 { --tc: var(--t0); } .ferme .t1 { --tc: var(--t1); } .ferme .t2 { --tc: var(--t2); } .ferme .t3 { --tc: var(--t3); }

/* ---------- joystick ---------- */
.ferme .fe-joy { position: absolute; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; background: rgba(248,238,214,.22); box-shadow: inset 0 0 0 3px rgba(36,21,12,.45); z-index: 2; pointer-events: none; }
.ferme .fe-joy i { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: rgba(248,238,214,.85); box-shadow: 0 3px 0 rgba(36,21,12,.5), inset 0 -3px 0 #D9C49A; }

/* ---------- fenêtres (carte, registre, carte du monde) ---------- */
.ferme .fe-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(20,12,6,.55); overflow-y: auto; touch-action: pan-y; }
.ferme .fe-sheet { position: relative; width: 100%; max-width: 380px; padding: 14px 14px 12px; display: grid; gap: 10px; --pxbg: var(--paper); max-height: calc(100% - 8px); overflow-y: auto; }
.ferme .fe-sheet h2 { margin: 0; font-weight: 400; font-size: 30px; line-height: 1; }
.ferme .fe-sheet h3 { margin: 4px 0 0; font-family: var(--font-s); font-size-adjust: none; font-weight: 400; font-size: 11px; color: var(--ink-muted); letter-spacing: .04em; }
.ferme .fe-sub { margin: 0; font-size: 18px; color: var(--ink-muted); line-height: 1.15; }
.ferme .fe-close { justify-self: center; min-width: 140px; min-height: 44px; font-size: 22px; --pxbg: #E8B640; --pxhl: #F6DC86; --pxsh: #B8862A; }
.ferme .fe-close:active { transform: translateY(var(--u)); --dn: 1; }
.ferme .fe-grow { position: relative; min-height: 22px; /* [i18n] le texte peut passer sur deux lignes */ background: var(--paper-3); box-shadow: inset 0 2px 0 rgba(0,0,0,.15); }
.ferme .fe-grow i { position: absolute; left: 0; top: 0; bottom: 0; background: #7CC25A; box-shadow: inset 0 -3px 0 #4E9A3A; }
.ferme .fe-grow span { position: relative; display: block; padding: 2px 8px; font-size: 17px; line-height: 18px; }
.ferme .fe-chips { display: flex; flex-wrap: wrap; gap: 6px 6px; }
.ferme .fe-chip { font-size: 18px; padding: 2px 7px 4px; line-height: 1.05; --pxbg: var(--cream); display: inline-flex; gap: 4px; align-items: baseline; }
.ferme .fe-chip small { font-size: 14px; color: var(--ink-muted); }
.ferme .fe-chip.r-rare { --pxo: #2A4FBF; } .ferme .fe-chip.r-tres-rare { --pxo: #7A52B0; } .ferme .fe-chip.r-legendaire { --pxo: #B8862A; --pxbg: #FBF0C8; }
.ferme .fe-chip.ghost { --pxbg: var(--paper-2); color: #8A6A48; letter-spacing: .06em; cursor: default; }

/* carte d'un mot */
.ferme .fe-card { display: grid; gap: 8px; }
.ferme .fe-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ferme .fe-card-top b { font-weight: 400; font-size: 30px; line-height: 1; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.ferme .fe-force { min-width: 34px; height: 30px; display: grid; place-items: center; font-size: 22px; padding: 0 4px 2px; --pxbg: var(--tc); --pxhl: rgba(255,255,255,.4); --pxsh: rgba(0,0,0,.15); }
.ferme .fe-card-art { display: block; width: 100%; height: 150px; image-rendering: pixelated; background: #5C9E3E; box-shadow: 0 0 0 2px var(--wood-0); }
.ferme .fe-card.r-legendaire .fe-card-art { box-shadow: 0 0 0 2px #6A4210, 0 0 0 4px #E8B640; }
.ferme .fe-card.r-tres-rare .fe-card-art { box-shadow: 0 0 0 2px #3E2470, 0 0 0 4px #B892FF; }
.ferme .fe-card-type { font-size: 17px; color: var(--ink-muted); display: flex; justify-content: space-between; gap: 8px; line-height: 1.1; }
.ferme .fe-card-type span { white-space: nowrap; }
.ferme .fe-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.ferme .fe-bar span { display: flex; justify-content: space-between; font-size: 16px; color: var(--ink-muted); line-height: 1.1; }
.ferme .fe-bar span b { font-weight: 400; color: var(--inkc); }
.ferme .fe-bar i { display: block; height: 6px; background: var(--paper-3); box-shadow: inset 0 1px 0 rgba(0,0,0,.18); }
.ferme .fe-bar em { display: block; height: 100%; background: #C4BBA8; }
.ferme .fe-bar em.hi { background: #4E9A3A; } .ferme .fe-bar em.lo { background: #E2604F; }
.ferme .fe-def { margin: 0; font-family: var(--font-r); font-size-adjust: none; font-size: 14px; line-height: 1.35; color: var(--inkc); }
.ferme .fe-meta { font-size: 16px; color: var(--ink-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; line-height: 1.1; }

/* carte du monde */
.ferme .fe-sheet-map { max-width: 760px; justify-items: center; }
.ferme .fe-map { position: relative; box-shadow: 0 0 0 2px var(--wood-0); }
.ferme .fe-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.ferme .fe-maplab { position: absolute; transform: translate(-50%, -50%); font-size: 15px; padding: 1px 5px 3px; --u: 1px; --dn: 2; white-space: nowrap; --pxbg: var(--cream); display: inline-flex; gap: 4px; align-items: baseline; line-height: 1; }
.ferme .fe-maplab small { font-size: 13px; color: #2E6A22; }
.ferme .fe-map.petit .fe-maplab { font-size: 12px; padding: 0 3px 2px; gap: 2px; }
.ferme .fe-map.petit .fe-maplab small { font-size: 11px; }
.ferme .fe-maplab.off { --pxbg: var(--paper-3); color: #6E5A44; }
.ferme .fe-maplab.off small { color: #8A6A48; }
.ferme .fe-me { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #C8322E; box-shadow: 0 0 0 2px #F8EED6, 0 0 0 4px #24150C; animation: fe-blink 1s steps(2) infinite; }
@keyframes fe-blink { 50% { opacity: .35; } }
