/* =============================================================================
   KICKOFF 35 - System state screens: Launch / Loading / Maintenance.
   Re-authored from the design kit (inset-cool-field-kit) onto the app's LOCKED
   --mh-* tokens. No hardcoded brand colours - tints are color-mix() of tokens.
   Dark mode flows from the existing body.dark cascade (mh-theme.css). These render
   on EmptyLayout (outside .mh-app), so everything is scoped under .mh-sys to avoid
   any collision with the app shell. Fonts reuse the already-loaded families
   (Source Serif 4 gets its first use here).
   ========================================================================== */

.mh-sys {
  --sys-sans:  "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --sys-serif: "Source Serif 4", Georgia, serif;
  --sys-mono:  "IBM Plex Mono", ui-monospace, Menlo, monospace;

  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 32px;
  font-family: var(--sys-sans);
  color: var(--mh-ink);
  background: var(--mh-cream);
  background-image:
    radial-gradient(900px 500px at 50% -8%, color-mix(in srgb, var(--mh-surface) 60%, transparent) 0%, transparent 62%),
    linear-gradient(170deg, color-mix(in srgb, var(--mh-surface) 35%, var(--mh-cream)) 0%, var(--mh-cream) 100%);
  -webkit-font-smoothing: antialiased;
  overflow: auto;
}
.mh-sys * { box-sizing: border-box; }

/* logo theme-swap: pine on light surfaces, cream on dark. One pair, CSS toggles. */
.mh-sys .sys-logo.is-dark { display: none; }
body.dark .mh-sys .sys-logo.is-light { display: none; }
body.dark .mh-sys .sys-logo.is-dark { display: block; }

@keyframes mh-sys-spin { to { transform: rotate(360deg); } }

/* =========================================================
   LOADING  (boot splash + dashboard data-load share this)
   ========================================================= */
.mh-sys-load .panel,
.mh-sys-maint .panel {
  width: min(560px, 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; text-align: center;
}
.loader-ring { position: relative; width: 86px; height: 86px; display: grid; place-items: center; }
.loader-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--mh-r-pill);
  border: 3px solid color-mix(in srgb, var(--mh-green) 22%, transparent);
  border-top-color: var(--mh-green);
  animation: mh-sys-spin .9s linear infinite;
}
.loader-ring img { width: 46px; height: 46px; object-fit: contain; }
.load-txt { font-family: var(--sys-serif); font-size: 21px; font-weight: 600; color: var(--mh-ink); }
.load-sub { font-size: 13.5px; color: var(--mh-muted); margin-top: -14px; }
.load-bar {
  width: 240px; height: 6px; border-radius: var(--mh-r-pill); overflow: hidden;
  background: var(--mh-ctrl-fill); border: 1px solid var(--mh-line);
}
.load-bar i {
  display: block; height: 100%; width: 38%; border-radius: var(--mh-r-pill); background: var(--mh-green);
  animation: mh-sys-loadbar 1.4s cubic-bezier(.2,.7,.25,1) infinite;
}
@keyframes mh-sys-loadbar { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }

/* skeleton list (kit-faithful) */
.skel-list { width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.skel-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--mh-r-card);
  background: var(--mh-surface); border: 1px solid var(--mh-line); box-shadow: var(--mh-shadow-sm);
}
.skel {
  background: linear-gradient(90deg,
    var(--mh-ctrl-fill) 25%, color-mix(in srgb, var(--mh-ink) 8%, var(--mh-ctrl-fill)) 37%, var(--mh-ctrl-fill) 63%);
  background-size: 400% 100%; animation: mh-sys-shimmer 1.4s ease infinite; border-radius: 7px;
}
@keyframes mh-sys-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-card .skel.avatar { width: 44px; height: 44px; border-radius: var(--mh-r-pill); flex: none; }
.skel-card .lines { flex: 1; display: flex; flex-direction: column; gap: 9px; align-items: flex-start; }

/* The #mh-boot rules lived here. The boot splash was removed on 14 Aug 2026 (CEO):
   it painted a full-screen "Loading your dashboard..." on the first byte and was held
   for a fixed floor after page load, so on a warm sign-in it delayed the app instead of
   describing a delay. The .mh-sys / .mh-sys-load classes above stay - the real system
   screens (Maintenance, Launch countdown) still use them. */

/* Reconnect overlay suppression during the INITIAL connect: while <html> carries the
   mh-preconnect marker (set on first byte, cleared by Routes once the circuit connects
   once), the framework reconnect/rejoin dialog is hidden even if it opens - so it can
   never flash during sign-in. After the marker clears it behaves normally for real drops. */
html.mh-preconnect #components-reconnect-modal { display: none !important; }

/* =========================================================
   MAINTENANCE
   ========================================================= */
.mh-sys-maint .m-ic {
  position: relative; width: 104px; height: 104px; border-radius: var(--mh-r-pill);
  display: grid; place-items: center; flex: none;
  background: var(--mh-surface); border: 1px solid var(--mh-line); box-shadow: var(--mh-shadow-sm);
}
.mh-sys-maint .m-ring {
  position: absolute; inset: 7px; border-radius: var(--mh-r-pill);
  border: 3px solid color-mix(in srgb, var(--mh-green) 20%, transparent); border-top-color: var(--mh-green);
  animation: mh-sys-spin .95s linear infinite;
}
.mh-sys-maint .m-logo { position: relative; width: 50px; height: auto; object-fit: contain; }
.mh-sys-maint .m-title { font-family: var(--sys-serif); font-size: 27px; font-weight: 600; color: var(--mh-ink); margin: 4px 0 0; }
.mh-sys-maint .m-sub { font-size: 15px; line-height: 1.6; color: var(--mh-muted); max-width: 440px; margin: 0; }
.mh-sys-maint .m-meta {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 7px 14px; border-radius: var(--mh-r-pill);
  background: color-mix(in srgb, var(--mh-warning) 18%, var(--mh-surface)); color: var(--mh-warning-d);
  font-size: 12.5px; font-weight: 700;
}
.mh-sys-maint .m-meta .d { width: 8px; height: 8px; border-radius: 50%; background: var(--mh-warning); animation: mh-sys-pulse 1.5s ease infinite; }
@keyframes mh-sys-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.mh-sys-maint .btnrow { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }

/* local button vocabulary (these screens live outside the app shell) */
.mh-sys .ui-btn {
  height: 42px; padding: 0 18px; border-radius: var(--mh-r-btn); cursor: pointer;
  font-family: var(--sys-sans); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent;
  transition: background .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.mh-sys .ui-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mh-sys .ui-btn.secondary { background: var(--mh-surface); border-color: var(--mh-line); color: var(--mh-ink); box-shadow: var(--mh-shadow-sm); }
.mh-sys .ui-btn.secondary:hover { background: var(--mh-ctrl-fill); transform: translateY(-1px); }
.mh-sys .ui-btn.ghost { background: transparent; border-color: var(--mh-line); color: var(--mh-ink); }
.mh-sys .ui-btn.ghost:hover { background: var(--mh-ctrl-fill); }
.mh-sys .ui-btn.primary { background: var(--mh-green); color: #fff; }
.mh-sys .ui-btn.primary:hover { background: var(--mh-green-d); transform: translateY(-1px); }

/* --- developer contact modal --- */
.devmodal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; }
.devmodal .dm-backdrop {
  position: absolute; inset: 0; background: color-mix(in srgb, var(--mh-slate-2) 55%, transparent);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .24s cubic-bezier(.2,.7,.25,1);
}
.devmodal.open .dm-backdrop { opacity: 1; }
.devmodal .dm-card {
  position: relative; width: 380px; max-width: 100%; background: var(--mh-surface);
  border: 1px solid var(--mh-line); border-radius: var(--mh-r-card); box-shadow: var(--mh-shadow-lg);
  padding: 30px 28px 26px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: 0; transform: translateY(14px) scale(.97); transition: opacity .24s cubic-bezier(.2,.7,.25,1), transform .24s cubic-bezier(.2,.7,.25,1);
}
.devmodal.open .dm-card { opacity: 1; transform: translateY(0) scale(1); }
.devmodal .dm-x {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--mh-line); background: var(--mh-ctrl-fill); border-radius: var(--mh-r-pill); cursor: pointer;
  color: var(--mh-muted); transition: background .2s, color .2s;
}
.devmodal .dm-x:hover { background: var(--mh-cream-2); color: var(--mh-ink); }
.devmodal .dm-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.devmodal .dm-eyebrow {
  font-family: var(--sys-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--mh-green-d);
}
.devmodal .dm-avatar {
  width: 76px; height: 76px; margin: 8px 0 6px; border-radius: var(--mh-r-pill); display: grid; place-items: center;
  font-family: var(--sys-serif); font-size: 27px; font-weight: 600; color: #F4F1E8;
  background: linear-gradient(165deg, var(--mh-sage-300) 0%, var(--mh-green) 100%);
  box-shadow: inset 0 -4px 10px color-mix(in srgb, var(--mh-sidebar-2) 30%, transparent), 0 8px 20px color-mix(in srgb, var(--mh-green) 30%, transparent);
}
.devmodal .dm-name { font-family: var(--sys-serif); font-size: 22px; font-weight: 600; color: var(--mh-ink); margin: 0; }
.devmodal .dm-role { font-size: 13px; color: var(--mh-muted); margin: 0 0 16px; }
.devmodal .dm-rows { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.devmodal .dm-row {
  display: flex; align-items: center; gap: 13px; text-align: left; text-decoration: none;
  padding: 12px 14px; border-radius: var(--mh-r-card); border: 1px solid var(--mh-line); background: var(--mh-ctrl-fill);
  box-shadow: var(--mh-shadow-sm); transition: background .2s, transform .2s, box-shadow .2s;
}
.devmodal .dm-row:hover { background: var(--mh-cream-2); transform: translateY(-1px); box-shadow: var(--mh-shadow); }
.devmodal .dm-ic {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  background: color-mix(in srgb, var(--mh-green) 12%, transparent); color: var(--mh-green-d);
}
.devmodal .dm-ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.devmodal .dm-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.devmodal .dm-label { font-family: var(--sys-mono); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--mh-muted); }
.devmodal .dm-val { font-size: 14.5px; font-weight: 600; color: var(--mh-ink); overflow: hidden; text-overflow: ellipsis; }

/* =========================================================
   LAUNCH / SPLASH  (always-dark pine surface in BOTH themes)
   Built from the non-flipping brand tokens (--mh-sidebar*, --mh-sage-*).
   ========================================================= */
.mh-sys-launch {
  /* fixed brand palette - intentionally identical in light + dark */
  --ls-cream: var(--mh-sage-50);
  --ls-sage:  var(--mh-sage-300);
  --ls-sage-2: var(--mh-sage-400);
  padding: 0;
}
.mh-sys-launch .launch {
  position: relative; overflow: hidden; width: 100%; height: 100%; min-height: calc(100 * var(--mh-vh));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center;
  padding: 52px 44px;
  background: var(--mh-sidebar-2);
  background-image:
    radial-gradient(120% 80% at 50% 18%, var(--mh-sidebar) 0%, var(--mh-sidebar-2) 55%, transparent 100%),
    radial-gradient(90% 60% at 50% 120%, color-mix(in srgb, var(--mh-sage-300) 22%, transparent), transparent 60%);
}
.mh-sys-launch .mark-wrap {
  position: relative; width: 156px; height: 156px; border-radius: var(--mh-r-pill); display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--ls-cream) 10%, transparent);
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--ls-cream) 16%, transparent) 0%, color-mix(in srgb, var(--ls-cream) 5%, transparent) 42%, transparent 70%);
  opacity: 0; transform: scale(.8);
  animation: mh-ls-pop 1s cubic-bezier(.2,.7,.25,1) .15s forwards, mh-ls-aura 4.5s ease-in-out 1.3s infinite;
}
.mh-sys-launch .mark-wrap::before {
  content: ""; position: absolute; inset: 4px; border-radius: var(--mh-r-pill);
  background: conic-gradient(from 0deg,
    color-mix(in srgb, var(--ls-sage) 0%, transparent) 0deg,
    color-mix(in srgb, var(--ls-sage) 18%, transparent) 150deg,
    color-mix(in srgb, var(--ls-sage) 45%, transparent) 300deg,
    color-mix(in srgb, var(--ls-cream) 85%, transparent) 348deg,
    var(--ls-cream) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px));
  animation: mh-sys-spin 5s linear infinite;
}
.mh-sys-launch .mark-wrap::after {
  content: ""; position: absolute; inset: 4px; border-radius: var(--mh-r-pill);
  background: radial-gradient(circle 3.5px at 50% calc(0% + 1.25px), var(--ls-cream) 0%, color-mix(in srgb, var(--ls-cream) 85%, transparent) 40%, transparent 72%);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ls-cream) 90%, transparent)) drop-shadow(0 0 11px color-mix(in srgb, var(--ls-sage) 60%, transparent));
  animation: mh-sys-spin 5s linear infinite;
}
@keyframes mh-ls-aura { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ls-sage) 0%, transparent); } 50% { box-shadow: 0 0 38px 2px color-mix(in srgb, var(--ls-sage) 28%, transparent); } }
@keyframes mh-ls-pop { to { opacity: 1; transform: scale(1); } }

.mh-sys-launch .launch-mark {
  position: relative; width: 74px; height: 74px; filter: drop-shadow(0 6px 16px rgba(0,0,0,.35));
  animation: mh-ls-float 4.5s ease-in-out 1.6s infinite;
}
@keyframes mh-ls-float {
  0%,100% { transform: translateY(0); filter: drop-shadow(0 6px 16px rgba(0,0,0,.35)); }
  50% { transform: translateY(-6px); filter: drop-shadow(0 13px 20px rgba(0,0,0,.4)) drop-shadow(0 0 13px color-mix(in srgb, var(--ls-sage) 40%, transparent)); }
}
.mh-sys-launch .launch-mark .roof {
  fill: none; stroke: var(--ls-cream); stroke-width: 6.4; stroke-linecap: square; stroke-linejoin: miter;
  stroke-dasharray: 120; stroke-dashoffset: 120; animation: mh-ls-roof .75s cubic-bezier(.2,.7,.25,1) .55s forwards;
}
.mh-sys-launch .launch-mark .col { fill: var(--ls-cream); transform-box: fill-box; transform-origin: bottom; transform: scaleY(0); }
.mh-sys-launch .launch-mark .c1 { animation: mh-ls-col .55s cubic-bezier(.2,.7,.25,1) .8s forwards; }
.mh-sys-launch .launch-mark .c2 { animation: mh-ls-col .55s cubic-bezier(.2,.7,.25,1) .95s forwards; }
.mh-sys-launch .launch-mark .c3 { animation: mh-ls-col .55s cubic-bezier(.2,.7,.25,1) 1.1s forwards; }
@keyframes mh-ls-roof { to { stroke-dashoffset: 0; } }
@keyframes mh-ls-col { to { transform: scaleY(1); } }

.mh-sys-launch .l-word {
  font-family: var(--sys-serif); font-weight: 600; font-size: 34px; line-height: 1.12; letter-spacing: .01em;
  color: var(--ls-cream); margin: 0; max-width: 580px; text-wrap: balance;
  opacity: 0; transform: translateY(16px); animation: mh-ls-rise .8s cubic-bezier(.2,.7,.25,1) 1.3s forwards;
}
.mh-sys-launch .l-tag {
  font-family: var(--sys-mono); font-size: 12px; font-weight: 600; line-height: 1.5; letter-spacing: .2em;
  text-transform: uppercase; color: color-mix(in srgb, var(--ls-sage) 85%, transparent); max-width: 480px; margin: -10px 0 0;
  opacity: 0; transform: translateY(14px); animation: mh-ls-rise .8s cubic-bezier(.2,.7,.25,1) 1.5s forwards;
}
.mh-sys-launch .countdown {
  display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 10px 0 2px;
  opacity: 0; transform: translateY(12px); animation: mh-ls-rise .7s cubic-bezier(.2,.7,.25,1) 1.7s forwards;
}
.mh-sys-launch .cd-eyebrow {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--sys-mono); font-size: 10.5px;
  font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: color-mix(in srgb, var(--ls-sage) 92%, transparent);
}
.mh-sys-launch .cd-eyebrow::before, .mh-sys-launch .cd-eyebrow::after { content: ""; width: 16px; height: 1px; background: color-mix(in srgb, var(--ls-sage) 45%, transparent); }
.mh-sys-launch .cd-units { display: flex; align-items: flex-start; gap: 10px; }
.mh-sys-launch .cd-unit {
  display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 78px; padding: 16px 12px 12px; border-radius: 16px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--ls-cream) 10%, transparent) 0%, color-mix(in srgb, var(--ls-cream) 4%, transparent) 100%);
  border: 1px solid color-mix(in srgb, var(--ls-cream) 16%, transparent);
  box-shadow: inset 0 1px 2px color-mix(in srgb, var(--ls-cream) 10%, transparent), 0 8px 22px rgba(0,0,0,.32);
}
.mh-sys-launch .cd-num { font-family: var(--sys-serif); font-size: 44px; font-weight: 600; line-height: 1; color: var(--ls-cream); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.mh-sys-launch .cd-lbl { font-family: var(--sys-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: color-mix(in srgb, var(--ls-sage) 70%, transparent); }

/* Sign out - a small pill echoing the Login button (brand pine on the dark surface), so a
   held Staff/Viewer user can always get back to /login. Rises in just after the countdown. */
.mh-sys-launch .ls-signout {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; height: 40px; padding: 0 22px;
  font-family: var(--sys-sans); font-size: 14px; font-weight: 700; letter-spacing: .01em;
  color: #F6FAF8; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--ls-cream) 22%, transparent);
  border-radius: var(--mh-r-pill);
  background: linear-gradient(180deg, #5C8B80 0%, var(--mh-green) 58%, #436E64 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 20px rgba(0,0,0,.32);
  transition: transform .14s ease, filter .2s ease, box-shadow .2s ease;
  opacity: 0; transform: translateY(12px);
  animation: mh-ls-rise .7s cubic-bezier(.2,.7,.25,1) 1.95s forwards;
}
.mh-sys-launch .ls-signout:hover {
  filter: brightness(1.06); transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 12px 26px rgba(0,0,0,.4);
}
.mh-sys-launch .ls-signout:active { transform: translateY(0); }
.mh-sys-launch .ls-signout:focus-visible {
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 3px var(--mh-sidebar-2), 0 0 0 5px color-mix(in srgb, var(--ls-sage) 65%, transparent);
}
.mh-sys-launch .ls-signout-ic { flex: 0 0 auto; display: block; }

@keyframes mh-ls-rise { to { opacity: 1; transform: translateY(0); } }
@media (max-width: 560px) {
  .mh-sys-launch .cd-unit { min-width: 0; flex: 1; padding: 12px 6px 9px; }
  .mh-sys-launch .cd-num { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .mh-sys [class*="mark-wrap"], .mh-sys .launch-mark, .mh-sys .launch-mark .roof, .mh-sys .launch-mark .col,
  .mh-sys .l-word, .mh-sys .l-tag, .mh-sys .countdown, .mh-sys .ls-signout, .loader-ring::before, .load-bar i, .skel, .mh-sys-maint .m-ring {
    animation: none !important; opacity: 1 !important; transform: none !important; stroke-dashoffset: 0 !important;
  }
  .mh-sys .launch-mark .col { transform: scaleY(1) !important; }
}
