/*
================================================================================
  ◎ DEMO KXCLOUD — DISPOSITION EN PANNEAUX FLOTTANTS (ADR-007)
  Fichier  : /opt/cortex/demo/src/css/layout.css
  Rôle     : Établi asymétrique — sidebar contexte · liste leads · zone focus.
             REFUS de la grille rigide 12 colonnes : les panneaux flottent,
             séparés par le « Ma » (--space-g*), jamais par des lignes.
  Version  : v4.0 — desktop flottant ←→ mobile empilé + tab bar basse
================================================================================
*/

/* ── CALQUE DE FOND (v66.4) — image HD + voile + grain, jamais bloquant ────
   Conteneur position:fixed (PAS de background-attachment:fixed — coûteux et
   bogué iOS). cover + center : l'image se recadre à toutes les tailles. */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg-deep);
  background-image: var(--page-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Couche GPU dédiée (v66.12) : isole le calque du flux — le scroll ne
     déclenche plus de repaint du fond fixe (fluidité mobile). */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Voile Washi : garantit les ratios WCAG du texte quel que soit le fond */
.page-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--page-veil);
}

/* Grain fractal — un unique calque, opacité infime, ancrage matériel.
   DESKTOP SEUL : feTurbulence est coûteux à recomposer ; il est désactivé
   sur mobile (v66.12) où il provoquait des saccades au scroll. */
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.05;
  pointer-events: none;
}

@media (max-width: 1023px) {
  .page-bg::after {
    display: none; /* zéro feTurbulence sur tactile → scroll 60fps */
  }
}

/* ── SQUELETTE : sidebar fixe + scène fluide ───────────────────────────────── */
body {
  min-height: 100svh;
  display: flex;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 84px;
  z-index: 10;
}

.stage {
  flex: 1;
  min-width: 0;
  margin-left: 84px;
  display: flex;
  flex-direction: column;
  padding: var(--space-g2) var(--space-g2) var(--space-g4);
}

/* ── EN-TÊTE DE SCÈNE (mince, sans paroi) ──────────────────────────────────── */
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;                      /* jamais de débordement horizontal */
  gap: var(--space-g1);
  padding-bottom: var(--space-g1);
  margin-bottom: var(--space-g1);
  border-bottom: 1px solid var(--line); /* filet laiton — guide de l'œil */
  min-height: 100px;                    /* = hauteur réelle du logo : le header
                                           ne grandit pas au chargement (CLS) */
}

.stage-head .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--ink);
  letter-spacing: -0.03em;
  text-decoration: none;
}

.stage-head .brand em {
  font-style: normal;
  color: var(--signal-deep);
}

/* Logo image (v66.6) : width ET height FIXES en CSS, au ratio exact des
   attributs HTML (125×100) — jamais de width:auto qui écrase l'attribut
   et annule la réservation (cause du « Unsized image element »). L'image
   est visible D'EMBLÉE (l'espace est tenu avant chargement, zéro saut) ;
   le repli texte n'apparaît que sur erreur. object-fit:contain absorbe
   tout ratio de fichier sans déformation. */
.brand-logo {
  width: 125px;
  height: 100px;
  object-fit: contain;
  display: block;
}

.brand-logo[hidden] {
  display: none; /* l'attribut hidden prime sur display:block (repli texte) */
}

@media (max-width: 1023px) {
  .brand-logo {
    width: 75px;  /* réduction PROPORTIONNELLE (ratio 125:100 conservé) */
    height: 60px;
  }
}

.stage-head nav {
  display: flex;
  align-items: center;
  gap: var(--space-g2);
}

/* ── L'ÉTABLI : deux colonnes asymétriques qui respirent ───────────────────── */
.board {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: var(--space-g4); /* le « Ma » — macro-respiration, jamais comblé */
  align-items: start;
  flex: 1;
}

.board-rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-g2);
  min-width: 0;
}

/* ── PANNEAU FLOTTANT (pièce d'atelier générique) ──────────────────────────── */
/* Verre fumé ambré (v66.4) : translucidité simple PARTOUT (peu coûteuse) ;
   le floutage backdrop-filter est réservé au desktop (≥1024px, voir bas de
   fichier) — jamais de chute de performance mobile pour l'esthétique. */
.panel {
  background-color: var(--glass-structure);
  border: 1px solid var(--line);          /* tracé à la plume, 1px, jamais plus */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: var(--space-g2);
}

.panel-paper {
  background-color: var(--glass-paper);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-g1);
  margin-bottom: var(--space-g1);
  padding-bottom: var(--space-z1);
  border-bottom: 1px solid var(--line);   /* filet laiton — guide de l'œil */
}

/* ── TAB BAR MOBILE (la sidebar se replie en barre basse) ──────────────────── */
.tabbar {
  display: none;
}

/* ── BASCULE MOBILE/TABLETTE : navigation native basse, contenu pleine
      largeur. DÉFENSIF : la sidebar est neutralisée en largeur ET en
      affichage, la compensation margin-left est verrouillée — aucun résidu
      desktop ne peut tronquer le contenu (cause du titre coupé, v66.5). ── */
@media (max-width: 1023px) {
  .sidebar {
    display: none;
    width: 0;
  }

  .stage {
    margin-left: 0 !important; /* verrou anti-troncature (résidu desktop) */
    width: 100%;
    max-width: 100vw;
    padding: clamp(14px, 3.5vw, 24px) clamp(12px, 3vw, 24px)
      calc(72px + var(--space-g1) + env(safe-area-inset-bottom, 0px));
  }

  .board {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(20px, 4.5vw, 32px); /* aération verticale mobile */
    min-height: 60svh;             /* assise réservée du conteneur principal */
  }

  .board-focus,
  .board-rail,
  .panel,
  .focus-panel {
    min-width: 0;
    max-width: 100%;
  }

  /* Priorité d'exécution : la zone focus passe AVANT la liste (dossier 05 §5.3) */
  .board > .board-focus {
    order: 1;
  }
  .board > .board-rail {
    order: 2;
  }

  .panel {
    padding: var(--space-g1);
    border-radius: var(--radius-md);
  }

  /* En-tête mobile compact : le contenu métier prime sur la navigation */
  .stage-head {
    min-height: 60px; /* = hauteur du logo mobile : zéro saut au chargement */
    gap: var(--space-z1);
  }

  .stage-head nav {
    gap: var(--space-z1);
  }

  .stage-head .btn-ghost {
    display: none; /* « Retour vitrine » vit déjà dans la tab bar basse */
  }

  .stage-head .btn-primary {
    padding: 0.5rem 0.95rem;
    font-size: var(--text-sm);
  }

  .tabbar {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px); /* notch/Dynamic Island */
    z-index: 10;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--line-on-dark);
    align-items: center;
    justify-content: space-around;
  }
}

/* ── PALIER TABLETTE (768–1023px) : empilé, rail en deux colonnes ──────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .stage {
    padding: var(--space-g2) var(--space-g2) calc(72px + var(--space-g2));
  }

  .board-rail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-g2);
    align-items: start;
  }

  .panel {
    border-radius: var(--radius-lg);
    padding: var(--space-g2);
  }
}

/* ── GRAND ÉCRAN : la respiration s'amplifie ───────────────────────────────── */
@media (min-width: 1440px) {
  .stage {
    padding: var(--space-g3) var(--space-g4) var(--space-g4);
  }

  .board {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  }
}

/* ── FLOUTAGE DESKTOP SEUL (v66.4) — le verre révèle les teintes du fond ───── */
@media (min-width: 1024px) {
  @supports (backdrop-filter: blur(1px)) {
    .panel,
    .focus-panel,
    .lead-input,
    .modal-card {
      backdrop-filter: blur(14px) saturate(1.08);
      -webkit-backdrop-filter: blur(14px) saturate(1.08);
    }
  }
}
