/* Extracted from assets/modal.css — MODAL CORE (overlay/panel/header/close/iframe/animations) — Step 7 */

.modal-overlay {
  position: fixed;
  inset: 0;
  /* top:0; right:0; bottom:0; left:0 */
  display: none;
  /* hidden by default */
  align-items: center;
  /* vertical centering */
  justify-content: center;
  /* horizontal centering */
  background: rgba(0, 0, 0, 0.65);
  /* dim backdrop */
  z-index: 1000;
}

.modal-overlay.is-open {
  display: flex;
  /* open = flex centering */
  overflow: hidden;
}

.modal-panel {
  position: relative;
  margin: 0;
  /* flex centering does the work */
  left: auto;
  right: auto;
  /* neutralize any older positioning */
  top: auto;
  bottom: auto;
  transform: none;
  /* neutralize legacy slide-in offsets */
  width: min(960px, calc(100% - 32px));
  max-height: min(92vh, 1000px);
  overflow: auto;
  border-radius: 14px;
  background: var(--panel, #0c0e10);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
}

/* center the X and keep the rounded square */
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  line-height: 1;
  /* prevents vertical mis-centering */
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
}

.modal-close:hover {
  background: #151922;
}

/* Kill focus outlines/shadows on the square X */
.modal-close,
.modal-close:focus,
.modal-close:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Keep the close button fixed in the panel corner at all times */
.modal-panel {
  position: relative;
}

/* already present above */
.modal-panel .modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  /* above embedded content */
}

.modal-panel .modal-close {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.modal-panel .modal-close:focus {
  outline: none;
  box-shadow: none;
}

.modal-title,
.modal-body {
  margin: 0;
  padding: 0;
}

/* Small phones: shave a tad more side padding */
@media (max-width: 480px) {
  .modal-panel {
    width: calc(100% - 24px);
    max-height: 92vh;
  }
}

/* Ultra-narrow phones (iPhone SE/older Android widths) */
@media (max-width: 360px) {
  .modal-panel {
    width: calc(100% - 12px);
    /* use more of the screen */
  }
}

@media (max-width: 780px) {

  /* Let the overlay do the centering; just give the panel sensible bounds */
  .modal-overlay {
    align-items: flex-start;
    /* start at top with a little padding */
    padding: 5vh 12px 12px;
    /* keeps edges off the screen */
  }

  .modal-panel {
    position: relative;
    width: 100%;
    max-width: 640px;
    /* keep a nice readable width cap */
    max-height: calc(100vh - 7vh);
    /* account for overlay padding */
    margin: 0 auto;
    /* center horizontally within overlay */
    border-radius: 12px;
    overflow-y: auto;

    /* 🔑 neutralize any previous positioning */
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
  }

  .modal-body {
    padding: 14px;
    display: block;
  }

}

/* =========================================================
   XL / Fullscreen modal for pages embedded via <iframe>
   Toggles on the overlay element: .mod-size-xl
   ========================================================= */

/* Make the panel nearly fullscreen and center it */
.mod-size-xl .modal-panel {
  position: fixed;
  /* fixed is more robust than absolute here */
  max-width: none;
  max-height: none;
  border-radius: 10px;
  overflow: hidden;
  /* the iframe will handle scrolling */
  width: 100vw;
  height: calc(100vh - 4vh);
  left: 50%;
  top: 2vh;
  transform: translateX(-50%);
  /* horizontal centering only */
}

/* No header for the embedded page */
.mod-size-xl .modal-header {
  display: none;
}

/* The body must have a definite height for the iframe’s 100% to work */
.mod-size-xl .modal-body {
  display: block;
  padding: 0;
  height: 100%;
  /* <-- critical line */
  overflow: hidden;
}

/* The iframe should occupy the full panel area */
.modal-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ===== Phase 8: Modal fade-in (animations) ===== */
@keyframes fadeSlideUpModal {
  from {
    opacity: 0;
    transform: var(--enter-transform, translateY(10px));
  }

  to {
    opacity: 1;
    transform: var(--enter-transform, translateY(0));
  }
}

.modal-overlay,
.modal-panel {
  opacity: 0;
  transform: var(--enter-transform, translateY(10px));
  animation: fadeSlideUpModal 0.6s ease forwards;
}

/* Fallback: guarantee visibility whenever the modal is open (WebKit/iPad) */
.modal-overlay.is-open,
.modal-overlay.is-open .modal-panel {
  opacity: 1;
  transform: none;
}

/* Only animate when open */
.modal-overlay.is-open,
.modal-overlay.is-open .modal-panel {
  animation: fadeSlideUpModal 0.6s ease forwards;
}

/* Keep XL panel horizontally centered even while animating */
.mod-size-xl .modal-panel {
  --enter-transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {

  .modal-overlay,
  .modal-panel {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
  }
}

/* Hide the modal title/header bar globally */
.modal-panel .modal-header,
.modal-panel .modal-title {
  display: none !important;
}

/* Hide the modal title/header bar globally */
.modal-panel .modal-header,
.modal-panel .modal-title {
  display: none !important;
}

/* Mobile: remove the close button entirely */
@media (max-width: 768px) {
  .modal-panel .modal-close {
    display: none !important;
  }
}

/* Overlay always on top, grid-centers content */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  /* higher than your .mobile-fixed-nav (1201) */
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .58);
}

.modal-overlay.is-open {
  display: grid;
}

/* Panel scrolls internally; never taller than viewport */
.modal-panel {
  position: relative;
  width: min(1080px, 92vw);
  max-height: min(92vh, 1200px);
  overflow: auto;
  background: #0b0b0b;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
}

/* Header keeps context, but close is absolutely positioned */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0, 0, 0, .9), rgba(0, 0, 0, .85));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 16px;
}

/* Reliable, non-purple, always-on-top “X” */
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  outline: none;
}

.modal-close:hover {
  background: rgba(255, 255, 255, .14);
}

.modal-close:focus {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .22);
}

/* XL iframe mode: hide the title bar visuals but keep the small overlay X */
.mod-size-xl .modal-head {
  background: transparent !important;
  border: 0 !important;
  height: 0 !important;
  padding: 0 !important;
}

.mod-size-xl #modal-title {
  display: none !important;
}

/* Ensure the overlay X remains visible in the top-right of the panel */
.mod-size-xl .modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Overlay close button: add semi-transparent black backdrop for visibility */
.modal-close {
  display: flex;
  align-items: center;
  /* vertical centering */
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.45);
  /* black tint behind the X */
  border-radius: 6px;
  /* soften corners */
  color: #fff;
  /* white icon/text */
  width: 28px;
  height: 28px;
  line-height: 28px;
  font-size: 26px;
  text-align: center;
  transition: background-color 0.2s ease;
}

.modal-close:hover,
.modal-close:focus {
  background-color: rgba(0, 0, 0, 0.65);
}

/* Collapse the modal header chrome but keep the close button visible */
.modal-panel .modal-head {
  background: transparent !important;
  border: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  position: relative;
}

.modal-panel #modal-title {
  display: none !important;
}

/* Keep the X positioned at the panel corner by default */
.modal-panel .modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Keep vertical scroll, allow horizontal scroll if content needs it */
.modal-panel {
  display: flex;
  flex-direction: column;
  /* no overflow rule here */
}

.modal-head {
  flex: 0 0 auto;
}

#modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  /* vertical scrollbar ON */
  overflow-x: auto;
  /* horizontal scrollbar ALLOWED */
}

/* Nudge close button left so it doesn't kiss the scrollbar */
.modal-panel .modal-close {
  right: 22px;
}

/* was 10px */
.mod-size-xl .modal-close {
  right: 16px;
}

/* Added from assets/modal.css — modal shell quirks (10B cleanup) */
/* WebKit autofill override inside modals (desktop UI) */
.modal-panel input:-webkit-autofill,
.modal-panel input:-webkit-autofill:hover,
.modal-panel input:-webkit-autofill:focus,
.modal-panel input:-webkit-autofill:active,
.modal-panel textarea:-webkit-autofill,
.modal-panel textarea:-webkit-autofill:hover,
.modal-panel textarea:-webkit-autofill:focus,
.modal-panel textarea:-webkit-autofill:active,
.modal-panel select:-webkit-autofill,
.modal-panel select:-webkit-autofill:hover,
.modal-panel select:-webkit-autofill:focus,
.modal-panel select:-webkit-autofill:active {
  -webkit-text-fill-color: #e9ecf1 !important;
  /* explicit, not var(--ink) — iOS 16 fix */
  box-shadow: 0 0 0 1000px #0f1116 inset !important;
  /* explicit, not var(--panel-bg) */
  -webkit-box-shadow: 0 0 0 1000px #0f1116 inset !important;
  background-clip: padding-box !important;
  -webkit-background-clip: padding-box !important;
  filter: none !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* iOS 16 WebKit internal autofill (Vivaldi/Safari) */
.modal-panel input:-internal-autofill-selected,
.modal-panel textarea:-internal-autofill-selected,
.modal-panel select:-internal-autofill-selected {
  -webkit-text-fill-color: #e9ecf1 !important;
  /* explicit — iOS 16 fix */
  box-shadow: 0 0 0 1000px #0f1116 inset !important;
  -webkit-box-shadow: 0 0 0 1000px #0f1116 inset !important;
  background-clip: padding-box !important;
  -webkit-background-clip: padding-box !important;
  filter: none !important;
}

/* Desktop positioning for in-content close button */
@media (min-width: 769px) {
  .modal-panel .in-section {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 25px;
    /* was 40px; ~25% smaller */
    height: 25px;
    /* match width for square */
    font-size: 15px;
    /* was 26px; 25% smaller symbol */
    line-height: 1;
    border-radius: 6px;
    /* keep proportions tight */
  }
}
