/* Charte La Plateforme_ : bleu prioritaire, accents secondaires, fond crème
   pour rester dans la continuité visuelle du portail Minecraft d'Allauch.
   La pixel-art des jeux apporte la couleur, le chrome de la page reste sobre. */
:root {
  --lp-bleu: #0062ff;
  --lp-noir: #000000;
  --lp-blanc: #ffffff;
  --lp-vert: #00988f;
  --lp-orange: #ff4a23;
  --lp-violet: #9d61ff;

  --bg: #f0eee8;
  --ink: #1a1a1a;
  --ink-soft: #444;

  /* Largeur "compressée" d'une carte quand une autre est ouverte. */
  --card-collapsed-flex: 0.18;
  --card-expanded-flex: 4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  font-family: "Poppins", "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ------------------------------------------------------------------ HERO */

/* Même wrapper (max-width + padding) que .cards : titre et description
   s'alignent exactement sur le bord gauche de la première carte. */
.hero {
  padding: 28px 32px 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.hero-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 720px;
}

.hero a {
  color: var(--lp-bleu);
  text-decoration: underline;
  text-decoration-color: rgba(0, 98, 255, 0.35);
  text-underline-offset: 2px;
  font-weight: 500;
}
.hero a:hover { text-decoration-color: var(--lp-bleu); }

.hero-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: #888;
  font-style: italic;
}

/* ------------------------------------------------------------------ CARDS */

.cards {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 28px 32px 80px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
  /* Hauteur calée pour donner la place à l'iframe FlowLab quand on l'ouvre,
     tout en laissant le hero visible au-dessus. */
  min-height: min(70vh, 640px);
}

.card {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: flex 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Bord façon "bloc voxel" pour rester dans la continuité du portail
     Minecraft, mais affiné en 2D : un cadre noir net, pas d'arrondi. */
  border-radius: 0;
  outline: 3px solid var(--ink);
  outline-offset: -3px;
}

/* Quand une carte est ouverte, les autres se rétractent en bandeau étroit. */
.cards.has-expanded .card:not(.is-expanded) {
  flex: var(--card-collapsed-flex);
  cursor: pointer;
}
.cards.has-expanded .card.is-expanded {
  flex: var(--card-expanded-flex);
  cursor: default;
}

.card-cover {
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Les screenshots sont en pixel-art : on évite le lissage qui gomme les pixels. */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.card:hover .card-cover {
  filter: brightness(1.05);
}

/* Carte rétractée : on garde la couleur dominante (--bg) en fond, le screenshot
   est trop petit pour être lisible. Le nom reste affiché à la verticale. */
.cards.has-expanded .card:not(.is-expanded) .card-cover {
  opacity: 0;
}
.cards.has-expanded .card:not(.is-expanded) {
  background: var(--bg, #ccc);
}

/* Carte ouverte : on masque le screenshot pour faire place à l'iframe. */
.card.is-expanded .card-cover {
  opacity: 0;
}

.card-label {
  position: absolute;
  left: 14px;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
  pointer-events: none;
  /* Pastille noire derrière le texte pour rester lisible sur n'importe quel
     fond pixel-art. Padding interne réglé pour un effet "étiquette". */
  align-items: flex-start;
}

.card-num {
  background: var(--ink);
  color: var(--lp-blanc);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  letter-spacing: 0.04em;
}

.card-name {
  background: var(--lp-blanc);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  padding: 4px 10px;
  letter-spacing: -0.01em;
  line-height: 1;
}

/* Rotation verticale du label quand la carte est compressée : sinon le nom
   dépasse de la bande étroite. */
.cards.has-expanded .card:not(.is-expanded) .card-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
}
.cards.has-expanded .card:not(.is-expanded) .card-name {
  font-size: 16px;
}

/* Le frame contient l'iframe. Caché par défaut (rien ne charge),
   créé à la volée par script.js quand la carte est ouverte. */
.card-frame {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--bg, #000);
}
.card.is-expanded .card-frame {
  display: block;
}

.card-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Bandeau "contrôles + activation clavier" sous l'iframe, visible uniquement
   quand la carte est ouverte. Le contenu est volontairement générique (les
   touches dépendent de l'auteur du jeu sur FlowLab) — éditer le HTML de chaque
   carte pour préciser, p.ex. "Flèches · Espace" pour un jeu donné. */
.card-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%) translateY(8px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--lp-blanc);
  font-size: 11px;
  line-height: 1.2;
  border-radius: 10px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease 0.15s,
    transform 0.3s ease 0.15s;
  max-width: calc(100% - 20px);
}
/* L'ordre DOM est (controls, sep, focus) — on bascule visuellement pour
   afficher "Clique dans le jeu..." en premier, puis "Touche de jeu : XXX". */
.card-hint-focus { order: 0; opacity: 0.85; }
.card-hint-controls { order: 1; font-weight: 600; letter-spacing: 0.02em; }
.card-hint-sep { display: none; }

/* Préfixe "Touche de jeu :" injecté en CSS pour ne pas dupliquer le label
   dans les 4 cartes (chaque .card-hint-controls ne contient que les touches). */
.card-hint-controls::before {
  content: "Touche de jeu : ";
  font-weight: 400;
  opacity: 0.7;
  margin-right: 2px;
}
.card.is-expanded .card-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Bouton fermer : seulement visible sur la carte ouverte. */
.card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--ink);
  color: var(--lp-blanc);
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.card.is-expanded .card-close {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.card-close:hover { background: #333; }

/* ---------------------------------------------------------------- CREDITS */

.credits {
  padding: 16px 32px 20px;
  font-size: 12px;
  color: #555;
  text-align: right;
}

.credits a {
  color: var(--lp-bleu);
  text-decoration: underline;
  text-decoration-color: rgba(0, 98, 255, 0.35);
  text-underline-offset: 2px;
  font-weight: 500;
}
.credits a:hover { text-decoration-color: var(--lp-bleu); }

/* ----------------------------------------------------------------- MOBILE */

@media (max-width: 767px) {
  .hero {
    padding: 16px 16px 0;
  }
  .hero h1 {
    font-size: 26px;
  }
  .hero-desc {
    font-size: 13px;
  }

  /* Sur mobile : passage en colonne, la transition flex devient height pour
     que la carte ouverte prenne assez de place verticale pour l'iframe. */
  .cards {
    flex-direction: column;
    padding: 16px 16px 40px;
    min-height: 0;
    gap: 10px;
  }
  .card {
    flex: 0 0 auto;
    height: 120px;
    transition: height 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .cards.has-expanded .card:not(.is-expanded) {
    flex: 0 0 auto;
    height: 56px;
  }
  .cards.has-expanded .card.is-expanded {
    flex: 0 0 auto;
    /* Hauteur calée pour respecter l'aspect 4:3 le plus restrictif (Tom/Leo)
       sur la largeur viewport ; suffit aussi pour les autres jeux. */
    height: min(80vh, 520px);
  }

  .cards.has-expanded .card:not(.is-expanded) .card-label {
    transform: translate(-50%, -50%);
    flex-direction: row;
  }
  .cards.has-expanded .card:not(.is-expanded) .card-name {
    font-size: 14px;
  }

  .credits {
    padding: 8px 16px 16px;
    text-align: center;
  }

  /* Sur mobile : la phrase "Clique dans le jeu..." est redondante au tactile
     (l'utilisateur tape forcément dans le jeu). On la masque, seule
     "Touche de jeu : XXX" reste affichée. */
  .card-hint-focus {
    display: none;
  }
  .card-hint {
    font-size: 10px;
    padding: 6px 12px;
  }
}
