/* ==========================================================================
   RoadQuest — School Portal (reference design)
   ========================================================================== */

:root {
    --portal-ink: #1a2e24;
    --portal-ink-soft: #6b7c72;
    --portal-pine: #1b4332;
    --portal-green: #1f6b4a;
    --portal-green-light: #2d8f5f;
    --portal-blue: #2563eb;
    --portal-blue-light: #3b82f6;
    --portal-purple: #7c3aed;
    --portal-purple-light: #9333ea;
    --portal-bg: #f7faf8;
    --portal-card: #ffffff;
    --portal-border: rgba(27, 67, 50, 0.1);
    --portal-radius-lg: 24px;
    --portal-radius-md: 16px;
    --portal-shadow: 0 4px 24px rgba(20, 35, 28, 0.07);
    --portal-shadow-hover: 0 12px 36px rgba(20, 35, 28, 0.12);
    --portal-content-max: 1120px;
}

.auth-shell:has(.auth-panel--portal) {
    display: block;
    min-height: 100dvh;
    padding: 0;
    width: 100%;
    overflow-x: clip;
}

.auth-body:has(.auth-panel--portal) {
    min-height: 100dvh;
    background: var(--portal-bg);
    overflow-x: clip;
}

.auth-panel--portal {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: clamp(1.5rem, 3vw, 2.75rem) clamp(1.25rem, 4vw, 2.5rem);
    background: var(--portal-bg);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: clip;
    overflow-y: visible;
    isolation: isolate;
}

.auth-panel--portal > :not(.portal-decor) {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: var(--portal-content-max);
    margin-left: auto;
    margin-right: auto;
}

/* -- background decor ---------------------------------------------------- */

.portal-decor {
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.portal-decor--blob {
    border-radius: 50%;
    filter: blur(0);
}

.portal-decor--blob-tl {
    top: -120px;
    left: -100px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(200, 230, 210, 0.55) 0%, rgba(200, 230, 210, 0) 70%);
}

.portal-decor--blob-br {
    bottom: -80px;
    right: -60px;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(200, 220, 245, 0.45) 0%, rgba(200, 220, 245, 0) 70%);
}

.portal-decor--plane {
    top: 28px;
    right: clamp(1rem, 5vw, 4rem);
    width: 28px;
    height: 28px;
    opacity: 0.35;
    background:
        linear-gradient(135deg, transparent 40%, #94a89c 40%, #94a89c 55%, transparent 55%),
        linear-gradient(45deg, transparent 45%, #b8c9bf 45%, #b8c9bf 60%, transparent 60%);
    transform: rotate(-15deg);
}

/* -- hero ---------------------------------------------------------------- */

.portal-hero {
    text-align: center;
    margin-bottom: 1.75rem;
}

.portal-hero__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.portal-hero__logo,
.portal-hero__mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.portal-hero__logo {
    object-fit: contain;
}

.portal-hero__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--portal-green-light), var(--portal-green));
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.04em;
    box-shadow: 0 6px 16px rgba(31, 107, 74, 0.22);
}

.portal-hero__app {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-ink-soft);
    letter-spacing: 0.01em;
}

.portal-hero__title {
    margin: 0 0 8px;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--portal-pine);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.15;
}

.portal-hero__subtitle {
    margin: 0;
    font-size: 15px;
    color: var(--portal-ink-soft);
}

.portal-hero__divider {
    display: block;
    width: 48px;
    height: 3px;
    margin: 16px auto 0;
    border-radius: 3px;
    background: var(--portal-green);
}

/* -- feature strip ------------------------------------------------------- */

.portal-features {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 2rem;
    padding: 0;
}

.portal-features__item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--portal-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-md);
    box-shadow: 0 2px 10px rgba(20, 35, 28, 0.04);
}

.portal-features__item div {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    min-width: 0;
}

.portal-features__item strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--portal-ink);
}

.portal-features__item div > span {
    font-size: 11.5px;
    color: var(--portal-ink-soft);
}

.portal-features__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.portal-features__item--green .portal-features__icon  { background: #e8f5ef; color: var(--portal-green); }
.portal-features__item--blue .portal-features__icon   { background: #e8f1ff; color: var(--portal-blue); }
.portal-features__item--purple .portal-features__icon { background: #f3e8ff; color: var(--portal-purple); }
.portal-features__item--amber .portal-features__icon  { background: #fff7ed; color: #d97706; }

/* -- role picker / tabs -------------------------------------------------- */

.role-picker {
    width: 100%;
    max-width: var(--portal-content-max);
    margin-left: auto;
    margin-right: auto;
}

.role-tabs {
    display: none;
}

.role-tabs__btn {
    appearance: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* -- role grid ----------------------------------------------------------- */

.role-grid--portal {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: clamp(1.25rem, 3vw, 2rem);
    align-content: center;
}
.role-grid--portal .role-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1.25rem 1.25rem;
    background: var(--portal-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-lg);
    box-shadow: var(--portal-shadow);
    text-decoration: none;
    color: var(--portal-ink);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.role-grid--portal .role-card:hover,
.role-grid--portal .role-card:focus-visible {
    transform: translateY(-6px);
    box-shadow: var(--portal-shadow-hover);
    outline: none;
}

.role-grid--portal .role-card:focus-visible {
    outline: 2px solid var(--portal-green);
    outline-offset: 3px;
}

.role-grid--portal .role-card__badge {
    position: absolute;
    top: 14px;
    left: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    z-index: 2;
}

.role-grid--portal .role-card--principal .role-card__badge { background: var(--portal-green); }
.role-grid--portal .role-card--teacher .role-card__badge   { background: var(--portal-blue); }
.role-grid--portal .role-card--student .role-card__badge   { background: var(--portal-purple); }

.role-grid--portal .role-card__figure {
    width: 200px;
    height: 200px;
    margin: 0.5rem 0 0.75rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.role-grid--portal .role-card__figure .lottie-wrap {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    border-radius: 0;
    background: transparent;
}

.role-grid--portal .role-card__figure .lottie-player,
.role-grid--portal .role-card__figure dotlottie-player {
    width: 100%;
    height: 100%;
    display: block;
}

.role-grid--portal .role-card__copy {
    width: 100%;
    padding: 0 0.25rem;
}

.role-grid--portal .role-card__copy h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 800;
}

.role-grid--portal .role-card--principal .role-card__copy h2 { color: var(--portal-green); }
.role-grid--portal .role-card--teacher .role-card__copy h2   { color: var(--portal-blue); }
.role-grid--portal .role-card--student .role-card__copy h2   { color: var(--portal-purple); }

.role-grid--portal .role-card__copy > span {
    display: block;
    font-size: 13px;
    color: var(--portal-ink-soft);
    margin-bottom: 1rem;
    line-height: 1.45;
}

.role-grid--portal .role-card__features {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.role-grid--portal .role-card__features li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 4px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--portal-ink-soft);
    line-height: 1.25;
    text-align: center;
}

.role-grid--portal .role-card__features li span {
    font-size: inherit;
    color: inherit;
    line-height: inherit;
}

.role-grid--portal .role-card--principal .role-card__features svg { color: var(--portal-green); }
.role-grid--portal .role-card--teacher .role-card__features svg   { color: var(--portal-blue); }
.role-grid--portal .role-card--student .role-card__features svg   { color: var(--portal-purple); }

.role-grid--portal .role-card__cta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 11px 12px 11px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    position: relative;
    z-index: 2;
}

.role-grid--portal .role-card--principal .role-card__cta {
    background: linear-gradient(135deg, var(--portal-green-light), var(--portal-green));
}

.role-grid--portal .role-card--teacher .role-card__cta {
    background: linear-gradient(135deg, var(--portal-blue-light), var(--portal-blue));
}

.role-grid--portal .role-card--student .role-card__cta {
    background: linear-gradient(135deg, var(--portal-purple-light), var(--portal-purple));
}

.role-grid--portal .role-card__cta-label {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1.2;
}

.role-grid--portal .role-card__cta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    flex-shrink: 0;
}

.role-grid--portal .role-card__dots {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    mask-image: linear-gradient(to top, #000 30%, transparent);
    -webkit-mask-image: linear-gradient(to top, #000 30%, transparent);
}

.role-grid--portal .role-card--principal .role-card__dots {
    background-image: radial-gradient(circle, rgba(31, 107, 74, 0.35) 1.5px, transparent 1.5px);
    background-size: 10px 10px;
}

.role-grid--portal .role-card--teacher .role-card__dots {
    background-image: radial-gradient(circle, rgba(37, 99, 235, 0.3) 1.5px, transparent 1.5px);
    background-size: 10px 10px;
}

.role-grid--portal .role-card--student .role-card__dots {
    background-image: radial-gradient(circle, rgba(124, 58, 237, 0.3) 1.5px, transparent 1.5px);
    background-size: 10px 10px;
}

/* -- trust footer -------------------------------------------------------- */

.portal-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 24px;
    border-radius: 999px;
    background: var(--portal-card);
    border: 1px solid var(--portal-border);
    box-shadow: 0 4px 20px rgba(20, 35, 28, 0.06);
}

.portal-trust__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
}

.portal-trust__icon--shield {
    background: #e8f5ef;
    color: var(--portal-green);
    border-radius: 10px;
}

.portal-trust__icon--school {
    background: transparent;
    color: var(--portal-green);
    width: auto;
    height: auto;
}

.portal-trust__text {
    margin: 0;
    font-size: 13px;
    color: var(--portal-ink-soft);
    text-align: center;
    line-height: 1.5;
}

.portal-trust__text strong {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: var(--portal-ink);
    margin-bottom: 2px;
}

.portal-trust__text > span {
    display: block;
    font-size: 12.5px;
}

/* -- responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
    .auth-panel--portal {
        grid-template-rows: auto auto auto 1fr auto;
        min-height: 100dvh;
        padding: 0.9rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
        padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
    }

    /* Keep the choose-role screen short on phones/tablets */
    .portal-features {
        display: none;
    }

    .portal-hero {
        margin-bottom: 0.85rem;
    }

    .portal-hero__title {
        font-size: clamp(1.35rem, 5.5vw, 1.85rem);
        letter-spacing: 0.05em;
        word-break: break-word;
    }

    .portal-hero__subtitle {
        font-size: 14px;
    }

    .portal-hero__divider {
        margin-top: 12px;
    }

    .role-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        padding: 4px;
        margin: 0 0 0.85rem;
        border-radius: 999px;
        background: #eef4f0;
        border: 1px solid var(--portal-border);
    }

    .role-tabs__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
        min-height: 2.7rem;
        padding: 0.45rem 0.4rem;
        border-radius: 999px;
        color: var(--portal-ink-soft);
        font-size: 0.78rem;
        font-weight: 700;
        line-height: 1.1;
        transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    }

    .role-tabs__btn svg {
        flex-shrink: 0;
        opacity: 0.85;
    }

    .role-tabs__btn.is-active {
        background: #fff;
        color: var(--portal-pine);
        box-shadow: 0 2px 8px rgba(20, 35, 28, 0.08);
    }

    .role-tabs__btn[data-role-tab="principal"].is-active {
        color: var(--portal-green);
    }

    .role-tabs__btn[data-role-tab="teacher"].is-active {
        color: var(--portal-blue);
    }

    .role-tabs__btn[data-role-tab="student"].is-active {
        color: var(--portal-purple);
    }

    .role-tabs__btn:focus-visible {
        outline: 2px solid var(--portal-green);
        outline-offset: 2px;
    }

    .role-grid--portal {
        grid-template-columns: 1fr;
        max-width: 420px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 0.85rem;
        gap: 0;
    }

    .role-grid--portal .role-card:not(.is-active) {
        display: none;
    }

    .role-grid--portal .role-card {
        padding: 1rem 0.95rem 0.95rem;
        border-radius: 18px;
        animation: role-panel-in 0.22s ease;
    }

    .role-grid--portal .role-card:hover,
    .role-grid--portal .role-card:focus-visible {
        transform: none;
    }

    .role-grid--portal .role-card__figure {
        width: min(150px, 40vw);
        height: min(150px, 40vw);
        margin: 0.1rem 0 0.4rem;
    }

    .role-grid--portal .role-card__copy h2 {
        font-size: 1.15rem;
    }

    .role-grid--portal .role-card__copy > span {
        font-size: 12.5px;
        margin-bottom: 0.7rem;
    }

    .role-grid--portal .role-card__features {
        margin-bottom: 0.85rem;
        gap: 4px;
    }

    .role-grid--portal .role-card__features li {
        padding: 6px 2px;
        font-size: 10px;
    }

    .role-grid--portal .role-card__cta {
        min-height: 2.75rem;
        padding: 10px 10px 10px 16px;
        font-size: 13.5px;
    }

    .portal-trust {
        flex-direction: row;
        align-items: center;
        border-radius: 16px;
        padding: 10px 12px;
        gap: 10px;
        width: 100%;
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
    }

    .portal-trust__icon--school {
        display: none;
    }

    .portal-trust__text {
        font-size: 12px;
        text-align: left;
    }

    .portal-trust__text strong {
        font-size: 13px;
    }

    .portal-decor--plane,
    .portal-decor--blob-tl,
    .portal-decor--blob-br {
        display: none;
    }
}

@media (max-width: 640px) {
    .auth-panel--portal {
        padding-top: 0.75rem;
    }

    .portal-hero__brand {
        gap: 4px;
        margin-bottom: 8px;
    }

    .portal-hero__logo,
    .portal-hero__mark {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .portal-hero {
        margin-bottom: 0.7rem;
    }

    .role-tabs__btn span {
        font-size: 0.74rem;
    }

    .role-grid--portal .role-card__figure {
        width: min(132px, 38vw);
        height: min(132px, 38vw);
    }

    .role-grid--portal .role-card__features li span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 400px) {
    .role-tabs__btn {
        flex-direction: column;
        gap: 0.2rem;
        min-height: 3rem;
        font-size: 0.68rem;
        padding: 0.35rem 0.2rem;
    }

    .role-tabs__btn span {
        font-size: 0.68rem;
    }

    .role-grid--portal .role-card__features {
        display: none;
    }
}

@keyframes role-panel-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -- Android APK download ------------------------------------------------ */

.auth-panel--portal .auth-apk {
    display: grid;
    gap: .7rem;
    width: min(100%, 420px);
    margin: 0 auto 1.1rem;
    padding: .95rem 1rem;
    text-align: left;
    border-radius: 18px;
    border: 1.5px solid rgba(31, 107, 74, 0.14);
    background:
        radial-gradient(ellipse 70% 80% at 0% 0%, rgba(47, 191, 113, 0.12), transparent 55%),
        linear-gradient(180deg, #ffffff 0%, #f4faf7 100%);
    box-shadow: 0 8px 20px rgba(20, 35, 28, 0.06);
}

.auth-panel--portal .auth-apk__icon {
    display: none;
}

.auth-panel--portal .auth-apk__copy {
    min-width: 0;
    display: grid;
    gap: .2rem;
}

.auth-panel--portal .auth-apk__title {
    color: #1b4332;
    font-size: .95rem;
    font-weight: 900;
    line-height: 1.25;
}

.auth-panel--portal .auth-apk__text {
    margin: 0;
    color: #6b7c72;
    font-size: .82rem;
    font-weight: 650;
    line-height: 1.4;
}

.auth-panel--portal .auth-apk__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 2.65rem;
    padding: .55rem 1rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #2d8f5f, #1f6b4a);
    color: #fff;
    font-size: .88rem;
    font-weight: 850;
    text-decoration: none;
    box-shadow: 0 4px 0 #14532d;
    transition: transform .12s ease, filter .12s ease;
}

.auth-panel--portal .auth-apk__btn:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.auth-panel--portal .auth-apk__btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #14532d;
}

@media (min-width: 480px) {
    .auth-panel--portal .auth-apk--portal {
        grid-template-columns: auto 1fr auto;
        align-items: center;
        column-gap: .85rem;
    }

    .auth-panel--portal .auth-apk--portal .auth-apk__icon {
        display: grid;
        place-items: center;
        width: 2.55rem;
        height: 2.55rem;
        border-radius: 14px;
        background: linear-gradient(180deg, #49d98a, #2fbf71);
        color: #fff;
        box-shadow: 0 4px 0 #1f9a58;
    }

    .auth-panel--portal .auth-apk--portal .auth-apk__btn {
        width: fit-content;
        white-space: nowrap;
    }
}

@media (max-width: 479px) {
    .auth-panel--portal .auth-apk__btn {
        width: 100%;
    }
}

/* -- reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .role-grid--portal .role-card {
        transition: none;
        animation: none;
    }

    .role-grid--portal .role-card:hover {
        transform: none;
    }

    .auth-panel--portal .auth-apk__btn {
        transition: none;
    }

    .auth-panel--portal .auth-apk__btn:hover,
    .auth-panel--portal .auth-apk__btn:active {
        transform: none;
    }
}
