:root {
  /* Modal */
  --modal-width: 600px; /* default size (Bootstrap default) */
  --modal-width-sm: 300px; /* .modal--sm */
  --modal-width-lg: 800px; /* .modal--lg, applies from 992px up */
  --modal-width-xl: 1140px; /* .modal--xl, applies from 1200px up */

  --modal-gutter: var(--space-sm); /* gap between dialog and screen edge */
  --modal-padding: 40px 50px;
  --modal-bg: var(--color-surface-light);
  --modal-text-color: var(--color-text-on-light);
  --modal-title-color: var(--color-heading-on-light);
  --modal-backdrop-bg: rgb(35 31 32 / 0.8); /* --palette-black @ 80% */
  --modal-border-color: var(--color-border);
  --modal-accent-color: var(--color-border-brand);
  --modal-radius: var(--card-border-radius);
  --modal-close-color: var(--color-text-muted);
  --modal-close-color-hover: var(--color-highlight);
}

html.is-modal-open {
  overflow: hidden;
}

html.is-modal-open body {
  /* Stops the page from jumping sideways when the scrollbar disappears. */
  padding-right: var(--scrollbar-width, 0);
}

/* ---------- Backdrop + centering ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--modal-gutter);
  background: var(--modal-backdrop-bg);

  /* Hidden state. visibility is delayed so the fade-out can finish. */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-base),
    visibility 0s linear var(--transition-base);
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* ---------- Dialog box (default size: 500px) ---------- */
.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--modal-width);
  max-height: 100%;
  background: var(--modal-bg);
  color: var(--modal-text-color);
  border-radius: var(--modal-radius);
  box-shadow: var(--shadow-box);
  outline: 0;

  transform: translateY(-12px);
  transition: transform var(--transition-base);
}

.modal.is-open .modal-content {
  transform: none;
}

/* ---------- Sizes (reference: Bootstrap modal sizes) ----------
   Add ONE of these classes next to .modal:
     (none)                    500px
     .modal--sm                300px
     .modal--lg                800px  from 992px up, otherwise 500px
     .modal--xl                1140px from 1200px up, otherwise as lg/500px
     .modal--fullscreen        fills the screen at every size
     .modal--fullscreen-md-down fills the screen below 768px
   ------------------------------------------------------------- */
.modal--sm .modal-content {
  max-width: var(--modal-width-sm);
}

@media (min-width: 992px) {
  .modal--lg .modal-content,
  .modal--xl .modal-content {
    max-width: var(--modal-width-lg);
  }
}

@media (min-width: 1200px) {
  .modal--xl .modal-content {
    max-width: var(--modal-width-xl);
  }
}

.modal--fullscreen {
  padding: 0;
}

.modal--fullscreen .modal-content {
  max-width: none;
  height: 100%;
  border-radius: 0;
}

@media (max-width: 767.98px) {
  .modal--fullscreen-md-down {
    padding: 0;
  }

  .modal--fullscreen-md-down .modal-content {
    max-width: none;
    height: 100%;
    border-radius: 0;
  }
}

@media (max-width: 576.98px) {
  :root {
    --modal-padding: 30px;
  }
}

/* ---------- Header / title / close ---------- */
.modal-header {
  flex: 0 0 auto;
  padding: var(--modal-padding);
  padding-right: calc(var(--modal-padding) + 40px); /* room for the X */
  padding-bottom: 0;
}

.modal-title {
  margin: 0;
  font-family: var(--font-family-heading);
  font-size: var(--font-size-h2);
  line-height: 1.25;
  color: var(--modal-title-color);
  margin-bottom: 10px;
}

.card-benefit-wrapper {
  display: grid;
  grid-template-columns: 3fr 7fr;
  gap: var(--gap-default);
  & .img-wrapper img {
    height: 300px;
    width: auto;
    margin: 0 auto;
  }
  & .text-wrapper {
    padding: 20px;
    background-color: #efefef;
    color: var(--color-primary);

    & ul,
    & ol {
      list-style-type: revert;
      margin-left: 1rem;
    }

    & p {
      margin-bottom: 1rem;
      color: var(--color-primary);
    }
  }

  @media screen and (max-width: 575.98px) {
    grid-template-columns: 1fr;
  }
}

.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--modal-close-color);
  cursor: pointer;
  transition: color var(--transition-base);
}

.modal-close:hover,
.modal-close:focus-visible {
  color: var(--modal-close-color-hover);
}

.modal-close:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -6px;
}

/* ---------- Body (scrolls when content is tall) ---------- */
.modal-body {
  flex: 1 1 auto;
  padding: var(--modal-padding);
  padding-top: var(--space-sm);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-img {
  display: block;
  width: 100%;
  height: auto;
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-content {
    transition: none;
  }
}

/* ==========================================================================
   EPIC CARDS — modal triggers
   ========================================================================== */

/* Benefits are only shown inside the modal (JS copies them there). */
.epic-card .card-benefits,
.epic-card .card-category-benefits {
  display: none;
}

/* Image: click target for mouse/touch. */
.epic-card .card-image.is-clickable {
  cursor: pointer;
}

/* Name: JS wraps it in a button; make it look like the plain heading. */
.card-name .card-modal-trigger {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  transition: color var(--transition-base);
}

.card-name .card-modal-trigger:hover {
  color: var(--color-link-hover);
}

.modal .tab-panel-layout .tabs {
  overflow-x: auto;
}
.modal .tab-panel-layout .tab-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* .card-name .card-modal-trigger:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
} */
