/* ==========================================================
   ui.css - palette de commandes, notifications passagères,
   squelettes, états vides, tiroir mobile, démarrage.
   ========================================================== */

/* ==========================================================
   PALETTE DE COMMANDES (Cmd+K)
   ========================================================== */
.pal-backdrop {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(20,19,17,.42);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  opacity: 0; transition: opacity .13s;
}
.pal-backdrop.open { opacity: 1; }

.pal {
  width: 100%; max-width: 640px;
  background: var(--bg-card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  overflow: hidden;
  transform: translateY(-8px) scale(.985);
  transition: transform .13s;
  display: flex; flex-direction: column;
  max-height: 72vh;
}
.pal-backdrop.open .pal { transform: none; }

.pal-input-row {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.pal-input-row svg { width: 17px; height: 17px; color: var(--ink-4); flex: none; }
.pal-input {
  flex: 1; border: 0; outline: 0; background: none;
  font-family: var(--sans); font-size: 16px; color: var(--ink);
}
.pal-input::placeholder { color: var(--ink-4); }
.pal-esc {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; flex: none;
}

.pal-results { overflow-y: auto; flex: 1; padding: 6px; }
.pal-group-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-4);
  padding: 10px 12px 5px;
}
.pal-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 9px 12px; border: 0; background: none; border-radius: 6px;
  cursor: pointer; text-decoration: none; color: var(--ink);
}
.pal-item:hover, .pal-item.sel { background: rgba(29,78,216,.08); }
.pal-item.sel { box-shadow: inset 2px 0 0 var(--blue); }
.pal-icon {
  width: 28px; height: 28px; flex: none; border-radius: 5px;
  background: var(--bg-soft); display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  overflow: hidden;
}
.pal-icon img { width: 100%; height: 100%; object-fit: cover; }
.pal-body { flex: 1; min-width: 0; }
.pal-title {
  font-size: 14px; font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pal-sub {
  font-size: 12px; color: var(--ink-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pal-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); flex: none; }
.pal-item mark { background: rgba(29,78,216,.2); color: inherit; padding: 0 1px; border-radius: 2px; }

.pal-foot {
  display: flex; align-items: center; gap: 16px;
  padding: 9px 16px; border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
}
.pal-foot kbd {
  font-size: 10px; padding: 1px 5px; border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 3px; background: var(--bg-card);
}
.pal-empty { padding: 34px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }
.pal-empty b { display: block; color: var(--ink); margin-bottom: 5px; }

/* ==========================================================
   NOTIFICATIONS PASSAGÈRES
   ========================================================== */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 700;
  display: flex; flex-direction: column-reverse; gap: 9px;
  max-width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px; border-radius: 8px;
  background: var(--ink); color: #ecebe6;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  font-size: 13.5px; line-height: 1.5;
  pointer-events: auto;
  animation: toast-in .2s cubic-bezier(.2,.8,.3,1);
}
.toast.out { animation: toast-out .16s forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(16px); } }
.toast-icon { flex: none; width: 17px; height: 17px; margin-top: 1px; }
.toast.ok    .toast-icon { color: #7fce7a; }
.toast.error .toast-icon { color: #f08a7a; }
.toast.info  .toast-icon { color: #a8c0f0; }
.toast-body { flex: 1; min-width: 0; }
.toast-body b { display: block; color: #fff; margin-bottom: 2px; font-weight: 600; }
.toast-close {
  flex: none; border: 0; background: none; color: rgba(236,235,230,.55);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
.toast-close:hover { color: #fff; }
.toast-action {
  background: none; border: 0; color: #a8c0f0; cursor: pointer;
  font-size: 13px; text-decoration: underline; padding: 4px 0 0; display: block;
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.out { animation: none; }
}

/* ==========================================================
   SQUELETTES DE CHARGEMENT
   ---------------------------------------------------------- 
   Un squelette de la forme du contenu attendu, pas un spinner :
   la page ne saute pas quand les données arrivent.
   ========================================================== */
.sk {
  background: linear-gradient(90deg,
    var(--bg-soft) 25%, rgba(0,0,0,.045) 37%, var(--bg-soft) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: 4px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

.sk-line { height: 12px; margin-bottom: 8px; }
.sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; } .sk-line.w100 { width: 100%; }
.sk-title { height: 20px; width: 45%; margin-bottom: 14px; }
.sk-tile {
  border: 1px solid var(--line); border-radius: 3px;
  padding: 22px 14px 14px; min-height: 214px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.sk-tile .sk-icon { width: 62px; height: 62px; border-radius: 3px; }
.sk-row {
  display: grid; grid-template-columns: 46px 1fr 90px; gap: 14px;
  align-items: center; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 3px; margin-bottom: 10px;
}
.sk-avatar { width: 46px; height: 46px; border-radius: 3px; }
.sk-block { height: 120px; border-radius: var(--r-md); margin-bottom: 12px; }

/* ==========================================================
   ÉTATS VIDES
   ========================================================== */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px;
  padding: 56px 24px;
  border: 1px dashed var(--line-2); border-radius: var(--r-md);
  background: var(--bg-soft);
}
.empty-icon {
  width: 44px; height: 44px; color: var(--ink-4);
  margin-bottom: 4px; opacity: .55;
}
.empty b { font-size: 16px; font-weight: 500; color: var(--ink); }
.empty span { font-size: 14px; color: var(--ink-3); max-width: 44ch; line-height: 1.55; }
.empty .btn { margin-top: 8px; border-radius: 3px; }
.empty.error { border-style: solid; border-color: #e8c4be; background: #fdf3f1; }
.empty.error b { color: #a3341f; }

/* ==========================================================
   TIROIR DE NAVIGATION MOBILE
   ========================================================== */
.nav-burger {
  display: none; width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-card); cursor: pointer; color: var(--ink);
}
.nav-burger svg { width: 19px; height: 19px; }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 550;
  background: rgba(20,19,17,.38);
  opacity: 0; transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 560;
  width: min(320px, 86vw);
  background: var(--bg-card); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.drawer-close {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); cursor: pointer; color: var(--ink);
}
.drawer-search {
  margin: 14px 18px; padding: 10px 13px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--bg); color: var(--ink-3);
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; cursor: pointer; width: calc(100% - 36px);
  text-align: left;
}
.drawer-search svg { width: 15px; height: 15px; }
.drawer-search .k { margin-left: auto; font-family: var(--mono); font-size: 10.5px; }
.drawer-group { padding: 6px 0 12px; }
.drawer-group h5 {
  font-family: var(--mono); font-size: 10px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-4); padding: 10px 18px 4px;
}
.drawer a.drawer-link {
  display: block; padding: 11px 18px; font-size: 15px;
  color: var(--ink); text-decoration: none; border-left: 2px solid transparent;
}
.drawer a.drawer-link:hover { background: var(--bg-soft); }
.drawer a.drawer-link.active { border-left-color: var(--blue); color: var(--blue); background: rgba(29,78,216,.05); }
.drawer-foot { margin-top: auto; padding: 16px 18px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.drawer-foot .btn { width: 100%; justify-content: center; border-radius: 6px; }

@media (max-width: 900px) {
  .nav-burger { display: flex; }
  nav.topnav .nav-links { display: none; }
}

/* ==========================================================
   DÉMARRAGE
   ========================================================== */
.start-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg-card); overflow: hidden; margin-bottom: 20px;
}
.start-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--bg-soft);
}
.start-head h3 { font-size: 16px; margin: 0; flex: 1; }
.start-progress { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.start-bar { height: 4px; background: var(--line); }
.start-bar i { display: block; height: 100%; background: var(--blue); transition: width .35s; }
.start-step {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 14px;
  align-items: start; padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.start-step:last-child { border-bottom: 0; }
.start-tick {
  width: 22px; height: 22px; border-radius: 50%; margin-top: 1px;
  border: 1px solid var(--line-2); background: var(--bg);
  display: grid; place-items: center; cursor: pointer;
  font-family: var(--mono); font-size: 11px; color: var(--ink-4);
}
.start-step.done .start-tick { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.start-step.done .start-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.start-title { font-size: 15px; font-weight: 500; margin-bottom: 3px; }
.start-desc { font-size: 13.5px; color: var(--ink-3); line-height: 1.5; }
.start-step .btn { border-radius: 3px; padding: 5px 12px; font-size: 12.5px; }
.start-dismiss {
  background: none; border: 0; color: var(--ink-4); cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; text-decoration: underline;
}

/* ==========================================================
   404 / 500
   ========================================================== */
.err-page {
  max-width: 620px; margin: 0 auto;
  padding: calc(var(--doc-top,64px) + 90px) 24px 120px; text-align: center;
}
.err-code {
  font-family: var(--mono); font-size: 76px; line-height: 1;
  color: var(--line-2); letter-spacing: -0.04em; margin-bottom: 18px;
}
.err-page h1 { font-size: 30px; font-weight: 400; letter-spacing: -0.028em; margin-bottom: 12px; }
.err-page p { font-size: 15.5px; color: var(--ink-2); line-height: 1.65; margin-bottom: 12px; }
.err-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.err-actions .btn { border-radius: 3px; }
.err-suggest {
  margin-top: 40px; padding-top: 26px; border-top: 1px solid var(--line);
  text-align: left;
}
.err-suggest h4 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-4); margin-bottom: 12px; text-align: center;
}
.err-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 8px; }
.err-links a {
  display: block; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 3px; background: var(--bg-card);
  text-decoration: none; color: var(--ink); font-size: 14px;
}
.err-links a:hover { border-color: var(--blue); color: var(--blue); }
.err-links span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* bouton de recherche dans la barre */
.nav-search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg-card);
  color: var(--ink-3); cursor: pointer;
}
.nav-search-btn:hover { border-color: var(--blue); color: var(--blue); }
.nav-search-btn svg { width: 15px; height: 15px; }
.nav-search-btn .k { font-family: var(--mono); font-size: 11px; opacity: .7; }
@media (max-width: 1100px) { .nav-search-btn .k { display: none; } }
@media (max-width: 900px)  { .nav-search-btn { display: none; } }
