/**
 * IM Popup front end styles.
 * Colours, width and radius arrive as custom properties on .imp-root.
 */

.imp-root[hidden] { display: none; }

.imp-root {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .25s ease;
  /* Font is inherited from the theme on purpose, so the popup looks native. */
  font-size: 16px;
  line-height: 1.55;
  color: var(--imp-text, #1f1f1f);
}
.imp-root.is-open { opacity: 1; }

/* Corner variant: no overlay, no full-screen trap */
.imp-root--corner {
  inset: auto 0 0 auto;
  padding: 0 20px 20px 0;
  display: block;
  pointer-events: none;
}
.imp-root--corner .imp-dialog { pointer-events: auto; }

.imp-overlay {
  position: absolute;
  inset: 0;
  background: var(--imp-overlay, rgba(0, 0, 0, .6));
}

.imp-dialog {
  position: relative;
  width: 100%;
  max-width: var(--imp-width, 560px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--imp-bg, #fff);
  border-radius: var(--imp-radius, 8px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .28);
  transform: translateY(10px) scale(.985);
  transition: transform .3s cubic-bezier(.25, 1, .33, 1);
}
.imp-root.is-open .imp-dialog { transform: none; }

.imp-root--corner .imp-dialog { max-width: min(var(--imp-width, 560px), 380px); }

/* Close button */
.imp-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  color: #1f1f1f;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.imp-close:hover { background: #fff; transform: scale(1.06); }
.imp-close:focus-visible { outline: 2px solid var(--imp-accent, #0d6d85); outline-offset: 2px; }
.imp-close svg { width: 18px; height: 18px; }

/* Media */
.imp-media { overflow: hidden; }
.imp-media__img { display: block; width: 100%; height: auto; }

.imp-img--top .imp-media__img {
  border-radius: var(--imp-radius, 8px) var(--imp-radius, 8px) 0 0;
}

/* Beside-the-text layout */
.imp-img--left .imp-dialog {
  display: grid;
  grid-template-columns: 40% 1fr;
  align-items: stretch;
}
.imp-img--left .imp-media__img {
  height: 100%;
  object-fit: cover;
  border-radius: var(--imp-radius, 8px) 0 0 var(--imp-radius, 8px);
}

/* Body */
.imp-body { padding: 32px; }
.imp-img--left .imp-body { padding: 28px; }

.imp-heading {
  /* Right padding keeps long headings clear of the close button. */
  margin: 0 0 12px;
  padding-right: 40px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  color: inherit;
}

/* The dialog is focused programmatically on open so assistive tech announces
   the heading. It is a container, not a control, so it gets no focus ring:
   the modal itself is the visual affordance. Real controls keep theirs. */
.imp-dialog:focus,
.imp-dialog:focus-visible { outline: none; }

.imp-text { margin: 0; }
.imp-text > :first-child { margin-top: 0; }
.imp-text > :last-child { margin-bottom: 0; }
.imp-text p { margin: 0 0 12px; }
.imp-text a { color: var(--imp-accent, #0d6d85); }

.imp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  margin: 22px 0 0;
}

.imp-btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 3px;
  background: var(--imp-accent, #0d6d85);
  color: var(--imp-btn-text, #fff);
  font-weight: 600;
  text-decoration: none;
  transition: filter .2s ease, transform .2s ease;
}
.imp-btn:hover,
.imp-btn:focus {
  color: var(--imp-btn-text, #fff);
  filter: brightness(.92);
  transform: translateY(-1px);
  text-decoration: none;
}
.imp-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.imp-link {
  color: var(--imp-accent, #0d6d85);
  font-weight: 600;
  text-decoration: underline;
}

/* Scroll lock for the centred modal */
html.imp-locked,
html.imp-locked body { overflow: hidden; }

/* Small screens: never use the side-by-side image */
@media (max-width: 600px) {
  .imp-root { padding: 12px; }
  .imp-img--left .imp-dialog { grid-template-columns: 1fr; }
  .imp-img--left .imp-media__img {
    height: auto;
    max-height: 180px;
    border-radius: var(--imp-radius, 8px) var(--imp-radius, 8px) 0 0;
  }
  .imp-body,
  .imp-img--left .imp-body { padding: 24px; }
  .imp-heading { font-size: 22px; }
  .imp-root--corner { padding: 0 12px 12px 0; }
  .imp-root--corner .imp-dialog { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .imp-root,
  .imp-dialog,
  .imp-btn,
  .imp-close { transition: none; }
  .imp-dialog { transform: none; }
}
