/* ─────────────────────────────────────────────────────────────────────────────
   THE SIGN-IN PAGE — glass panels over soft turning shapes, on phones and on
   computers. Behaviour (welcome screen, Back, keyboard) is in
   assets/signin-glass.js.

   Chosen by trying samples. A phone must keep three things:
     · username and password on ONE screen;
     · the logo and the name never disappear while typing, they only get smaller;
     · nothing on the page can be selected, only what is typed in a box.
   A computer shows the name and four features on the left and the sign-in card
   on the right.
   The logo's gold glow and particles stay in assets/logo-glow.css.

   Order: both sizes, then phones (up to 820px), then computers.
   ───────────────────────────────────────────────────────────────────────────── */

/* parts that exist only on a phone */
.sp-only, .sp-phone { display: none; }

/* ══════════════════════════════ BOTH SIZES ══════════════════════════════ */
html {
  color-scheme: dark;
  --sp-glass: rgba(255,255,255,.075); --sp-field: rgba(255,255,255,.06); --sp-rim: rgba(255,255,255,.18);
  --sp-line: rgba(255,255,255,.18);   --sp-shine: rgba(255,255,255,.28); --sp-shadow: rgba(0,0,0,.45);
  --sp-name: #fff; --sp-name-shadow: 0 2px 14px rgba(0,0,0,.55);
  --sp-orb2: #7c3aed; --sp-orb3: #0e7490; --sp-on-accent: #fff;
}
html[data-theme="light"] {
  color-scheme: light;
  --sp-glass: rgba(255,255,255,.55); --sp-field: rgba(255,255,255,.72); --sp-rim: rgba(255,255,255,.95);
  --sp-line: rgba(20,30,60,.14);     --sp-shine: #fff; --sp-shadow: rgba(60,40,100,.18);
  --sp-name: #13213f; --sp-name-shadow: 0 1px 12px rgba(255,255,255,.85);
  --sp-orb2: #c4b5fd; --sp-orb3: #8fe3f2;
}
/* the default dark look is gold: white words on gold are hard to read */
html:not([data-theme="light"])[data-accent="blue"] { --sp-on-accent: #241703; }

/* ── the soft shapes behind everything ── */
.sp-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.sp-shape { position: absolute; animation: spTurn 46s linear infinite; }
.sp-shape-a { opacity: .9; }
.sp-shape-b { opacity: .55; animation: spTurn 38s linear infinite reverse; }
.sp-shape-c { opacity: .35; }
.sp-shape-b path { fill: var(--sp-orb3); }
.sp-shape-c path { fill: var(--sp-orb2); }
.sp-g1 { stop-color: var(--accent); }
.sp-g2 { stop-color: var(--sp-orb2); }
@keyframes spTurn { to { transform: rotate(360deg); } }
@keyframes spUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }

.page { position: relative; z-index: 1; }
#appearance-btn { background: var(--sp-glass) !important; border-color: var(--sp-rim) !important;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

/* ── messages and headings ── */
.form-msg { border-radius: 16px; font-size: 12.5px; }
html[data-theme="light"] .form-msg.err { color: #b91c1c; }
html[data-theme="light"] .form-msg.warn { color: #92400e; }
.form-title, .sp-title { font-size: 46px; line-height: 1.04; letter-spacing: -1.8px; font-weight: 800; margin: 0; }
.form-sub, .sp-sub { font-size: 14px; line-height: 1.55; color: var(--text2); margin: 10px 0 0; }
#otp-form .form-title, #register-form .form-title, #forgot-form .form-title { font-size: 30px; letter-spacing: -.9px; }

/* ── boxes ── */
input, select { font-size: 16px; border-radius: 16px; background: var(--sp-field); border: 1px solid var(--sp-line); min-height: 48px; }
input:focus, select:focus { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .22); }
select option { color: var(--text); }
label { font-size: 11px; color: var(--text2); }
#username-hint, #pw-checklist, #username-suggestions .uname-chip { font-size: 11px !important; }

/* sign in and forgot password: the label sits in the box and rises as you type */
#login-form .field, #forgot-form .field { position: relative; margin: 0 0 10px; }
#login-form .field > label, #forgot-form .field > label { position: absolute; z-index: 2; left: 46px; top: 20px; margin: 0;
  font-size: 13.5px; font-weight: 500; text-transform: none; letter-spacing: 0; pointer-events: none; transition: top .18s, font-size .18s; white-space: nowrap; }
#login-form .field > label:first-child + .field-icon input, #forgot-form .field > label + .field-icon input {
  height: 58px; padding: 17px 46px 0 46px; border-radius: 18px; }
#login-form .field:focus-within > label, #login-form .field.sp-up > label,
#forgot-form .field:focus-within > label, #forgot-form .field.sp-up > label { top: 9px; font-size: 10.5px; font-weight: 600; }
#login-form input::placeholder, #forgot-form input::placeholder { color: transparent; }
#login-form input:focus::placeholder, #forgot-form input:focus::placeholder { color: var(--text3); }
#l-password { letter-spacing: 1px; }
#l-username, #f-who { padding-right: 12px !important; }   /* no eye in these: room for the whole hint */
@keyframes spAutofill { from { opacity: 1; } to { opacity: 1; } }
input:-webkit-autofill { animation-name: spAutofill; }

/* line icons in the boxes */
.field-icon .fi-ic.fi-user, .field-icon .fi-ic.fi-lock { font-size: 0; left: 15px; width: 20px; height: 20px; background-color: var(--text2);
  -webkit-mask: var(--sp-ic) center / contain no-repeat; mask: var(--sp-ic) center / contain no-repeat; }
.field-icon:focus-within .fi-ic.fi-user, .field-icon:focus-within .fi-ic.fi-lock { background-color: var(--accent); }
.fi-user { --sp-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7'/%3E%3C/svg%3E"); }
.fi-lock { --sp-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='4.5' y='10.5' width='15' height='10' rx='3'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5'/%3E%3C/svg%3E"); }
#login-form .pw-eye { font-size: 0; right: 7px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
#login-form .pw-eye::after { content: ''; width: 21px; height: 21px; background: var(--text2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Cpath d='M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat; }
#login-form .pw-eye.on::after { background: var(--accent); }
#login-form .field a { display: inline-block; padding: 4px 2px; font-size: 12.5px !important; font-weight: 600; color: var(--text); }
#login-form .field:nth-of-type(2) { margin-bottom: 4px; }

/* ── buttons and links ── */
.btn-submit { height: 52px; border-radius: 18px; font-size: 15px; font-weight: 700; color: var(--sp-on-accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 12px 28px -10px rgba(var(--accent-rgb), .75); }
.btn-submit .spinner { border-color: rgba(127,127,127,.35); border-top-color: var(--sp-on-accent); }
.form-footer { font-size: 12.5px; font-weight: 600; color: var(--text); margin-top: 14px; padding-bottom: 2px; }
.form-footer a { font-weight: 700; }
#change-school a, #change-school-welcome a { font-weight: 600; cursor: pointer; }

/* Google · Facebook · Apple */
.social-divider { margin: 14px 0 12px; font-size: 10px; color: var(--text2); letter-spacing: 1.4px; }
.social-divider::before, .social-divider::after { background: var(--sp-line); }
.social-btn { width: 50px; height: 50px; padding: 0; background: var(--sp-field); border: 1px solid var(--sp-line); color: var(--text); }
.social-btn svg { width: 22px; height: 22px; }
.social-btn:disabled { opacity: .5; cursor: default; }
#google-note { font-size: 11px; color: var(--text2); text-align: center; margin-top: 10px; line-height: 1.55; }

.sp-badge { width: 40px; height: 40px; border-radius: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: var(--sp-on-accent); background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.sp-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ════════════════════════════════ PHONES ════════════════════════════════ */
@media (max-width: 820px) {
  html { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
  input, textarea, #otp-dev-code { -webkit-user-select: text; user-select: text; }
  img { -webkit-user-drag: none; }

  .sp-phone { display: inline; }
  .sp-desk { display: none; }

  .sp-shape-a { width: 340px; height: 340px; right: -190px; top: -140px; }
  .sp-shape-b { width: 300px; height: 300px; left: -150px; bottom: 40px; }
  .sp-shape-c { display: none; }

  /* ── the frame ── */
  .page { height: 100vh; height: 100dvh; }
  .right { background: transparent; border-left: 0; }
  .form-wrap { flex: 1 0 auto; justify-content: flex-start; min-height: 100%; width: 100%; max-width: 480px;
    margin: 0 auto; padding: 0 20px 14px; }

  /* ── logo, name, tagline ── */
  .mobile-brand { display: flex; margin: 56px 0 0; flex-shrink: 0; }   /* the height it was chosen at */
  .mobile-brand img { width: 92px; height: 92px; margin-bottom: 0; transition: width .25s, height .25s; }
  .mobile-brand .mb-name { font-size: 23px; line-height: 1.25; margin-top: 24px; color: var(--sp-name); text-shadow: var(--sp-name-shadow); }
  .mobile-brand .mb-tag { font-size: 10px; letter-spacing: 2.2px; margin-top: 6px; color: var(--sp-name); text-shadow: var(--sp-name-shadow); }

  .form-msg { margin: 14px 0 0; }
  .form-title, .sp-title { margin-top: 26px; }
  #login-form .form-title { font-size: min(46px, 11vw); white-space: nowrap; }
  #change-school { margin-top: 8px !important; }
  .social-divider { margin: 10px 0 9px; }
  .social-btn { width: 46px; height: 46px; }

  /* ── welcome ── */
  #sp-welcome { flex-direction: column; flex: 1 0 auto; }
  html[data-sp="welcome"] #sp-welcome { display: flex; }
  html[data-sp="welcome"] #login-form, html[data-sp="welcome"] #register-form,
  html[data-sp="welcome"] #otp-form, html[data-sp="welcome"] #forgot-form { display: none !important; }
  .sp-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 20px 0 8px; }
  .sp-tile { border-radius: 24px; padding: 15px; animation: spUp .55s cubic-bezier(.22,1.2,.4,1) both; }
  .sp-tile:nth-child(2) { animation-delay: .07s; }
  .sp-tile:nth-child(3) { animation-delay: .14s; }
  .sp-tile.sp-wide { grid-column: 1 / -1; display: flex; gap: 13px; align-items: center; }
  .sp-tile strong { display: block; font-size: 13px; margin-bottom: 3px; }
  .sp-tile span.sp-txt { display: block; font-size: 11px; color: var(--text2); line-height: 1.5; }
  .sp-tile:not(.sp-wide) .sp-badge { margin-bottom: 11px; }
  .sp-actions { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 11px; }
  .sp-ghost { height: 52px; border-radius: 18px; font: 700 14px 'Sora', sans-serif; color: var(--text); cursor: pointer; }
  .sp-actions .btn-submit { margin: 0; }
  #change-school-welcome { text-align: center; font-size: 12px; }
  #change-school-welcome a { color: var(--text); }

  /* ── glass ── */
  .sp-tile, .sp-ghost, #login-form form, #register-form form, #otp-form form, #forgot-form form {
    background: var(--sp-glass); border: 1px solid var(--sp-rim);
    -webkit-backdrop-filter: blur(26px) saturate(165%); backdrop-filter: blur(26px) saturate(165%);
    box-shadow: inset 0 1px 0 var(--sp-shine), 0 18px 50px -12px var(--sp-shadow);
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sp-tile, .sp-ghost, #login-form form, #register-form form, #otp-form form, #forgot-form form { background: var(--bg2); }
  }

  /* ── forms: heading at the top, the panel down where the thumb is ── */
  #login-form, #otp-form, #forgot-form { flex: 1 0 auto; display: flex; flex-direction: column; }
  #login-form form, #otp-form form, #forgot-form form { margin-top: auto; padding: 14px; border-radius: 32px; animation: spUp .45s cubic-bezier(.22,1.2,.4,1); }
  #login-form .form-sub, #otp-form .form-sub, #forgot-form .form-sub { margin-bottom: 14px; }
  #register-form form { margin-top: 16px; padding: 16px; border-radius: 28px; }
  #register-form input, #register-form select { scroll-margin-top: 84px; }

  /* ── creating an account is a long form: the name stays at the top while it scrolls ── */
  html[data-sp="register"] .mobile-brand { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center;
    column-gap: 12px; position: sticky; top: 0; z-index: 5; margin: 0 -20px; padding: 10px 48px 10px 20px; text-align: left;
    background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  html[data-sp="register"] .mobile-brand img { grid-row: 1 / span 2; width: 44px; height: 44px; }
  html[data-sp="register"] .mobile-brand .mb-name { font-size: 16px; margin: 0; align-self: end; }
  html[data-sp="register"] .mobile-brand .mb-tag { font-size: 8px; margin: 2px 0 0; align-self: start; }
  html[data-sp="register"] #register-form .form-title { margin-top: 14px; }

  /* ── keyboard up: logo and name stay, smaller; the big heading and the extra links make room ── */
  html.sp-typing:not([data-sp="register"]) .mobile-brand { margin-top: 12px; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand img { width: 56px; height: 56px; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand .mb-name { font-size: 19px; margin-top: 11px; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand .mb-tag { margin-top: 4px; }
  html.sp-typing #login-form .form-title, html.sp-typing #login-form .form-sub, html.sp-typing #login-form .form-footer,
  html.sp-typing #otp-form .form-title, html.sp-typing #forgot-form .form-title, html.sp-typing #change-school,
  html.sp-typing .social-divider, html.sp-typing .social-row, html.sp-typing #google-note { display: none !important; }
  html.sp-typing #login-form form, html.sp-typing #otp-form form, html.sp-typing #forgot-form form { animation: none; margin-bottom: 0; }
}

/* ── small phones ── */
@media (max-width: 820px) and (max-height: 700px) {
  .mobile-brand { margin-top: 26px; }
  .mobile-brand img { width: 62px; height: 62px; }
  .mobile-brand .mb-name { font-size: 18px; margin-top: 13px; }
  .mobile-brand .mb-tag { margin-top: 3px; }
  .form-title, .sp-title { font-size: 31px; margin-top: 8px; letter-spacing: -1.2px; }
  .form-sub, .sp-sub { font-size: 13px; margin-top: 5px; }
  .sp-tiles { margin-top: 8px; gap: 8px; }
  .sp-tile { padding: 9px 12px; }
  .sp-tile:not(.sp-wide) .sp-badge { width: 30px; height: 30px; margin-bottom: 6px; }
  #login-form .form-title { font-size: 31px; }
  #login-form .form-sub { display: none; }
  #login-form form { padding: 11px; margin-bottom: 0; }
  #change-school { margin-top: 4px !important; }
  .sp-actions { gap: 8px; }
  .social-divider { margin: 7px 0 6px; }
  .social-btn { width: 38px; height: 38px; }
  .social-btn svg { width: 18px; height: 18px; }
  .form-footer { margin-top: 8px; }

  /* typing: the logo goes beside the name */
  html.sp-typing:not([data-sp="register"]) .mobile-brand { display: grid; grid-template-columns: auto auto; justify-content: center;
    align-items: center; column-gap: 12px; margin-top: 0; text-align: left; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand img { grid-row: 1 / span 2; width: 40px; height: 40px; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand .mb-name { font-size: 15px; margin: 0; align-self: end; }
  html.sp-typing:not([data-sp="register"]) .mobile-brand .mb-tag { font-size: 8px; margin: 2px 0 0; align-self: start; }
  html.sp-typing #login-form form { padding: 10px; margin-top: 8px; }
  html.sp-typing #login-form .field { margin-bottom: 8px; }
  html.sp-typing #login-form .field > label { top: 15px; }
  html.sp-typing #login-form .field > label:first-child + .field-icon input { height: 48px; padding-top: 14px; }
  html.sp-typing #login-form .field:focus-within > label, html.sp-typing #login-form .field.sp-up > label { top: 5px; }
  html.sp-typing #login-form .field:nth-of-type(2) { margin-bottom: 2px; }
  html.sp-typing #login-form .btn-submit { height: 42px; margin-top: 4px; }
}

/* ═══════════════════════════════ COMPUTERS ══════════════════════════════ */
@media (min-width: 821px) {
  .sp-shape-a { width: 620px; height: 620px; right: -230px; top: -270px; }
  .sp-shape-b { width: 520px; height: 520px; left: -250px; bottom: -200px; }
  .sp-shape-c { width: 260px; height: 260px; left: 52%; bottom: -140px; }

  .body { justify-content: center; gap: 48px; padding: 0 max(24px, 5vw); }
  input, select { font-size: 15px; }

  /* ── left: logo, name, four features ── */
  .left { background: transparent; overflow: visible; padding: 20px 0; max-width: 760px; min-width: 0; }
  .left::before, .left::after { display: none; }
  .brand { margin-bottom: 38px; }
  .brand-icon { width: 96px; height: 96px; margin: 0 auto; }
  .brand-name { font-size: 30px; line-height: 1.2; margin: 22px 0 0; color: var(--sp-name); text-shadow: var(--sp-name-shadow); }
  .brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; margin-top: 7px; color: var(--sp-name); }
  .features { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 640px; }
  .feat { display: block; border-radius: 26px; padding: 18px; }
  .feat .sp-badge { margin-bottom: 13px; }
  .feat-txt { font-size: 11.5px; line-height: 1.55; }
  .feat-txt strong { font-size: 13.5px; margin-bottom: 4px; }

  /* ── right: the sign-in card ── */
  .right { width: 460px; flex-shrink: 0; align-self: center; max-height: calc(100% - 40px); border-radius: 36px;
    animation: spUp .45s cubic-bezier(.22,1.2,.4,1); }
  .form-wrap { flex: 0 0 auto; min-height: 0; justify-content: flex-start; padding: 34px 32px 26px; }
  #login-form form, #forgot-form form, #otp-form form { margin-top: 22px; }
  #register-form form { margin-top: 14px; }
  #register-form input, #register-form select { min-height: 42px; height: 42px; border-radius: 13px; }
  #register-form form .field, #register-form form .field-grid { margin-top: 10px !important; }
  #register-form form .field-grid > .field { margin-top: 0 !important; }
  #register-form .btn-submit { margin-top: 12px !important; }

  /* ── glass ── */
  .right, .feat {
    background: var(--sp-glass); border: 1px solid var(--sp-rim);
    -webkit-backdrop-filter: blur(26px) saturate(165%); backdrop-filter: blur(26px) saturate(165%);
    box-shadow: inset 0 1px 0 var(--sp-shine), 0 28px 70px -18px var(--sp-shadow);
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .right, .feat { background: var(--bg2); }
  }
}

/* ── a narrow window: the features become a short list ── */
@media (min-width: 821px) and (max-width: 1080px) {
  .body { gap: 20px; padding: 0 20px; }
  .right { width: 400px; }
  .form-wrap { padding: 28px 24px 22px; }
  .form-title { font-size: 38px; }
  .features { grid-template-columns: 1fr; gap: 9px; max-width: 360px; }
  .feat { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 18px; }
  .feat .sp-badge { width: 34px; height: 34px; border-radius: 11px; margin: 0; }
}

/* ── a short window (most school laptops, once the browser's own bars are there) ── */
@media (min-width: 821px) and (max-height: 720px) {
  .brand { margin-bottom: 22px; }
  .brand-icon { width: 76px; height: 76px; }
  .brand-name { font-size: 25px; margin-top: 16px; }
  .feat { padding: 12px 14px; border-radius: 20px; }
  .feat .sp-badge { width: 32px; height: 32px; border-radius: 11px; margin-bottom: 8px; }
  .right { max-height: calc(100% - 20px); }
  .form-wrap { padding: 22px 28px 16px; }
  .form-title { font-size: 34px; }
  .form-sub { margin-top: 5px; }
  #login-form form { margin-top: 14px; }
  .btn-submit { height: 46px; }
  .social-divider { margin: 9px 0 8px; }
  .social-btn { width: 42px; height: 42px; }
  .form-footer { margin-top: 9px; }
}
@media (min-width: 821px) and (max-height: 540px) {
  .features { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-shape, .sp-tile, .right, #login-form form, #otp-form form, #forgot-form form { animation: none !important; }
  .mobile-brand img { transition: none; }
}
