/* Orbium login & sign-up — "WeStud" style: grey stage with reacting
   white form card on the left, characters on the right (swapped 2026-11-02).
   Styling only: every ID and JS hook the auth scripts use is unchanged. */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --stage: #FAF7F2;
  --card: #FFFFFF;
  --ink: #1E1E22;
  --muted: #6F6F76;
  --faint: #A3A3AA;
  --line: #CFCFD4;
  --pill: #F1F1F2;
  --red: #E5484D;
  --green: #1E8A4C;
  --purple: #6C2BF5;
  --black: #1E1E22;
  --orange: #F0833A;
  --yellow: #E4D00A;
  --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
  background: var(--stage);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Two-panel frame ---------- */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr);
  width: min(100%, 1600px);
  height: 100vh;
  margin: 0 auto;
}

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card {
  position: relative;
  margin: 14px 14px 14px 0;
  background: var(--card);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Only the form area scrolls, and only if the window is too short. */
.card-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  padding: 34px clamp(28px, 6vw, 96px) 26px;
}

.card-body {
  width: min(100%, 360px);
  margin: auto;
}

/* ---------- Brand mark ---------- */

.brand-logo {
  width: 34px;
  height: 34px;
  margin: 0 auto 26px;
}
.brand-logo svg, .brand-logo img { display: block; width: 34px; height: 34px; }

h1 {
  font-weight: 700;
  font-size: clamp(26px, 2.4vw, 34px);
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: 6px;
}

.lead {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  margin-bottom: 26px;
}

/* ---------- Role / use toggle (pill segmented control) ---------- */

#useSelectorWrap,
#roleSelectorWrap { margin-bottom: 18px; }

#useSelector,
#roleSelector {
  display: flex;
  background: var(--pill);
  border-radius: 999px;
  padding: 4px;
}

#useSelector button,
#roleSelector button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}

#useSelector .active-role,
#roleSelector .active-role {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

/* ---------- Underlined fields ---------- */

.field {
  position: relative;
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
}

#useSelectorWrap > label,
#roleSelectorWrap > label { margin-bottom: 8px; }

input[type='text'],
input[type='email'],
input[type='password'],
#schoolBoard {
  width: 100%;
  padding: 7px 0 9px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

input::placeholder { color: var(--faint); }
input:focus { border-bottom-color: var(--ink); }

/* Wrong password: red label + underline, as in the design */
.has-error .field-pwd label { color: var(--red); }
.has-error .field-pwd input { border-bottom-color: var(--red); }

.row { display: flex; gap: 18px; }
.name-row .field { flex: 1; min-width: 0; }

.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 34px; }

.pwd-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.pwd-toggle svg { width: 18px; height: 18px; }
.pwd-toggle .eye-closed { display: none; }
.pwd-toggle.is-shown .eye-open { display: none; }
.pwd-toggle.is-shown .eye-closed { display: block; }

/* ---------- Remember / forgot ---------- */

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: -6px 0 22px;
}

.actions label.small {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

input[type='checkbox'] {
  accent-color: var(--ink);
  width: 14px;
  height: 14px;
}

.forgot {
  font-size: 11.5px;
  color: var(--faint);
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.forgot:hover { color: var(--ink); }

/* ---------- Buttons ---------- */

button { font-family: inherit; cursor: pointer; }

.btn-primary,
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 46px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn-primary {
  border: none;
  color: #fff;
  background: var(--ink);
  margin-bottom: 14px;
}
.btn-primary:hover { filter: brightness(1.25); }
.btn-primary:active { transform: scale(0.99); }

.btn-google {
  border: none;
  background: var(--pill);
  color: var(--ink);
}
.btn-google:hover { background: #E8E8EA; }
.btn-google svg { width: 18px; height: 18px; }

/* ---------- Footer link ---------- */

.link-line {
  margin-top: 28px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

.link-line a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
}
.link-line a:hover { text-decoration: underline; }

/* ---------- Messages ---------- */

.error {
  color: var(--red);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
}
.error:not(:empty) { margin: -8px 0 14px; }

/* ---------- Misc / states ---------- */

:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }

button[disabled],
input[disabled] { opacity: 0.6; cursor: not-allowed; }

input:-webkit-autofill {
  box-shadow: 0 0 0 1000px var(--card) inset;
  -webkit-text-fill-color: var(--ink);
}

.hidden { display: none !important; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ======================================================================
   Characters on the stage — Orbium's own cast:
   a tall indigo "fin", a charcoal scholar in a mortarboard, a coral
   ringed planet and a sunflower bean, plus a twinkling spark.
   ====================================================================== */

.crew {
  position: relative;
  width: min(80%, 520px);
  aspect-ratio: 470 / 400;
}

/* Soft ground shadow under the group */
.crew::after {
  content: '';
  position: absolute;
  left: -2%;
  right: 4%;
  bottom: -14px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 30, 34, 0.16), rgba(30, 30, 34, 0));
  z-index: 0;
}

.ch {
  position: absolute;
  bottom: 0;
  transform-origin: 50% 100%;
  transition: transform 0.55s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.ch-fin {
  left: 16%; width: 29%; height: 80%; z-index: 1;
  border-radius: 100% 12% 0 0 / 34% 4% 0 0;
  background: linear-gradient(160deg, #6A4DFF 0%, #4B2EE6 100%);
}
.ch-cap {
  left: 41%; width: 23%; height: 52%; z-index: 2;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(160deg, #34343C 0%, #1C1C21 100%);
}
.ch-planet {
  left: 1%; width: 41%; height: 48.2%; z-index: 4;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #FF9C66 0%, #F2703A 62%, #E35F2B 100%);
}
.ch-bean {
  left: 57%; width: 36%; height: 21%; z-index: 3;
  border-radius: 999px;
  background: linear-gradient(170deg, #FADB55 0%, #EDC21F 100%);
}

/* Mortarboard on the scholar, with an orange tassel */
.cap-hat {
  position: absolute;
  left: 50%;
  top: -26px;
  width: 130%;
  height: 38px;
  transform: translateX(-50%);
  z-index: 2;
}
.cap-hat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #121216;
  clip-path: polygon(50% 0, 100% 42%, 50% 84%, 0 42%);
}
.cap-hat::after {
  content: '';
  position: absolute;
  right: 12%;
  top: 40%;
  width: 3px;
  height: 30px;
  background: #F2703A;
  border-radius: 2px;
  box-shadow: 0 30px 0 2px #F2703A;
  transform-origin: top center;
  animation: tassel 3.2s ease-in-out infinite;
}

/* Saturn-style ring around the planet */
.ring {
  position: absolute;
  left: -16%;
  top: 56%;
  width: 132%;
  height: 22%;
  border: 4px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  transform: rotate(-12deg);
  pointer-events: none;
}

/* A small four-point spark that twinkles above the group */
.spark {
  position: absolute;
  right: 4%;
  top: 4%;
  width: 30px;
  height: 30px;
  background: #1E1E22;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: twinkle 2.8s ease-in-out infinite;
}
.spark.sm { right: 18%; top: 16%; width: 14px; height: 14px; background: #6A4DFF; animation-delay: 1.2s; }

/* Faces sit near the top of each body; the whole face slides to "look". */
.face {
  position: absolute;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.35s ease;
  z-index: 3;
}
.ch-fin    .face { top: 13%; width: 40px; margin-left: -12px; }
.ch-cap    .face { top: 20%; width: 40px; margin-left: -20px; }
.ch-planet .face { top: 24%; width: 60px; margin-left: -30px; }
.ch-bean   .face { top: 24%; width: 56px; margin-left: -28px; }

.brows { display: flex; gap: 10px; height: 6px; margin-bottom: 3px; transition: transform 0.3s ease; }
.brows b {
  display: block;
  width: 10px;
  height: 2.5px;
  border-radius: 2px;
  background: #fff;
  transition: transform 0.3s ease;
}
.ch-cap .brows b { width: 11px; }

.eyes { display: flex; gap: 8px; align-items: center; }
.ch-planet .eyes { gap: 20px; }
.ch-bean   .eyes { gap: 16px; }

.eye {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  transition: transform 0.12s ease;
}
.ch-cap .eye { width: 14px; height: 14px; }

/* Planet and bean have plain dark dot eyes */
.ch-planet .eye,
.ch-bean .eye { background: transparent; overflow: visible; }

.pupil {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #16161A;
  transition: transform 0.12s linear;
}
.ch-cap .pupil { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; }
.ch-planet .pupil,
.ch-bean .pupil { width: 8px; height: 8px; margin: -4px 0 0 -4px; }

/* Blink: eyes squash for a moment */
.crew.blink .eye { transform: scaleY(0.12); }

/* Rosy cheeks on the planet */
.cheeks { display: flex; gap: 30px; margin-top: -2px; }
.cheeks i { width: 9px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }

/* Mouths */
.mouth {
  margin-top: 5px;
  width: 12px;
  height: 6px;
  border: 2.5px solid #16161A;
  border-top: none;
  border-radius: 0 0 12px 12px;
  transition: all 0.3s ease;
}
.ch-fin .mouth    { border-color: #fff; width: 10px; height: 5px; }
.ch-cap .mouth    { width: 12px; height: 0; border: none; border-top: 2.5px solid #fff; border-radius: 2px; margin-top: 8px; }
.ch-planet .mouth { width: 16px; height: 8px; margin-top: 2px; }
.ch-bean .mouth   { width: 22px; height: 9px; }

/* --- State: leaning toward the form while typing --- */
.crew.lean .ch-fin    { transform: skewX(-10deg); }
.crew.lean .ch-cap    { transform: rotate(6deg); }
.crew.lean .ch-planet { transform: translateX(5%) rotate(10deg); }
.crew.lean .ch-bean   { transform: skewX(-14deg); }
.crew.lean .brows     { transform: translateY(-2px); }
.crew.lean .ch-planet .mouth { width: 8px; height: 8px; border: 2.5px solid #16161A; border-radius: 50%; }

/* --- State: password visible — everyone straightens up and looks away --- */
.crew.peek .ch { transform: none; }
.crew.peek .brows b:first-child { transform: translateY(-2px) rotate(-12deg); }
.crew.peek .brows b:last-child  { transform: translateY(-2px) rotate(12deg); }
.crew.peek .ch-bean .mouth { width: 14px; height: 0; border: none; border-top: 2.5px solid #16161A; border-radius: 2px; margin-top: 8px; }

/* --- State: wrong password / error — sad, slumped --- */
.crew.sad .ch-fin    { transform: rotate(-6deg) scaleY(0.95); }
.crew.sad .ch-cap    { transform: scaleY(0.86); }
.crew.sad .ch-planet { transform: translateY(4%) scale(0.97); }
.crew.sad .ch-bean   { transform: scaleY(0.82); }
.crew.sad .brows b:first-child { transform: rotate(-16deg); }
.crew.sad .brows b:last-child  { transform: rotate(16deg); }
.crew.sad .mouth { border: 2.5px solid #16161A !important; border-bottom: none !important;
                   border-radius: 12px 12px 0 0 !important; height: 6px !important; width: 12px !important;
                   background: none !important; margin-top: 7px !important; }
.crew.sad .ch-fin .mouth,
.crew.sad .ch-cap .mouth { border-color: #fff !important; }
.crew.shake { animation: shake 0.45s ease; }

/* --- State: success — happy bounce --- */
.crew.happy .ch { animation: hop 0.6s ease 2; }
.crew.happy .ch-cap    { animation-delay: 0.08s; }
.crew.happy .ch-bean   { animation-delay: 0.16s; }
.crew.happy .ch-planet { animation-delay: 0.24s; }
.crew.happy .brows { transform: translateY(-3px); }
.crew.happy .mouth { width: 16px !important; height: 8px !important; background: none !important;
                     border: 2.5px solid #16161A !important; border-top: none !important;
                     border-radius: 0 0 16px 16px !important; margin-top: 5px !important; }
.crew.happy .ch-fin .mouth,
.crew.happy .ch-cap .mouth { border-color: #fff !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-14px); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(0.6) rotate(45deg); opacity: 0.55; }
}

@keyframes tassel {
  0%, 100% { transform: rotate(4deg); }
  50% { transform: rotate(-6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ch, .face, .pupil { transition: none; }
  .crew.shake, .crew.happy .ch, .card, .spark, .cap-hat::after { animation: none; }
}

/* ======================================================================
   Fit to the screen: spacing shrinks with the window height, so neither
   page scrolls on a normal laptop. Only the card scrolls, as a last resort.
   ====================================================================== */

body, .auth-shell { height: 100vh; height: 100dvh; }

.card-scroll { padding: clamp(14px, 4vh, 34px) clamp(28px, 6vw, 96px) clamp(12px, 3vh, 26px); }
.brand-logo { margin-bottom: clamp(8px, 3vh, 26px); }
h1 { font-size: clamp(22px, min(2.4vw, 4.4vh), 34px); }
.lead { margin-bottom: clamp(10px, 3vh, 26px); }
.field { margin-bottom: clamp(8px, 2.4vh, 20px); }
#useSelectorWrap,
#roleSelectorWrap { margin-bottom: clamp(8px, 2vh, 18px); }
#useSelector button,
#roleSelector button { padding: clamp(5px, 1vh, 8px) 0; }
input[type='text'],
input[type='email'],
input[type='password'] { padding: clamp(3px, 0.9vh, 7px) 0 clamp(5px, 1.1vh, 9px); font-size: clamp(13.5px, 1.9vh, 15px); }
.actions { margin: clamp(-6px, -0.6vh, -2px) 0 clamp(10px, 2.6vh, 22px); }
.btn-primary,
.btn-google { height: clamp(36px, 5.6vh, 46px); }
.btn-primary { margin-bottom: clamp(8px, 1.7vh, 14px); }
.link-line { margin-top: clamp(10px, 3.4vh, 28px); }

/* Sign-up has more fields: tighter rhythm so it fits without scrolling */
#signupForm .field { margin-bottom: clamp(6px, 1.7vh, 14px); }
#signupForm #useSelectorWrap,
#signupForm #roleSelectorWrap { margin-bottom: clamp(6px, 1.5vh, 12px); }
#signupForm #useSelectorWrap > label,
#signupForm #roleSelectorWrap > label { margin-bottom: clamp(3px, 0.8vh, 8px); }
#signupForm .actions { margin: 0 0 clamp(8px, 2vh, 16px); }
#signupForm .link-line { margin-top: clamp(8px, 2vh, 18px); }
.card-body:has(#signupForm) .brand-logo { margin-bottom: clamp(6px, 2vh, 16px); }
.card-body:has(#signupForm) .lead { margin-bottom: clamp(8px, 2.2vh, 18px); }

/* Very short windows: drop the logo rather than scroll */
@media (max-height: 600px) {
  .brand-logo { display: none; }
}

/* ---------- Small screens: form only ---------- */

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .stage { display: none; }
  .card { margin: 0; border-radius: 0; }
  .card-scroll { padding: 28px 22px; }
}

/* Sign-up: password and confirm side by side to save height */
.pwd-row .field { flex: 1; min-width: 0; }

/* Full Orbium logo (icon + name) on login/signup, 2026-11-01 */
.brand-logo:has(img.brand-lockup) { width: auto; display: flex; justify-content: center; }
.brand-logo img.brand-lockup { width: auto; height: 34px; }

/* ======================================================================
   2026-11-02: sides swapped. Form card on the LEFT, characters on the
   RIGHT, and the whole cast mirrored left-to-right (so they still face
   and lean toward the form). Layout only: colours and features unchanged.
   ====================================================================== */

.auth-shell { grid-template-columns: minmax(380px, 1fr) minmax(0, 1.25fr); }
.card  { grid-column: 1; grid-row: 1; margin: 14px 0 14px 14px; }
.stage { grid-column: 2; grid-row: 1; }

/* Mirrored positions (new left = 100% - old left - width) */
.ch-fin    { left: 55%; border-radius: 12% 100% 0 0 / 4% 34% 0 0;
             background: linear-gradient(200deg, #6A4DFF 0%, #4B2EE6 100%); }
.ch-cap    { left: 36%; background: linear-gradient(200deg, #34343C 0%, #1C1C21 100%); }
.ch-planet { left: 58%; background: radial-gradient(circle at 68% 28%, #FF9C66 0%, #F2703A 62%, #E35F2B 100%); }
.ch-bean   { left: 7%;  background: linear-gradient(190deg, #FADB55 0%, #EDC21F 100%); }
html[data-theme="dark"] body .ch-cap { background: linear-gradient(200deg, #4C4C57 0%, #2E2E36 100%); }

.ch-fin .face { margin-left: -28px; }
.ring { transform: rotate(12deg); }
.cap-hat::after { right: auto; left: 12%; animation-name: tassel-mirror; }
.spark    { right: auto; left: 4%; }
.spark.sm { right: auto; left: 18%; }
.crew::after { left: 4%; right: -2%; }

/* Leaning toward the form, which is now on the left */
.crew.lean .ch-fin    { transform: skewX(10deg); }
.crew.lean .ch-cap    { transform: rotate(-6deg); }
.crew.lean .ch-planet { transform: translateX(-5%) rotate(-10deg); }
.crew.lean .ch-bean   { transform: skewX(14deg); }
.crew.sad  .ch-fin    { transform: rotate(6deg) scaleY(0.95); }

@keyframes tassel-mirror {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(6deg); }
}

/* Phones and small tablets: form only, edge to edge (unchanged) */
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .card { margin: 0; }
}

/* ======================================================================
   2026-11-02 (b): no inner scrolling, and a balanced box.
   - The form card and the stage split the screen 50 / 50.
   - The card is sized to its content (not stretched top to bottom) and
     centred, with the form filling a steady share of the card's width.
   - The form never scrolls inside the card; spacing shrinks with the
     window height instead (see "Fit to the screen" above).
   ====================================================================== */

.auth-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card {
  align-self: center;
  justify-self: center;
  width: calc(100% - 28px);
  max-width: 600px;
  max-height: calc(100dvh - 28px);
  margin: 14px;
}
.card-scroll { overflow: hidden; padding-left: 12%; padding-right: 12%; }
.card-body { width: 100%; max-width: 420px; }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .card { width: 100%; max-width: none; max-height: none; height: 100dvh; margin: 0; border-radius: 0; }
  .card-scroll { padding: 28px 22px; }
}

/* Very short windows: sign-up tightens further so nothing is cut off */
@media (max-height: 600px) {
  .card-scroll { padding-top: 12px; padding-bottom: 10px; }
  #signupForm .field { margin-bottom: 4px; }
  #signupForm .link-line { margin-top: 6px; }
  .card-body:has(#signupForm) .lead { margin-bottom: 6px; }
  .card-body:has(#signupForm) h1 { margin-bottom: 2px; }
}

/* Three roles (teacher, student, school head) share the pill: keep each label on one line. */
#roleSelector button { white-space: nowrap; padding-left: 6px; padding-right: 6px; }
@media (max-width: 380px) { #roleSelector button { font-size: 11.5px; } }

/* School head's Board choice: looks like the other fields */
#schoolBoard { cursor: pointer; }
#schoolBoard:focus { border-bottom-color: var(--ink); }

/* Full screen on iPhone home-screen app (2026-11-16): the page now runs
   under the clock and battery (status bar), so keep the logo below it. */
@media (max-width: 860px) {
  .card-scroll { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
}
