/* ─── HEADER COMMUN ──────────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: .55rem 1.4rem;
  background: rgba(221, 238, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 10px rgba(74,144,217,.10);
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Hauteur fixe pour que le header ne s'écrase jamais */
#app-header { min-height: 60px; }

/* Zone gauche : bouton Info (accueil) ou Maison (autres pages) */
#app-header .app-header__left {
  position: absolute;
  left: 1.4rem;
  display: flex;
  align-items: center;
  z-index: 105;
}

/* Groupe logo + texte centré comme un bloc */
#app-header .app-header__brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  z-index: 105;
  cursor: pointer;
  transition: opacity .15s ease;
}
#app-header .app-header__brand:hover,
#app-header .app-header__brand:focus-visible {
  opacity: .8;
}
#app-header .app-header__brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

#app-header .app-header__logo {
  position: absolute;
  right: 100%;
  margin-right: .55rem;
  height: 38px;
  width: 38px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
  mix-blend-mode: multiply;
}

#app-header .app-header__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .05rem;
}

#app-header .app-header__title {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1;
}
#app-header .app-header__title span { color: var(--accent); }

#app-header .app-header__tagline {
  font-family: var(--mono);
  font-size: .58rem;
  color: var(--muted);
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1;
}

/* PIN inline dans le header (mode PC→PC actif) */
#app-header .pc2pc-pin-inline {
  margin-left: .3rem;
}

#app-header .app-header__actions {
  margin-left: auto;
  display: flex;
  gap: .6rem;
  align-items: center;
}

/* Réduire la taille des boutons placés dans le header pour éviter
   d'augmenter la hauteur du header. S'applique aux boutons carrés. */
#app-header .btn-zip-square {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  gap: .25rem;
  font-size: .52rem;
}
#app-header .btn-zip-square svg { width: 20px; height: 20px; }
#app-header .btn-zip-square .btn-info-logo { width: 20px; height: 20px; border-radius:6px; }

/* Bouton Accueil (rond nichoir) dans le header */
#app-header .btn-home {
  width: 42px;
  height: 42px;
}
#app-header .btn-home .btn-home-img {
  width: 26px;
  height: 26px;
}

/* Assurer un alignement vertical compact si d'autres éléments coexistent */
#app-header .app-header__actions > * { padding: 0; }

/* ─── BODY : flex-colonne pour coller le header en haut ──── */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── CONTENEUR PRINCIPAL ────────────────────────────────── */
.app {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  padding: 6px 20px 8px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  transition: all .4s cubic-bezier(.4,0,.2,1);
}

/* ─── MODE-BAR dans le flux idle ─────────────────────────── */
.app.idle .mode-bar {
  align-self: center;
  flex-shrink: 0;
}

/* Anciennement utilisé pour cacher la vue le temps de l'init JS.
   La vue principale n'a plus la classe 'loading' au démarrage :
   le layout est visible immédiatement, seul le QR a son placeholder. */
.app.loading {
  /* visibility: hidden; — désactivé : la mode-bar doit être visible d'emblée */
}

/* ── État idle : titre centré + deux colonnes logo/QR ─────── */
.app.idle {
  align-items: center;
  justify-content: flex-start; /* align content to top so mode-bar stays near header */
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 8px; /* keep a small gap from the sticky header */
  box-sizing: border-box;
}

/* En idle, le panneau Send a la même contrainte que la mode-bar */
.app.idle #panel-send {
  width: 100%;
  max-width: 420px;
}


/* Header en idle : deux colonnes (logo | QR) + sous-titre pleine largeur */
.app.idle #panel-receive .receiver-header {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  margin-bottom: 0;
  width: 100%;
  max-width: 1060px;
  align-self: center;
  box-sizing: border-box;
}

/* QR en idle : col. droite, grand format — le wrapper prend l'order */
.app.idle #panel-receive .receiver-header .qr-col-block {
  order: 3;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.app.idle #panel-receive .receiver-header .qr-wrap {
  width: 420px;
  height: 420px;
  padding: 16px;
  margin: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.app.idle #panel-receive .qr-wrap img,
.app.idle #panel-receive .qr-wrap canvas { width: 388px !important; height: 388px !important; }

/* QR masqué en mode actif */
.app.active .qr-col-block { display: none; }
.app.active .qr-wrap { display: none; }

/* Sous-titre carrousel vertical sous les colonnes */
.idle-subtitle-block {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--muted);
  margin-top: .75rem;
  width: 100%;
  text-align: center;
}

/* Fenetre : une seule ligne visible */
.idle-subtitle-carousel {
  overflow: hidden;
  height: 1.6em;
  position: relative;
  width: 100%;
}

/* Tous les items superposés en absolu, centré */
.idle-subtitle-item {
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  line-height: 1.6;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(110%);
  animation: subtitleScroll 12s ease-in-out infinite;
}
/* Désactivé quand piloté dynamiquement (un seul enfant, géré par dyk-in/out) */
.idle-subtitle-item.dyk-in,
.idle-subtitle-item.dyk-out {
  animation: none;
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  line-height: 1.6;
  white-space: nowrap;
}
.idle-subtitle-item.dyk-in  { opacity: 1; transform: translateY(0); }
.idle-subtitle-item.dyk-out { opacity: 0; transform: translateY(-6px); }
.idle-subtitle-item:nth-child(2) { animation-delay: 4s; }
.idle-subtitle-item:nth-child(3) { animation-delay: 8s; }

.idle-subtitle-block strong  { color: var(--accent); font-weight: 700; }
.app:not(.idle) .idle-subtitle-block { display: none; }

/* ── H2 SEO sous le QR code ─────────────────────────────── */
.qr-h2-seo {
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .3rem;
  line-height: 1.3;
}
.qr-p-seo {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  margin: 0;
  letter-spacing: .01em;
}
/* Exception : carrousel visible sous la drop zone du panneau Envoyer */
.pcs-drop-subtitle { display: block; }

/* ── État actif : header compact ─────────────────────────── */
.app.active .receiver-header {
  flex-direction: row;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 20px;
  flex-shrink: 0;
  position: relative;
}

/* Groupe ZIP + Info : masqué en idle, visible en actif à droite */
.app.idle .action-btns-group { display: none; }
.app.active .action-btns-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .6rem;
  margin-left: auto;
}

/* Card masquée en idle */
.app.idle .card    { display: none; }
.app.active .card  { display: block; flex: 1; }

/* ── RECEIVER HEADER ─────────────────────────────────────── */
.receiver-header {
  display: flex;
  flex-shrink: 0;
  transition: all .4s cubic-bezier(.4,0,.2,1);
}
.receiver-brand { display: flex; flex-direction: column; gap: .2rem; }

/* ── GRILLE FICHIERS ─────────────────────────────────────── */
.files-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .8rem;
  align-items: start;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 400px) {
  .card { padding: 1.5rem 1rem; }
}

/* Header mobile : on cache le bouton nichoir (relance de session) pour
   désencombrer le header. Le logo + titre + tagline (.app-header__brand)
   déclenchent déjà la même action (voir wireHeaderBrandHome() dans
   index.html), donc rien n'est perdu en fonctionnalité. */
@media (max-width: 480px) {
  #app-header .app-header__left {
    display: none;
  }
}

/* ── PIN inline dans le titre actif (mode PC→PC) ── */
.pc2pc-pin-inline {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.pc2pc-pin-sep {
  color: var(--border);
  font-size: 1rem;
  font-weight: 300;
}
.pc2pc-pin-inline-label {
  font-family: var(--mono);
  font-size: .52rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
  text-transform: uppercase;
  background: #e9f4ff;
  border: 1px solid #b3d5f7;
  border-radius: 6px;
  padding: .1rem .35rem;
}
.pc2pc-pin-inline-digits {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: .2em;
}

/* ── Bloc PIN dans le flux idle (sous le duo QR/logo) ─── */
.app.idle .recv-pin-block {
  order: 4;
  align-self: center;
}

/* ── PIN idle : affiché sous le QR code en mode accueil ──── */
.idle-pin-block {
  order: 3;
  flex: 0 0 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .2rem;
}

.idle-pin-label {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
}

.idle-pin-digits {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.idle-pin-digit {
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f7ff, #e8f2ff);
  border: 1.5px solid var(--accent);
  border-radius: 7px;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 1rem;
  color: var(--accent);
  box-shadow: 0 1px 5px rgba(74,144,217,.12);
  letter-spacing: -.01em;
}

.idle-pin-sep {
  font-size: .75rem;
  color: var(--border);
  font-weight: 700;
}

/* Visible uniquement en mode idle */
.app:not(.idle) .idle-pin-block { display: none; }

/* ─── RESPONSIVE MOBILE : QR limité à la largeur de la mode-bar ── */
@media (max-width: 480px) {
  /* Padding-bottom pour que le subtitle ne disparaisse pas sous le footer fixe */
  .app.idle {
    padding-bottom: 5rem;
  }

  /* Le panneau receive prend toute la largeur dispo */
  .app.idle #panel-receive,
  .app.idle #panel-receive .receiver-header {
    width: 100%;
    max-width: 100%;
  }

  /* Le bloc QR col prend toute la largeur disponible */
  .app.idle #panel-receive .receiver-header .qr-col-block {
    width: 100%;
    max-width: 100%;
  }

  /* Le wrapper QR : carré, pas de padding (géré sur le canvas) */
  .app.idle #panel-receive .receiver-header .qr-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    box-sizing: border-box;
    padding: 0;
    margin-left: 0;
    margin-right: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Le canvas : carré avec marges uniformes via calc */
  .app.idle #panel-receive .qr-wrap canvas,
  .app.idle #panel-receive .qr-wrap img {
    display: block;
    width: calc(100% - 28px) !important;
    height: calc(100% - 28px) !important;
    max-width: 100%;
  }

  /* Placeholder génération QR : s'adapte au conteneur en mobile */
  .app.idle #panel-receive .qr-wrap .qr-generating {
    width: 100%;
    height: 100%;
  }

  /* Sous-titre : déjà en colonne, rien à surcharger */
}
