/* =========================================================================
   style.css — thème HitsuBlu / ABCD
   inspiré de la maquette InDesign : grille-bingo.idml
   ========================================================================= */

/* --- Polices issues du dossier resources --- */
@font-face {
  font-family: "Coolvetica";
  src: url("../fonts/coolvetica.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "BilboINC";
  src: url("../fonts/BilboINC.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* === Palette inspirée du IDML === */
  --color-bg:           #0d0d0d;     /* fond noir */
  --color-surface:      #ffffff;     /* cases blanches */
  --color-text:         #1a1a1a;     /* texte principal sur clair */
  --color-text-on-dark: #f5f1e6;     /* texte sur fond noir */
  --color-text-muted:   #8a8378;     /* texte secondaire sur fond sombre */
  --color-gold:         #ffd335;     /* jaune/or de l'IDML (RGB 255,211,53) */
  --color-grey:         #cccccc;     /* gris */
  --color-gold-soft:    #f5c022;
  --color-primary:      var(--color-gold);
  --color-primary-text: #111111;
  --color-drawn:        var(--color-gold);
  --color-drawn-text:   #111111;
  --color-hidden:       #ffffff;
  --color-hidden-text:  #1a1a1a;
  --color-border:       rgba(255, 255, 255, 0.15);
  --color-success:      #2e7d32;
  --color-danger:       #b00020;

  /* === Typo === */
  --font-display: "BilboINC", "Coolvetica", Georgia, serif;
  --font-num:     "Coolvetica", Impact, "Arial Narrow", system-ui, sans-serif;
  --font-body:    "Coolvetica", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* === Espacement === */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* === Rayons === */
  --radius-sm: 4px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* === Ombres === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* === Reset léger === */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text-on-dark);
  line-height: 1.4;
  min-height: 100vh;
  letter-spacing: 0.02em;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: var(--color-gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Boutons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--color-gold);
  color: var(--color-primary-text);
  border-color: var(--color-gold);
  font-weight: 700;
}
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-ghost { background: transparent; color: var(--color-text-on-dark); }

/* === Champs de formulaire === */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.field label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}
.field input,
.field textarea,
.field select {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}

/* =========================================================================
   PAGE VISITEUR
   ========================================================================= */

body.viewer-page {
  background:
    linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)),
    url("../img/bg.jpg") center / cover no-repeat fixed,
    var(--color-bg);
}

.viewer {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr) minmax(180px, 1fr);
  grid-template-rows: auto;
  gap: var(--space-5);
  padding: clamp(12px, 2.5vw, 32px);
  max-width: 1920px;
  margin: 0 auto;
  min-height: 100vh;
  align-items: start;
}

/* --- Colonne centrale : grille + info-bar --- */
.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.center-col .info-bar,
.center-col .bingo-grid,
.center-col .status-line {
  width: 100%;
  /* limite la largeur de la grille pour qu'elle tienne en hauteur sur 1 écran
     (la grille fait 10:9, on garde ~260px pour le padding/info-bar agrandie/status) */
  max-width: calc((100vh - 190px) * 10 / 9);
}

/* --- Colonne gauche (wrapper) : side-left + partenaires empilés --- */
.left-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

/* --- Colonne gauche : titre + Tips --- */
.side-left {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-6);
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.brand-tag {
  font-family: var(--font-display);
  color: var(--color-gold);
  font-size: clamp(0.9rem, 1.4vw, 1.4rem);
  letter-spacing: 0.12em;
  text-transform: lowercase;
}
.brand-title {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5));
}

/* --- Colonne droite : Instagram + hôtes --- */
.side-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}
.ig-logo {
  width: clamp(40px, 4vw, 64px);
  height: auto;
  display: block;
  margin: 6px auto var(--space-3);
}
.host-cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
}

/* --- "Tips" + cartes hôte : encart QR avec label BilboINC --- */
.tip-block,
.host-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: 0;
  padding: 0;
  text-align: center;
  color: var(--color-text-on-dark);
}
.tip-block .qr-label,
.host-card .host-name {
  font-family: var(--font-display);
  font-size: clamp(3rem, 3.6vw, 3.6rem);
  letter-spacing: 0.08em;
  line-height: 1.05;
  text-transform: uppercase;
}
.tip-block .qr-label { color: var(--color-text-on-dark); }
.host-card .host-name { color: var(--color-gold); }

.qr-img,
.host-card img.qr-img {
  width: clamp(110px, 11vw, 170px);
  height: auto;
  background: #fff;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: block;
}
.host-card .host-link {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  word-break: break-all;
}
.host-card.empty {
  font-style: italic;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

/* --- Encart Partenaires (sous Tips, liste de noms cliquables) --- */
.partners-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: center;
  color: var(--color-text-on-dark);
}
.partners-block[hidden] { display: none; }
.partners-label {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.6vw, 1.6rem);
  letter-spacing: 0.08em;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--color-text-on-dark);
}
.partners-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: center;
  width: 100%;
}
.partners-list li {
  width: 100%;
  text-align: center;
}
.partners-list a {
  color: var(--color-gold);
  font-family: var(--font-body);
  font-size: clamp(0.9rem, 1.2vw, 1.1rem);
  letter-spacing: 0.02em;
  word-break: break-word;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.partners-list .partner-plain {
  color: var(--color-text-on-dark);
  opacity: 0.85;
}
.partners-list .partner-logo {
  max-width: clamp(80px, 9vw, 140px);
  max-height: clamp(36px, 4.5vw, 64px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  /* le fond est sombre — un petit padding clair évite que les logos transparents
     se "noient" si le logo est sombre. On ne force pas le fond blanc pour éviter
     un effet "carte" trop visible. */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* --- Bandeau infos (compteur + derniers numéros), GROS au-dessus de la grille
       pour être lu de loin sur écran --- */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  color: var(--color-text-on-dark);
  font-size: 1.1rem;
}
.last-numbers {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.last-numbers-label {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  font-size: clamp(1.2rem, 1.8vw, 2rem);
  margin-right: var(--space-2);
}
.last-numbers-list {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.last-numbers-list .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-gold);
  color: var(--color-primary-text);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 2.4rem);
  line-height: 1;
  min-width: clamp(48px, 5vw, 72px);
  height: clamp(48px, 5vw, 72px);
  text-align: center;
  box-sizing: border-box;
}
.last-numbers-list .num.latest {
  font-size: clamp(3.2rem, 5vw, 5rem);
  min-width: clamp(80px, 6vw, 110px);
  height: clamp(80px, 5vw, 110px);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 3px rgba(255, 211, 53, 0.45), 0 4px 16px rgba(0, 0, 0, 0.35);
}
.last-numbers-list .num.placeholder {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-muted);
  font-weight: normal;
  font-style: italic;
}
.counter {
  font-family: var(--font-num);
  color: var(--color-text-on-dark);
  opacity: 0.85;
  font-size: clamp(1.3rem, 2vw, 2rem);
  font-weight: 700;
}

/* --- Grille de bingo --- */
.bingo-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px;
  border: 2px solid #fff;
}
.bingo-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-hidden);
  color: var(--color-grey);
  font-family: var(--font-num);
  font-weight: 700;
  /* gros pour être lus de loin, mais avec un peu d'air pour rester lisibles */
  font-size: clamp(1.3rem, 3.4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.01em;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
}
.bingo-cell.drawn {
  background: var(--color-gold);
  color: var(--color-drawn-text);
  animation: cell-pop 0.5s ease;
}
@keyframes cell-pop {
  0%   { transform: scale(0.85); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Ancien bloc "logo lieu" et footer : on les gère en bas, discret */
.viewer-logo,
.viewer-footer,
.hosted-by-title {
  display: none; /* la maquette n'a pas ces éléments séparés */
}

.status-line {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

/* === Responsive : sur petit écran on empile === */
@media (max-width: 900px) {
  .viewer {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  /* "Libère" partners-block du wrapper .left-col pour qu'il devienne
     directement enfant de .viewer et puisse passer en bas via order. */
  .left-col {
    display: contents;
  }
  .partners-block {
    order: 99;
    margin-top: var(--space-3);
  }
  .side-left,
  .side-right {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    min-height: auto;
  }
  .brand-title { max-width: 220px; }
  .ig-logo { display: none; }
  .host-cards {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: var(--space-4);
    flex-wrap: wrap;
    width: 100%;
  }
  .host-cards .host-card {
    flex: 1 1 0;
    min-width: 0;
    max-width: 50%;
  }
  /* sur mobile, on ne contraint plus la grille en hauteur */
  .center-col .info-bar,
  .center-col .bingo-grid,
  .center-col .status-line {
    max-width: 100%;
  }
}

/* =========================================================================
   PAGE HÔTE (style "back-office", thème clair pour rester lisible)
   ========================================================================= */

body:not(.viewer-page) {
  background: #f4f1ea;
  color: #1a1a1a;
}

.host-page {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-4);
  color: #1a1a1a;
}
.host-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.host-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: #1a1a1a;
}
.host-section {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
  color: #1a1a1a;
}
.host-section h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.1rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

/* Saisie d'un numéro — input + bouton valider gros, faciles à viser */
.number-input {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  flex-wrap: nowrap;
}
.number-input input {
  flex: 1;
  min-width: 0;
  padding: var(--space-4);
  font-size: 3rem;
  text-align: center;
  border: 2px solid #d6cfbe;
  border-radius: var(--radius-md);
  font-family: var(--font-num);
  font-weight: 700;
  height: 96px;
}
.btn-validate {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  font-size: 3rem;
  font-weight: 700;
  padding: 0;
  border-radius: var(--radius-md);
}
.btn-reset {
  display: block;
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-5) var(--space-4);
  font-size: 2rem;
}

/* Pavé numérique pour saisie au doigt (longs ongles ok) — compact pour
   tenir entier sur l'écran d'un téléphone */
.numpad {
  margin-top: var(--space-3);
  padding: var(--space-2);
  background: #efe9d8;
  border-radius: var(--radius-md);
}
.numpad-display {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid #d6cfbe;
  border-radius: var(--radius-md);
  font-family: var(--font-num);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #1a1a1a;
  margin-bottom: var(--space-2);
}
.numpad-display.empty { color: var(--color-text-muted); }
.numpad-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.numpad-key {
  height: clamp(80px, 12.5vh, 120px);
  background: #fff;
  color: #1a1a1a;
  border: 2px solid #d6cfbe;
  border-radius: var(--radius-md);
  font-family: var(--font-num);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.05s ease;
  user-select: none;
}
.numpad-key:hover { background: #f7f2e3; }
.numpad-key:active { transform: scale(0.96); background: var(--color-gold); }
.numpad-key.numpad-clear { color: var(--color-danger); }
.numpad-key.numpad-back { color: #6b6b6b; }
.numpad-validate {
  width: 100%;
  margin-top: var(--space-2);
  font-size: 2rem;
  padding: var(--space-4);
  min-height: 88px;
  font-weight: 700;
}

/* Mini-grille de l'hôte (cliquable) */
.host-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--space-1);
  margin-top: var(--space-3);
}
.host-cell {
  aspect-ratio: 1 / 1;
  background: #efe9d8;
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius-sm);
  font-size: clamp(1rem, 2.8vw, 1.6rem);
  font-weight: 700;
  font-family: var(--font-num);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.host-cell.drawn {
  background: var(--color-gold);
  color: #111;
}
.host-cell:hover { outline: 2px solid var(--color-gold); }

/* Liste des hôtes (admin) */
.hosts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.hosts-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid #d6cfbe;
  border-radius: var(--radius-sm);
  background: #fff;
}
.hosts-list .host-name { flex: 1; font-weight: 600; }
.hosts-list .host-link { flex: 2; color: #6b6b6b; font-size: 0.85rem; word-break: break-all; }
.hosts-list .host-delete {
  flex: 0 0 auto;
  background: #fff;
  color: var(--color-danger);
  border: 1px solid #d6cfbe;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.hosts-list .host-delete:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

/* Vignette logo dans la liste admin des partenaires */
.hosts-list .partner-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid #d6cfbe;
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hosts-list .partner-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.hosts-list .partner-thumb-empty {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* Modale de confirmation */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 400px;
  margin: var(--space-4);
  box-shadow: var(--shadow-md);
}
.modal h3 { margin-top: 0; }
.modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

/* Toast / message d'erreur */
.toast {
  position: fixed;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 60;
  max-width: 90vw;
}
.toast.error { background: var(--color-danger); }

/* QR code (page hôte) */
.qr-block {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.qr-block img {
  width: 140px;
  height: 140px;
  border: 1px solid #d6cfbe;
  border-radius: var(--radius-sm);
  background: #fff;
}
.qr-block .qr-info {
  flex: 1;
  min-width: 200px;
}
.qr-block code {
  background: #efe9d8;
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}

/* Page index hôte / login */
.landing {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}
.landing h1 {
  font-family: var(--font-display);
  margin-top: 0;
}
.games-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.games-list a {
  display: block;
  padding: var(--space-3) var(--space-4);
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid #d6cfbe;
  color: #1a1a1a;
  text-decoration: none;
}
.games-list a:hover { box-shadow: var(--shadow-sm); }

.login-box {
  max-width: 360px;
  margin: 10vh auto;
  background: #fff;
  color: #1a1a1a;
  padding: var(--space-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.login-box h1 { margin-top: 0; font-family: var(--font-display); }

/* Petits utilitaires */
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 1 auto; }
.spacer { flex: 1; }
.muted { color: var(--color-text-muted); }
.hidden { display: none !important; }
