/* Shared interaction and accessibility contract for storefront and admin UI. */

.mzaA11yAnnouncer {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mzaIconAction,
button[aria-label],
a[aria-label].btn {
  min-width: 44px;
  min-height: 44px;
}

.mzaIconAction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html:not(.mzaPointerNavigation) .storefront-body :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
html.mzaKeyboardNavigation .storefront-body :is(a, button, input, select, textarea, summary, [tabindex]):focus,
html:not(.mzaPointerNavigation) .mzaAdminBody :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
html.mzaKeyboardNavigation .mzaAdminBody :is(a, button, input, select, textarea, summary, [tabindex]):focus {
  outline: 2px solid #111827;
  outline-offset: 2px;
  box-shadow: 0 0 0 1px #ffffff !important;
}

html:not(.mzaPointerNavigation) .storefront-body .btn-check:focus-visible + label,
html.mzaKeyboardNavigation .storefront-body .btn-check:focus + label {
  outline: 2px solid #111827;
  outline-offset: 2px;
  box-shadow: 0 0 0 1px #ffffff !important;
}

html.mzaPointerNavigation .storefront-body :is(a, button, input, select, textarea, summary, [tabindex]):focus,
html.mzaPointerNavigation .mzaAdminBody :is(a, button, input, select, textarea, summary, [tabindex]):focus,
html.mzaPointerNavigation .storefront-body .btn-check:focus + label {
  outline: none !important;
  box-shadow: none !important;
}

:where(.storefront-body, .mzaAdminBody)
  :where(input, select, textarea)[aria-invalid="true"] {
  border-color: #b42318;
  box-shadow: 0 0 0 0.2rem rgba(180, 35, 24, 0.18);
}

[aria-busy="true"] {
  cursor: progress;
}

.mzaLoadingState {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.mzaLoadingState::before {
  width: 1rem;
  height: 1rem;
  content: "";
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: mza-a11y-spin 0.8s linear infinite;
}

.mzaThemePreviewBanner {
  position: sticky;
  top: 0;
  z-index: 1090;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: #ffffff;
  background: #101828;
  border-bottom: 3px solid #fdb022;
  text-align: center;
}

.mzaThemePreviewBanner a {
  color: #ffffff;
  font-weight: 700;
}

.mzaThemePreviewBanner a:hover,
.mzaThemePreviewBanner a:focus-visible {
  color: #fedf89;
}

.mzaResponsiveTableWrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table[data-responsive-table] {
  width: 100%;
}

table[data-responsive-table] :where(th, td) {
  vertical-align: top;
}

.mzaFieldError,
[data-field-error] {
  color: #b42318;
  font-weight: 600;
}

@keyframes mza-a11y-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  table[data-responsive-table="cards"] thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  table[data-responsive-table="cards"],
  table[data-responsive-table="cards"] tbody,
  table[data-responsive-table="cards"] tr,
  table[data-responsive-table="cards"] tbody th,
  table[data-responsive-table="cards"] td {
    display: block;
    width: 100%;
  }

  table[data-responsive-table="cards"] tr {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--admin-surface, var(--store-surface, #ffffff));
    border: 1px solid var(--admin-border, var(--store-border-color, #d0d5dd));
    border-radius: 0.75rem;
  }

  table[data-responsive-table="cards"] tbody th,
  table[data-responsive-table="cards"] td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 40%) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.5rem 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  table[data-responsive-table="cards"] tbody th::before,
  table[data-responsive-table="cards"] td::before {
    align-self: start;
    content: attr(data-label);
    font-weight: 700;
  }

  table[data-responsive-table="cards"] tbody th[data-label=""]::before,
  table[data-responsive-table="cards"] td[data-label=""]::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
