/*
 * modals.css — ANZ v3 Modal Component
 *
 * Namespace: .anz-v3-modal
 * Covers: content / close / overlay / focus-trap hooks
 * All selectors scoped: body.anz-v3 .anz-v3-modal*
 * No hex values — var(--...) only.
 *
 * Phase 4 pages: loading modal (DIGITAL-6475), add-to-cart modal (DIGITAL-6479),
 *                message modal
 * Provenance: plan §4.8, IA spec §6.2 (radius-lg for modals)
 * Note: Bootstrap modal JS (show/hide/backdrop) is retained per Principle 3.
 *       This file overrides Bootstrap's CSS shape only.
 *       Bootstrap-shadow layer (.modal-content, .modal-header etc.) lives in
 *       v3-shell.css. New Razor markup uses .anz-v3-modal-* classes from here.
 */


/* ===================================================================
 * OVERLAY / BACKDROP
 * =================================================================== */

body.anz-v3 .anz-v3-modal-overlay {
  background-color: var(--anz-deep-sea);
  inset: 0;
  opacity: 0.6;
  position: fixed;
  z-index: 500000;
}


/* ===================================================================
 * DIALOG WRAPPER
 * =================================================================== */

body.anz-v3 .anz-v3-modal {
  display: none;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: fixed;
  z-index: 500001;
}

body.anz-v3 .anz-v3-modal.is-open {
  display: flex;
}

body.anz-v3 .anz-v3-modal__dialog {
  align-items: flex-start;
  display: flex;
  justify-content: center;
  margin: var(--space-12) auto;
  max-width: 560px;
  padding: 0 var(--space-4);
  width: 100%;
}

body.anz-v3 .anz-v3-modal__dialog--lg {
  max-width: 800px;
}

body.anz-v3 .anz-v3-modal__dialog--sm {
  max-width: 400px;
}


/* ===================================================================
 * CONTENT PANEL
 * =================================================================== */

body.anz-v3 .anz-v3-modal__content {
  background-color: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  animation: anz-v3-modal-enter var(--motion-modal) var(--motion-easing) both;
}

@keyframes anz-v3-modal-enter {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ===================================================================
 * HEADER
 * =================================================================== */

body.anz-v3 .anz-v3-modal__header {
  align-items: center;
  background-color: var(--surface-inverse);
  color: var(--text-on-inverse);
  display: flex;
  gap: var(--space-4);
  justify-content: space-between;
  padding: var(--space-6);
}

body.anz-v3 .anz-v3-modal__title {
  color: var(--text-on-inverse);
  font-size: var(--type-h3-size);
  font-weight: var(--font-weight-medium);
  line-height: var(--type-h3-lh);
  margin: 0;
}

body.anz-v3 .anz-v3-modal__close {
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-on-inverse);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  font-size: var(--type-h3-size);
  height: 32px;
  justify-content: center;
  line-height: 1;
  opacity: 0.8;
  padding: 0;
  transition: opacity var(--motion-fast) var(--motion-exit);
  width: 32px;
}

body.anz-v3 .anz-v3-modal__close:focus,
body.anz-v3 .anz-v3-modal__close:hover {
  opacity: 1;
}


/* ===================================================================
 * BODY
 * =================================================================== */

body.anz-v3 .anz-v3-modal__body {
  background-color: var(--surface);
  color: var(--text);
  flex: 1;
  font-size: var(--type-body-m-size);
  line-height: var(--type-body-m-lh);
  /* Vertical breathing bumped to space-8 (polish batch 2026-04-20) —
   * short-content modals (e.g. AddToCart confirmation) read less compressed. */
  padding: var(--space-8) var(--space-6);
}


/* ===================================================================
 * FOOTER
 * =================================================================== */

body.anz-v3 .anz-v3-modal__footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-6);
}

/* data attribute for focus-trap JS hook */
body.anz-v3 [data-v3-modal="loading"],
body.anz-v3 [data-v3-modal="message"],
body.anz-v3 [data-v3-modal="add-to-cart"] {
  /* Marker attributes for tenant-isolation smoke test assertions.
     No display property — Bootstrap's `.modal { display: none }` baseline
     must win until Bootstrap JS toggles `.in` via `.modal('show')`. */
  --anz-v3-modal-marker: 1;
}


/* ===================================================================
 * RESPONSIVE
 * =================================================================== */

@media (max-width: 768px) {
  body.anz-v3 .anz-v3-modal__dialog {
    align-items: flex-end;
    margin: 0;
    max-width: 100%;
    padding: 0;
  }

  body.anz-v3 .anz-v3-modal__content {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}


/* ===================================================================
 * REDUCED MOTION
 * =================================================================== */

@media (prefers-reduced-motion: reduce) {
  body.anz-v3 .anz-v3-modal__content {
    animation: none;
  }
}
