/* ── TOKENS ──────────────────────────────────────────── */
:root {
  --header-height:    44px;
  --ticker-h:         0px;
  --notif-ring-color: var(--accent-light);
}
.dark { --notif-ring-color: var(--accent); }

/* ── SCROLLBAR ───────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--card);
}
*::-webkit-scrollbar             { width: 7px; background: var(--card); }
*::-webkit-scrollbar-thumb       { background: var(--accent); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }
*::-webkit-scrollbar-corner      { background: var(--card); }

/* ── FLASH TICKER ────────────────────────────────────── */

/*
  FIX #5 – Ticker now uses exactly 2 <span> copies.
  The animation translates -50%, so copy-2 seamlessly
  follows copy-1 for a true infinite loop at any text length.
*/
.ftw {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--ticker-h, 26px);
  z-index: 201;
  overflow: hidden;
  display: flex;
  align-items: center;
  transform: translateZ(0); /* own compositor layer */
}

/*
  Couleurs calées sur les tokens sémantiques de base.css.
  --on-* = texte certifié lisible sur le fond correspondant
  (géré automatiquement en dark via les overrides de base.css).
  Le variant "success" utilise --accent (choix produit) et non --success.
*/
.ftw--success { background: var(--accent);  color: var(--on-accent);  }
.ftw--error   { background: var(--danger);  color: var(--on-danger);  }
.ftw--warning { background: var(--warning); color: var(--on-warning); }
.ftw--info    { background: var(--info);    color: var(--on-info);    }

.ftw__track {
  display: flex;
  align-items: center;
  width: max-content;
  white-space: nowrap;
  will-change: transform;
  animation: ftwScroll 150s linear infinite;
}
@keyframes ftwScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.ftw__item {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: .95;
  padding: 0 2.5rem;
}
.ftw__item + .ftw__item::before {
  content: '·';
  margin-right: 2.5rem;
  opacity: .5;
}

/* ── HEADER SHELL ────────────────────────────────────── */

/*
  FIX #7 – ±2px trick covers a 1px sub-pixel gap between ticker & header.
  FIX #12 – translateZ(0) promotes header to own compositor layer.
*/
.header {
  position: fixed;
  top: calc(var(--ticker-h) - 2px);
  left: 0;
  width: 100%;
  height: calc(var(--header-height) + 2px);
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 2px 2rem 0;
  gap: .8em;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  box-shadow: var(--shadow-2);
  transform: translateZ(0);
  will-change: transform;
  transition: top .25s ease;
}

/*
  FIX #13 – iOS Safari drops backdrop-filter layers on fast scroll.
  Mobile → fully opaque background.
*/
@media (max-width: 900px) {
  .header {
    background: var(--card) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ── LOGO ────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: .4em;
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  flex-shrink: 0;
  transition: opacity var(--duration-2) var(--ease-out);
}
.logo:hover { opacity: .8; }
.logo svg   { display: block; flex-shrink: 0; }

/* FIX #10 – Wordmark en HTML pour contrôle CSS total de la police */
.logo__wordmark em {
  font-style: normal;
  font-family: Georgia, serif;
}

/* ── DIVIDER ─────────────────────────────────────────── */
.header-divider {
  width: 1px;
  height: 20px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  flex-shrink: 0;
}

/* ── NAV ─────────────────────────────────────────────── */
.nav-desktop,
.nav-mobile {
  display: flex;
  align-items: center;
  margin-left: auto;
}
.nav-desktop { gap: .4em; }
.nav-mobile  { gap: .5em; display: none; }

@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .nav-mobile  { display: flex; }
}

/* ── NAV LINKS ───────────────────────────────────────── */
.animated-link {
  display: inline-flex;
  align-items: center;
  padding: .3em .7em;
  border-radius: var(--radius-pill);
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .005em;
  transition:
    color      var(--duration-2) var(--ease-out),
    background var(--duration-2) var(--ease-out);
}
.animated-link:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

/* ── NOTIFICATION BELL ───────────────────────────────── */
.notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.notif-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  transition:
    color      var(--duration-2) var(--ease-out),
    background var(--duration-2) var(--ease-out),
    transform  var(--duration-2) var(--ease-out);
}
.notif-link:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  transform: scale(1.08);
}
.notif-link:active { transform: scale(.95); }

.notif-badge {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.01em;
  border-radius: var(--radius-pill);
  border: 2px solid var(--card);
  box-shadow:
    0 1px 6px color-mix(in srgb, var(--accent) 45%, transparent),
    0 0   0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  pointer-events: none;
  z-index: 1;
  animation: notif-pop .25s cubic-bezier(.34, 1.56, .64, 1) both;
}

.notif-badge::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--notif-ring-color);
  opacity: 0;
  animation: notif-pulse 2.6s ease-out 1.4s infinite;
}

@keyframes notif-pop {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}
@keyframes notif-pulse {
  0%   { transform: scale(.8);  opacity: .7; }
  65%  { transform: scale(1.9); opacity: 0;  }
  100% { transform: scale(1.9); opacity: 0;  }
}

/* ── AVATAR ──────────────────────────────────────────── */
.avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  transition: box-shadow var(--duration-2) var(--ease-out);
}
.avatar-wrap:hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

.avatar,
.avatar-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--card);
}
.avatar {
  overflow: hidden;
  display: block;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-initial {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: .88rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── THEME TOGGLE ────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  padding: 0;
  transition:
    color      var(--duration-2) var(--ease-out),
    background var(--duration-2) var(--ease-out),
    transform  var(--duration-3) var(--ease-out);
}
.theme-toggle:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  transform: rotate(20deg);
}
.theme-toggle:active { transform: rotate(40deg) scale(.9); }
.theme-toggle svg    { display: block; }

/* ── FOCUS VISIBLE ───────────────────────────────────── */
.notif-link:focus-visible,
.avatar-wrap:focus-visible,
.theme-toggle:focus-visible,
.animated-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-pill);
}

/* ── REDUCED MOTION ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ftw__track,
  .notif-badge,
  .notif-badge::after { animation: none; }
  .theme-toggle,
  .notif-link {
    transition:
      color      var(--duration-2) var(--ease-out),
      background var(--duration-2) var(--ease-out);
  }
}

/* ── MOBILE ≤ 600px ──────────────────────────────────── */
@media (max-width: 600px) {
  :root           { --header-height: 36px; }
  .header         { padding: 2px 1rem 0; gap: .35em; }
  .logo           { font-size: 1.05rem; }
  .avatar,
  .avatar-initial { width: 24px !important; height: 24px !important; font-size: .8rem !important; }
  .notif-link     { width: 30px; height: 30px; }
  .theme-toggle   { width: 30px; height: 30px; }
}