/*
 * Modals and toasts. Loaded on every toolbox page, because resource cards
 * (and so the Save modal) appear on all of them. The pieces they share with
 * the pages (pill buttons, stars, ribbons, the author line, links) live in
 * components.css, and the --sr-x-* tokens in variables.css.
 *
 * Every rule is scoped to .sr-modal or .sr-toasts and sets what it relies
 * on, so neither the lab theme nor the shop theme's broad button, link and
 * form rules leak in.
 */



.sr-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

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

html.sr-modal-open,
html.sr-modal-open body {
    overflow: hidden;
}

.sr-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.75);
    color: var(--sr-x-body);
    font-family: var(--sr-x-body-font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    animation: sr-fade 150ms ease-out;
}
.sr-modal__panel {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: auto;
    padding: 60px;
    border-radius: 24px;
    background: #fff;
    text-align: left;
    animation: sr-rise 180ms ease-out;
}
.sr-modal__panel--sm {
    max-width: 640px;
}
.sr-modal__body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 32px;
}
.sr-modal__body > form {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.sr-modal:not(#sr-x) .sr-modal__close {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: var(--sr-x-light);
    cursor: pointer;
}
.sr-modal:not(#sr-x) .sr-modal__close:hover {
    background: var(--sr-x-bg-light);
    color: var(--sr-x-body);
}
.sr-modal:not(#sr-x) .sr-modal__close:active {
    background: var(--sr-x-border);
    color: var(--sr-x-body);
}
.sr-modal:not(#sr-x) .sr-modal__close:focus {
    outline: none;
}
.sr-modal:not(#sr-x) .sr-modal__close:focus-visible {
    outline: 3px solid var(--sr-x-focus);
    outline-offset: 0;
}
.sr-modal:not(#sr-x) .sr-modal__title {
    margin: 0;
    padding: 0;
    color: var(--sr-x-heading);
    font-family: var(--sr-x-head-font);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: normal;
    text-align: center;
    text-transform: none;
}
.sr-modal:not(#sr-x) .sr-modal__lede {
    max-width: 520px;
    margin: 0 auto;
    color: rgba(67, 74, 79, 0.75);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}
.sr-modal:not(#sr-x) .sr-modal__error {
    margin: -16px 0 0;
    padding: 12px 16px;
    border-radius: 8px;
    background: #FDEFF1;
    color: var(--sr-x-red);
    font-size: 14px;
    font-weight: 500;
}
.sr-modal:not(#sr-x) .sr-modal__error[hidden] {
    display: none;
}
.sr-modal:not(#sr-x) .sr-modal__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}
.sr-modal:not(#sr-x) .sr-pbtn--modal {
    width: 260px;
}

/* Resource summary in the Save and Saved Notes modals */
.sr-msummary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
    align-items: start;
}
.sr-msummary__thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 320 / 224;
    border-radius: 10px;
    background: var(--sr-x-bg-light);
}
.sr-msummary__thumb > img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}
.sr-msummary__thumb > img.sr-msummary__placeholder {
    object-fit: contain;
    padding: 24px;
}
.sr-msummary__text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding-top: 8px;
}
.sr-msummary__text p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}
.sr-msummary .sr-msummary__title {
    overflow: hidden;
    color: var(--sr-x-body);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sr-msummary__rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.sr-msummary__rating:empty,
.sr-msummary__posted:empty,
.sr-msummary__author:empty {
    display: none;
}
.sr-msummary__score {
    margin-left: 2px;
    color: var(--sr-x-body);
}
.sr-msummary__none {
    margin-left: 4px;
    color: var(--sr-x-light);
}
.sr-msummary__posted {
    color: var(--sr-x-light);
}

/* Notes field */
.sr-mfield {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sr-modal:not(#sr-x) .sr-mfield label,
.sr-modal:not(#sr-x) .sr-mnotes__label {
    margin: 0;
    color: var(--sr-x-body);
    font-family: var(--sr-x-body-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}
.sr-mfield__hint {
    color: var(--sr-x-light);
    font-weight: 400;
}
.sr-modal textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    margin: 0;
    padding: 10px 16px;
    border: 1px solid rgba(85, 86, 102, 0.25);
    border-radius: 8px;
    background: #fff;
    box-shadow: none;
    color: var(--sr-x-body);
    font-family: var(--sr-x-body-font);
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
}
.sr-modal textarea::placeholder {
    color: var(--sr-x-body);
    opacity: 0.5;
}
.sr-modal textarea:focus {
    border-color: var(--sr-x-sky);
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 174, 219, 0.25);
}

/* Saved notes, view and edit */
.sr-mnotes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
    background: var(--sr-x-sky-bg);
}
.sr-mnotes--edit {
    padding: 0;
    background: none;
}
.sr-mnotes__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 24px;
}
.sr-modal:not(#sr-x) .sr-mnotes .sr-mnotes__label {
    color: var(--sr-x-heading);
}
.sr-modal:not(#sr-x) .sr-mnotes__edit,
.sr-modal:not(#sr-x) .sr-mnotes__save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    margin: -4px -6px -4px 0;
    padding: 4px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: var(--sr-x-heading);
    font-family: var(--sr-x-body-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
}
.sr-modal:not(#sr-x) .sr-mnotes__save {
    color: var(--sr-x-blue);
}
.sr-modal:not(#sr-x) .sr-mnotes__edit:hover,
.sr-modal:not(#sr-x) .sr-mnotes__save:hover {
    background: rgba(1, 104, 165, 0.08);
    color: var(--sr-x-blue);
}
.sr-modal:not(#sr-x) .sr-mnotes__edit:active,
.sr-modal:not(#sr-x) .sr-mnotes__save:active {
    background: rgba(1, 104, 165, 0.16);
    color: var(--sr-x-blue-active);
}
.sr-modal:not(#sr-x) .sr-mnotes__save:disabled {
    opacity: 0.6;
    cursor: default;
}
.sr-modal:not(#sr-x) .sr-mnotes__text {
    max-height: 240px;
    margin: 0;
    overflow-y: auto;
    color: var(--sr-x-body);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.sr-modal:not(#sr-x) .sr-mnotes--edit textarea {
    font-size: 14px;
}

/* No notes yet, and the sign-in gate */
.sr-mempty,
.sr-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    text-align: center;
}
.sr-mempty > img,
.sr-gate__logo {
    display: block;
    width: 80px;
    height: auto;
}
.sr-mempty .sr-modal__lede {
    margin-top: -8px;
}
.sr-mempty__actions {
    display: flex;
    gap: 16px;
    width: 100%;
}
.sr-mempty__actions .sr-pbtn {
    flex: 1 1 0;
}
.sr-gate {
    gap: 24px;
}
.sr-gate__actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 364px;
    margin-top: 8px;
}

/* ---------------------------------------------------------------
   Toast
   --------------------------------------------------------------- */

.sr-toasts {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom, 0px));
    z-index: 100001;
    width: max-content;
    max-width: calc(100% - 32px);
    transform: translateX(-50%);
    font-family: var(--sr-x-body-font);
}
.sr-toast {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 8px 10px 20px;
    border-radius: 12px;
    background: var(--sr-x-heading);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
    animation: sr-rise 180ms ease-out;
}
.sr-toast__text {
    min-width: 0;
    overflow-wrap: anywhere;
}
.sr-toasts:not(#sr-x) .sr-toast__action,
.sr-toasts:not(#sr-x) .sr-toast__action:visited {
    flex: none;
    margin: 0;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: #C5E8A1;
    font-family: var(--sr-x-body-font);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.sr-toasts:not(#sr-x) .sr-toast__action:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.sr-toasts:not(#sr-x) .sr-toast__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
}
.sr-toasts:not(#sr-x) .sr-toast__close svg {
    width: 12px;
    height: 12px;
}
.sr-toasts:not(#sr-x) .sr-toast__close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.sr-toasts:not(#sr-x) :is(.sr-toast__action, .sr-toast__close):focus-visible {
    outline: 3px solid #fff;
    outline-offset: 1px;
}

@keyframes sr-fade {
    from { opacity: 0; }
}
@keyframes sr-rise {
    from { opacity: 0; transform: translateY(12px); }
}
.sr-toasts:not(#sr-x) .sr-toast {
    animation-name: sr-fade;
}
@media (prefers-reduced-motion: reduce) {
    .sr-modal,
    .sr-modal__panel,
    .sr-toast {
        animation: none;
    }
}

/* Phones: the modal is a sheet from the bottom of the screen. */
@media (max-width: 599px) {
    .sr-modal {
        align-items: flex-end;
        padding: 0;
    }
    .sr-modal__panel,
    .sr-modal__panel--sm {
        max-width: none;
        max-height: calc(100% - 24px);
        margin: auto 0 0;
        padding: 56px 20px max(24px, env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        border-radius: 24px 24px 0 0;
        overscroll-behavior: contain;
    }
    .sr-modal:not(#sr-x) .sr-modal__close {
        top: 8px;
        right: 8px;
    }
    .sr-modal__body,
    .sr-modal__body > form {
        gap: 24px;
    }
    .sr-modal:not(#sr-x) .sr-modal__title {
        font-size: 24px;
    }
    .sr-msummary {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 16px;
    }
    .sr-msummary__text {
        gap: 6px;
        padding-top: 0;
    }
    .sr-msummary .sr-msummary__title {
        font-size: 16px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .sr-msummary .sr-ribbons--small {
        display: none;
    }
    .sr-msummary__text p {
        font-size: 13px;
    }
    .sr-modal:not(#sr-x) .sr-modal__actions,
    .sr-mempty__actions {
        flex-direction: column;
    }
    .sr-modal:not(#sr-x) .sr-pbtn--modal {
        width: 100%;
    }
    .sr-modal:not(#sr-x) .sr-modal__actions .sr-pbtn {
        width: 100%;
    }
    .sr-gate__actions {
        max-width: none;
    }
    .sr-modal:not(#sr-x) .sr-modal__error {
        margin-top: -8px;
    }
}
