/* =====================================================================
   Plateforme de pilotage — shell unifié
   Direction : "mission control" infra/devtools, chrome neutre qui encadre
   les deux dashboards. Signature : rail d'icônes Lucide animées.
   ===================================================================== */

:root {
  --accent: #2bb8e6;
  --accent-deep: #109ccb;

  --chrome: #0c1116;
  --chrome-2: #11181f;
  --rail: #0a0e13;
  --line: #1f2a33;
  --line-soft: #18222a;

  --text: #e8eef2;
  --text-dim: #9fb0bc;
  --text-mut: #66798a;

  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --rail-w: 76px;

  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
}

[data-chrome="light"] {
  --chrome: #eef2f5;
  --chrome-2: #f6f9fb;
  --rail: #e4eaee;
  --line: #d3dde3;
  --line-soft: #dde5ea;
  --text: #16242e;
  --text-dim: #45596a;
  --text-mut: #748694;
  --shadow: 0 18px 50px -22px rgba(20, 40, 55, 0.28);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--chrome);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: #04121a;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  transition: top var(--ease) 0.2s;
}
.skip-link:focus { top: 12px; }

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- RAIL ---------- */
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 0 14px;
}

.rail__brand {
  color: var(--text);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 12px;
  transition: transform var(--ease) 0.4s;
}
.rail__brand:hover { transform: rotate(-8deg) scale(1.05); }
.rail__mark { width: 30px; height: 30px; }
.rail__mark circle { opacity: 0.55; }

.rail__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  align-items: center;
}

.rail__item {
  position: relative;
  width: 52px;
  height: 52px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color var(--ease) 0.25s, background var(--ease) 0.25s, border-color var(--ease) 0.25s;
}
.rail__item:hover { color: var(--text); background: var(--chrome-2); }
.rail__item.is-active {
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.rail__item.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 4px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent);
  transform: translateY(-50%);
  box-shadow: 0 0 14px var(--accent);
}
.rail__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.rail__item .ico { width: 24px; height: 24px; }
.rail__item .ico svg { width: 100%; height: 100%; display: block; }

.rail__spacer { flex: 1; }
.rail__item--ghost { width: 44px; height: 44px; color: var(--text-mut); }

/* tooltip */
.rail__tip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: var(--chrome-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  box-shadow: var(--shadow);
  z-index: 20;
}
.rail__item:hover .rail__tip { opacity: 1; transform: translateY(-50%) translateX(0); }

/* =====================================================================
   ICÔNES ANIMÉES "avec intention" (esprit lucide-animated / itshover)
   Animation au survol + boucle douce sur l'élément actif.
   ===================================================================== */
@media (prefers-reduced-motion: no-preference) {

  /* grid : les tuiles entrent en quinconce */
  .ico-grid .g { transform-origin: center; transition: transform 0.4s var(--ease), opacity 0.4s var(--ease); }
  .rail__item:hover .ico-grid .g1, .is-active .ico-grid .g1 { animation: gridpop 0.5s var(--ease) 0s both; }
  .rail__item:hover .ico-grid .g2, .is-active .ico-grid .g2 { animation: gridpop 0.5s var(--ease) 0.06s both; }
  .rail__item:hover .ico-grid .g3, .is-active .ico-grid .g3 { animation: gridpop 0.5s var(--ease) 0.12s both; }
  .rail__item:hover .ico-grid .g4, .is-active .ico-grid .g4 { animation: gridpop 0.5s var(--ease) 0.18s both; }
  @keyframes gridpop { 0% { transform: scale(0.4); opacity: 0.2; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

  /* server : les deux baies se désassemblent (décommissionnement) + LED clignotent */
  .ico-server .srv { transition: transform 0.45s var(--ease); }
  .rail__item:hover .ico-server .srv-top, .pcard:hover .ico-server .srv-top { transform: translateY(-2.4px); }
  .rail__item:hover .ico-server .srv-bot, .pcard:hover .ico-server .srv-bot { transform: translateY(2.4px); }
  .ico-server .led { stroke-width: 2.6; transition: opacity 0.3s; }
  .rail__item:hover .ico-server .led, .is-active .ico-server .led,
  .pcard:hover .ico-server .led { animation: blink 1.1s steps(1) infinite; }
  .rail__item:hover .ico-server .led2, .is-active .ico-server .led2,
  .pcard:hover .ico-server .led2 { animation-delay: 0.55s; }
  @keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.15; } }

  /* bot : antenne pulse, yeux clignent */
  .ico-bot .bot-bulb { transform-origin: 12px 3px; }
  .rail__item:hover .ico-bot .bot-bulb, .is-active .ico-bot .bot-bulb,
  .pcard:hover .ico-bot .bot-bulb { animation: pulse 1.2s var(--ease) infinite; }
  @keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.7); opacity: 0.6; } }
  .ico-bot .bot-eye { transform-origin: center; transform-box: fill-box; }
  .rail__item:hover .ico-bot .bot-eye, .is-active .ico-bot .bot-eye,
  .pcard:hover .ico-bot .bot-eye { animation: eyeblink 2.4s steps(1) infinite; }
  @keyframes eyeblink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }

  /* theme : rotation des rayons */
  .ico-theme .th-rays { transform-origin: center; transition: transform 0.5s var(--ease); }
  #chrome-toggle:hover .ico-theme .th-rays { transform: rotate(45deg); }
  .ico-theme .th-core { transition: transform 0.5s var(--ease); }
}

/* ---------- STAGE ---------- */
.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 78% -8%, color-mix(in oklab, var(--accent) 9%, transparent), transparent 60%),
    var(--chrome);
}
.stage:focus { outline: none; }

/* ---------- HOME ---------- */
.home {
  height: 100%;
  overflow-y: auto;
  padding: clamp(28px, 4vw, 64px) clamp(24px, 5vw, 80px);
  display: none;
  flex-direction: column;
}
.home.is-visible { display: flex; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-mut);
  margin: 0 0 18px;
}
.eyebrow__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.home__hero { max-width: 760px; margin-bottom: clamp(34px, 5vw, 60px); }
.home__title {
  font-size: clamp(2.6rem, 1.4rem + 4.6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 18px;
}
.home__lede {
  font-size: clamp(1rem, 0.94rem + 0.4vw, 1.22rem);
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0;
  max-width: 60ch;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: clamp(16px, 2vw, 24px);
  margin-bottom: auto;
}

.pcard {
  position: relative;
  background: linear-gradient(180deg, var(--chrome-2), color-mix(in oklab, var(--chrome-2) 70%, var(--chrome)));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease), box-shadow 0.4s var(--ease);
}
.pcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(420px 200px at 100% 0%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}
.pcard:hover {
  transform: translateY(-4px);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
  box-shadow: var(--shadow);
}
.pcard:hover::after { opacity: 1; }
.pcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.pcard__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.pcard__icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 26%, transparent);
}
.pcard__icon svg { width: 26px; height: 26px; }

.pcard__tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mut);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 999px;
}
.pcard__tag--live { color: #f0b24a; border-color: color-mix(in oklab, #f0b24a 40%, transparent); display: inline-flex; align-items: center; gap: 6px; }
.livedot { width: 6px; height: 6px; border-radius: 50%; background: #f0b24a; box-shadow: 0 0 8px #f0b24a; animation: pulse 1.6s var(--ease) infinite; }

.pcard__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 10px; }
.pcard__desc { font-size: 0.95rem; line-height: 1.55; color: var(--text-dim); margin: 0 0 18px; }

.pcard__facets { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; padding: 0; margin: 0 0 22px; }
.pcard__facets li {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--chrome);
  border: 1px solid var(--line-soft);
  padding: 4px 10px;
  border-radius: 7px;
}

.pcard__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
}
.pcard__arrow { width: 18px; height: 18px; transition: transform 0.35s var(--ease); }
.pcard:hover .pcard__arrow { transform: translateX(5px); }

.home__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(28px, 4vw, 48px);
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-mut);
}
.home__foot-sep { opacity: 0.5; }

/* ---------- FRAMES ---------- */
.frames { height: 100%; display: none; flex-direction: column; }
.frames.is-visible { display: flex; }

.frames__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome-2);
  flex: 0 0 auto;
}
.frames__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px 7px 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.frames__back:hover { color: var(--text); border-color: var(--accent); background: var(--chrome); }
.frames__back svg { width: 16px; height: 16px; }
.frames__crumb { font-weight: 700; letter-spacing: -0.01em; font-size: 0.95rem; margin-right: auto; }
.frames__pop {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-dim);
  transition: color 0.2s, border-color 0.2s;
}
.frames__pop:hover { color: var(--accent); border-color: var(--accent); }
.frames__pop svg { width: 16px; height: 16px; }

.frames__host { position: relative; flex: 1 1 auto; background: var(--chrome); }
.frames__host iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
  background: #fff;
}
.frames__host iframe.is-active { display: block; }
.frames__host .frame-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-mut);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

@media (max-width: 640px) {
  :root { --rail-w: 60px; }
  .rail__item { width: 44px; height: 44px; }
  .rail__item .ico { width: 21px; height: 21px; }
}
