/* KubeNow — front v0.5 : tableau de bord.
   Idée directrice : le temps est la matière du produit. Le compte à rebours est le seul élément
   qui crie (sa graisse s'amincit avec le temps qui reste) ; tout le reste se tait : une bande de
   mesures, une dalle sombre pour le terminal, une colonne pour les applications. */

@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/unbounded-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --glacier: #e9eef2;
  --abyss: #0d2b3e;
  --signal: #3d4bff;
  --signal-ink: #2a36d6;
  --ice: #c9f2ff;
  --mist: #8fb3c4;
  --slate: #4a6373;
  --amber: #f5b83d;
  --amber-ink: #8a5300;
  --danger: #b3243a;

  --bg: var(--glacier);
  --ink: var(--abyss);
  --ink-2: var(--slate);
  --surface: #f6f9fb;
  --slab: var(--abyss);
  --rule: rgba(13, 43, 62, 0.14);
  --track: rgba(13, 43, 62, 0.1);
  --ok: #10805a;
  --ok-bg: #d4f1e4;
  --warn-bg: #fbe8c2;

  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --text: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --wght: 800; /* graisse du compte à rebours, pilotée par app.js */
}

/* Thème sombre : celui du système, sauf choix explicite (bouton, data-theme sur <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071a26;
    --ink: #e4edf2;
    --ink-2: #93acba;
    --surface: #0c2433;
    --slab: #03111a;
    --rule: rgba(228, 237, 242, 0.13);
    --track: rgba(228, 237, 242, 0.12);
    --signal: #6b76ff;
    --signal-ink: #9aa2ff;
    --amber-ink: var(--amber);
    --danger: #ff8d9b;
    --ok: #7ee2b8;
    --ok-bg: rgba(126, 226, 184, 0.14);
    --warn-bg: rgba(245, 184, 61, 0.16);
  }
}
:root[data-theme="dark"] {
  --bg: #071a26;
  --ink: #e4edf2;
  --ink-2: #93acba;
  --surface: #0c2433;
  --slab: #03111a;
  --rule: rgba(228, 237, 242, 0.13);
  --track: rgba(228, 237, 242, 0.12);
  --signal: #6b76ff;
  --signal-ink: #9aa2ff;
  --amber-ink: var(--amber);
  --danger: #ff8d9b;
  --ok: #7ee2b8;
  --ok-bg: rgba(126, 226, 184, 0.14);
  --warn-bg: rgba(245, 184, 61, 0.16);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 var(--gutter); }
code { font-family: var(--mono); font-size: 0.88em; font-variant-ligatures: none; }
a { color: var(--signal-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; border-radius: 6px; }

/* ---- Vues : une seule visible à la fois ---------------------------------------------------- */
.view { display: none; }
body[data-view="anon"] .view[data-for="anon"],
body[data-view="empty"] .view[data-for="empty"],
body[data-view="progress"] .view[data-for="progress"],
body[data-view="ready"] .view[data-for="ready"],
body[data-view="deleting"] .view[data-for="deleting"],
body[data-view="failed"] .view[data-for="failed"] { display: block; }
body[data-view="anon"] .view.landing { display: grid; }
body:not([data-view="anon"]) .anon-only { display: none; }

/* ---- En-tête ------------------------------------------------------------------------------ */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px var(--gutter);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 22px/1 var(--display); letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
/* le symbole : le temps qui reste (arc) et « maintenant » (point) — même dessin que favicon.svg */
.mark { width: 30px; height: 30px; flex: none; }
.mark rect { fill: var(--abyss); }
.mark path { fill: none; stroke: var(--ice); stroke-width: 7; stroke-linecap: round; }
.mark circle { fill: var(--signal); }
.is-dark .mark rect { fill: #e4edf2; }
.is-dark .mark path { stroke: var(--abyss); }
.is-dark .mark circle { fill: #3d4bff; }
.bar-end { display: flex; align-items: center; gap: 12px; }
.theme-toggle {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule); border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ink-2); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun { display: none; }
.is-dark .theme-toggle .sun { display: block; }
.is-dark .theme-toggle .moon { display: none; }
.who { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 15px; }

/* ---- Boutons ------------------------------------------------------------------------------ */
.btn, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 12px;
  font: 600 16px/1 var(--text); text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn { border: 0; background: var(--signal); color: #fff; }
.btn:hover { background: var(--signal-ink); color: #fff; }
.btn.big { min-height: 56px; padding: 0 30px; font-size: 18px; border-radius: 14px; }
.ghost { border: 1px solid var(--rule); background: transparent; color: var(--ink); }
.ghost:hover { border-color: var(--ink-2); }
.ghost.small { min-height: 44px; padding: 0 14px; font-size: 15px; font-weight: 500; }
.ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.ghost.danger:hover { border-color: var(--danger); }
.btn:disabled, .ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.armed { background: var(--danger) !important; color: #fff !important; border-color: var(--danger) !important; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 560px); margin: 0; padding: 12px 18px; border-radius: 12px;
  background: var(--danger); color: #fff; font-weight: 500;
}

/* ---- Titres partagés ---------------------------------------------------------------------- */
.display {
  margin: 0; font: 300 clamp(38px, 6.2vw, 84px)/1.02 var(--display); letter-spacing: -0.035em;
  max-width: 15ch;
}
.lede { margin: 0; max-width: 38em; font-size: clamp(17px, 1.6vw, 20px); color: var(--ink-2); }
.fine { margin: 0; font-size: 15px; color: var(--ink-2); }

/* ---- Visiteur ----------------------------------------------------------------------------- */
.landing {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(28px, 4vw, 64px); align-items: center;
  padding: clamp(24px, 6vh, 72px) 0 56px;
}
.landing .pitch { display: flex; flex-direction: column; gap: 26px; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; }
.demo {
  margin: 0; background: var(--slab); border-radius: 22px; padding: 26px 26px 30px;
  min-height: 360px; box-shadow: 0 30px 60px -30px rgba(13, 43, 62, 0.55);
}
.demo pre {
  margin: 0; font: 400 14.5px/1.7 var(--mono); color: #dcebf2; white-space: pre-wrap; overflow-wrap: break-word;
}
.demo .p { color: var(--mist); }
.demo .ok { color: #7ee2b8; }
.demo .url { color: var(--ice); text-decoration: underline; text-underline-offset: 3px; }
.demo .caret { display: inline-block; width: 9px; height: 1.15em; vertical-align: -0.2em; background: var(--ice); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.facts {
  grid-column: 1 / -1; list-style: none; margin: 24px 0 0; padding: 28px 0 0;
  border-top: 1px solid var(--rule);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px;
  color: var(--ink-2); font-size: 16px;
}
.facts strong { display: block; color: var(--ink); font: 600 17px/1.4 var(--display); margin-bottom: 6px; letter-spacing: -0.01em; }

/* ---- Accueil connecté, création, suppression ---------------------------------------------- */
.welcome, .making, .gone { padding: clamp(32px, 8vh, 96px) 0 64px; }
.welcome > * + *, .making > * + *, .gone > * + * { margin-top: 26px; }
.included {
  margin-top: 48px !important; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px;
  border-top: 1px solid var(--rule); padding-top: 24px; max-width: 960px;
}
.included dt { font: 600 15px/1.3 var(--display); }
.included dd { margin: 4px 0 0; color: var(--ink-2); }

.steps { list-style: none; padding: 0; display: grid; gap: 12px; font: 500 17px/1.4 var(--mono); max-width: 560px; }
.steps li { display: flex; align-items: center; gap: 14px; color: var(--ink-2); }
.steps li::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--rule);
}
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.current { color: var(--ink); font-weight: 700; }
.steps li.current::before { border-color: var(--signal); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meter { height: 6px; max-width: 560px; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--signal); border-radius: 99px; transition: width 0.6s ease; }

/* ---- Tableau de bord ---------------------------------------------------------------------- */
.dash { padding: 12px 0 48px; }
.life {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 20px 32px;
}
.status { margin: 0 0 6px; display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 15px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.countdown {
  margin: 0; font-family: var(--display); font-weight: var(--wght);
  font-size: clamp(64px, 11vw, 148px); line-height: 0.95; letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums; transition: font-weight 1.2s ease;
}
.note { margin: 10px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.lifeline { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.lifeline span { display: block; height: 100%; background: var(--signal); transform-origin: left; transition: transform 1s ease; }
body.late .countdown { color: var(--amber-ink); }
body.late .lifeline span { background: var(--amber); }

/* Une bande de mesures, pas des cartes : séparées par des filets verticaux */
.gauges {
  margin-top: 28px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.gauge { padding: 18px 22px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gauge + .gauge { border-left: 1px solid var(--rule); }
.gauge:first-child { padding-left: 0; }
.gauge h2 { margin: 0; font: 500 15px/1.3 var(--text); color: var(--ink-2); }
.gauge .value { margin: 0; font: 700 30px/1.15 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.gauge .unit { font: 500 15px var(--text); color: var(--ink-2); letter-spacing: 0; }
.gauge .of, .gauge .split { margin: 0; font-size: 14px; color: var(--ink-2); }
.spark { width: 100%; height: 32px; overflow: visible; }
.spark path { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.gauge .track { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; margin: 13px 0; }
.gauge .track span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width 0.6s ease; }
.split .pending { color: var(--amber-ink); }
.split .failed { color: var(--danger); }
.gauges-note { grid-column: 1 / -1; margin: 0; padding: 10px 0 12px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--ink-2); }

.work { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 28px; align-items: start; }

.slab {
  position: relative; background: var(--slab); border-radius: 22px; padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 10px; height: clamp(420px, 62vh, 760px);
}
.slab-bar { display: flex; align-items: center; gap: 14px; padding: 0 4px 0 8px; }
.slab-title { font: 500 14px var(--display); color: var(--ice); letter-spacing: 0.01em; }
.slab-state { flex: 1; font-size: 13px; color: var(--mist); }
.slab-state.live { color: #7ee2b8; }
.icon {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(201, 242, 255, 0.22); border-radius: 10px; background: transparent; color: var(--ice); cursor: pointer;
}
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.term { flex: 1; min-height: 0; padding: 4px 6px; }
.term .xterm { height: 100%; }
.term .xterm-viewport { background-color: transparent !important; scrollbar-color: #1d4256 transparent; }
.ended {
  position: absolute; inset: 0; border-radius: 22px; display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center; background: color-mix(in srgb, var(--slab) 92%, transparent); color: #dcebf2;
}
body.term-max .slab { position: fixed; inset: 12px; z-index: 30; height: auto; }

.side { display: flex; flex-direction: column; gap: 32px; }
.side h2 { margin: 0 0 12px; font: 700 18px/1.3 var(--display); letter-spacing: -0.01em; }
.apps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.apps li { padding: 12px 0; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.apps li:first-child { border-top: 1px solid var(--rule); }
.apps a { font: 600 14.5px/1.4 var(--mono); word-break: break-all; font-variant-ligatures: none; }
.apps .where { font-size: 14px; color: var(--ink-2); }
.apps-empty p { margin: 0 0 14px; color: var(--ink-2); font-size: 15px; }
.facts-list { margin: 0; display: grid; gap: 10px; font-size: 15px; }
.facts-list div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
.facts-list dt { color: var(--ink-2); }
.facts-list dd { margin: 0; font-weight: 600; text-align: right; }

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 20px var(--gutter); font-size: 14px; color: var(--ink-2); border-top: 1px solid var(--rule);
}

/* ---- Petits écrans ------------------------------------------------------------------------ */
@media (max-width: 1000px) {
  .landing { grid-template-columns: minmax(0, 1fr); }
  .work { grid-template-columns: minmax(0, 1fr); }
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gauge:nth-child(3) { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); }
  .gauge:nth-child(4) { border-top: 1px solid var(--rule); }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .life { grid-template-columns: minmax(0, 1fr); }
  .actions { justify-content: flex-start; }
  .facts, .included { grid-template-columns: minmax(0, 1fr); }
  .gauge { padding: 14px 12px 16px; }
  .gauge .value { font-size: 24px; }
  .slab { height: 70vh; border-radius: 16px; padding: 10px; }
  .who span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
