/* ============================================================
   EDUCATION SCORE — Association Education Score quiz UI
   ============================================================
   Namespace: .es-* — rendered by /js/education-score.js into
   [data-es-mount]. Used inside the LP modal (#es-modal) and
   full-page on /tools/association-education-score/. Design-system tokens
   throughout; light surface in both contexts.
   ============================================================ */

/* ---------- Modal shell ---------- */

.es-modal {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(680px, calc(100% - 2rem));
    max-height: calc(100dvh - 4rem);
    overflow: hidden;
    border: none;
    border-radius: var(--radius-xl);
    padding: 0;
    box-shadow: var(--shadow-lg);
    background: #fff;
}

/* Column layout so the scroller takes the leftover height in both the
   capped desktop dialog and the full-height mobile one. Set on [open]
   because a bare display value would override the closed state. */
.es-modal[open] {
    display: flex;
    flex-direction: column;
}

/* The scroller, so the close button can sit above it without overlapping */
.es-modal__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.es-modal .es {
    /* room for the close button */
    padding-top: 3.5rem;
}

.es-modal::backdrop {
    background: rgba(26, 26, 36, 0.7);
    backdrop-filter: blur(3px);
}

.es-modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-grey-100);
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    z-index: 3;
    /* halo keeps it legible if content scrolls beneath */
    box-shadow: 0 0 0 5px #fff;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.es-modal__close:hover {
    background: var(--color-grey-200);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.es-modal__close:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

@media (max-width: 767px) {
    /* Full-screen sheet. Stretched by inset rather than width:100% — under
       mobile device emulation a percentage resolves against the layout
       viewport and leaves a gap at the right edge. */
    .es-modal {
        inset: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }
}

/* ---------- Official rules dialog (shared include) ---------- */

.asae-rules {
    position: fixed;
    inset: 0;
    margin: auto;
    max-width: 560px;
    width: calc(100% - 3rem);
    max-height: min(80vh, 640px);
    overflow-y: auto;
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    color: var(--color-text-secondary);
}

.asae-rules::backdrop {
    background: rgba(26, 26, 36, 0.65);
    backdrop-filter: blur(3px);
}

.asae-rules__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.asae-rules__head h2 {
    font-size: var(--text-h6);
    color: var(--color-text-primary);
    line-height: var(--leading-snug);
    margin: 0;
}

.asae-rules__close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-grey-100);
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.asae-rules__close:hover {
    background: var(--color-grey-200);
    color: var(--color-text-primary);
}

.asae-rules p {
    margin: 0;
    font-size: var(--text-small);
    line-height: var(--leading-relaxed);
}

/* ---------- Standalone page (/tools/association-education-score/) ---------- */

/* Evergreen page only. Every rule here hangs off .es-standalone, which the
   /lp/asae/ modal does not use, so the show build is untouched. */
.es-standalone {
    background: #f1f1f6;   /* fallback, and fills any gap if the photo 404s */
    padding: calc(80px + 3rem) 1.5rem 4rem;
    min-height: 100vh;
    display: flex;
}

/* The photo rides on a fixed pseudo-element so it always covers exactly the
   viewport: on a tall results screen an absolute layer would have to `cover` a
   3000px box and zoom the image to nothing. The scrim is a flat gradient over
   the same layer, in the page tint, so the card still separates from it.
   The file is pre-blurred rather than CSS-filtered — a runtime blur of a
   full-size photo costs real paint time on phones. Downsampled to 1600px from
   a 6049px original, so at desktop it is about 1:1 and the Gaussian radius 5
   is real display pixels; the earlier 690px source had to be upscaled ~2x,
   which compounded its blur and softened the detail underneath it. Reads as a
   defocused photograph rather than a colour wash, which is the point. */
.es-standalone::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(241, 241, 246, 0.5), rgba(241, 241, 246, 0.5)),
        url('/images/lp/es-quiz-bg-blur.jpg') center / cover no-repeat;
    z-index: 0;
    pointer-events: none;
}

/* Centred with auto margins rather than align-items: center — when the results
   screen is taller than the viewport, auto margins still let it scroll from the
   top, where centring would clip the head of it. */
.es-standalone > .es {
    position: relative;
    z-index: 1;
    width: 100%;
    margin: auto;
    box-shadow: var(--shadow-lg);
}

/* ---------- Quiz container ---------- */

.es {
    padding: var(--space-2xl) clamp(1.5rem, 5vw, 3rem) var(--space-2xl);
    font-family: var(--font-body);
    color: var(--color-text-secondary);
}

.es--page {
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ---------- Screen transitions ----------
   Each render() replaces the screen element, so the entrance animation
   fires once per step. Direction comes from .es-screen--back, set by the
   engine when the reader moves backwards. */

@keyframes es-screen-in {
    from { opacity: 0; transform: translateX(14px); }
    to   { opacity: 1; transform: none; }
}

@keyframes es-screen-in-back {
    from { opacity: 0; transform: translateX(-14px); }
    to   { opacity: 1; transform: none; }
}

.es-screen {
    animation: es-screen-in 0.15s var(--easing-smooth) both;
}

.es-screen--back {
    animation-name: es-screen-in-back;
}

.es-eyebrow {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-accent-primary);
    margin: 0 0 var(--space-sm);
}

.es-title {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    line-height: var(--leading-tight);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-md);
}

.es-lede {
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    margin: 0 0 var(--space-lg);
}

.es-note {
    font-size: var(--text-small);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-lg);
}

.es-note i {
    color: var(--color-accent-secondary);
    margin-left: 0;
}

.es-ruleslink {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.es-ruleslink:hover {
    color: var(--color-text-primary);
}

/* ---------- Buttons ---------- */

.es-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.es-btn--primary {
    background: var(--color-accent-primary);
    color: #fff;
}

.es-btn--primary:hover {
    background: var(--color-accent-primary-dark);
}

.es-btn--primary:active {
    transform: scale(0.98);
}

.es-btn--primary:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

.es-btn--lg {
    font-size: var(--text-lg);
    padding: var(--space-md) var(--space-xl);
}

.es-back {
    background: none;
    border: none;
    font-family: var(--font-heading);
    font-weight: var(--weight-medium);
    color: var(--color-accent-primary);
    cursor: pointer;
    padding: var(--space-sm) 0 0;
    margin-top: var(--space-lg);
}

.es-back:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.es-back i {
    margin-right: 0.35rem;
}

/* ---------- Progress + question ---------- */

.es-progress {
    height: 6px;
    background: var(--color-grey-100);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: var(--space-xl);
}

.es-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(120deg, var(--color-accent-tertiary), var(--color-accent-tertiary-light));
    transition: width 0.25s ease;
}

.es-qmeta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-md);
    margin-bottom: var(--space-xs);
}

.es-qcat {
    font-family: var(--font-heading);
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent-tertiary);
}

.es-qcount {
    font-size: var(--text-caption);
    color: var(--color-text-muted);
}

.es-qtext {
    font-family: var(--font-heading);
    font-size: clamp(1.25rem, 2.6vw, 1.625rem);
    line-height: var(--leading-snug);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-md);
}

.es-options {
    display: grid;
    gap: var(--space-sm);
}

.es-option {
    position: relative;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 2px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    font: inherit;
    color: var(--color-text-primary);
    cursor: pointer;
    overflow: hidden;
    transition: border-color var(--transition-fast), background var(--transition-fast),
                transform var(--transition-fast), box-shadow var(--transition-fast);
}

/* Accent bar slides in from the left edge on hover / when picked */
.es-option::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 6px;
    /* darker than the hover border so the stripe still reads against it */
    background: var(--color-accent-primary-dark);
    transform: translateX(-100%);
    transition: transform var(--transition-fast);
}

@media (hover: hover) {
    .es-option:hover {
        border-color: var(--color-accent-primary);
        background: rgba(123, 92, 213, 0.06);
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(123, 92, 213, 0.14);
    }

    .es-option:hover::before {
        transform: translateX(0);
    }
}

.es-option:active {
    transform: translateY(0) scale(0.99);
    box-shadow: none;
}

.es-option:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

.es-option.is-picked {
    border-color: var(--color-accent-primary);
    background: rgba(123, 92, 213, 0.08);
}

.es-option.is-picked::before {
    transform: translateX(0);
}

/* ---------- Gate form ---------- */

.es-form {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.es-form .es-btn {
    justify-self: start;
}

.es-form__row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

@media (max-width: 479px) {
    .es-form__row {
        grid-template-columns: 1fr;
    }
}

.es-form + .es-fineprint {
    margin-top: var(--space-sm);
}

.es-fineprint {
    text-align: left;
    font-size: var(--text-caption);
    color: var(--color-text-muted);
    line-height: var(--leading-normal);
    margin: 0 0 var(--space-xs);
}

.es-fineprint i {
    color: var(--color-accent-secondary);
    margin-right: 0.3rem;
}

.es-field label {
    display: block;
    font-family: var(--font-heading);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.es-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: var(--text-body);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: #fff;
}

.es-input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px rgba(123, 92, 213, 0.15);
}

.es-error {
    color: #c2410c;
    font-size: var(--text-small);
    margin: 0;
}

/* ---------- Results ---------- */

.es-band {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.35rem 1rem;
    border-radius: var(--radius-pill);
    margin-bottom: var(--space-md);
    /* arrives a half-beat after the score, so the reader lands on the number first */
    animation: es-band-in 0.4s var(--easing-smooth) 0.35s both;
}

@keyframes es-band-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.es-band--leading         { background: rgba(16, 185, 129, 0.12); color: #067a55; }
.es-band--strong          { background: rgba(0, 161, 172, 0.12);  color: var(--color-accent-tertiary-dark); }
.es-band--developing      { background: rgba(249, 147, 13, 0.14); color: #b26a09; }
.es-band--getting-started { background: rgba(220, 38, 38, 0.1);   color: #b91c1c; }

.es-bars {
    display: grid;
    gap: var(--space-sm);
    background: var(--color-grey-100);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin: var(--space-xl) 0;
}

.es-bar-row {
    display: grid;
    grid-template-columns: minmax(110px, 150px) 1fr 3.2ch;
    align-items: center;
    gap: var(--space-sm) var(--space-md);
}

.es-bar-row.is-weakest .es-bar-label {
    font-weight: var(--weight-bold);
}

.es-bar-pct {
    font-family: var(--font-heading);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    text-align: right;
}

.es-bar-label {
    font-family: var(--font-heading);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    color: var(--color-text-primary);
}

.es-bar-label .es-flag {
    display: block;
    margin-top: 0.15rem;
}

.es-bar {
    display: block;
    height: 10px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.es-bar i {
    display: block;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(120deg, var(--color-accent-tertiary), var(--color-accent-tertiary-light));
    /* grows to its inline width on reveal; see es-bar-grow */
    transform-origin: left center;
    animation: es-bar-grow 0.55s var(--easing-smooth) 0.1s both;
}

@keyframes es-bar-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* Each row starts a beat after the one above it */
.es-bar-row:nth-child(2) .es-bar i { animation-delay: 0.2s; }
.es-bar-row:nth-child(3) .es-bar i { animation-delay: 0.3s; }
.es-bar-row:nth-child(4) .es-bar i { animation-delay: 0.4s; }

.es-bar-row--critical .es-bar i {
    background: linear-gradient(120deg, #dc2626, var(--color-accent-secondary));
}

.es-bar-row--watch .es-bar i {
    background: linear-gradient(120deg, var(--color-accent-secondary), #ffb454);
}

.es-flag {
    white-space: nowrap;
    font-family: var(--font-heading);
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #b91c1c;
}

.es-total {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    margin-bottom: var(--space-sm);
}

.es-total strong {
    font-size: clamp(3rem, 6vw, 4.25rem);
    font-weight: var(--weight-black);
    line-height: var(--leading-none);
    background: linear-gradient(120deg, var(--color-accent-tertiary), var(--color-accent-tertiary-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.es-total span {
    font-size: var(--text-lg);
    color: var(--color-text-muted);
}

.es-verdict-line {
    font-family: var(--font-heading);
    font-size: var(--text-h6);
    font-weight: var(--weight-bold);
    line-height: var(--leading-snug);
    color: var(--color-text-primary);
    margin: 0 0 var(--space-xl);
}

.es-cta {
    background: var(--color-grey-500);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.es-cta > p:first-child {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--weight-medium);
    color: #fff;
}

/* Sized to match the printable report's CTA append (16px), so the same
   sentence does not shrink between the two surfaces */
.es-cta__append {
    font-size: var(--text-body) !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

.es-cta h3 {
    font-family: var(--font-heading);
    font-size: var(--text-h6);
    color: #fff;
    margin: 0 0 var(--space-sm);
}

.es-cta p {
    color: rgba(255, 255, 255, 0.82);
    line-height: var(--leading-relaxed);
    margin: 0 0 var(--space-lg);
}

/* ---------- Results banner: score left, download right ---------- */

.es-resulthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.es-resulthead__action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-xs);
}

@media (max-width: 560px) {
    .es-resulthead__action {
        align-items: flex-start;
        width: 100%;
    }
}

.es-btn--ghost {
    background: transparent;
    color: var(--color-text-primary);
    border: 2px solid var(--color-border-strong);
}

.es-btn--ghost:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.es-btn--ghost:active {
    transform: scale(0.98);
}

.es-btn--ghost:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
}

/* ---------- Reduced motion ----------
   Everything below is decorative. Readers who ask for less motion get the
   same layout with no movement — bars render at full width immediately. */

@media (prefers-reduced-motion: reduce) {
    .es-screen,
    .es-band,
    .es-bar i {
        animation: none;
    }

    .es-option,
    .es-option::before,
    .es-modal__close,
    .es-progress span {
        transition: none;
    }

    .es-option::before {
        transform: translateX(-100%);
    }

    .es-option.is-picked::before,
    .es-option:hover::before {
        transform: translateX(0);
    }

    @media (hover: hover) {
        .es-option:hover {
            transform: none;
        }
    }

    .es-modal__close:hover {
        transform: none;
    }
}
