/* GCSE revision guide pop-up. Scoped to #tsl-gpop so Bootstrap 4, global.css and gcse-style.css can't reach it. */

#tsl-gpop[hidden] { display: none !important; }

#tsl-gpop {
    position: fixed;
    inset: 0;
    z-index: 100002; /* above WP admin bar (99999) and cookie bar */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(27, 27, 31, 0.5);
    font-family: Nunito, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1B1B1F;
    letter-spacing: normal;
    text-align: left;
    opacity: 0;
    transition: opacity 200ms ease;
    -webkit-tap-highlight-color: transparent;
}
#tsl-gpop.is-open { opacity: 1; }

#tsl-gpop *,
#tsl-gpop *::before,
#tsl-gpop *::after { box-sizing: border-box; }

#tsl-gpop :where(p, h2, a, img, button) { margin: 0; }

/* Dialog */
#tsl-gpop .tsl-gpop__dialog {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 32px;
    align-items: center;
    padding: 66px 32px 32px;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    outline: none;
    transform: translateY(12px) scale(0.98);
    transition: transform 200ms ease;
}
#tsl-gpop.is-open .tsl-gpop__dialog { transform: none; }
#tsl-gpop.tsl-gpop--no-cover .tsl-gpop__dialog { grid-template-columns: 1fr; max-width: 560px; }

/* Yellow "Free resource" tab, flush with the dialog's top-left corner */
#tsl-gpop .tsl-gpop__tab {
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px 20px;
    border-radius: 16px 0 16px 0;
    background: #F9DD4A;
    color: #1B1B1F;
    font-size: 20px;
    line-height: 30px;
    font-weight: 700;
}

/* Close */
#tsl-gpop .tsl-gpop__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 20px;
    background: #F9F8F8;
    color: #1B1B1F;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 150ms ease;
}
#tsl-gpop .tsl-gpop__close:hover { background: #EEEEEE; }

/* Cover */
#tsl-gpop .tsl-gpop__cover {
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: #E4F2FF;
}
#tsl-gpop .tsl-gpop__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    border-radius: 0;
    box-shadow: none;
}

/* Text */
#tsl-gpop .tsl-gpop__body { min-width: 0; }

#tsl-gpop .tsl-gpop__pill {
    margin: 0 0 8px;
    color: #002D6E;
    font-size: 12px;
    line-height: 16px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#tsl-gpop .tsl-gpop__title {
    margin: 0 0 12px;
    padding: 0 24px 0 0;
    color: #1B1B1F;
    font-family: inherit;
    font-size: 30px;
    line-height: 36px;
    font-weight: 700;
    text-transform: none;
    border: 0;
}

#tsl-gpop .tsl-gpop__copy {
    margin: 0 0 24px;
    color: #1B1B1F;
    font-size: 20px;
    line-height: 30px;
    font-weight: 400;
}

/* Button */
#tsl-gpop .tsl-gpop__btn {
    display: inline-block;
    padding: 8px 24px;
    border: 0;
    border-radius: 24px;
    background: #F9DD4A;
    color: #1B1B1F;
    font-size: 20px;
    line-height: 28px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
#tsl-gpop .tsl-gpop__btn:hover,
#tsl-gpop .tsl-gpop__btn:focus { background: #FFF1A8; color: #1B1B1F; text-decoration: none; }

/* Keyboard focus */
#tsl-gpop .tsl-gpop__close:focus-visible,
#tsl-gpop .tsl-gpop__btn:focus-visible {
    outline: 3px solid #1970F4;
    outline-offset: 2px;
}

/* Tablet: narrower cover so the text column keeps a usable width */
@media (min-width: 600px) and (max-width: 767px) {
    #tsl-gpop .tsl-gpop__dialog { grid-template-columns: 180px 1fr; gap: 24px; padding: 66px 24px 24px; }
    #tsl-gpop .tsl-gpop__title { font-size: 26px; line-height: 32px; }
    #tsl-gpop .tsl-gpop__copy { font-size: 18px; line-height: 28px; }
}

/* Phone: bottom sheet */
@media (max-width: 599px) {
    #tsl-gpop { align-items: flex-end; padding: 0; }

    #tsl-gpop .tsl-gpop__dialog,
    #tsl-gpop.tsl-gpop--no-cover .tsl-gpop__dialog {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 60px 20px calc(20px + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    #tsl-gpop.is-open .tsl-gpop__dialog { transform: none; }

    #tsl-gpop .tsl-gpop__tab { padding: 10px 16px; font-size: 17px; line-height: 24px; }
    #tsl-gpop .tsl-gpop__cover { aspect-ratio: auto; width: 100%; height: 140px; }
    #tsl-gpop .tsl-gpop__title { padding-right: 0; font-size: 25px; line-height: 32px; }
    #tsl-gpop .tsl-gpop__copy { margin-bottom: 20px; font-size: 18px; line-height: 28px; }
    #tsl-gpop .tsl-gpop__btn { display: block; text-align: center; font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    #tsl-gpop,
    #tsl-gpop .tsl-gpop__dialog { transition: none !important; }
    #tsl-gpop .tsl-gpop__dialog { transform: none !important; }
}
