/*
 * Wartungsbildschirm. Die Besucheransicht liefert die Farben über die Theme-Tokens;
 * die Vorschau im Planlabor nutzt die Standardwerte (dunkles Theme, grüner Akzent).
 */
.maintenance {
  --mt-bg: var(--bg, #0d110f);
  --mt-glow: var(--bg-glow, #13241a);
  --mt-surface: var(--surface, #141a16);
  --mt-line: var(--line-strong, #353c38);
  --mt-text: var(--text-strong, #f5f8f6);
  --mt-muted: var(--muted, #9ba59f);
  --mt-accent: var(--accent, #43e28b);
  --mt-on-accent: var(--on-accent, #07160e);
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  overflow: hidden auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: var(--mt-bg);
  color: var(--mt-text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
  animation: mt-fade .4s ease both;
}
.maintenance[hidden] { display: none; }
.maintenance.is-leaving { animation: mt-fade .3s ease reverse both; }

.mt-glow {
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--mt-accent) 20%, transparent) 0, transparent 34%),
    radial-gradient(circle at 72% 68%, color-mix(in oklab, var(--mt-accent) 12%, transparent) 0, transparent 38%),
    radial-gradient(circle at 50% 50%, var(--mt-glow) 0, transparent 60%);
  animation: mt-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

.mt-stage { position: relative; width: min(100%, 520px); display: grid; justify-items: center; }
.mt-stage > * { animation: mt-rise .6s cubic-bezier(.2, .75, .25, 1) both; }
.mt-stage > :nth-child(2) { animation-delay: .08s; }
.mt-stage > :nth-child(3) { animation-delay: .14s; }
.mt-stage > :nth-child(4) { animation-delay: .2s; }
.mt-stage > :nth-child(n+5) { animation-delay: .26s; }

/* Illustration: a small timetable that is being worked on by two meshing gears. */
.mt-art { position: relative; width: 250px; height: 190px; margin-bottom: 30px; }
.mt-card {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 196px;
  padding: 14px;
  border: 1px solid var(--mt-line);
  border-radius: 18px;
  background: var(--mt-surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  animation: mt-float 6s ease-in-out infinite;
}
.mt-card-head { display: flex; gap: 6px; margin-bottom: 12px; }
.mt-card-head span { height: 6px; border-radius: 3px; background: var(--mt-line); }
.mt-card-head span:nth-child(1) { width: 44px; background: var(--mt-accent); }
.mt-card-head span:nth-child(2) { width: 26px; }
.mt-card-head span:nth-child(3) { width: 16px; }
.mt-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mt-grid i {
  height: 20px;
  border-radius: 6px;
  background: var(--mt-line);
  animation: mt-cell 2.8s ease-in-out infinite;
  animation-delay: calc((var(--c) + var(--r)) * .16s);
}
.mt-grid i.mt-hot { background: var(--mt-accent); }

.mt-gear { position: absolute; fill: var(--mt-accent); filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .35)); }
.mt-gear-a { width: 96px; height: 96px; right: 4px; bottom: 0; animation: mt-spin 12s linear infinite; }
/* Sizes follow the tooth counts (12 : 8) so the pitch circles touch and the teeth mesh. */
.mt-gear-b { width: 70px; height: 70px; right: 76px; bottom: -16.5px; fill: var(--mt-text); opacity: .9; animation: mt-spin-back 8s linear infinite; }

.mt-spark { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--mt-accent); opacity: 0; animation: mt-spark 3.2s ease-out infinite; }
.mt-spark-a { right: 2px; top: 44px; }
.mt-spark-b { right: 46px; top: 18px; width: 6px; height: 6px; animation-delay: 1.1s; }
.mt-spark-c { left: -4px; bottom: 30px; width: 5px; height: 5px; animation-delay: 2s; }

.mt-eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.mt-brand { padding: 0; border: 0; background: none; color: var(--mt-accent); font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1; letter-spacing: .1em; cursor: default; -webkit-tap-highlight-color: transparent; }
.mt-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--mt-line); border-radius: 999px; color: var(--mt-muted); font-size: 11px; font-weight: 700; }
.mt-badge i { font-size: 13px; animation: mt-wrench 2.4s ease-in-out infinite; transform-origin: 70% 30%; }
.mt-title { margin: 0 0 12px; font-size: clamp(28px, 6vw, 40px); line-height: 1.1; letter-spacing: -.035em; text-wrap: balance; overflow-wrap: anywhere; }
.mt-message { margin: 0; max-width: 44ch; color: var(--mt-muted); font-size: 16px; line-height: 1.6; text-wrap: pretty; overflow-wrap: anywhere; white-space: pre-line; }
.mt-until { display: inline-flex; align-items: center; gap: 8px; margin: 20px 0 0; padding: 9px 14px; border-radius: 999px; background: color-mix(in oklab, var(--mt-accent) 14%, transparent); color: var(--mt-text); font-size: 14px; font-weight: 700; }
.mt-until i { font-size: 17px; color: var(--mt-accent); }

.mt-progress { position: relative; width: min(100%, 280px); height: 6px; margin: 30px 0 16px; overflow: hidden; border-radius: 999px; background: var(--mt-line); }
.mt-progress span { position: absolute; inset: 0 auto 0 0; width: 38%; border-radius: inherit; background: var(--mt-accent); animation: mt-progress 1.9s cubic-bezier(.45, 0, .55, 1) infinite; }
.mt-auto { display: inline-flex; align-items: center; gap: 9px; margin: 0; color: var(--mt-muted); font-size: 13px; line-height: 1.5; }
.mt-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--mt-accent); animation: mt-pulse 1.8s ease-out infinite; }

/* Hint for signed-in admins, who keep seeing the normal app. */
.maintenance-banner { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 11px 14px; border: 1px solid var(--warn-line, #5a4c26); border-radius: 14px; background: var(--warn-bg, rgba(85, 72, 31, .2)); color: var(--warn, #f0d68a); font-size: 13px; font-weight: 700; line-height: 1.45; animation: mt-rise .4s ease both; }
.maintenance-banner[hidden] { display: none; }
.maintenance-banner i { flex: none; font-size: 18px; animation: mt-wrench 2.4s ease-in-out infinite; transform-origin: 70% 30%; }
.maintenance-banner a { margin-left: auto; color: inherit; white-space: nowrap; }
@media (max-width: 760px) {
  .maintenance-banner { margin-bottom: 12px; padding: 8px 12px; font-size: 12px; }
  .maintenance-banner-more { display: none; }
}

@keyframes mt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mt-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes mt-drift { from { transform: translate(-3%, -2%) rotate(0deg); } to { transform: translate(3%, 2%) rotate(8deg); } }
@keyframes mt-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(-1deg); } }
@keyframes mt-cell { 0%, 100% { opacity: .35; transform: scale(.9); } 45%, 60% { opacity: 1; transform: scale(1); } }
@keyframes mt-spin { to { transform: rotate(360deg); } }
@keyframes mt-spin-back { from { transform: rotate(1deg); } to { transform: rotate(-359deg); } }
@keyframes mt-spark { 0% { opacity: 0; transform: translateY(6px) scale(.4); } 30% { opacity: .9; } 100% { opacity: 0; transform: translateY(-22px) scale(1); } }
@keyframes mt-wrench { 0%, 100% { transform: rotate(0deg); } 30% { transform: rotate(-24deg); } 60% { transform: rotate(12deg); } }
@keyframes mt-progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(290%); } }
@keyframes mt-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--mt-accent) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

@media (max-height: 560px) {
  .mt-art { transform: scale(.72); margin: -22px 0 4px; }
  .mt-progress { margin-top: 20px; }
}
[data-motion="off"] .mt-progress span { width: 100%; opacity: .5; }
@media (prefers-reduced-motion: reduce) {
  .maintenance, .maintenance *, .maintenance-banner, .maintenance-banner * { animation: none !important; }
  .mt-progress span { width: 100%; opacity: .5; }
}
