/* ---------- Rail latéral vitré (style Sideboard) + volet projet + barre mobile ---------- */
body {
  --rail-w: 0px;
  --fly-w: 0px;
  --spring: cubic-bezier(0.3, 1.1, 0.4, 1);
  transition: padding-left 0.5s var(--spring), padding-right 0.45s var(--spring);
}
/* Bureau : rail 60 px (84 avec ses marges), 236 déplié ; le volet projet ajoute 392 px. La page est poussée, jamais recouverte. */
body.rail-on { --rail-w: 84px; padding-left: calc(var(--rail-w) + var(--fly-w)); }
body.rail-on.rail-open { --rail-w: 236px; }
/* Volet : deux fois plus large qu'avant (jusqu'à 760 px), réduit sur les écrans moyens */
body.rail-on { --fly-full: clamp(380px, 46vw, 760px); }
body.rail-on.flyout-open { --fly-w: calc(var(--fly-full) + 12px); }

.rail, .dock, .flyout, .fly-back { font-family: inherit; }
.rail button, .dock button, .flyout button { font: inherit; color: inherit; cursor: pointer; }

/* ----- Rail ----- */
.rail {
  position: fixed;
  z-index: 55;
  top: 12px;
  bottom: 12px;
  left: 12px;
  width: 60px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(130% 40% at 0% 0%, rgba(0, 229, 255, 0.2), transparent 70%),
    radial-gradient(100% 45% at 100% 100%, rgba(31, 94, 255, 0.28), transparent 70%),
    rgba(7, 18, 48, 0.62);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.18);
  opacity: 0;
  transform: translateX(-34px);
  filter: blur(8px);
  transition: width 0.5s var(--spring), opacity 0.5s, transform 0.6s var(--spring), filter 0.5s;
}
body.rail-on .rail { display: flex; }
body.rail-ready .rail { opacity: 1; transform: none; filter: none; }
.rail.expanded { width: 212px; }

.rail-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 8px; flex: none; }
.rail-logo {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 30%;
  background: var(--brand);
  box-shadow: 0 0 22px rgba(31, 94, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: box-shadow 0.3s, transform 0.3s var(--spring);
}
.rail-logo:hover { transform: scale(1.08) rotate(-5deg); box-shadow: 0 0 28px rgba(0, 229, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.rail-logo:active { transform: scale(0.92); }
.rail-logo svg { width: 28px; height: 28px; overflow: visible; }
.rail-logo .chk { stroke-dasharray: 1; stroke-dashoffset: 0; }

.rail-brand {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.12s, transform 0.12s;
}
.rail-v { width: 0.82em; height: auto; }
.rail-fr { color: var(--accent); font-weight: 700; margin-left: 1px; }
.rail.expanded .rail-brand { opacity: 1; transform: none; transition: opacity 0.3s 0.12s, transform 0.4s 0.12s var(--spring); }

.rail-pin {
  margin-left: auto;
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, background-color 0.15s, visibility 0s 0.15s;
}
.rail-pin .ico { width: 14px; height: 14px; transition: transform 0.4s var(--spring); }
.rail-pin[aria-pressed="false"] .ico { transform: rotate(180deg); }
.rail.expanded .rail-pin { opacity: 1; visibility: visible; transition: opacity 0.3s 0.15s, background-color 0.15s, visibility 0s; }
.rail-pin:hover { background: rgba(255, 255, 255, 0.18); }

.rail-label { height: 18px; padding: 0 20px; font-size: 10px; font-weight: 700; letter-spacing: 0.18em; color: rgba(245, 247, 251, 0.4); white-space: nowrap; opacity: 0; transition: opacity 0.12s; flex: none; }
.rail.expanded .rail-label { opacity: 1; transition: opacity 0.3s 0.15s; }

.rail-list {
  position: relative;
  list-style: none;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.rail-list::-webkit-scrollbar { display: none; }
.rail-list li { position: relative; z-index: 1; flex: none; }
.rail-list li.rail-sep { height: 1px; margin: 6px 8px; background: rgba(255, 255, 255, 0.12); }
body.rail-ready .rail-list li:not(.rail-sep) { animation: ri-in 0.55s var(--spring) backwards; animation-delay: calc(var(--i, 0) * 55ms + 180ms); }
@keyframes ri-in { from { opacity: 0; transform: translateX(-18px); } }

.rail-item {
  position: relative;
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: rgba(245, 247, 251, 0.66);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: left;
  overflow: hidden;
  transition: background-color 0.2s, color 0.2s, transform 0.3s var(--spring);
}
.rail-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.rail-item:active { transform: scale(0.96); }
.rail-item[aria-current="true"], .rail-item[aria-pressed="true"] { color: #fff; }
.rail-item[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); }
.ri-ico { position: relative; flex: none; width: 24px; height: 24px; display: grid; place-items: center; transition: transform 0.35s var(--spring); }
.ri-ico .ico { width: 20px; height: 20px; }
.rail-item:hover .ri-ico { transform: scale(1.14) translateX(1px); }
.ri-label { opacity: 0; transform: translateX(-8px); overflow: hidden; text-overflow: ellipsis; transition: opacity 0.1s, transform 0.1s; }
.rail.expanded .ri-label { opacity: 1; transform: none; transition: opacity 0.3s 0.1s, transform 0.4s 0.1s var(--spring); }
.ri-live {
  position: absolute;
  top: 9px;
  left: 28px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: ri-pulse 2.4s ease-in-out infinite;
}
@keyframes ri-pulse { 50% { box-shadow: 0 0 0 5px rgba(0, 229, 255, 0); } }

/* Indicateur du projet ouvert : glisse d'un projet à l'autre */
.rail-ind {
  position: absolute;
  z-index: 0;
  left: 8px;
  right: 8px;
  top: 0;
  height: var(--ih, 44px);
  transform: translateY(var(--iy, 0px));
  border-radius: 14px;
  border: 1px solid rgba(0, 229, 255, 0.4);
  background: linear-gradient(135deg, rgba(31, 94, 255, 0.5), rgba(0, 229, 255, 0.14));
  box-shadow: 0 0 18px rgba(0, 194, 224, 0.28);
  opacity: 0;
  transition: transform 0.5s var(--spring), height 0.4s var(--spring), opacity 0.3s;
  pointer-events: none;
}
.rail-ind::before { content: ""; position: absolute; left: -9px; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: #fff; box-shadow: 0 0 8px #fff; }
.rail-ind.on { opacity: 1; }

/* Sélecteur de langue (bas du rail) : replié = drapeau courant, déplié = les trois */
.rail-langs { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 8px 2px; }
.rail-lang { width: 36px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: rgba(255, 255, 255, 0.07); opacity: 0.55; transition: opacity 0.2s, background-color 0.2s, transform 0.3s var(--spring), border-color 0.2s; }
.rail-lang svg { width: 22px; height: 15px; border-radius: 2px; display: block; }
.rail-lang:hover { opacity: 1; background: rgba(255, 255, 255, 0.16); transform: translateY(-2px) scale(1.06); }
.rail-lang:active { transform: scale(0.92); }
.rail-lang.cur { opacity: 1; border-color: var(--accent); box-shadow: 0 0 12px rgba(0, 229, 255, 0.35); }
.rail:not(.expanded) .rail-lang:not(.cur) { display: none; }
.rail.expanded .rail-lang { animation: lang-in 0.45s var(--spring) backwards; }
.rail.expanded .rail-lang:nth-child(2) { animation-delay: 0.06s; }
.rail.expanded .rail-lang:nth-child(3) { animation-delay: 0.12s; }
@keyframes lang-in { from { opacity: 0; transform: translateY(8px) scale(0.8); } }
/* Bureau : les drapeaux vivent dans le rail ; sur mobile l'en-tête garde les siens */
body.rail-on .lang { display: none; }

/* Barres décoratives (aucune donnée audio : pur effet) */
.rail-bars { flex: none; height: 28px; margin: 4px 0 12px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.rail-bars i { display: block; width: 4px; height: 100%; border-radius: 4px; background: linear-gradient(to top, var(--accent), #8ff3ff); box-shadow: 0 0 10px rgba(0, 229, 255, 0.6); transform-origin: bottom; transform: scaleY(0.3); animation: rb 1.05s ease-in-out infinite paused; }
.rail.expanded .rail-bars i { animation-play-state: running; }
.rail-bars i:nth-child(2) { animation-delay: 0.13s; height: 62%; }
.rail-bars i:nth-child(3) { animation-delay: 0.26s; }
.rail-bars i:nth-child(4) { animation-delay: 0.39s; height: 74%; }
.rail-bars i:nth-child(5) { animation-delay: 0.52s; height: 48%; }
@keyframes rb { 0%, 100% { transform: scaleY(0.28); } 50% { transform: scaleY(1); } }

/* ----- Volet projet ----- */
.flyout {
  position: fixed;
  z-index: 54;
  top: 12px;
  bottom: 12px;
  left: var(--rail-w);
  width: var(--fly-full, 380px);
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(120% 50% at 0% 0%, rgba(0, 194, 224, 0.2), transparent 65%),
    radial-gradient(100% 50% at 100% 100%, rgba(31, 94, 255, 0.28), transparent 65%),
    rgba(7, 18, 48, 0.7);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.16);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-28px) scale(0.95);
  transform-origin: left center;
  filter: blur(8px);
  transition: left 0.5s var(--spring), transform 0.5s var(--spring), opacity 0.3s, filter 0.4s, visibility 0s 0.5s;
}
body.rail-on .flyout { display: flex; }
.flyout.on { opacity: 1; visibility: visible; transform: none; filter: none; transition-delay: 0s; }
.flyout:focus { outline: none; }

.flyout.swap > * { animation: fly-in 0.6s var(--spring) backwards; }
.flyout.swap > :nth-child(2) { animation-delay: 0.06s; }
.flyout.swap > :nth-child(3) { animation-delay: 0.12s; }
.flyout.swap > :nth-child(4) { animation-delay: 0.18s; }
.flyout.swap > :nth-child(5) { animation-delay: 0.24s; }
.flyout.swap > :nth-child(6) { animation-delay: 0.3s; }
@keyframes fly-in { from { opacity: 0; transform: translateY(16px); filter: blur(6px); } }

.fly-top { display: flex; align-items: center; gap: 14px; }
.fly-ico {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(31, 94, 255, 0.7), rgba(0, 194, 224, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 26px -8px rgba(31, 94, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.fly-ico .ico { width: 26px; height: 26px; }
.fly-titles { min-width: 0; flex: 1; }
.fly-titles h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.fly-tag { margin-top: 2px; color: var(--accent); font-size: 0.8125rem; font-weight: 600; }
.fly-close {
  flex: none;
  align-self: flex-start;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  transition: background-color 0.2s, transform 0.3s var(--spring);
}
.fly-close:hover { background: rgba(255, 255, 255, 0.2); transform: rotate(90deg); }

.fly-shot { border-radius: 14px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.18); background: #050c20; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4); transition: transform 0.4s var(--spring); }
.fly-shot:hover { transform: translateY(-3px) scale(1.01); }
.fly-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: rgba(255, 255, 255, 0.07); border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.fly-bar i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); }
.fly-bar span { margin-left: 8px; flex: 1; min-width: 0; padding: 2px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fly-screen { aspect-ratio: 16 / 10; overflow: hidden; }
.fly-screen img { width: 100%; height: 100%; display: block; object-fit: cover; }
.flyout.swap .fly-screen img { animation: shot-in 0.9s var(--spring) 0.15s backwards; }
@keyframes shot-in { from { transform: scale(1.18); filter: blur(10px); opacity: 0; } }

.fly-video { border-radius: 14px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.18); background: #000; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4); }
.fly-video video { display: block; width: 100%; max-height: min(54vh, 440px); object-fit: contain; background: #000; }
.fly-desc { color: var(--muted); font-size: 0.9375rem; line-height: 1.6; }
.fly-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
.fly-go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), #00a8d0);
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
  text-decoration: none;
  box-shadow: 0 12px 28px -10px rgba(31, 94, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.3s var(--spring), box-shadow 0.3s;
}
.fly-go .ico { width: 18px; height: 18px; transition: transform 0.3s var(--spring); }
.fly-go:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(0, 229, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.fly-go:hover .ico { transform: translate(2px, -2px); }
.fly-go:active { transform: scale(0.97); }
.fly-host { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.fly-host .live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.fly-soon { padding: 8px 14px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--muted); font-size: 0.8125rem; }

.fly-nav { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.fly-count { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.fly-step { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 12px; background: rgba(255, 255, 255, 0.07); transition: background-color 0.2s, transform 0.3s var(--spring); }
.fly-step:hover { background: rgba(255, 255, 255, 0.18); transform: scale(1.1); }
.fly-step.next .ico { transform: rotate(180deg); }

/* ----- Mobile / tactile : barre en bas + feuille remontante ----- */
.dock { display: none; }
.fly-back { display: none; }
body.dock-mode { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
body.dock-mode.flyout-open { overflow: hidden; }
body.dock-mode .dock {
  position: fixed;
  z-index: 56;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  height: 68px;
  display: flex;
  gap: 4px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(7, 18, 48, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.16);
  animation: dock-in 0.6s var(--spring) backwards;
}
body.dock-mode .dock::-webkit-scrollbar { display: none; }
@keyframes dock-in { from { transform: translateY(90px); opacity: 0; } }
.dock-item {
  flex: 1 0 auto;
  min-width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 8px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: rgba(245, 247, 251, 0.66);
  font-size: 10px;
  font-weight: 600;
  scroll-snap-align: center;
  transition: background-color 0.2s, color 0.2s, transform 0.3s var(--spring);
}
.dock-item .ri-label { opacity: 1; transform: none; max-width: 68px; white-space: nowrap; }
.dock-item:active { transform: scale(0.92); }
.dock-item[aria-current="true"] { color: #fff; background: linear-gradient(135deg, rgba(31, 94, 255, 0.6), rgba(0, 229, 255, 0.2)); box-shadow: 0 0 16px rgba(0, 194, 224, 0.3); }
body.dock-mode:not(.side-open) .side-toggle { display: none; }
body.dock-mode .flyout {
  display: flex;
  z-index: 58;
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-height: 82vh;
  max-height: 82dvh;
  border-radius: 26px 26px 0 0;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transform-origin: bottom center;
  filter: none;
}
body.dock-mode .flyout.on { transform: none; }
body.dock-mode .fly-back { display: block; position: fixed; inset: 0; z-index: 57; background: rgba(3, 8, 22, 0.62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.35s; }
body.dock-mode .fly-back.on { opacity: 1; pointer-events: auto; }

.rail :focus-visible, .dock :focus-visible, .flyout :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  body, .rail, .rail *, .flyout, .flyout *, .dock, .dock *, .fly-back { transition-duration: 0.01ms !important; transition-delay: 0s !important; animation: none !important; }
  .rail-bars i { transform: scaleY(0.6); }
}
