/* CyberSeren — état des services
   Principe : la couleur est un signal, pas un décor.
   Tout est opérationnel -> encre et filets. Quelque chose bouge -> la couleur apparaît. */

:root {
  --ink: #0F1435;
  --ink-soft: #3A3F5E;
  --mute: #6E7391;
  --faint: #9AA0B8;
  --paper: #FCFCFD;
  --surface: #FFFFFF;
  --rule: #E4E5ED;
  --rule-firm: #D3D6E3;
  --leader: #BFC3D4;
  --brand: #2000E0;
  --brand-deep: #1700A6;

  --ok: #0E8A5F;
  --info: #2000E0;
  --warn: #A96400;
  --alert: #CF4E0B;
  --crit: #C4162A;

  --signal: var(--ok);

  --sans: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shell: 54rem;
  --gutter: clamp(1.25rem, 5vw, 2rem);
  --bar: 3px;
}

[data-status='operational']    { --signal: var(--ok); }
[data-status='maintenance']    { --signal: var(--info); }
[data-status='degraded']       { --signal: var(--warn); }
[data-status='partial_outage'] { --signal: var(--alert); }
[data-status='major_outage']   { --signal: var(--crit); }

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }

time, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
  letter-spacing: -0.01em;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 2px;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ── Bandeau ─────────────────────────────────────────────── */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  height: 4rem;
}

.masthead__brand { display: inline-flex; }
.masthead__brand img { height: 2rem; width: auto; object-fit: contain; display: block; }

.masthead__section {
  color: var(--mute);
  font-size: 0.8125rem;
  padding-left: 0.875rem;
  border-left: 1px solid var(--rule);
}

/* ── Corps ───────────────────────────────────────────────── */

.page {
  flex: 1;
  padding-block: clamp(2.5rem, 7vw, 4rem) 4rem;
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 6vw, 3.5rem);
}

/* Les groupes de services sont rendus en JS : même rythme vertical que la page. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.page > div:empty { display: none; }

/* ── Relevé principal ────────────────────────────────────── */

.readout {
  display: grid;
  grid-template-columns: var(--bar) 1fr;
  column-gap: clamp(1rem, 3vw, 1.5rem);
}

.readout__spine {
  background: var(--signal);
  position: relative;
  overflow: hidden;
}

.readout__spine::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 34%;
  background: linear-gradient(to bottom, transparent, #fff 55%, transparent);
  opacity: 0;
}

.readout.is-checking .readout__spine::after { animation: sweep 1s cubic-bezier(0.33, 0, 0.2, 1); }

@keyframes sweep {
  from { opacity: 0.85; transform: translateY(-120%); }
  to   { opacity: 0;    transform: translateY(320%); }
}

.readout__state {
  font-size: clamp(1.75rem, 5.2vw, 2.75rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.03em;
  max-width: 18ch;
  text-wrap: balance;
}

.readout__meta {
  margin-top: 0.875rem;
  color: var(--mute);
  font-size: 0.875rem;
}

.readout.is-loading .readout__spine { background: var(--rule-firm); }
.readout.is-loading .readout__state { color: var(--faint); }

/* ── Blocs ───────────────────────────────────────────────── */

.block { display: flex; flex-direction: column; gap: 0.5rem; }

.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--rule-firm);
}

.block__title { font-size: 1.0625rem; }
.block__note { color: var(--faint); font-size: 0.8125rem; }

.link {
  color: var(--brand);
  font-size: 0.8125rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent);
  transition: text-decoration-color 0.15s;
}
.link:hover { color: var(--brand-deep); text-decoration-color: currentColor; }

/* ── Index des services ──────────────────────────────────── */

.entries { display: flex; flex-direction: column; }

.entry {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-block: 0.6875rem;
}

.entries > li:not(:last-child) > .entry,
.entries > .entry:not(:last-child) { border-bottom: 1px solid var(--rule); }

.entry__mark {
  flex: none;
  width: var(--bar);
  height: 0.875rem;
  background: var(--signal);
  align-self: center;
}

.entry__logo {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  object-fit: contain;
  align-self: center;
}

.entry__name { color: var(--ink-soft); min-width: 0; overflow-wrap: anywhere; }

.entry__leader {
  flex: 1 1 1.5rem;
  min-width: 1.5rem;
  border-bottom: 1px dotted var(--leader);
  transform: translateY(-0.3em);
}

.entry__state {
  flex: none;
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--mute);
}

/* Seuls les états qui font l'actualité portent la couleur. */
.entry:not([data-status='operational']) .entry__state { color: var(--signal); font-weight: 500; }

.grid-2 { display: grid; gap: 0 2.5rem; }

@media (min-width: 44rem) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-2 > .entry:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

/* ── Incidents en cours ──────────────────────────────────── */

.alerts { display: flex; flex-direction: column; gap: 0.75rem; }

.alert {
  display: block;
  color: inherit;
  text-decoration: none;
  border-left: var(--bar) solid var(--signal);
  background: color-mix(in srgb, var(--signal) 6%, var(--surface));
  padding: 1.125rem 1.25rem;
  transition: background 0.15s;
}
.alert:hover { background: color-mix(in srgb, var(--signal) 11%, var(--surface)); }

.alert__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.alert__title { font-size: 0.9375rem; }
.alert__state { flex: none; font-size: 0.8125rem; font-weight: 500; color: var(--signal); }
.alert__body { margin-top: 0.375rem; color: var(--ink-soft); max-width: 66ch; }
.alert__stamp { margin-top: 0.625rem; color: var(--mute); font-size: 0.8125rem; }

/* ── Historique ──────────────────────────────────────────── */

.entry--record { align-items: center; gap: 0.875rem; text-decoration: none; color: inherit; }
.entry--record:hover .entry__name { color: var(--ink); }
.entry--record .entry__name { font-weight: 500; color: var(--ink-soft); transition: color 0.15s; }
.entry__period { color: var(--faint); font-size: 0.8125rem; }

/* ── Fiche incident ──────────────────────────────────────── */

.records { display: flex; flex-direction: column; gap: 2.75rem; }

.record { scroll-margin-top: 2rem; }

.record__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule-firm);
}

.record__title { font-size: 1.125rem; }
.record__state { flex: none; font-size: 0.8125rem; font-weight: 500; color: var(--signal); }
.record[data-open='false'] .record__state { color: var(--mute); }
.record__period { margin-top: 0.5rem; color: var(--faint); font-size: 0.8125rem; }

.log { margin-top: 1.5rem; display: flex; flex-direction: column; }

.log__step { display: grid; grid-template-columns: var(--bar) 1fr; column-gap: 1.125rem; }

.log__rail { position: relative; background: var(--rule-firm); }
.log__step:first-child .log__rail { background: linear-gradient(to bottom, transparent 0 0.5rem, var(--rule-firm) 0.5rem); }
.log__step:last-child .log__rail { background: linear-gradient(to bottom, var(--rule-firm) 0 0.75rem, transparent 0.75rem); }

.log__rail::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0.4375rem;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  background: var(--signal);
}

.log__body { padding-bottom: 1.5rem; }
.log__step:last-child .log__body { padding-bottom: 0; }

.log__head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.log__label { font-weight: 500; font-size: 0.875rem; }
.log__stamp { color: var(--faint); font-size: 0.8125rem; }
.log__text { margin-top: 0.25rem; color: var(--ink-soft); max-width: 66ch; }

/* ── États vides et pannes de chargement ─────────────────── */

.notice {
  color: var(--mute);
  font-size: 0.875rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}
.notice:only-child { border-bottom: 0; }

/* ── Pied ────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  color: var(--faint);
  font-size: 0.8125rem;
  padding-block: 1.5rem;
}

/* ── Page historique ─────────────────────────────────────── */

.lede { display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start; }
.lede__title { font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: -0.025em; }

/* Sous 34rem, un titre d'incident et sa période ne tiennent plus sur une ligne. */
@media (max-width: 34rem) {
  .entry--record { flex-wrap: wrap; align-items: baseline; row-gap: 0.125rem; }
  .entry--record .entry__leader { display: none; }
  .entry--record .entry__period { flex-basis: 100%; margin-left: calc(var(--bar) + 0.875rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
