/* ---------------------------------------------------------------------------
   NYSERDA Priority Populations — in-page definitions dialog
   Opened from the "Click here to see the list of Priority Populations" link
   on the registration form (see priority-populations-modal.js).

   Self-contained: every value is scoped to --pp-* custom properties declared
   on the dialog itself, so nothing here depends on (or leaks into) the theme.
   --------------------------------------------------------------------------- */

.pp-modal {
    /* Brand tokens (mirrors the NYC Accelerator palette) */
    --pp-blue: #2518D2;
    --pp-blue-dark: #1B11A0;
    --pp-amber: #FFAA00;
    --pp-text: #171F24;
    --pp-text-muted: #66737C;
    --pp-surface: #FFFFFF;
    --pp-surface-subtle: #F6F8FA;
    --pp-cream: #FFF8EB;
    --pp-border: #E3E7EA;
    --pp-scrim: rgba(23, 31, 36, .55);
    --pp-radius: 16px;
    --pp-ease: cubic-bezier(.16, 1, .3, 1);
    --pp-duration-in: 260ms;
    --pp-duration-out: 180ms;

    /* Modern browsers get this from the UA's `dialog:not([open])` rule, but a
       browser without <dialog> support treats this as an unknown inline element
       with no such rule — leaving a transparent, click-eating scrim over the
       whole form. .pp-modal[open] below re-raises it to flex. */
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    /* Reset the UA dialog box so the element itself acts as the scrim */
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: var(--pp-scrim);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    color: var(--pp-text);
    opacity: 0;
    transition: opacity var(--pp-duration-out) ease;
}

.pp-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.pp-modal.is-open {
    opacity: 1;
    transition-duration: var(--pp-duration-in);
}

.pp-modal::backdrop {
    background: transparent;
}

/* --------------------------------- Panel --------------------------------- */

.pp-modal__panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    max-height: min(86vh, 760px);
    background: var(--pp-surface);
    border-radius: var(--pp-radius);
    box-shadow: 0 24px 60px rgba(23, 31, 36, .22), 0 2px 8px rgba(23, 31, 36, .08);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(.98);
    transition: transform var(--pp-duration-out) ease-in, opacity var(--pp-duration-out) ease-in;
}

.pp-modal.is-open .pp-modal__panel {
    opacity: 1;
    transform: none;
    transition: transform var(--pp-duration-in) var(--pp-ease), opacity var(--pp-duration-in) var(--pp-ease);
}

/* --------------------------------- Header -------------------------------- */

.pp-modal__header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--pp-border);
}

.pp-modal__heading-group {
    flex: 1 1 auto;
    min-width: 0;
}

.pp-modal__eyebrow {
    display: block;
    margin: 0 0 6px;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--pp-blue);
}

.pp-modal__title {
    margin: 0;
    font-family: 'ClashGrotesk-Variable', 'ClashGrotesk-Semibold', 'Poppins', system-ui, -apple-system, sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--pp-text);
}

.pp-modal__close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: -6px -8px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--pp-text-muted);
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}

.pp-modal__close:hover {
    background: var(--pp-surface-subtle);
    color: var(--pp-text);
}

.pp-modal__close svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* ---------------------------------- Body --------------------------------- */

.pp-modal__body {
    flex: 1 1 auto;
    padding: 22px 28px 26px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    font-size: .9375rem;
    line-height: 1.6;
    color: var(--pp-text);
}

.pp-modal__body::-webkit-scrollbar {
    width: 10px;
}

.pp-modal__body::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
    background-color: #CFD4D7;
}

.pp-modal__body::-webkit-scrollbar-thumb:hover {
    background-color: #ABB4BA;
}

.pp-modal__intro {
    margin: 0 0 16px;
    color: var(--pp-text-muted);
}

.pp-modal__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pp-modal__list li {
    position: relative;
    padding: 0 0 0 26px;
    margin: 0 0 14px;
}

.pp-modal__list li:last-child {
    margin-bottom: 0;
}

.pp-modal__list li::before {
    content: "";
    position: absolute;
    top: .6em;
    left: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pp-blue);
}

.pp-modal__term {
    font-weight: 600;
}

.pp-modal__note {
    display: flex;
    gap: 10px;
    margin: 24px 0 0;
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 3px solid var(--pp-amber);
    background: var(--pp-cream);
    font-size: .875rem;
    line-height: 1.55;
    color: var(--pp-text);
}

.pp-modal__note svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 3px;
    color: #B37700;
}

/* --------------------------------- Footer -------------------------------- */

/* Scroll affordances: only shown while there is content out of view. */
.pp-modal__panel[data-pp-scroll="middle"] .pp-modal__header,
.pp-modal__panel[data-pp-scroll="bottom"] .pp-modal__header {
    box-shadow: 0 6px 12px -10px rgba(23, 31, 36, .55);
}

.pp-modal__panel[data-pp-scroll="top"] .pp-modal__footer,
.pp-modal__panel[data-pp-scroll="middle"] .pp-modal__footer {
    box-shadow: 0 -6px 12px -10px rgba(23, 31, 36, .55);
}

.pp-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 28px 20px;
    border-top: 1px solid var(--pp-border);
    background: var(--pp-surface);
}

.pp-modal__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .875rem;
    font-weight: 500;
    color: var(--pp-blue);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.pp-modal__source:hover {
    color: var(--pp-blue-dark);
    border-bottom-color: currentColor;
}

.pp-modal__source svg {
    width: 14px;
    height: 14px;
}

.pp-modal__dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 28px;
    border: 0;
    border-radius: 999px;
    background: var(--pp-blue);
    color: #FFFFFF;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .18s ease, transform .18s ease;
}

.pp-modal__dismiss:hover {
    background: var(--pp-blue-dark);
}

.pp-modal__dismiss:active {
    transform: translateY(1px);
}

/* -------------------------------- Focus ring ------------------------------ */

.pp-modal :focus-visible {
    outline: 2px solid var(--pp-blue);
    outline-offset: 2px;
}

/* The panel is only focused programmatically (for screen readers) — never
   paint a ring around the whole dialog. */
.pp-modal__panel:focus,
.pp-modal__panel:focus-visible {
    outline: none;
}

/* ------------------------------ Trigger ----------------------------------- */

/* A button, not a link — the definitions live in the dialog, so there is no
   external URL to navigate to. Styled to render identically to the sibling
   field-description links. */
.pp-modal-trigger {
    /* Form controls are coerced to inline-block by the engine; max-width keeps
       the label wrapping inside the field description instead of overflowing. */
    display: inline;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: #2518D2;
    text-align: left;
    text-decoration: underline;
    white-space: normal;
    cursor: pointer;
}

.pp-modal-trigger:hover {
    color: #1B11A0;
}

.pp-modal-trigger:focus-visible {
    outline: 2px solid #2518D2;
    outline-offset: 2px;
    border-radius: 3px;
}

/* Prevent background scroll while the dialog is open */
html.pp-modal-open,
html.pp-modal-open body {
    overflow: hidden;
}

/* ------------------------------- Responsive ------------------------------- */

@media (max-width: 640px) {
    .pp-modal[open] {
        align-items: flex-end;
        padding: 0;
    }

    .pp-modal__panel {
        max-width: none;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(24px);
    }

    .pp-modal__header {
        padding: 20px 20px 16px;
    }

    .pp-modal__title {
        font-size: 1.25rem;
    }

    .pp-modal__body {
        padding: 18px 20px 22px;
    }

    .pp-modal__footer {
        padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px));
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .pp-modal__dismiss {
        width: 100%;
    }

    .pp-modal__source {
        justify-content: center;
    }
}

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

    .pp-modal,
    .pp-modal__panel,
    .pp-modal.is-open .pp-modal__panel {
        transition-duration: .01ms;
    }

    .pp-modal__panel {
        transform: none;
    }
}
