/*
 * Sign-in, sign-up and student entry pages (guest layout), in the Lembar Guru look:
 * the form is an answer sheet on a desk. Loaded after app.css; everything is
 * scoped to body.auth so the teacher/student app keeps its own styles.
 */
@font-face {
    font-family: "Jakarta";
    src: url("../fonts/jakarta-var.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Pen";
    src: url("../fonts/kalam-700.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

body.auth {
    --paper: #ffffff;
    --desk: #f1f4f7;
    --graphite: #23252b;
    --graphite-2: #585e6b;
    --rule: #e3e7ec;
    --field: #cdd3dc;
    --pen: #d42a3c;
    --ljk: #f2a9b3;
    --marker: #ffe14a;
    --ok: #12805a;
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    font-family: "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--graphite);
    background: var(--desk);
    -webkit-font-smoothing: antialiased;
}

body.auth :focus-visible { outline: 3px solid var(--graphite); outline-offset: 2px; box-shadow: 0 0 0 6px var(--marker); }

/* ── Page & sheet ────────────────────────────────────── */
body.auth .login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem 1rem;
    background: var(--desk);
}

.auth-logo { color: var(--graphite); display: inline-flex; }
.auth-logo svg { height: 34px; width: auto; display: block; }

body.auth .login-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--paper);
    border: 1px solid #ecd0d4;
    border-radius: 8px;
    padding: 1.75rem 2.4rem 1.75rem 1.75rem;
    box-shadow: 0 1px 0 #f3e3e5, 0 30px 60px -36px rgba(35, 37, 43, .45), 0 12px 20px -16px rgba(35, 37, 43, .18);
}
/* Timing marks down the right edge, like a scan sheet. */
body.auth .login-card::after {
    content: "";
    position: absolute;
    top: 1.75rem;
    bottom: 1.75rem;
    right: .8rem;
    width: 6px;
    background: repeating-linear-gradient(to bottom, var(--graphite) 0 7px, transparent 7px 26px);
    opacity: .9;
    pointer-events: none;
}

.auth-sheet__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 2px solid var(--ljk); padding-bottom: .55rem; margin-bottom: 1rem; }
.auth-sheet__title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.025em; margin: 0; line-height: 1.1; }
.auth-sheet__date { color: var(--pen); font-size: .78rem; font-weight: 600; text-align: right; }
.auth-sheet__lead { color: var(--graphite-2); font-size: .93rem; line-height: 1.55; margin: 0 0 1.25rem; }

@media (max-width: 479.98px) {
    body.auth .login-page { justify-content: flex-start; padding: 1.25rem .75rem 2rem; gap: 1.1rem; }
    body.auth .login-card { padding: 1.4rem 2rem 1.4rem 1.25rem; }
    body.auth .login-card::after { right: .65rem; width: 5px; }
    .auth-sheet__date { display: none; }
}

/* ── Notes (success / error) ─────────────────────────── */
.auth-note { display: flex; gap: .6rem; align-items: flex-start; border-radius: 8px; padding: .7rem .85rem; font-size: .9rem; line-height: 1.45; margin-bottom: 1.1rem; }
.auth-note i { font-size: 1.1rem; line-height: 1.3; flex: none; }
.auth-note--error { background: #fdedef; color: #8f1525; box-shadow: inset 3px 0 0 var(--pen); }
.auth-note--error i { color: var(--pen); }
.auth-note--info { background: #fffbea; color: #5c4600; box-shadow: inset 3px 0 0 var(--marker, #ffe14a); }
.auth-note--info i { color: #8a5a00; }
.auth-note--ok { background: #e8f5ef; color: #0b5a3f; box-shadow: inset 3px 0 0 var(--ok); }

/* ── Fields ──────────────────────────────────────────── */
.auth-form { display: grid; gap: 1.1rem; }
.auth-field { display: grid; gap: .4rem; }
.auth-field label, .auth-code label { font-weight: 700; font-size: .9rem; }
.auth-field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.auth-field__row a { font-size: .85rem; font-weight: 600; color: var(--graphite-2); text-decoration: underline; text-decoration-color: var(--ljk); text-underline-offset: 3px; }
.auth-field__row a:hover { color: var(--graphite); text-decoration-color: var(--pen); }

.auth-field input, .auth-code input {
    width: 100%;
    min-height: 52px;
    padding: .7rem .9rem;
    font: inherit;
    font-size: 1rem; /* 16px: no zoom on iPhone */
    color: var(--graphite);
    background: #fff;
    border: 1.5px solid var(--field);
    border-radius: 8px;
    transition: border-color .15s, box-shadow .15s;
}
.auth-field input::placeholder, .auth-code input::placeholder { color: #9aa1ad; }
.auth-field input:hover, .auth-code input:hover { border-color: #aab2be; }
.auth-field input:focus, .auth-code input:focus { outline: none; border-color: var(--graphite); box-shadow: 0 0 0 4px rgba(255, 225, 74, .7); }
.auth-field input[aria-invalid="true"], .auth-code input[aria-invalid="true"] { border-color: var(--pen); }

.auth-pass { position: relative; }
.auth-pass input { padding-right: 3.2rem; }
.auth-pass__toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; border-radius: 6px; color: var(--graphite-2); font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center; }
.auth-pass__toggle:hover { color: var(--graphite); background: var(--desk); }

.auth-field__hint { margin: 0; font-size: .82rem; display: flex; gap: .35rem; align-items: center; }
.auth-caps { color: #8a5a00; font-weight: 600; }
.auth-field__hint--error { color: #a3192b; font-weight: 600; margin-top: .45rem; }

/* ── Submit ──────────────────────────────────────────── */
.auth-submit {
    position: relative;
    min-height: 54px;
    margin-top: .25rem;
    border: 2px solid var(--graphite);
    border-radius: 8px;
    background: var(--graphite);
    color: #fff;
    font: inherit;
    font-weight: 800;
    font-size: 1.02rem;
    transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), background-color .15s;
}
.auth-submit:hover { background: #000; transform: translateY(-1px); box-shadow: 0 3px 0 var(--marker); }
.auth-submit:active { transform: translateY(1px); box-shadow: none; }
.auth-submit:disabled { cursor: progress; transform: none; box-shadow: none; }
.auth-submit .spinner-border, .auth-code button .spinner-border { border-color: rgba(255, 255, 255, .35); border-top-color: var(--marker); }
.auth-code button .spinner-border { border-color: rgba(35, 37, 43, .25); border-top-color: var(--graphite); }
body.auth button.is-loading { cursor: progress; }

/* ── Student exam code ───────────────────────────────── */
.auth-divider { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0 1.1rem; color: var(--graphite-2); font-size: .8rem; font-weight: 600; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px dashed var(--ljk); }
.auth-code { display: grid; gap: .45rem; }
.auth-code__row { display: flex; gap: .5rem; }
.auth-code input { flex: 1; min-width: 0; font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.auth-code input::placeholder { font-weight: 600; letter-spacing: .08em; }
.auth-code button { flex: none; min-height: 52px; padding: 0 1rem; border: 2px solid var(--graphite); border-radius: 8px; background: #fff; color: var(--graphite); font: inherit; font-weight: 700; font-size: .93rem; }
.auth-code button:hover { background: var(--graphite); color: #fff; }

/* ── Demo accounts (APP_DEMO only) ───────────────────── */
.auth-demo { border: 2px dashed var(--field); border-radius: 8px; padding: .75rem; margin-bottom: 1.2rem; }
.auth-demo__head { font-weight: 800; font-size: .85rem; margin-bottom: .5rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; }
.auth-demo__head span { font-weight: 500; color: var(--graphite-2); }
.auth-demo__head code { color: var(--graphite); background: var(--marker); padding: 0 .3rem; border-radius: 4px; }
.auth-demo__list { display: flex; flex-wrap: wrap; gap: .4rem; }
.auth-demo__item { flex: 1 1 auto; min-height: 40px; border: 1.5px solid var(--field); border-radius: 6px; background: #fff; font: inherit; font-size: .86rem; font-weight: 700; color: var(--graphite); display: inline-flex; gap: .4rem; align-items: center; justify-content: center; }
.auth-demo__item:hover { border-color: var(--graphite); }
.auth-demo__item.is-active { background: var(--graphite); border-color: var(--graphite); color: #fff; }

/* ── Agreement checkbox (sign-up): a box the teacher ticks in red pen ── */
.auth-agree {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    padding: .85rem .9rem;
    margin-bottom: 1rem;
    border: 1.5px solid var(--field);
    border-radius: 8px;
    background: #fff;
    transition: border-color .15s, background-color .15s;
}
.auth-agree:hover { border-color: #aab2be; }
.auth-agree:has(.auth-agree__box:checked) { border-color: var(--graphite); background: #fbfbfc; }
.auth-agree.is-invalid { border-color: var(--pen); background: #fff7f8; }
.auth-agree__box {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 24px;
    height: 24px;
    margin: 0;
    border: 2px solid var(--graphite);
    border-radius: 5px;
    background: #fff center / 18px 18px no-repeat;
    cursor: pointer;
    transition: transform .15s var(--ease-out);
}
.auth-agree__box:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3.5 10.5l4 4L16.5 4' fill='none' stroke='%23d42a3c' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    animation: auth-tick .25s var(--ease-out);
}
.auth-agree__box:focus-visible { outline: 3px solid var(--graphite); outline-offset: 2px; box-shadow: 0 0 0 6px var(--marker); }
.auth-agree.is-invalid .auth-agree__box { border-color: var(--pen); }
@keyframes auth-tick { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.auth-agree__text { font-size: .9rem; line-height: 1.5; color: var(--graphite-2); cursor: pointer; margin: 0; }
body.auth .auth-agree__text a { color: var(--graphite); font-weight: 700; text-decoration: underline; text-decoration-color: var(--pen); text-decoration-thickness: 2px; text-underline-offset: 3px; }
body.auth .auth-agree__text a:hover { color: var(--pen); }

/* ── Links under the sheet ───────────────────────────── */
.auth-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1.5rem; font-size: .9rem; color: var(--graphite-2); text-align: center; }
.auth-foot a { color: var(--graphite); font-weight: 700; text-decoration: underline; text-decoration-color: var(--pen); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.auth-foot a:hover { color: var(--pen); }

/* ── Other guest pages (register, reset, 2FA, exam entry) adopt the same look ── */
body.auth .login-brand { text-align: left; margin-bottom: 1.25rem; border-bottom: 2px solid var(--ljk); padding-bottom: .75rem; }
body.auth .login-brand h1 { font-weight: 800; letter-spacing: -.02em; }
body.auth .login-brand-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--graphite); color: #fff; font-size: 1.2rem; margin-bottom: .75rem; }
body.auth .login-card .login-logo { margin-bottom: .9rem; }
body.auth .form-label { font-weight: 700; font-size: .9rem; color: var(--graphite); }
body.auth .form-control, body.auth .form-select { min-height: 48px; border: 1.5px solid var(--field); border-radius: 8px; font-size: 1rem; color: var(--graphite); }
body.auth .form-control:focus, body.auth .form-select:focus { border-color: var(--graphite); box-shadow: 0 0 0 4px rgba(255, 225, 74, .7); }
body.auth .form-control.is-invalid { border-color: var(--pen); }
body.auth .input-group-text { border: 1.5px solid var(--field); }
body.auth .btn { border-radius: 8px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
body.auth .btn-primary { background: var(--graphite); border: 2px solid var(--graphite); color: #fff; min-height: 50px; box-shadow: none; }
body.auth .btn-primary:hover, body.auth .btn-primary:focus { background: #000; border-color: #000; color: #fff; }
body.auth .btn-outline-primary { border: 2px solid var(--graphite); color: var(--graphite); min-height: 50px; }
body.auth .btn-outline-primary:hover { background: var(--graphite); color: #fff; }
body.auth .login-card a:not(.btn):not(.auth-logo):not(.login-logo) { color: var(--graphite); font-weight: 600; text-decoration-color: var(--pen); text-underline-offset: 3px; }
body.auth .alert { border: 0; border-radius: 8px; }
body.auth .alert-danger { background: #fdedef; color: #8f1525; box-shadow: inset 3px 0 0 var(--pen); }
body.auth .alert-info, body.auth .alert-secondary, body.auth .alert-warning { background: var(--desk); color: var(--graphite); box-shadow: inset 3px 0 0 var(--graphite); }
body.auth .btn-link { color: var(--graphite-2); text-decoration: underline; text-decoration-color: var(--pen); text-underline-offset: 3px; }
body.auth .btn-link:hover { color: var(--graphite); }
body.auth .form-check-input { width: 1.2em; height: 1.2em; border: 2px solid var(--graphite); border-radius: 4px; }
body.auth .form-check-input:checked { background-color: var(--graphite); border-color: var(--graphite); }
body.auth .form-check-input:focus { border-color: var(--graphite); box-shadow: 0 0 0 4px rgba(255, 225, 74, .7); }
body.auth .form-text { color: var(--graphite-2); }
body.auth .text-primary, body.auth .link-primary { color: var(--graphite) !important; }
body.auth .alert-success { background: #e8f5ef; color: #0b5a3f; box-shadow: inset 3px 0 0 var(--ok); }

/* ── Error pages: the code is "graded" in red pen ── */
.err { padding-top: 2rem; }
.err__mark { position: absolute; top: 1rem; right: 2.2rem; width: 7.5rem; height: 4.6rem; display: flex; align-items: center; justify-content: center; color: var(--pen); transform: rotate(-7deg); }
.err__mark span { font-family: "Pen", cursive; font-size: 2.6rem; line-height: 1; }
.err__mark svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--pen); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 300; animation: err-ring .7s ease-in-out .2s both; }
@keyframes err-ring { from { stroke-dashoffset: 300; } to { stroke-dashoffset: 0; } }
.err__code { color: var(--pen); font-weight: 700; font-size: .8rem; margin: 0 0 .35rem; }
.err__title { max-width: calc(100% - 7.5rem); margin-bottom: .75rem; text-wrap: balance; }
.err__tips { list-style: none; padding: 0; margin: 0 0 1.4rem; display: grid; gap: .55rem; border-top: 2px solid var(--ljk); padding-top: 1rem; }
.err__tips li { position: relative; padding-left: 1.6rem; font-size: .92rem; color: var(--graphite-2); line-height: 1.5; }
.err__tips li::before { content: ""; position: absolute; left: .25rem; top: .3rem; width: .45rem; height: .8rem; border: solid var(--pen); border-width: 0 2.5px 2.5px 0; transform: rotate(40deg); }
.err__actions { display: grid; gap: .6rem; }
@media (max-width: 479.98px) {
    .err__mark { right: 1.6rem; top: .6rem; width: 6rem; height: 3.8rem; }
    .err__mark span { font-size: 2.1rem; }
    .err__title { max-width: calc(100% - 5.5rem); }
}

@media (prefers-reduced-motion: reduce) {
    body.auth *, body.auth *::before { animation: none !important; transition: none !important; }
}
