/* ================================================================
   STUDENT EXPERIENCE — class-link join, PDF download sheet, welcome
   (js/tools/StudentExperience.js)
   ================================================================ */

/* ---------- join panel ---------- */
.student-entry-overlay .student-panel-content {
    max-height: calc(var(--app-vh, 100vh) - 32px);
    overflow-y: auto;
}

.student-entry-overlay .sx-code-input {
    text-transform: uppercase;
    letter-spacing: 0.35em;
    font-weight: 800;
    text-align: center;
    font-size: 1.25rem !important;
    font-variant-numeric: tabular-nums;
}
.student-entry-overlay .sx-code-input::placeholder {
    letter-spacing: normal;
    font-weight: 500;
    font-size: 1rem;
}

.sx-code-status {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: -6px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.35;
    font-family: inherit;
}
.sx-code-status.is-checking,
.sx-code-status.is-ok,
.sx-code-status.is-bad { display: flex; }
.sx-code-status.is-checking { background: #f4f2ec; color: #5d6378; }
.sx-code-status.is-ok { background: #ecfdf5; color: #047857; }
.sx-code-status.is-ok b { color: #065f46; }
.sx-code-status.is-bad { background: #fef2f2; color: #b91c1c; }

.student-entry-overlay .auth-input.sx-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12) !important;
    animation: sx-shake 0.38s ease;
}
@keyframes sx-shake {
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

#btn-student-join-direct.is-busy { opacity: 0.8; cursor: progress; transform: none; }

@media (max-width: 520px) {
    .student-entry-overlay { align-items: flex-end; }
    .student-entry-overlay .student-panel-content {
        width: 100%;
        max-width: none;
        border-radius: 26px 26px 0 0;
        padding: 36px 22px calc(26px + env(safe-area-inset-bottom));
    }
    .student-entry-overlay .student-panel-content h3 { font-size: 1.45rem; padding-inline-end: 44px; }
    .student-entry-overlay .auth-input { font-size: 16px; } /* stop iOS zoom-on-focus */
}

/* ---------- download confirmation sheet ---------- */
.sx-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    transition: background 0.2s, backdrop-filter 0.2s;
    font-family: 'Outfit', 'Inter', 'Cairo', sans-serif;
}
.sx-sheet-overlay.show {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.sx-sheet {
    width: 100%;
    max-width: 400px;
    background: #fff;
    color: #1d2235;
    border-radius: 24px;
    padding: 28px 24px 22px;
    text-align: center;
    box-shadow: 0 30px 70px rgba(15, 20, 40, 0.35);
    transform: translateY(18px) scale(0.96);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.2s;
}
.sx-sheet-overlay.show .sx-sheet { transform: none; opacity: 1; }
.sx-sheet-grip { display: none; }
.sx-sheet-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    color: #ef4444;
    background: linear-gradient(135deg, #fee2e2, #fff1f2);
}
.sx-sheet .sx-sheet-title {
    margin: 0 0 14px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #1d2235 !important;
    -webkit-text-fill-color: #1d2235 !important;
    background: none !important;
}
.sx-file {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-bottom: 12px;
}
.sx-file-name { font-weight: 700; word-break: break-word; color: #0f172a; }
.sx-file-meta { font-size: 0.82rem; color: #64748b; font-weight: 600; letter-spacing: 0.02em; }
.sx-sheet-msg { margin: 0 0 20px; color: #5d6378; font-size: 0.92rem; line-height: 1.5; }
.sx-sheet-actions { display: flex; gap: 10px; }
.sx-sheet-actions .sx-btn { flex: 1; }

.sx-btn {
    border: none;
    border-radius: 14px;
    padding: 13px 18px;
    font: inherit;
    font-weight: 700;
    font-size: 0.98rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
    min-height: 46px;
}
.sx-btn:active { transform: scale(0.97); }
.sx-btn--primary { background: #4f46e5; color: #fff; box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.6); }
.sx-btn--primary:hover { background: #4338ca; }
.sx-btn--ghost { background: #f1f5f9; color: #334155; }
.sx-btn--ghost:hover { background: #e2e8f0; }
.sx-btn:focus-visible { outline: 3px solid rgba(79, 70, 229, 0.45); outline-offset: 2px; }

@media (max-width: 520px) {
    .sx-sheet-overlay { align-items: flex-end; padding: 0; }
    .sx-sheet {
        max-width: none;
        border-radius: 24px 24px 0 0;
        padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
        transform: translateY(100%);
    }
    .sx-sheet-grip { display: block; width: 42px; height: 5px; border-radius: 3px; background: #cbd5e1; margin: 0 auto 16px; }
}

/* ---------- "PDF" buttons on cards ---------- */
/* library-drawer.css resets every drawer button, so match its specificity */
html body #onenote-nav.lib-drawer .sx-dl-btn,
.sx-dl-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.09);
    color: #dc2626;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.15s, color 0.15s;
}
html body #onenote-nav.lib-drawer .sx-dl-btn:hover,
.sx-dl-btn:hover { background: #ef4444; color: #fff; }
html body #onenote-nav.lib-drawer .sx-dl-btn:active { transform: scale(0.94); }
.sx-dl-btn:focus-visible { outline: 2px solid #ef4444; outline-offset: 2px; }
.sx-dl-btn i { font-size: 0.85rem; }

/* small phones: keep both buttons, the download one shrinks to its icon */
@media (max-width: 520px) {
    html body #onenote-nav.lib-drawer .lf-item .sx-dl-btn { width: 36px; height: 30px; padding: 0; }
    html body #onenote-nav.lib-drawer .lf-item .sx-dl-btn span { display: none; }
}

/* ---------- welcome card ---------- */
.sx-welcome {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 2147483500;
    width: min(460px, calc(100% - 32px));
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 14px;
    align-items: center;
    padding: 16px;
    border-radius: 20px;
    background: #fff;
    color: #1d2235;
    box-shadow: 0 24px 60px rgba(15, 20, 40, 0.28);
    border: 1px solid #e7e3d8;
    font-family: 'Outfit', 'Inter', 'Cairo', sans-serif;
    transform: translate(-50%, 140%);
    transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.sx-welcome.show { transform: translate(-50%, 0); }
.sx-welcome-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.sx-welcome-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sx-welcome-text b { font-size: 1.05rem; color: #1d2235; }
.sx-welcome-text span { font-size: 0.92rem; color: #334155; }
.sx-welcome-text small { font-size: 0.8rem; color: #64748b; line-height: 1.4; margin-top: 2px; }
.sx-welcome-go { grid-column: 1 / -1; width: 100%; }

/* ---------- library tip ---------- */
.sx-lib-tip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: inherit;
    font-size: 0.85rem;
    line-height: 1.4;
}
.sx-lib-tip > i { color: #f59e0b; }
.sx-lib-tip span { flex: 1; }
.sx-lib-tip b { color: #dc2626; white-space: nowrap; }
.sx-lib-tip button {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
}
.sx-lib-tip button:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }

/* ---------- student toolbar download ---------- */
#btn-student-download-pdf i { color: #ef4444; }

@media (prefers-reduced-motion: reduce) {
    .sx-sheet, .sx-welcome, .sx-sheet-overlay { transition: none; }
    .student-entry-overlay .auth-input.sx-invalid { animation: none; }
}

/* ── Student join panel: "Continue with Google" + the signed-in account's class-code step ── */
.student-entry-overlay .sx-google-row .auth-divider { margin: 16px 0 10px; }
.student-entry-overlay.sx-account .close-panel,
.student-entry-overlay.sx-account .student-remember-me,
.student-entry-overlay.sx-account .sx-google-row { display: none !important; }
.student-entry-overlay .sx-signout {
    display: block;
    margin: 14px auto 0;
    background: none;
    border: 0;
    color: #6b7187;
    font: inherit;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}
.student-entry-overlay .sx-signout:hover { color: #1d2235; }

/* One-time "Teacher or Student?" question for an account that signed in without a role */
.acct-role-ask { z-index: 2147483000; }
.acct-role-ask .auth-modal { max-width: 440px; }
.acct-role-ask .role-card { cursor: pointer; }
