/* ═══════════════════════════════════════════════════════════════════════════
   ambiance.css — ticker, horloge, hub, glitch calme, level-up, coucher.
   À charger APRÈS lcd.css / panels.css (override par spécificité, sans !important
   sauf pour couper les animations en mode « No Strobe »).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Ticker : vitesse constante (80 px/s) — variables posées par ticker.js ──
   --ticker-from / --ticker-to : translateX de départ / d'arrivée (px)
   --ticker-duration           : (largeur conteneur + largeur contenu) / 80          */
.ticker-bar .ticker-content[data-scroll] {
  animation: vfg-ticker-scroll var(--ticker-duration, 35s) linear infinite;
  will-change: transform;
}
@keyframes vfg-ticker-scroll {
  from { transform: translateX(var(--ticker-from, 100%)); }
  to   { transform: translateX(var(--ticker-to, -100%)); }
}

/* prefers-reduced-motion : plus de défilement, texte statique tronqué */
@media (prefers-reduced-motion: reduce) {
  .ticker-bar .ticker-content,
  .ticker-bar .ticker-content[data-scroll],
  .ticker-bar .ticker-content--reverse {
    animation: none;
    transform: none;
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ── No Strobe : coupe clignotements, glitch ambiant et flashs ─────────────── */
body.no-strobe .crt-ambient-glitch {
  animation: none !important;
  filter: none !important;
}
body.no-strobe .levelup-text,
body.no-strobe .conn-offline .conn-dot {
  animation: none !important;
}

.no-strobe-toggle {
  font-family: var(--font-mono);
  font-size: var(--type-small);
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green-dim);
  padding: 2px 8px;
  min-height: 32px;
  cursor: pointer;
  letter-spacing: 0.06em;
}
.no-strobe-toggle[aria-pressed="true"] {
  border-color: var(--green);
  box-shadow: 0 0 8px var(--green-muted);
}
.no-strobe-toggle:disabled { opacity: 0.6; cursor: not-allowed; }
.no-strobe-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── Horloge : repères +5/+15 seulement en large / TV ──────────────────────── */
.clock.clock--offsets-off .clock__sep,
.clock.clock--offsets-off .clock__cell--t5,
.clock.clock--offsets-off .clock__cell--t15 {
  display: none;
}
.clock.clock--offsets-off .clock__grid { grid-template-columns: auto; }
.clock.clock--date-off .clock__date { display: none; }

/* ── Glitch calme (No Strobe / reduced-motion) : message fixe, sans secousse ── */
#glitch-overlay.go-calm,
#glitch-overlay.go-calm * {
  animation: none !important;
  filter: none !important;
  transform: none !important;
  mix-blend-mode: normal !important;
}
#glitch-overlay.go-calm #glitch-noise-canvas,
#glitch-overlay.go-calm .go-bars { display: none; }
#glitch-overlay.go-calm .go-rule-name { text-shadow: none; }

/* ── Level-up : 3,2 s ; titre fixe en No Strobe ────────────────────────────── */
.levelup-overlay { animation-duration: 3.2s; }
.levelup-overlay.levelup--calm .levelup-text { animation: none; }

/* ── Hub : canvas focalisable, jauges du lieu ──────────────────────────────── */
.matrix-hub-canvas { image-rendering: auto; touch-action: manipulation; }
.matrix-hub-canvas:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
.matrix-hub-gauges {
  display: grid;
  gap: 4px;
  margin: 4px 0 6px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, #5fd4ff 25%, #111);
  background: rgba(5, 15, 18, 0.7);
}
.matrix-hub-gauges__title {
  font-family: var(--font-pixel);
  font-size: var(--type-caption);
  color: #b7eeff;
  letter-spacing: 0.08em;
}
.hub-gauge {
  display: grid;
  grid-template-columns: minmax(84px, 30%) 1fr auto;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--type-small);
  color: #d3f7ff;
}
.hub-gauge__bar {
  display: block;
  height: 10px;
  border: 1px solid rgba(95, 212, 255, 0.35);
  background: rgba(0, 0, 0, 0.6);
}
.hub-gauge__bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2aa6c9, #9ee8ff);
  transition: width 0.4s ease;
}
.hub-gauge__val { min-width: 64px; text-align: right; }
@media (prefers-reduced-motion: reduce) {
  .hub-gauge__bar > i { transition: none; }
}

/* ── Coucher : cérémonie non fermable ─────────────────────────────────────── */
#bedtime-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000; /* au-dessus de #glitch-overlay (99999) */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(4, 10, 24, 0.94), rgba(0, 0, 4, 0.98));
  color: var(--blue);
  font-family: var(--font-mono);
  outline: none;
}
#bedtime-overlay.bt-active {
  display: flex;
  animation: bt-fade-in 0.8s ease-out both;
}
@keyframes bt-fade-in { from { opacity: 0; } to { opacity: 1; } }

#bedtime-overlay .bt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg, transparent 0, transparent 3px,
    rgba(92, 225, 255, 0.05) 3px, rgba(92, 225, 255, 0.05) 4px
  );
}
#bedtime-overlay .bt-content {
  position: relative;
  width: min(100%, 640px);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  display: grid;
  gap: 14px;
}
#bedtime-overlay .bt-label {
  font-family: var(--font-pixel);
  font-size: var(--type-h3);
  color: var(--rose);
  text-shadow: var(--rose-glow);
  letter-spacing: 0.1em;
}
#bedtime-overlay .bt-phase {
  font-size: var(--type-h2);
  color: var(--blue);
  text-shadow: var(--blue-glow);
  letter-spacing: 0.14em;
}
#bedtime-overlay .bt-act-title {
  font-size: var(--type-h2);
  color: var(--amber);
  text-shadow: var(--amber-glow);
  min-height: 1.2em;
}
#bedtime-overlay .bt-act-lines {
  display: grid;
  gap: 6px;
  min-height: 4.5em;
  font-size: var(--type-h4);
  color: #cfeeff;
}
#bedtime-overlay .bt-act-lines p { margin: 0; line-height: 1.35; }
#bedtime-overlay .bt-countdown {
  font-size: var(--type-h3);
  color: var(--green);
  text-shadow: var(--green-glow);
  font-variant-numeric: tabular-nums;
}
#bedtime-overlay .bt-hint {
  font-size: var(--type-small);
  color: var(--dim);
}

/* Écritures désactivées : réversible, retiré avec body.bedtime-mode.
   (L'attribut inert posé par bedtime-overlay.js double ce garde-fou.) */
body.bedtime-mode :is(button, input, select, textarea, [role="slider"], [role="button"], .stat-bar):not(#bedtime-overlay *) {
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 599px) {
  #bedtime-overlay .bt-label { font-size: var(--type-h4); }
  #bedtime-overlay .bt-phase,
  #bedtime-overlay .bt-act-title { font-size: var(--type-h3); }
}
@media (prefers-reduced-motion: reduce) {
  #bedtime-overlay.bt-active { animation: none; }
}
