/* =====================================================================
   PE Group of Institutions: "Apply Online" popup
   Loaded on every page (the header button opens it).
   Reuses the colour tokens from pe-header.css, with fallbacks.
   ===================================================================== */

.pe-apply {
    --pa-forest: var(--pe-forest, #17392c);
    --pa-green: var(--pe-green, #2f6b4f);
    --pa-sage-50: var(--pe-sage-50, #f3f6f0);
    --pa-sage-100: var(--pe-sage-100, #e5ebe0);
    --pa-mustard: var(--pe-mustard, #d9a036);
    --pa-ink: var(--pe-ink, #1c2521);
    --pa-muted: var(--pe-muted, #5b675f);
    --pa-line: #dfe4dd;
    --pa-error: #c92a3b;

    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 28px);
    color: var(--pa-ink);
    font-family: var(--pe-font-ui, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
}
.pe-apply[hidden] { display: none; }
/* anything with the hidden attribute inside the popup really is hidden:
   without this, rules like .pe-apply__form { display: grid } win over it */
.pe-apply [hidden] { display: none !important; }
.pe-apply *, .pe-apply *::before, .pe-apply *::after { box-sizing: border-box; }
.pe-apply :focus-visible { outline: 2px solid var(--pa-forest); outline-offset: 3px; }

.pe-apply__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 22, 16, .62);
    -webkit-backdrop-filter: blur(3px);
            backdrop-filter: blur(3px);
    animation: pe-apply-fade .2s ease both;
}
.pe-apply__dialog {
    position: relative;
    width: min(520px, 100%);
    max-height: 100%;
    padding: clamp(22px, 3vw, 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .8);
    animation: pe-apply-pop .28s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes pe-apply-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pe-apply-pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.pe-apply__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--pa-sage-50);
    color: var(--pa-forest);
    font-size: .95rem;
    cursor: pointer;
    transition: background-color .2s, color .2s;
}
.pe-apply__close:hover { background: var(--pa-forest); color: #fff; }

.pe-apply__head { margin-bottom: 20px; padding-right: 44px; }
.pe-apply__title {
    margin: 0 0 6px;
    color: var(--pa-forest);
    font-family: var(--pe-font-display, Georgia, "Times New Roman", serif);
    font-size: clamp(1.5rem, 1.2rem + 1vw, 1.875rem);
    font-weight: 400;
    line-height: 1.2;
}
.pe-apply__sub {
    margin: 0;
    color: var(--pa-muted);
    font-size: .9875rem;
    line-height: 1.55;
}

/* ---------- Form ---------- */
.pe-apply__form { display: grid; gap: 14px; }
.pe-apply__hp {
    position: absolute !important;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.pe-apply__field { display: grid; gap: 6px; }
.pe-apply__field label {
    color: var(--pa-forest);
    font-size: .875rem;
    font-weight: 600;
}
.pe-apply__field input,
.pe-apply__field select {
    width: 100%;
    min-height: 50px;
    padding: 13px 14px;
    border: 1.5px solid var(--pa-line);
    border-radius: 12px;
    background: #fff;
    color: var(--pa-ink);
    font: inherit;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
}
.pe-apply__field input:focus,
.pe-apply__field select:focus {
    border-color: var(--pa-green);
    outline: none;
    box-shadow: 0 0 0 4px rgba(47, 107, 79, .15);
}
.pe-apply__field.is-invalid input,
.pe-apply__field.is-invalid select {
    border-color: var(--pa-error);
    box-shadow: 0 0 0 4px rgba(201, 42, 59, .12);
}
.pe-apply__error {
    color: var(--pa-error);
    font-size: .8125rem;
    line-height: 1.4;
}
.pe-apply__error:empty { display: none; }

/* ---------- Consent ---------- */
.pe-apply__consent {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 12px;
    margin-top: 2px;
}
.pe-apply__consent input {
    -webkit-appearance: none;
            appearance: none;
    width: 22px;
    height: 22px;
    margin: 2px 0 0;
    border: 2px solid #c3cbc2;
    border-radius: 6px;
    background: #fff center / 14px 14px no-repeat;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.pe-apply__consent input:checked {
    border-color: var(--pa-green);
    background-color: var(--pa-green);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.4' d='M3.5 8.5l3 3 6-7'/%3e%3c/svg%3e");
}
.pe-apply__consent.is-invalid input { border-color: var(--pa-error); }
.pe-apply__consent label {
    color: var(--pa-muted);
    font-size: .9375rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
}
.pe-apply__consent a { color: var(--pa-green); font-weight: 600; }
.pe-apply__consent .pe-apply__error { grid-column: 2; }

.pe-apply__submit {
    position: relative;
    width: 100%;
    margin-top: 4px;
}
.pe-apply__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(23, 57, 44, .3);
    border-top-color: var(--pa-forest);
    border-radius: 50%;
    animation: pe-apply-spin .7s linear infinite;
}
.pe-apply__submit.is-busy { pointer-events: none; opacity: .85; }
.pe-apply__submit.is-busy .pe-apply__spinner { display: block; }
@keyframes pe-apply-spin { to { transform: rotate(360deg); } }

.pe-apply__note {
    margin: 0;
    color: var(--pa-muted);
    font-size: .8125rem;
    text-align: center;
}

/* ---------- Thank you ---------- */
.pe-apply__done { text-align: center; }
.pe-apply__done[hidden] { display: none; }
.pe-apply__tick {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 6px auto 18px;
    border-radius: 50%;
    background: var(--pa-sage-100);
    color: var(--pa-forest);
    font-size: 1.8rem;
}
.pe-apply__done h2 {
    margin: 0 0 8px;
    color: var(--pa-forest);
    font-family: var(--pe-font-display, Georgia, "Times New Roman", serif);
    font-size: 1.625rem;
    font-weight: 400;
}
.pe-apply__done p {
    max-width: 34ch;
    margin: 0 auto 22px;
    color: var(--pa-muted);
    font-size: 1rem;
    line-height: 1.6;
}

html.pe-apply-lock, html.pe-apply-lock body { overflow: hidden; }

/* ---------- Phones ---------- */
@media (max-width: 575.98px) {
    .pe-apply { padding: 0; place-items: end stretch; }
    .pe-apply__dialog {
        width: 100%;
        max-height: 92vh;
        padding: 22px 18px 24px;
        border-radius: 22px 22px 0 0;   /* slides up from the bottom */
        animation: pe-apply-sheet .3s cubic-bezier(.2, .8, .3, 1) both;
    }
    @keyframes pe-apply-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
    .pe-apply__field input,
    .pe-apply__field select { min-height: 48px; font-size: 16px; }  /* 16px stops iOS zooming in */
}

@media (prefers-reduced-motion: reduce) {
    .pe-apply__backdrop, .pe-apply__dialog { animation: none; }
    .pe-apply__spinner { animation-duration: 1.6s; }
}

/* =====================================================================
   Small message popup (form results), shared by the forms
   ===================================================================== */
.pe-msg {
    --pm-forest: var(--pe-forest, #17392c);
    --pm-green: var(--pe-green, #2f6b4f);
    --pm-sage-50: var(--pe-sage-50, #f3f6f0);
    --pm-sage-100: var(--pe-sage-100, #e5ebe0);
    --pm-muted: var(--pe-muted, #5b675f);
    --pm-error: #c92a3b;

    position: fixed;
    inset: 0;
    z-index: 1400;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 28px);
    font-family: var(--pe-font-ui, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
}
.pe-msg[hidden] { display: none; }
.pe-msg *, .pe-msg *::before, .pe-msg *::after { box-sizing: border-box; }
.pe-msg :focus-visible { outline: 2px solid var(--pm-forest); outline-offset: 3px; }
.pe-msg__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 22, 16, .62);
    -webkit-backdrop-filter: blur(3px);
            backdrop-filter: blur(3px);
}
.pe-msg__dialog {
    position: relative;
    width: min(440px, 100%);
    max-height: 100%;
    padding: clamp(26px, 3vw, 34px) clamp(22px, 3vw, 30px) clamp(22px, 3vw, 28px);
    overflow-y: auto;
    border-radius: 22px;
    background: #fff;
    text-align: center;
    box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .8);
    animation: pe-apply-pop .25s cubic-bezier(.2, .8, .3, 1) both;
}
.pe-msg__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--pm-sage-50);
    color: var(--pm-forest);
    font-size: .9rem;
    cursor: pointer;
    transition: background-color .2s, color .2s;
}
.pe-msg__close:hover { background: var(--pm-forest); color: #fff; }
.pe-msg__icon {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    margin: 4px auto 16px;
    border-radius: 50%;
    background: var(--pm-sage-100);
    color: var(--pm-forest);
    font-size: 1.7rem;
}
.pe-msg.is-bad .pe-msg__icon { background: #fdeaec; color: var(--pm-error); }
.pe-msg__title {
    margin: 0 0 10px;
    color: var(--pm-forest);
    font-family: var(--pe-font-display, Georgia, "Times New Roman", serif);
    font-size: 1.625rem;
    font-weight: 400;
    line-height: 1.2;
}
.pe-msg.is-bad .pe-msg__title { color: var(--pm-error); }
.pe-msg__body {
    margin: 0 auto 22px;
    max-width: 34ch;
    color: var(--pm-muted);
    font-size: 1rem;
    line-height: 1.6;
}
.pe-msg__body p { margin: 0; }
.pe-msg__body ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
    text-align: left;
}
.pe-msg__body li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}
.pe-msg__body li::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-top: .55em;
    border-radius: 2px;
    background: var(--pm-error);
    transform: rotate(45deg);
}
.pe-msg__ok { width: 100%; }
@media (max-width: 575.98px) {
    .pe-msg { place-items: end stretch; padding: 0; }
    .pe-msg__dialog { width: 100%; border-radius: 22px 22px 0 0; }
}