/* ORBIT — mire d'accès sécurisé. Reproduit la maquette 360 de SECALYS.
   Pas de police ni d'asset externe (CSP self) : stack système + SVG inline.
   Seul asset à déposer : /assets/orbit-login-bg.png (fond photo composite). */

:root {
  --navy:    #14253a;
  --ink:     #1f2d3d;
  --muted:   #6b7785;
  --muted-2: #97a2ad;
  --bg:      #eef1f4;
  --card:    #ffffff;
  --line:    #e4e9ee;
  --line-2:  #eef2f5;

  --green:   #18a957;
  --green-d: #128043;

  --pulse:   #16a34a;
  --shield:  #d6a100;
  --pilot:   #e5484d;
  --alive:   #2563eb;

  --radius:  18px;
  --radius-s: 11px;
  --shadow:  0 18px 50px -24px rgba(20, 37, 58, .35);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.login-page {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Fond photo composite (déposer /assets/orbit-login-bg.png) */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg) url("/assets/orbit-login-bg.png") center top / cover no-repeat;
  opacity: .6;
  pointer-events: none;
}

.topbar, .stage, .footbar { position: relative; z-index: 1; }

/* ───────────────── Barre supérieure ───────────────── */
.topbar { padding: 22px 40px 0; }
.topbar-inner {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 30px;
}
.top-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 4px;
}
.top-link:hover { color: var(--navy); }
.lang-btn span { letter-spacing: .02em; }

/* ───────────────── Scène principale ───────────────── */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 44px;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 48px 64px;
}

/* Cluster droit : la chaîne d'apps collée à la carte de login */
.right-cluster {
  display: flex;
  align-items: center;
  gap: 0;
}

/* ───────────────── Colonne gauche : intro ───────────────── */
.intro { justify-self: end; margin-right: 124px; }
.brand { display: flex; align-items: center; gap: 16px; }
.orbit-mark img { display: block; }
.brand .orbit-mark img { height: 58px; width: auto; }
.wordmark {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--navy);
  padding-left: 4px;
}

.tagline {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  line-height: 1.55;
  color: var(--muted);
}
.tagline strong { color: var(--green); }

.headline {
  margin: 30px 0 0;
  font-size: 40px;
  line-height: 1.16;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--navy);
  white-space: nowrap;
}
.headline .dot { color: var(--green); }

.accent-rule {
  display: block;
  width: 64px;
  height: 4px;
  border-radius: 3px;
  background: var(--green);
  margin: 28px 0 0;
}

.lead {
  margin: 22px 0 0;
  max-width: 450px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}
.lead strong { color: var(--navy); font-weight: 600; }

.features {
  list-style: none;
  margin: 40px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 26px;
  justify-content: start;
}
.features li {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--navy);
  width: 86px;
}
.feat-ic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.c-pulse  { color: var(--pulse); }
.c-shield { color: var(--shield); }
.c-pilot  { color: var(--pilot); }
.c-alive  { color: var(--alive); }

/* ───────────────── Colonne centrale : pipeline ───────────────── */
.pipeline {
  display: flex;
  flex-direction: column;
  flex: none;
  position: relative;
  z-index: 1;
  transform: translateY(-8px);
}
.node {
  display: grid;
  grid-template-columns: auto 64px;
  align-items: center;
  column-gap: 16px;
  position: relative;
  padding: 26px 0;
}
/* connecteur pointillé entre les beads (aligné sur le centre du bead, à droite) */
.node::after {
  content: "";
  position: absolute;
  right: 31px;
  top: 50%;
  width: 2px;
  height: 100%;
  background-image: linear-gradient(var(--muted-2) 40%, transparent 0);
  background-size: 2px 7px;
  background-repeat: repeat-y;
  opacity: .5;
  z-index: 0;
}
.node:last-child::after { display: none; }

.bead {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  justify-self: center;
}
.bead svg { width: 26px; height: 26px; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bead img { width: 34px; height: 34px; object-fit: contain; display: block; }
.n-alive .bead img { width: 44px; height: auto; }
.appn {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  line-height: 1.2;
}
.app-name { font-size: 16px; font-weight: 700; letter-spacing: .03em; }
.app-sub { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.app-mark {
  width: 15px; height: 15px;
  position: relative;
  display: inline-block;
  flex: none;
}
.app-mark::before {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 4px; height: 13px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(22deg);
}

/* couleurs par étape : libellé d'étape sombre, app colorée (comme la maquette) */
.n-pulse  .appn { color: var(--pulse); }
.n-shield .appn { color: var(--shield); }
.n-pilot  .appn { color: var(--pilot); }
.n-alive  .appn { color: var(--alive); }

.n-pulse  .bead { box-shadow: 0 0 0 6px rgba(22,163,74,.10), 0 6px 18px -8px rgba(22,163,74,.5); color: var(--pulse); }
.n-shield .bead { box-shadow: 0 0 0 6px rgba(246,180,0,.12), 0 6px 18px -8px rgba(246,180,0,.5); color: var(--shield); }
.n-pilot  .bead { box-shadow: 0 0 0 6px rgba(229,72,77,.10), 0 6px 18px -8px rgba(229,72,77,.5); color: var(--pilot); }
.n-alive  .bead { box-shadow: 0 0 0 6px rgba(37,99,235,.10), 0 6px 18px -8px rgba(37,99,235,.5); color: var(--alive); }
.n-reprise .bead { box-shadow: 0 0 0 6px rgba(22,163,74,.10), 0 6px 18px -8px rgba(22,163,74,.5); color: var(--pulse); }
.bead svg { stroke: currentColor; }
.no-app .appn { display: none; }

/* ───────────────── Colonne droite : carte ───────────────── */
.login { width: 460px; flex: none; position: relative; z-index: 2; margin-left: -8px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 48px -12px rgba(20, 37, 58, .10), 0 4px 12px rgba(20, 37, 58, .05);
  padding: 32px;
  text-align: center;
}
.card-mark img { height: 52px; width: auto; margin: 0 auto; display: block; }
.card h2 {
  margin: 12px 0 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.01em;
}
.card-rule {
  display: block;
  width: 36px; height: 3px;
  border-radius: 2px;
  background: var(--green);
  margin: 12px auto 0;
}

.fp-ring { margin: 24px auto 0; width: 88px; height: 88px; }
.fp-ring img { display: block; width: 88px; height: 88px; }

.card-h { margin: 14px 0 0; font-size: 18px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.card-sub { margin: 7px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn .ic { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  margin-top: 20px;
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: #1d3350; }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-ghost {
  margin-top: 12px;
  background: #fff;
  border-color: var(--line);
  color: var(--navy);
}
.btn-ghost:hover { border-color: #c9d3dc; background: #fafbfc; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-ghost[disabled]:hover, .btn-ghost[aria-disabled="true"]:hover { border-color: var(--line); background: #fff; }

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--pilot);
}
.hint.ok { color: var(--green-d); }
.hint.busy {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.hint.busy::before {
  content: "";
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--muted);
  animation: boot-spin 0.8s linear infinite;
}

.sep {
  position: relative;
  text-align: center;
  margin: 22px 0 2px;
  color: var(--muted-2);
  font-size: 12px;
}
.sep::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--line);
}
.sep span { position: relative; background: var(--card); padding: 0 12px; }

.card-foot {
  margin: 22px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.card-foot a {
  color: var(--green-d);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card-foot a:hover { text-decoration: underline; }

/* ───────────────── Icônes utilitaires ───────────────── */
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 13px; height: 13px; }
.btn-primary .ic { stroke: #fff; }

/* ───────────────── Pied de page ───────────────── */
.footbar { padding: 0 40px 18px; text-align: right; }
.foot-brand { display: flex; align-items: center; gap: 12px; }
.secalys-mark img { width: 30px; height: auto; display: block; }
.foot-name { font-weight: 700; letter-spacing: .14em; color: var(--green-d); font-size: 15px; }
.foot-div { width: 1px; height: 30px; background: var(--line); }
.foot-tag { font-size: 12px; line-height: 1.5; color: var(--muted); }
.foot-meta { font-size: 12.5px; color: var(--muted); }
.foot-meta .ver { color: var(--muted-2); }

/* ───────────────── Responsive ───────────────── */
@media (max-width: 1180px) {
  .stage { grid-template-columns: 1fr 420px; }
  .pipeline { display: none; }
}
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; padding: 10px 22px 24px; }
  .intro { display: none; }
  .login { justify-self: center; margin: 0 auto; }
  .topbar { padding: 18px 22px 0; }
  .foot-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ═════════════════ App-shell SPA (bascule de mode + vues) ═════════════════
   Les wrappers de mode (#auth-view / #app-view) et de vue (.view) s'effacent du
   box-tree via `display: contents` - exactement comme `secalys-topbar` - pour que
   le CSS de la mire (body.login-page ...) et du dashboard (body.app-shell ...)
   s'applique SANS modification : leurs enfants participent directement au layout
   du body. `[hidden]` reprend la main (display: none) grâce à sa specificité. */
#auth-view, #app-view, .view { display: contents; }
#auth-view[hidden], #app-view[hidden], .view[hidden] { display: none; }

/* Le body porte la classe de mode (login-page | app-shell), posée par auth.js.
   En mode auth, on rétablit l'agencement colonne de la mire sur le body. */
body[data-orbit-mode="auth"] { /* body.login-page fournit déjà flex-column */ }

/* Écran d'amorçage : visible tant que /auth/me n'a pas répondu (mode boot). */
#boot-splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 10;
}
body[data-orbit-mode="auth"] #boot-splash,
body[data-orbit-mode="app"] #boot-splash { display: none; }
.boot-spin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--navy, #1e2a44);
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
