/* ==========================================================================
   Domo — base : remise à zéro, typographie, coquille de l'appli
   (barre latérale sur grand écran, barre d'onglets en bas sur mobile)
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
[hidden] { display: none !important; }
pre, code, kbd { font-family: var(--font-mono); font-size: 0.85em; }
table { border-collapse: collapse; }

h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: var(--fs-l); font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-m); font-weight: 650; }

/* Focus visible net, partout */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

::selection { background: var(--primary-soft); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: var(--fs-s); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-l { display: flex; flex-direction: column; gap: 20px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon { width: 22px; height: 22px; flex: none; stroke-width: 2; }
.icon-s { width: 18px; height: 18px; }
.icon-xs { width: 15px; height: 15px; }
.icon-l { width: 28px; height: 28px; }

/* ---------- Écran de démarrage (statique, dans index.html) ---------- */
.splash {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  color: var(--text-2);
}
.splash img { width: 64px; height: 64px; border-radius: 16px; box-shadow: var(--shadow-2); }
.splash__dots { display: flex; gap: 6px; }
.splash__dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  animation: splash-dot 1.1s var(--ease) infinite;
}
.splash__dots span:nth-child(2) { animation-delay: 0.15s; }
.splash__dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes splash-dot { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* ---------- Coquille ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
}

.main {
  padding:
    calc(var(--safe-top) + 12px)
    calc(var(--safe-right) + var(--gutter))
    calc(var(--tabbar-h) + var(--safe-bottom) + 28px)
    calc(var(--safe-left) + var(--gutter));
  max-width: 1280px;
  margin: 0 auto;
  outline: none;
}
.app--no-nav .main { padding-bottom: calc(var(--safe-bottom) + 28px); }

.view { animation: view-in var(--t-slow) var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Lien d'évitement (clavier) */
.skip-link {
  position: fixed; z-index: 100;
  top: calc(var(--safe-top) + 8px); left: 8px;
  padding: 10px 14px;
  border-radius: var(--r-s);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-2);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Barre d'onglets (mobile) ---------- */
.tabbar {
  position: fixed;
  z-index: 40;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 6px calc(var(--safe-right) + 6px) calc(var(--safe-bottom) + 6px) calc(var(--safe-left) + 6px);
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border);
}
.tabbar__item {
  flex: 1 1 0;
  max-width: 120px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--r-m);
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
.tabbar__item:hover { text-decoration: none; color: var(--text-2); }
.tabbar__pill {
  display: grid; place-items: center;
  width: 54px; height: 30px;
  border-radius: var(--r-full);
  transition: background-color var(--t-med) var(--ease), transform var(--t-fast) var(--ease);
}
.tabbar__item:active .tabbar__pill { transform: scale(0.92); }
.tabbar__item[aria-current="page"] { color: var(--primary); }
.tabbar__item[aria-current="page"] .tabbar__pill { background: var(--primary-soft); }

/* ---------- Barre latérale (grand écran) ---------- */
.sidebar { display: none; }

@media (min-width: 960px) {
  .tabbar { display: none; }
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0; bottom: 0; left: 0;
    width: calc(var(--sidebar-w) + var(--safe-left));
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: calc(var(--safe-top) + 22px) 14px calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 14px);
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(1.5) blur(20px);
    backdrop-filter: saturate(1.5) blur(20px);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .main {
    margin-left: calc(var(--sidebar-w) + var(--safe-left));
    padding: calc(var(--safe-top) + 32px) calc(var(--safe-right) + 36px) calc(var(--safe-bottom) + 40px) 36px;
    max-width: calc(1240px + 72px);
  }
  .app--no-nav .main { margin-left: auto; }
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 10px 18px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}
.brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-1); }
.brand small { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); letter-spacing: 0; }

.sidebar__section {
  margin: 14px 12px 4px;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.sidebar__item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-s);
  color: var(--text-2);
  font-weight: 560;
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sidebar__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar__item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.sidebar__spacer { flex: 1; }
.sidebar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar__user:hover { text-decoration: none; background: var(--surface-3); }
.sidebar__user .grow > span { display: block; }

/* ---------- En-têtes de page ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 8px 0 20px;
}
.page-head__titles { min-width: 0; }
.page-head__eyebrow {
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 4px;
}
.page-head__sub { margin-top: 6px; color: var(--text-2); font-size: var(--fs-m); }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head h1:focus { outline: none; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px;
  margin: -6px 0 0 -8px;
  padding: 0 10px 0 4px;
  border-radius: var(--r-s);
  color: var(--text-2);
  font-weight: 600;
}
.back-link:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }

.section { margin-top: 28px; }
.section__title {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  font-size: var(--fs-l);
}
.section__title .count {
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--text-3);
}

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
