/* =====================================================================
   app.css — layout & composants propres au hub de l'Atelier
   S'appuie sur les tokens de theme.css (parchemin & encre, filets dorés).
   UI en sans (boutons, nav), lecture en serif (titres, intentions).
   ===================================================================== */
:root { --nav-w: 266px; --view-max: 1120px; }
/* ---------- Ossature ---------- */
.wrap { display: flex; min-height: 100vh; align-items: stretch; }
#sidebar {
  flex: 0 0 var(--nav-w); width: var(--nav-w);
  position: sticky; top: 0; align-self: flex-start; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--paper-2); border-right: 1px solid var(--hairline);
  padding: 16px 14px; gap: 4px; overflow-y: auto;
}
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; min-height: 54px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-spacer { flex: 1 1 auto; }
.topbar-tools { display: flex; gap: 6px; }
.topbar-brand { display: none; }
/* B55 · badge du ticker global — le bloc en cours, visible partout, cliquable. */
.tk-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: .92rem;
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--c-c) 14%, transparent);
}
.tk-badge:hover { background: color-mix(in srgb, var(--c-c) 24%, transparent); }
.tk-badge[data-phase='pause'] { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.tk-badge[hidden] { display: none; }
.view { flex: 1 1 auto; width: 100%; max-width: var(--view-max); margin: 0 auto; padding: 26px 22px 64px; }
.view:focus { outline: none; }
/* ---------- Boutons d'icône (topbar) ---------- */
.iconbtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--hairline); background: var(--card); color: var(--ink-soft);
  border-radius: 10px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, color .15s;
}
.iconbtn:hover { border-color: var(--gold); color: var(--ink); }
.iconbtn:focus-visible { outline: 2px solid var(--c-a); outline-offset: 2px; }
.iconbtn svg { width: 19px; height: 19px; }
.menu-btn { display: inline-grid; }
/* ---------- Marque « </> » ---------- */
.brand-mark {
  font-family: var(--sans); font-weight: 700; letter-spacing: -.06em;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  border: 1.5px solid var(--gold); color: var(--gold);
  background: color-mix(in srgb, var(--gold) 9%, var(--card)); font-size: 12.5px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; text-decoration: none; color: inherit; }
.brand-t { display: flex; flex-direction: column; line-height: 1.18; }
.brand-t b { font-family: var(--serif); font-size: 16px; color: var(--ink); }
.brand-t span { font-family: var(--sans); font-size: 11px; color: var(--ink-soft); }
/* ---------- Navigation latérale ---------- */
.sidenav { display: flex; flex-direction: column; gap: 2px; }
/* Sélecteur d'années (portée globale) */
.scope-sel { padding: 4px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--hairline); }
.scope-lab { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.scope-hint { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--c-c); }
.scope-chips { display: flex; gap: 6px; }
.scope-chips + .scope-chips { margin-top: 5px; }
.scope-sems { gap: 4px; }
.scope-chip { flex: 1 1 0; min-width: 0; padding: 6px 0; border: 1px solid var(--hairline); border-radius: 8px; background: var(--card); font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.scope-chip:hover { border-color: var(--c-c); }
.scope-chip.is-on { background: var(--c-surface); border-color: var(--c-surface); color: var(--c-on); }
/* « Tout » = l'état par défaut, donc le plus calme : chips fantômes (lot 4). */
.scope-tout .scope-chip.is-on { background: var(--card); border-color: var(--hairline); color: var(--ink-soft); font-weight: 500; }
.scope-chip-sm { padding: 5px 0; font-size: 11px; border-radius: 7px; }
.scope-chip-sm.is-on { background: color-mix(in srgb, var(--c-surface) 82%, #000); }
.nav-section {
  font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft); padding: 14px 8px 5px;
}
.navlink {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink); text-decoration: none;
  border: 1px solid transparent;
}
.navlink:hover { background: var(--card); border-color: var(--hairline); }
.navlink.is-active { background: var(--card); border-color: var(--hairline); box-shadow: var(--shadow); font-weight: 600; }
.navlink svg { width: 17px; height: 17px; color: var(--ink-soft); flex: 0 0 auto; }
.nav-mark { width: 22px; height: 22px; font-size: 9px; border-radius: 6px; }
.nav-fam { display: flex; align-items: center; gap: 9px; padding: 6px 10px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); }
.nav-fam-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.nav-fam-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-fam-n { font-size: 11px; font-weight: 700; color: var(--ink-soft); opacity: .7; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; display: flex; flex-direction: column; gap: 3px;
  font-family: var(--sans); font-size: 10.5px; color: var(--ink-soft); border-top: 1px solid var(--hairline); }
.side-foot-priv { opacity: .8; }
/* ---------- Toasts ---------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { font-family: var(--sans); font-size: 13.5px; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok-surface); color: var(--ok-on); }
.toast.danger { background: var(--danger-surface); color: var(--danger-on); }
/*  Repli du panneau latéral (bureau) + « Repartir à neuf »              */
/* ===================================================================== */
@media (min-width: 861px) {
  #sidebar { transition: width .2s ease, flex-basis .2s ease, opacity .15s ease, padding .2s ease; }
  html.nav-replie #sidebar {
    width: 0; flex-basis: 0; min-width: 0; padding-left: 0; padding-right: 0;
    border-right: none; overflow: hidden; opacity: 0; pointer-events: none;
  }
  html.nav-replie .topbar-brand { display: inline-grid; place-items: center; }
}
@media (prefers-reduced-motion: reduce) { #sidebar { transition: none; } }
/* ---------- Scrim (mobile) ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 30; }
/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .menu-btn { display: inline-grid; }
  .topbar-brand { display: inline-grid; place-items: center; }
  .topbar-brand .brand-mark { width: 30px; height: 30px; }
  .view { padding: 20px 15px 56px; }
  .fam-grid, .panels { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar { transition: none; }
  .toast { transition: none; }
}

/* Impression : la coquille disparaît, seul le contenu s'imprime. */
@media print {
  #sidebar, .topbar, .scrim, .toast-host { display: none !important; }
}

/* Scrollbars fines, accordées au thème (color-scheme fait le reste — lot 1) */
* { scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }
::-webkit-scrollbar-track { background: transparent; }

/* ===================================================================== */
/*  Barre d'onglets basse (mobile) + navigation par familles — lot 4     */
/* ===================================================================== */
.nav-fam-h { display: flex; align-items: center; gap: 7px; padding-top: 16px; }
.nav-fam-ic { width: 14px; height: 14px; opacity: .8; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; margin: 0 5px; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 44;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
    border-top: 1px solid var(--hairline);
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; justify-content: flex-end;
    padding: 4px 2px; border: none; background: none; border-radius: var(--r-m);
    font-family: var(--sans); font-size: 10.5px; color: var(--ink-soft); text-decoration: none; cursor: pointer; }
  .tab svg { width: 21px; height: 21px; }
  .tab.is-active { color: var(--ink); font-weight: 600; }
  .tab.is-active .tab-l { position: relative; }
  .tab.is-active .tab-l::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); bottom: -4px;
    width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }
  /* Le Greffier au centre, en majesté : cercle marine cerclé d'or, posé sur la barre. */
  .tab-greffier { margin-top: -20px; }
  .tab-cercle { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
    background: var(--a-surface); color: var(--a-on); border: 2px solid var(--gold); box-shadow: var(--elev-1); }
  .tab-cercle svg { width: 24px; height: 24px; }
  .view { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast-host { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* ---- Blocs d'attente (lot 4) ---- */
.attente { display: flex; flex-direction: column; gap: var(--sp-3); max-width: var(--gab-large); margin: 0 auto; }
.attente-bloc { height: 72px; border-radius: var(--r-l); background: var(--card); border: 1px solid var(--hairline);
  animation: attente-pulse 1.2s var(--ease) infinite alternate; }
.attente-bloc:first-child { height: 116px; }
@keyframes attente-pulse { to { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .attente-bloc { animation: none; opacity: .7; } }

/* ---- View Transitions (lot 4) : seul #view traverse, la coquille ne bouge pas ---- */
@keyframes vt-entree { from { opacity: 0; transform: translateY(8px); } }
@keyframes vt-sortie { to { opacity: 0; } }
::view-transition-old(vue) { animation: vt-sortie var(--dur-2) var(--ease) both; }
::view-transition-new(vue) { animation: vt-entree var(--dur-2) var(--ease) both; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(vue), ::view-transition-new(vue) { animation: none; }
}
