/* MaxiMind skeleton screens (#1833, Phi 25/10/2026). Load after tokens.css.
   Gray blocks in the exact layout of the content that is coming. Build them inside the real
   containers (same row/card classes), so the content swaps in with no layout jump.
   The mm loader stays for app start, sign-in, reconnecting and long actions with a status line. */

/* One block: a bar, a box, an avatar. Size it with --mm-skel-w / --mm-skel-h / --mm-skel-size. */
.mm-skel {
  position: relative;
  display: block;
  flex: none;
  overflow: hidden;
  width: var(--mm-skel-w, 100%);
  max-width: 100%;
  height: var(--mm-skel-h, var(--mm-space-3, 12px));
  border-radius: var(--mm-skeleton-radius, 6px);
  background: var(--mm-skeleton, #e6dfd1);
  pointer-events: none;
  user-select: none;
}
.mm-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--mm-skeleton-shine, #f4efe6) 50%, transparent);
  transform: translateX(-100%);
  animation: mm-skel-shimmer var(--mm-skeleton-dur, 1.8s) ease-in-out infinite;
}
.mm-skel--circle {
  width: var(--mm-skel-size, 32px);
  height: var(--mm-skel-size, 32px);
  border-radius: 50%;
}
.mm-skel--pill { border-radius: 999px; }
/* Width steps for plain HTML (pages with a strict CSP cannot use style attributes). */
.mm-skel--w30 { --mm-skel-w: 30%; }
.mm-skel--w45 { --mm-skel-w: 45%; }
.mm-skel--w60 { --mm-skel-w: 60%; }
.mm-skel--w75 { --mm-skel-w: 75%; }
.mm-skel--w90 { --mm-skel-w: 90%; }
.mm-skel--control { height: var(--mm-control, 36px); border-radius: var(--mm-radius-sm, 6px); }

/* A text line. It holds a no-break space, so the real font and line-height set its height;
   the bar sits in the middle at --mm-skeleton-bar of the font size. */
.mm-skel-text {
  position: relative;
  display: block;
  min-width: 0;
  color: transparent;
  user-select: none;
  pointer-events: none;
}
.mm-skel-text > .mm-skel {
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  height: var(--mm-skeleton-bar, .7em);
  transform: translateY(-50%);
}

/* Fallback shapes for surfaces without their own row classes yet. Heights follow the density tokens. */
.mm-skel-preset { display: block; min-width: 0; }
.mm-skel-row {
  display: flex;
  align-items: center;
  gap: var(--mm-space-3, 12px);
  min-height: var(--mm-row-comfy, 56px);
  padding: 0 var(--mm-space-4, 16px);
  border-bottom: 1px solid var(--mm-hairline, #e2dccd);
}
.mm-skel-row > .mm-skel-stack { flex: 1 1 auto; }
.mm-skel-stack { display: flex; flex-direction: column; min-width: 0; }
.mm-skel-title { font-size: var(--mm-text-base, 15px); line-height: var(--mm-lh-base, 22px); }
.mm-skel-meta { font-size: var(--mm-text-sm, 13px); line-height: var(--mm-lh-sm, 18px); }
.mm-skel-heading { font-size: var(--mm-text-lg, 20px); line-height: var(--mm-lh-lg, 28px); margin-bottom: var(--mm-space-3, 12px); }
.mm-skel-preset[data-kind="cards"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--mm-space-3, 12px);
}
.mm-skel-card {
  display: flex;
  flex-direction: column;
  gap: var(--mm-space-2, 8px);
  min-height: 140px;
  padding: var(--mm-card-pad, 16px);
  border: 1px solid var(--mm-hairline, #e2dccd);
  border-radius: var(--mm-radius, 10px);
  background: var(--mm-surface, #fffdf8);
}
.mm-skel-preset[data-kind="table"] > .mm-skel-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(var(--mm-skel-cols, 3), minmax(0, 1fr));
  min-height: var(--mm-row, 44px);
}
.mm-skel-preset[data-kind="panel"] { padding: var(--mm-card-pad, 16px); }
.mm-skel-field {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(0, 3fr);
  gap: var(--mm-space-4, 16px);
  align-items: center;
  min-height: var(--mm-row, 44px);
  border-bottom: 1px solid var(--mm-hairline, #e2dccd);
}
.mm-skel-preset[data-kind="chat"] { display: flex; flex-direction: column; gap: var(--mm-space-4, 16px); padding: var(--mm-space-4, 16px); }
.mm-skel-bubble { display: flex; align-items: flex-start; gap: var(--mm-space-2, 8px); max-width: min(560px, 85%); }
.mm-skel-bubble--own { align-self: flex-end; flex-direction: row-reverse; }
.mm-skel-bubble > .mm-skel-stack {
  flex: 1 1 auto;
  padding: var(--mm-space-2, 8px) var(--mm-space-3, 12px);
  border-radius: var(--mm-radius, 10px);
  background: var(--mm-surface, #fffdf8);
  border: 1px solid var(--mm-hairline, #e2dccd);
}
.mm-skel-bubble--own > .mm-skel-stack { background: var(--mm-own, #f1e3d6); border-color: transparent; }

/* Screen readers hear one short status line instead of the gray blocks. */
.mm-skel-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.mm-skel-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--mm-space-3, 12px);
  min-height: var(--mm-row, 44px);
  padding: 0 var(--mm-space-4, 16px);
  color: var(--mm-muted, #6b665d);
  font-size: var(--mm-text-sm, 13px);
}
.mm-skel-error > button {
  min-height: var(--mm-control-sm, 28px);
  padding: 0 var(--mm-space-3, 12px);
  border: 1px solid var(--mm-border, #8c8171);
  border-radius: var(--mm-radius-sm, 6px);
  background: var(--mm-surface, #fffdf8);
  color: var(--mm-text, #1c1a17);
  font: inherit;
  cursor: pointer;
}
.mm-skel-error > button:focus-visible { outline: none; box-shadow: var(--mm-focus); }

/* The real content arrives in place with a short fade (opacity only, no movement). */
.mm-skel-in { animation: mm-skel-in var(--mm-dur, 160ms) var(--mm-ease, ease-out) both; }

@keyframes mm-skel-shimmer {
  0% { transform: translateX(-100%); }
  70%, 100% { transform: translateX(100%); }
}
@keyframes mm-skel-in { from { opacity: 0; } to { opacity: 1; } }

/* Save CPU: stop the shimmer after 60 s without input (Cockpit/desktop idle flags). */
html[data-cockpit-idle] .mm-skel::after,
html[data-mm-idle] .mm-skel::after { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  /* Reduce Motion: static gray blocks, no shimmer and no fade. */
  .mm-skel::after { animation: none; display: none; }
  .mm-skel-in { animation: none; }
}
@media print { .mm-skel::after { display: none; } }
