/* ============================================================================
 * GamePanel — Bibliothèque de jeux
 *
 * Catalogue, fiche de déploiement (tiroir latéral) et suivi de déploiement.
 *
 * Tous les tokens sont pris avec un repli (`var(--primary, var(--blue))`) :
 * `--primary` et `--secondary` n'existent qu'en V3, les thèmes saisonniers
 * n'exposent que la palette de base de style.css. Le repli disparaîtra avec
 * ces thèmes, à la refonte Vanguard II.
 *
 * Règles de grille à ne pas relâcher (cf. LRN-101) : `minmax(0, 1fr)` sur les
 * colonnes répétées, `min-width: 0` sur les enfants flex d'une cellule, et
 * `flex-wrap` sur les rangées de boutons. Sans les trois, une carte déborde de
 * sa colonne entre 1300 et 1500 px de large.
 * ========================================================================== */

/* ===== Bandeau d'automatisation ===== */

.lib-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  margin-bottom: 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  overflow: hidden;
}

.lib-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--secondary, var(--amber));
  opacity: 0.55;
}

.lib-banner-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--secondary, var(--amber));
  background: color-mix(in srgb, var(--secondary, #f59e0b) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--secondary, #f59e0b) 30%, transparent);
}

.lib-banner-text { flex: 1 1 auto; min-width: 0; }
.lib-banner-title { font-size: 14.5px; font-weight: 600; color: var(--text-0); }
.lib-banner-sub { font-size: 12.5px; color: var(--text-1); margin-top: 2px; }
.lib-banner-sub code { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-0); }

.lib-banner-stats { display: flex; gap: 20px; flex-shrink: 0; }
.lib-banner-stat { text-align: right; }
.lib-banner-stat-value { font-size: 19px; font-weight: 600; color: var(--text-0); line-height: 1.1; }
.lib-banner-stat-value.ok { color: var(--status-online, var(--green)); }
.lib-banner-stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin-top: 2px;
}

/* ===== Avertissement environnement ===== */

.lib-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg, 10px);
  background: var(--amber-bg);
  border: 1px solid var(--amber-dim);
  color: var(--text-0);
  font-size: 13px;
  line-height: 1.55;
}

.lib-warning code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-0);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ===== Barre de filtres ===== */

.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.lib-chip {
  height: 34px;
  padding: 0 15px;
  border-radius: 17px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.lib-chip:hover { border-color: var(--border-strong); color: var(--text-0); }

.lib-chip.active {
  background: var(--secondary, var(--amber));
  border-color: var(--secondary, var(--amber));
  color: var(--bg-0);
  font-weight: 600;
}

.lib-search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 240px;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.lib-search input {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text-0);
  font-family: inherit;
  font-size: 13px;
}

/* ===== Grille du catalogue ===== */

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 16px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  overflow: hidden;
  transition: transform 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              border-color 250ms ease,
              box-shadow 250ms ease;
}

.lib-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.lib-card.is-soon:hover { transform: none; box-shadow: none; border-color: var(--border); }

.lib-card-art {
  position: relative;
  height: 126px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--game-color) 8%, transparent);
}

.lib-card.is-soon .lib-card-art { background: var(--bg-2); }

.lib-card-art svg,
.lib-card-art img { width: 54px; height: 54px; color: var(--game-color); }
.lib-card.is-soon .lib-card-art svg { opacity: 0.4; }

/* Tuile portant l'art officielle : elle occupe toute la surface, la teinte de
   fond et le centrage flex n'ont plus lieu d'etre. */
.lib-card-art.has-art {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  /* La tuile mesurait 466x126, soit un ratio de 3.70, pour une banniere Steam
     de 460x215, ratio 2.14 : `cover` rognait donc 42 % de la hauteur de
     l image, en haut et en bas. Les logos places haut se retrouvaient coupes.

     On donne a la tuile le ratio de l art plutot que de deplacer le cadrage :
     l image entiere tient, il n y a plus rien a centrer. La hauteur fixe reste
     pour les tuiles sans art — Minecraft — dont la marque dessinee est centree
     par le flex du conteneur. */
  height: auto;
  aspect-ratio: 46 / 21;
}

/* Un jeu « bientot disponible » se lisait a son icone en opacite 0.4. Avec une
   art pleine tuile il lui faut l'equivalent, sinon plus rien ne distingue un
   jeu deployable d'un jeu qui ne l'est pas encore. */
.lib-card.is-soon .lib-card-art.has-art {
  filter: saturate(0.35) brightness(0.55);
}

.lib-card-badge {
  position: absolute;
  top: 9px;
  left: 9px;
  height: 20px;
  line-height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--bg-0);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-1);
  border: 1px solid var(--border-strong);
}

.lib-card-badge.on {
  color: var(--status-online, var(--green));
  border-color: var(--green-dim);
}

.lib-card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 13px 13px;
}

.lib-card-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-0);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.lib-card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  margin-top: 3px;
}

.lib-card-spacer { flex: 1 1 auto; }

.lib-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-0);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.lib-cta:hover { background: var(--bg-2); }

.lib-cta.primary {
  background: var(--secondary, var(--amber));
  border-color: var(--secondary, var(--amber));
  color: var(--bg-0);
}

.lib-cta.primary:hover { filter: brightness(1.08); background: var(--secondary, var(--amber)); }

.lib-cta:disabled,
.lib-cta.disabled {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-3);
  cursor: not-allowed;
}

/* ===== Serveurs déployés par le moteur ===== */

.lib-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}

.lib-section-title span:first-child {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-1);
}

.lib-section-title .count { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.lib-section-title .rule { flex: 1 1 auto; height: 1px; background: var(--border); }

.lib-stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.lib-stack {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
}

.lib-stack-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.lib-stack-dot.on {
  background: var(--status-online, var(--green));
  box-shadow: 0 0 7px var(--green-glow, rgba(16, 185, 129, 0.4));
}

.lib-stack-dot.busy { background: var(--primary, var(--blue)); }
.lib-stack-dot.err { background: var(--red); }

.lib-stack-info { flex: 1 1 auto; min-width: 0; }
.lib-stack-name { font-size: 13.5px; font-weight: 600; color: var(--text-0); }
.lib-stack-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.lib-stack-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

/* ===== Tiroir de la fiche jeu ===== */

.lib-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.lib-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.lib-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 201;
  width: min(980px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  border-left: 1px solid var(--border-strong);
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lib-drawer.open { transform: translateX(0); }

.lib-drawer-head {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--game-color) 7%, transparent);
}

.lib-drawer-mark {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--bg-0);
  border: 1px solid color-mix(in srgb, var(--game-color) 35%, transparent);
  color: var(--game-color);
}

.lib-drawer-mark svg, .lib-drawer-mark img { width: 42px; height: 42px; }

.lib-drawer-title { flex: 1 1 auto; min-width: 0; }
.lib-drawer-title h2 { margin: 0; font-size: 24px; font-weight: 600; color: var(--text-0); }
.lib-drawer-title p { margin: 4px 0 0; font-size: 13px; color: var(--text-1); }

.lib-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }

.lib-tag {
  height: 22px;
  line-height: 20px;
  padding: 0 9px;
  border-radius: 11px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-1);
}

.lib-tag.ok {
  color: var(--status-online, var(--green));
  border-color: var(--green-dim);
  background: var(--green-bg);
}

.lib-drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lib-drawer-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}

.lib-drawer-foot .spacer { flex: 1 1 auto; }

.lib-block-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--secondary, var(--amber));
  margin-bottom: 10px;
}

.lib-block-title .hint {
  font-weight: 400;
  letter-spacing: 0;
  font-size: 11.5px;
  color: var(--text-2);
  margin-left: 10px;
}

/* ===== Pré-requis ===== */

.lib-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  gap: 10px;
}

.lib-spec {
  min-width: 0;
  padding: 11px 13px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.lib-spec-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-2);
}

.lib-spec-value { font-size: 19px; font-weight: 600; color: var(--text-0); margin-top: 3px; }
.lib-spec-value small { font-size: 13px; color: var(--text-2); font-weight: 400; }
.lib-spec-note { font-size: 11px; margin-top: 4px; color: var(--text-2); }
.lib-spec-note.ok { color: var(--status-online, var(--green)); }
.lib-spec-note.warn { color: var(--amber); }
.lib-spec-note.err { color: var(--red); }

/* ===== Formulaire de configuration ===== */

.lib-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 14px 18px;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
}

.lib-field { min-width: 0; }
.lib-field.wide { grid-column: 1 / -1; }

.lib-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.lib-field label .spec {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--secondary, var(--amber));
  margin-left: 6px;
}

.lib-field input[type="text"],
.lib-field input[type="password"],
.lib-field input[type="number"],
.lib-field select {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  padding: 0 12px;
  background: var(--bg-0);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-0);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.lib-field input:focus,
.lib-field select:focus { border-color: var(--primary, var(--blue)); }

.lib-field-help {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.lib-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-1);
  cursor: pointer;
}

.lib-check input { width: 16px; height: 16px; accent-color: var(--secondary, var(--amber)); cursor: pointer; }

/* ===== Plan de déploiement ===== */

.lib-plan {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  overflow: hidden;
}

.lib-plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle, var(--border));
}

.lib-plan-row:last-child { border-bottom: none; }

.lib-plan-row svg { flex-shrink: 0; color: var(--status-online, var(--green)); }
.lib-plan-key { flex-shrink: 0; width: 150px; font-size: 12.5px; color: var(--text-1); }
.lib-plan-val {
  flex: 1 1 200px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-0);
  overflow-wrap: anywhere;
}

.lib-plan-pill {
  flex-shrink: 0;
  height: 20px;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--status-online, var(--green));
  background: var(--green-bg);
  border: 1px solid var(--green-dim);
}

/* ===== Suivi de déploiement ===== */

.lib-job {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(860px, 94vw);
}

.lib-job-bar-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.lib-job-bar-head .step { font-size: 13px; font-weight: 600; color: var(--text-0); }
.lib-job-bar-head .spacer { flex: 1 1 auto; }
.lib-job-bar-head .pct { font-size: 17px; font-weight: 700; color: var(--secondary, var(--amber)); }

.lib-job-bar {
  height: 7px;
  border-radius: 4px;
  background: var(--bg-2);
  overflow: hidden;
}

.lib-job-bar > div {
  height: 100%;
  width: 0;
  background: var(--secondary, var(--amber));
  transition: width 400ms ease;
}

.lib-job-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 8px 14px;
}

.lib-job-step {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-2);
}

.lib-job-step .bullet {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lib-job-step.done { color: var(--text-1); }
.lib-job-step.done .bullet { border-color: var(--status-online, var(--green)); background: var(--green-bg); }
.lib-job-step.done .bullet::after {
  content: '';
  width: 8px; height: 4px;
  border-left: 2px solid var(--status-online, var(--green));
  border-bottom: 2px solid var(--status-online, var(--green));
  transform: rotate(-45deg) translate(1px, -1px);
}

.lib-job-step.active { color: var(--text-0); font-weight: 600; }
.lib-job-step.active .bullet { border-color: var(--primary, var(--blue)); background: var(--blue-bg); }
.lib-job-step.active .bullet::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary, var(--blue));
}

.lib-job-console {
  height: 300px;
  overflow-y: auto;
  padding: 11px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lib-job-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lib-job-foot .spacer { flex: 1 1 auto; }
.lib-job-note { font-size: 12.5px; color: var(--text-2); }

.lib-job-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
}

.lib-job-result.ok { border-color: var(--green-dim); }
.lib-job-result.err { border-color: var(--red-dim); }
.lib-job-result-text { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text-0); }
.lib-job-result-text small { display: block; color: var(--text-2); font-size: 12px; margin-top: 3px; }

/* ===== États vides ===== */

.lib-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
}

/* ===== Responsive ===== */

@media (max-width: 900px) {
  .lib-banner { flex-wrap: wrap; }
  .lib-banner-stats { width: 100%; justify-content: flex-start; }
  .lib-banner-stat { text-align: left; }
  .lib-drawer-head { flex-wrap: wrap; }
  /* Sous 900 px la clé cède sa largeur fixe mais reste sur la même ligne que
     la coche : trois lignes pour une seule information, ce serait pire. */
  .lib-plan-key { width: auto; flex: 0 1 auto; font-weight: 600; }
  .lib-plan-val { flex: 1 1 100%; }
}
