/* Bac Hub — tokens de design, reset et composants communs (partagé app + landing)
   Mode sombre : en sombre, --navy / --ink / --text deviennent des couleurs de TEXTE claires.
   Pour un fond sombre fixe (bandeaux, boutons foncés), utiliser --hero / --hero-2 qui restent foncés. */

:root {
  --navy: #0B2545;
  --ink: #1F2A44;
  --text: #3B4A63;
  --muted: #6B7A90;
  --blue: #2F80ED;
  --blue-d: #1A5FC4;
  --sky: #8EC5FF;
  --pale: #D6E8FF;
  --ice: #EEF5FF;
  --line: #C9DCF5;
  --amber: #F5A524;
  --amber-d: #B9741A;
  --green: #1F9D6B;
  --red: #D64545;
  --bg: #F6F9FE;
  --card: #FFFFFF;

  /* dérivés */
  --hero: #0B2545;
  --hero-2: #1A5FC4;
  --on-hero: #FFFFFF;
  --link: #1A5FC4;
  --green-bg: #E6F6EF;
  --red-bg: #FCEBEB;
  --amber-bg: #FFF4E0;
  --purple: #7B5CE6;
  --purple-bg: #F0ECFD;
  --soft: #F1F6FD;
  --line-soft: #E3EDFA;
  --shadow-sm: 0 1px 2px rgba(11, 37, 69, .06), 0 1px 3px rgba(11, 37, 69, .05);
  --shadow: 0 2px 6px rgba(11, 37, 69, .05), 0 8px 24px rgba(11, 37, 69, .07);
  --shadow-lg: 0 12px 40px rgba(11, 37, 69, .14);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --f-head: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --fs-scale: 1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #EAF2FF; --ink: #DCE6F5; --text: #B9C7DB; --muted: #8E9DB3;
    --blue: #4D95F2; --blue-d: #8EC5FF; --sky: #8EC5FF; --pale: #1E3456; --ice: #142540; --line: #27406A;
    --amber: #F5A524; --amber-d: #F7BC5A; --green: #3CC28D; --red: #F07171;
    --bg: #08111F; --card: #101C30;
    --hero: #0E2547; --hero-2: #17468F; --link: #8EC5FF;
    --green-bg: #0F2E25; --red-bg: #361A1F; --amber-bg: #33260F; --purple: #A58FF5; --purple-bg: #221C40;
    --soft: #0D1828; --line-soft: #1B2C47;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy: #EAF2FF; --ink: #DCE6F5; --text: #B9C7DB; --muted: #8E9DB3;
  --blue: #4D95F2; --blue-d: #8EC5FF; --sky: #8EC5FF; --pale: #1E3456; --ice: #142540; --line: #27406A;
  --amber: #F5A524; --amber-d: #F7BC5A; --green: #3CC28D; --red: #F07171;
  --bg: #08111F; --card: #101C30;
  --hero: #0E2547; --hero-2: #17468F; --link: #8EC5FF;
  --green-bg: #0F2E25; --red-bg: #361A1F; --amber-bg: #33260F; --purple: #A58FF5; --purple-bg: #221C40;
  --soft: #0D1828; --line-soft: #1B2C47;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--fs-scale)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--f-body); font-size: 1rem; line-height: 1.7;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--f-head); color: var(--navy); line-height: 1.35; margin: 0; font-weight: 600; }
p { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--link); text-decoration: none; }
ul, ol { margin: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.katex { direction: ltr; unicode-bidi: isolate; font-size: 1.08em; }
.katex-display { direction: ltr; overflow-x: auto; overflow-y: hidden; padding: 4px 0; margin: .6em 0; }
.katex-display > .katex { white-space: nowrap; }
.ic { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: middle; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: .55em 1.15em; border-radius: 999px;
  font-family: var(--f-head); font-weight: 600; font-size: .95rem; line-height: 1.2;
  background: var(--blue); color: #fff; border: 1px solid transparent;
  transition: transform .15s var(--ease), background .15s, box-shadow .15s, opacity .15s;
  text-align: center; white-space: nowrap;
}
.btn:hover { background: var(--blue-d); }
:root[data-theme="dark"] .btn:not(.btn-ghost):not(.btn-soft):not(.btn-light):hover { background: #2F80ED; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-ghost { background: transparent; color: var(--blue-d); border-color: var(--line); }
.btn-ghost:hover { background: var(--ice); }
.btn-soft { background: var(--ice); color: var(--blue-d); }
.btn-soft:hover { background: var(--pale); }
.btn-light { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .35); backdrop-filter: blur(4px); }
.btn-light:hover { background: rgba(255, 255, 255, .28); }
.btn-amber { background: var(--amber); color: #2B1A00; }
.btn-amber:hover { background: #E8961A; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: .35em .9em; font-size: .85rem; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--navy); transition: background .15s;
}
.icon-btn:hover { background: var(--ice); }

/* ---------- cartes, puces ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line-soft); }
.chip {
  display: inline-flex; align-items: center; gap: .35em; padding: .2em .7em; border-radius: 999px;
  background: var(--ice); color: var(--blue-d); font-size: .8rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.chip-amber { background: var(--amber-bg); color: var(--amber-d); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-muted { background: var(--soft); color: var(--muted); }

/* ---------- squelettes ---------- */
.skel { position: relative; overflow: hidden; background: var(--line-soft); border-radius: 12px; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: skel 1.3s infinite;
}
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes skel { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
