/**
 * @file
 * CHR-6 (DONI-568) — the leaving-site interstitial, measured against Figma
 * for the first time on 2026-08-10. Every previous round on this ticket
 * verified BEHAVIOUR only (which links fire it, the whitelist match) — the
 * geometry, colour and typography below were never checked against the
 * design file at all, which is why this file rewrites most of it at once
 * rather than patching one QA-reported delta.
 *
 * Source: `TJC7pZhPM2o5S0wuc1tnVI`, found by trial ids near the already-known
 * HCP-gate pop-up frames under the "Interstitials" label (`29999:57058`) —
 * `29999:57086` (desktop, 1440×602 canvas, card auto-height) and
 * `29999:57099` (mobile, 375×812 canvas, card 343×302 at x=16 y=255.5).
 * Neither id existed anywhere in this repo before this pass.
 *
 * `css/base/external-link-popup.css` is shared by this dialog AND the old
 * `external-link-popup-id-modal-home_splash` selector — the HCP gate's
 * pre-`hcp-modal.css` name. The gate is fully overridden downstream by
 * class (not `:nth-child`), so none of this touches it; scoped here to
 * `.external-link-popup-id-default` only, which is the ONLY thing that
 * selector still styles live.
 *
 * Loads in the `component` group (`global` library) while the base file is
 * in `component`'s `base` group, so this wins at equal specificity without
 * needing `!important` — except where the base file's own comment already
 * explains one is unavoidable: the jQuery UI widget writes an inline
 * `width` style that nothing else can beat (C-013).
 */

.external-link-popup.external-link-popup-id-default.ui-dialog {
  /* MEASURED: Figma draws the card at the scrim's own gutter, not a
   * hardcoded max-width — 1440 - 2×94 = 1252 at 1440, and the base file's
   * `90% !important` mobile rule already tracks the viewport the same way
   * CHR-1's header gutter does. `width: 90% !important` inherited from the
   * base file is close at mobile (343 target vs measured ~90% of 375) but
   * wrong at desktop, where it was resolving to 893px against Figma's
   * 1252px. Capped, not fixed, so a very narrow desktop viewport can't
   * overflow past its own gutter. */
  width: min(1252px, calc(100% - 188px)) !important;
  max-width: none;
  padding: 16px 40px 40px;
  gap: 0;
  border-radius: 24px;
  box-shadow: 0 0 24px -4px rgba(81, 88, 97, 0.16);

  @media (max-width: 991px) {
    width: min(343px, calc(100% - 32px)) !important;
    padding: 24px;
  }

  /* The close control lives inside jQuery UI's titlebar, and the shared
   * base rule sets `.ui-dialog-titlebar { display: none }` — hiding the
   * close button along with a title string ("You Are Now Leaving This
   * Site") that Figma never draws at all. Un-hide the bar to get the
   * close button back, then hide only the title text, visually rather
   * than with `display: none`, so it stays in the accessible name.
   *
   * jQuery UI positions `.ui-dialog-titlebar-close` absolutely at
   * `top: 50%` inside the titlebar. With the title sr-only-only, the bar
   * collapses to ~0 height and the negative margin pulls the 40×40 asset
   * above the card's 16px top padding — the "X sits too high" QA miss.
   * Figma (`29999:57086 > Icon`, `29999:57099 > Icon`) keeps the control
   * in normal flow: a 40×40 row, end-aligned, inside the card padding. */
  .ui-dialog-titlebar {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    align-self: flex-end;
    width: auto;
    min-height: 40px;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;

    @media (max-width: 991px) {
      align-self: stretch;
      width: 100%;
      margin-bottom: 12px;
    }
  }

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

  /* MEASURED: 40×40, node `29999:57086 > Icon` (`Union` path), coral fill
   * — same asset at the same size on both breakpoints. jQuery UI's own
   * icon font glyph (`.ui-icon`) and its visually-hidden "Close" text stay
   * in the DOM for the accessible name; only the glyph's own paint is
   * swapped for the Figma asset. */
  .ui-dialog-titlebar-close {
    position: static;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: 0;
    transform: none;
    background: url('../../images/icons/close-icon-interstitial.svg') no-repeat center / contain;

    &:hover,
    &:focus,
    &:active {
      transform: none;
    }

    .ui-icon {
      display: none;
    }
  }

  .external-link-popup-content.ui-dialog-content.ui-widget-content {
    padding: 0;
    width: 100%;

    .external-link-popup-body {
      width: 100%;
      gap: 0;
      padding: 0;

      /* MEASURED: the base rule sets this heading in `--font-tilt-neon`
       * at 32px/26px — the decorative marketing display face used for
       * headlines like "FLIP THE SWITCH" elsewhere on the site. Figma
       * draws this dialog in Agenda Bold, 28px at 1440 (`29999:57086`)
       * and 24px at 375 (`29999:57099`) — the same body/heading face
       * every other modal on this site uses, not the neon script. The
       * headline sits flush under the 40×40 close row on desktop (card
       * inner height 146 = 40 icon + 34 headline + 24 gap + 48 buttons);
       * mobile adds 12px between the icon row and this text block. */
      h3 {
        width: 100%;
        margin: 0;
        padding: 0;
        text-align: center;
        color: var(--color-charcoal);
        font-family: var(--font-agenda);
        font-size: 28px;
        font-weight: 700;
        font-feature-settings: "liga" 0;

        @media (max-width: 991px) {
          font-size: 24px;
        }
      }
    }
  }

  .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix {
    margin-top: 24px;
    padding: 0;
    .ui-dialog-buttonset {
      margin: 0;
      gap: 24px;

      /* MEASURED: both buttons in Figma are h-48 pills, Agenda Bold 20px,
       * `--color-dark-coral` (#bb5844) — not `--color-primary` /
       * `--color-nav-active`, the legacy coral this base file still
       * defaults to. The two buttons are NOT interchangeable in style:
       * `Continue` (first) is filled with a trailing chevron; `Stay here`
       * (second) is an outline with no icon at all. The base rule has
       * this exactly backwards — first outlined, second filled — which
       * is what QA measured as "button background color does not match".
       *
       * Client dark-coral-to-coral override changed `--color-dark-coral`
       * to alias `--color-coral`, which made this button's resting and
       * hover states resolve to the same color (no visible hover
       * feedback). Fix: hover deliberately uses the preserved
       * --color-dark-coral-original so this one control keeps a
       * distinct hover state. Do not swap this back to --color-coral.
       */
      .button:nth-child(1) {
        background: var(--color-coral);
        border: 3px solid var(--color-coral);
        color: var(--color-white);
        gap: 8px;
      }

      .button:nth-child(1):hover {
        background: var(--color-dark-coral-original);
        border-color: var(--color-dark-coral-original);
      }

      .button:nth-child(1)::after {
        content: '';
        width: 24px;
        height: 24px;
        display: inline-block;
        background: url('../../images/icons/chevron-right.svg') no-repeat center / contain;
      }

      .button:nth-child(2) {
        background: var(--color-white);
        border: 3px solid var(--color-dark-coral);
        color: var(--color-dark-coral);
      }

      .button:nth-child(2):hover {
        background: var(--color-light-melon);
      }

      /* Figma draws no icon on this button at all — the base rule's
       * `arrow-coral-right.svg` on the old first-child position is
       * removed outright rather than recoloured. */
      .button:nth-child(2)::after {
        content: none;
        background-image: none;
      }

      @media (max-width: 991px) {
        .button:nth-child(1),
        .button:nth-child(2) {
          width: 100%;
        }

        .button:nth-child(1) {
          display: grid;
          grid-template-columns: 1fr auto;
          column-gap: 8px;
          align-items: center;
          padding: 12px 16px 10px 24px;
          text-align: center;
        }
      }
    }
  }
}
