/* ==========================================================================
 *  u_50n1_2 — OTA progress UI styles
 * ========================================================================== */

/* Overlay pattern — the card keeps its box; one absolutely positioned
   overlay covers it; every other child is hidden so nothing bleeds
   through.  Works on .mgr-card and .bound-device-card alike. */
.mgr-card.ota-active > *:not(.ota-overlay),
.mgr-card.ota-success > *:not(.ota-overlay),
.mgr-card.ota-failed > *:not(.ota-overlay),
.bound-device-card.ota-active > *:not(.ota-overlay),
.bound-device-card.ota-success > *:not(.ota-overlay),
.bound-device-card.ota-failed > *:not(.ota-overlay) {
  visibility: hidden;
  pointer-events: none;
}

.mgr-card.ota-active > .ota-overlay,
.mgr-card.ota-success > .ota-overlay,
.mgr-card.ota-failed > .ota-overlay,
.bound-device-card.ota-active > .ota-overlay,
.bound-device-card.ota-success > .ota-overlay,
.bound-device-card.ota-failed > .ota-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  visibility: visible;
  z-index: 5;
  text-align: center;
  pointer-events: auto;
}

/* Kill the QUIET pseudo and the amber left border while an OTA is up. */
.mgr-card.ota-active::after,
.mgr-card.ota-success::after,
.mgr-card.ota-failed::after { display: none !important; }

.mgr-card.ota-active,
.mgr-card.ota-success,
.mgr-card.ota-failed {
  border-left-width: 1px;
  border-left-color: var(--border);
}

/* Hero percent (manager card) */
.ota-percent {
  font-size: clamp(48px, 12vw, 72px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -1px;
}
.bound-device-card .ota-percent {
  font-size: 28px;
  letter-spacing: 0;
}

/* Progress bar */
.ota-bar {
  width: calc(100% - 32px);
  max-width: 320px;
  height: 12px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.bound-device-card .ota-bar {
  height: 6px;
  width: 100%;
  max-width: none;
}
.ota-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 400ms ease-out;
}

/* Attempt pill */
.ota-attempt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-mute);
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* Warning text */
.ota-warn {
  font-size: 13px;
  color: var(--fg-mute);
  line-height: 1.5;
  text-align: center;
  max-width: 90%;
}
.bound-device-card .ota-warn { font-size: 11.5px; }

/* Success glyph */
.ota-check {
  width: 72px;
  height: 72px;
  color: var(--green);
  display: block;
}
.bound-device-card .ota-check { width: 40px; height: 40px; }
.ota-check path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: otaCheckDraw 300ms ease-out forwards;
}
@keyframes otaCheckDraw {
  to { stroke-dashoffset: 0; }
}
.ota-success-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .5px;
}

/* Failure badge + actions */
.ota-failed-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  background: rgba(231, 76, 60, .15);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(231, 76, 60, .40);
}
.ota-failed-reason {
  font-size: 12px;
  color: var(--fg-dim);
  text-align: center;
  line-height: 1.5;
  max-width: 90%;
  word-break: break-word;
}
.ota-failed-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.ota-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background .12s, color .12s, border-color .12s;
}
.ota-btn:hover { background: var(--bg-3); border-color: var(--border-hi); }
.ota-btn.ota-retry {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}
.ota-btn.ota-retry:hover { background: var(--accent); border-color: var(--accent); }
.ota-btn.ota-dismiss { color: var(--fg-dim); }

/* Admin firmware table row */
.admin-ota-row {
  background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.admin-ota-row td {
  border-bottom: 1px solid var(--border);
}

/* Reduced-motion gate — the first place in this codebase that honours it */
@media (prefers-reduced-motion: reduce) {
  .ota-bar-fill,
  .ota-bar-mini .fill {
    transition: none !important;
  }
  .ota-check path {
    stroke-dashoffset: 0 !important;
    animation: none !important;
  }
}

/* u_50o_10 -- device name shown at the top of the OTA overlay.
 *
 * Absolute-positioned so it does not shift the big percentage or
 * the bar (which are centered by the overlay's flex layout).
 */
.ota-overlay > .ota-device-name {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--fg);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .78;
  pointer-events: none;
}
.bound-device-card .ota-overlay > .ota-device-name {
  top: 6px;
  font-size: 10.5px;
}
@media (max-width: 900px) {
  .ota-overlay > .ota-device-name              { font-size: 12px; top: 6px; }
  .bound-device-card .ota-overlay > .ota-device-name { font-size: 11px; top: 4px; }
}
