/* ==========================================================================
   App — auth shell ("اللوحة")
   The floating split card shared by every page under /auth: a tinted showcase
   panel beside a plain form panel, both inside one card on a soft wash.
   In RTL the showcase takes the leading side, so the form lands where the eye
   finishes rather than where it starts.

   Loaded from _BlankLayout's "pagecss" section, i.e. AFTER app-rtl.css and
   app-identity.css, so single-class selectors here beat the theme without
   needing !important.
   ========================================================================== */

.auth-split {
  /* Every value is an identity token: the shell is the school's teal wash and
     teal-leaning ink, not a palette of its own. */
  --auth-wash: var(--app-teal-50);
  /* --app-canvas is gray-50 on light and slate-950 on dark, so the panel needs
     no dark restatement. */
  --auth-panel: var(--app-canvas);
  --auth-card: var(--app-surface);
  --auth-ink: var(--app-ink);
  --auth-muted: var(--app-ink-muted);
  --auth-line: var(--app-line);
  --auth-dark: var(--app-gray-900);
  /* Not part of the palette: a metric, declared here so the card and the switcher
     bar above it share one edge at both breakpoints instead of repeating a literal
     that only one of them would get updated. */
  --auth-card-max: 60rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  /* A flat wash, not the radial gradient it used to be: no gradients
     (docs/design-system.md §7), and a flat ground gives the footer text on it
     one contrast ratio. */
  background-color: var(--auth-wash);
  font-family: var(--app-font-body);
  color: var(--auth-ink);
}

.auth-split__card {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: var(--auth-card-max);
  /* Absorbs the free space above the footer, keeping the card centred. */
  margin-block: auto;
  border-radius: clamp(1rem, 3vw, 1.75rem);
  overflow: hidden;
  background: var(--auth-card);
  box-shadow:
    0 1px 2px rgba(var(--app-gray-900-rgb), 0.06),
    0 30px 70px -30px rgba(var(--app-gray-900-rgb), 0.45);
}

/* --- showcase panel ------------------------------------------------------ */
.auth-split__show {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: clamp(2rem, 5vw, 3.25rem) clamp(1.5rem, 4vw, 3rem);
  background: var(--auth-panel);
  text-align: center;
}

/* The scene: the mark in a soft disc, ringed by what the panel manages */
.auth-split__scene {
  position: relative;
  width: min(20rem, 78vw);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-split__disc {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: var(--app-surface);
  box-shadow: 0 20px 45px -28px rgba(var(--app-gray-900-rgb), 0.55);
}

.auth-split__mark {
  position: relative;
  width: 42%;
  height: auto;
}

.auth-split__orbit {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--app-surface);
  color: var(--app-brand);
  font-size: 1.25rem;
  box-shadow: 0 8px 20px -10px rgba(var(--app-gray-900-rgb), 0.5);
  animation: auth-float 5.5s ease-in-out infinite;
}

.auth-split__orbit--1 {
  top: 2%;
  inset-inline-start: 26%;
  animation-delay: 0s;
}

.auth-split__orbit--2 {
  top: 20%;
  inset-inline-end: 1%;
  animation-delay: 0.7s;
}

.auth-split__orbit--3 {
  bottom: 21%;
  inset-inline-end: 0;
  animation-delay: 1.4s;
  color: var(--app-accent-hover);
}

.auth-split__orbit--4 {
  bottom: 2%;
  inset-inline-start: 30%;
  animation-delay: 2.1s;
}

.auth-split__orbit--5 {
  bottom: 20%;
  inset-inline-start: 0;
  animation-delay: 2.8s;
  color: var(--app-accent-hover);
}

.auth-split__orbit--6 {
  top: 19%;
  inset-inline-start: 1%;
  animation-delay: 3.5s;
}

/* Paused from the showcase's own toggle (auth-showcase.js). The float is
   infinite, so WCAG 2.2.2 needs a way to stop it; freezing it in place rather
   than snapping to rest keeps the scene from jumping. */
.auth-split__show--paused .auth-split__orbit {
  animation-play-state: paused;
}

@keyframes auth-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.auth-split__slides {
  position: relative;
  width: 100%;
  max-width: 24rem;
  min-height: 8.5rem;
}

/* One caption needs no reserved height — that space is only there to stop the
   rotating copy from resizing the panel between slides. */
.auth-split__slides--single {
  min-height: 0;
}

.auth-split__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease;
}

.auth-split__slide--on {
  position: relative;
  opacity: 1;
  visibility: visible;
}

.auth-split__slidetitle {
  color: var(--auth-ink);
  font-family: var(--app-font-display);
  font-size: clamp(1.25rem, 3vw, 1.625rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
}

.auth-split__slidebody {
  color: var(--auth-muted);
  font-size: 0.9375rem;
  line-height: 1.9;
  margin: 0;
}

.auth-split__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
}

/* The button is the 24px hit target (WCAG 2.5.8); the pill it shows is drawn
   by ::before inside it. Inactive pills are ink-faint (3:1 on the panel in
   both themes — the old teal-200 was 1.6:1), the current one brand ink. */
.auth-split__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 0.25rem;
  border: 0;
  border-radius: var(--app-radius-full);
  background: transparent;
  cursor: pointer;
}

.auth-split__dot::before {
  content: "";
  display: block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--app-radius-full);
  background: var(--app-ink-faint);
  transition:
    width 0.25s ease,
    background-color 0.25s ease;
}

.auth-split__dot[aria-current="true"]::before {
  width: 1.5rem;
  background: var(--app-brand-ink);
}

.auth-split__dot:focus-visible,
.auth-split__pause:focus-visible {
  outline: 2px solid var(--app-brand-ink);
  outline-offset: 1px;
}

/* Pause / play for the showcase's motion — injected by auth-showcase.js,
   which also owns its aria-pressed state. */
.auth-split__pause {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-inline-start: 0.5rem;
  padding: 0;
  border: 1px solid var(--auth-line);
  border-radius: var(--app-radius-full);
  background: var(--auth-card);
  color: var(--auth-muted);
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.auth-split__pause:hover {
  color: var(--auth-ink);
  border-color: var(--app-brand-ink);
}

/* --- form panel ---------------------------------------------------------- */
.auth-split__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 5vw, 3.25rem) clamp(1.5rem, 4vw, 3rem);
}

.auth-split__brand {
  text-align: center;
  margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}

.auth-split__centerlogo {
  max-height: 4rem;
  max-width: min(9rem, 55vw);
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.auth-split__centername {
  color: var(--auth-ink);
  font-family: var(--app-font-display);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}

/* Platform lockup under a centre's own branding. Modifications.css paints this
   white for the old dark wallpaper, so it has to be re-bound for the white panel. */
.auth-split .auth-poweredby {
  color: var(--auth-muted) !important;
  font-size: 0.75rem;
}

.auth-split .auth-poweredby:hover {
  color: var(--auth-ink) !important;
}

/* Page heading — the one line that says which auth step this is */
.auth-split__head {
  text-align: center;
  margin-bottom: clamp(1.5rem, 4vw, 2rem);
}

.auth-split__title {
  color: var(--auth-ink);
  font-family: var(--app-font-display);
  font-size: 1.375rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
}

.auth-split__subtitle {
  color: var(--auth-muted);
  font-size: 0.875rem;
  line-height: 1.8;
  margin: 0;
}

.auth-split .form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--auth-muted);
  margin-bottom: 0.4rem;
}

.auth-split .form-control {
  border: 1px solid var(--auth-line);
  border-radius: 0.5rem;
  background: var(--app-surface);
  padding: 0.75rem 0.9rem;
  font-size: 0.9375rem;
  color: var(--auth-ink);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.auth-split .form-control::placeholder {
  color: var(--app-ink-faint);
}

.auth-split .form-control:focus {
  border-color: var(--app-brand);
  box-shadow: 0 0 0 3px rgba(var(--app-brand-rgb), 0.14);
}

/* Rejected field. Bootstrap already styles .form-control.is-invalid, but at the
   same specificity as the rule above and from a stylesheet that loads earlier —
   so restating the border here is what re-declaring `border` at (0,2,0) costs.
   Without it the only sign of a wrong password was the message underneath, and
   the field the message was about looked untouched. */
.auth-split .form-control.is-invalid {
  border-color: var(--app-danger);
}

.auth-split .form-control.is-invalid:focus {
  border-color: var(--app-danger);
  box-shadow: 0 0 0 3px rgba(var(--app-danger-rgb), 0.16);
}

.auth-split .password-addon {
  inset-inline-end: 0.25rem;
  color: var(--auth-muted) !important;
}

/* One-time code: wide-tracked digits, read left-to-right even in RTL */
.auth-split .form-control.auth-split__otp {
  direction: ltr;
  text-align: center;
  font-family: var(--app-font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5rem;
  text-indent: 0.5rem;
  padding: 0.65rem 0.9rem;
}

.auth-split__forgot {
  display: block;
  text-align: end;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--auth-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-split__forgot:hover {
  color: var(--app-brand);
}

/* Also worn by an <a>: the pages under /Errors navigate rather than post, and
   their primary action is a link. display/text-align/text-decoration are the
   three defaults a <button> gets for free and an anchor does not — they change
   nothing for the buttons that already carry this class. */
.auth-split__submit {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  text-align: center;
  font-weight: 600;
  /* Bootstrap's own white token: the identity has no "ink on a brand fill"
     token, and --app-surface turns dark with the theme while this fill does not. */
  color: var(--tb-white);
  text-decoration: none;
  background: var(--auth-dark);
  transition:
    background-color 0.15s ease,
    transform 0.12s ease;
}

.auth-split__submit:hover:not(:disabled) {
  background: var(--app-brand);
  color: var(--tb-white);
}

/* Busy state set by auth.js while a plain POST is in flight */
.auth-split__submit:disabled {
  cursor: progress;
  opacity: 0.85;
}

.auth-split__submit:active:not(:disabled) {
  transform: translateY(1px);
}

/* Secondary action — same shape, no fill */
.auth-split__ghost {
  display: block;
  width: 100%;
  border: 1px solid var(--auth-line);
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--auth-ink);
  background: var(--app-surface);
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.auth-split__ghost:hover {
  border-color: var(--app-brand);
  color: var(--app-brand);
}

/* Divider slot: carries a real hint, never filler */
.auth-split__sep {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.5rem 0 1rem;
  /* Muted, not faint: «أو» is read, and faint ink is under 4.5:1 at 12px. */
  color: var(--auth-muted);
  font-size: 0.75rem;
}

.auth-split__sep::before,
.auth-split__sep::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--auth-line);
}

.auth-split__hint {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--auth-muted);
  margin: 0;
}

.auth-split__hint a {
  color: var(--app-brand);
  font-weight: 600;
  text-decoration: none;
}

.auth-split__hint a:hover {
  text-decoration: underline;
}

/* Status pages (the views under /Errors) — a single mark instead of a form */
.auth-split__status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: var(--auth-panel);
  color: var(--app-brand);
  font-size: 2.25rem;
}

/* Tone variants, for the pages under /Errors. The base medallion is the brand,
   which is right for a page that is merely a stop — logged out, offline, a link
   that moved. The two below are docs/design-system.md §1's feedback colours,
   each as INK on a wash of itself rather than white on a solid fill: at 5rem
   across, a filled red disc shouts a good deal louder than "we logged it and
   we are on it" needs to. Both read through --app-*-ink, which section 7 of
   app-identity.css already re-points for dark, so neither needs a dark rule. */
.auth-split__status--warning {
  background: rgba(var(--app-warning-rgb), 0.14);
  color: var(--app-warning-ink);
}

.auth-split__status--danger {
  background: rgba(var(--app-danger-rgb), 0.12);
  color: var(--app-danger-ink);
}

/* Vertical action stack. The error pages used to lay their buttons out in a
   wrapping centred row, which inside a 28rem panel wrapped anyway — but with a
   ragged gutter and a different rhythm from every form in this shell. The forms
   stack submit over ghost; these now do the same. */
.auth-split__actions {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* The HTTP status code, demoted. It used to be the hero: two 7rem gradient
   digits with the icon wedged between them, spending the top third of the page
   on the one thing on it the reader cannot act on — and spending it on a
   gradient, which docs/design-system.md §7 retires. It stays on the page
   because it is what support asks for over the phone, so it goes to the bottom,
   quiet, with the digits forced LTR so the RTL context cannot reorder them. */
.auth-split__code {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--auth-muted);
}

.auth-split__code span {
  font-weight: 700;
  color: var(--auth-ink);
}

/* Password rules panel on the reset-password step */
.auth-split__rules {
  padding: 0.9rem 1rem;
  border: 1px solid var(--auth-line);
  border-radius: 0.5rem;
  background: var(--app-gray-50);
}

.auth-split__rules-title {
  color: var(--auth-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
}

.auth-split__rules p {
  font-size: 0.8125rem;
  color: var(--auth-muted);
  margin: 0 0 0.4rem;
}

.auth-split__rules p:last-child {
  margin-bottom: 0;
}

.auth-split__rule-dot {
  font-size: 0.5rem;
}

/* The vendor theme hides #password-contain until the field has focus and
   paints its states in literal greens and reds (app-rtl.css, (1,1,1)). The
   rules stay visible here — the reader needs them before typing, not only
   while the caret is in the box — and the states read through the feedback
   INK tokens, which clear AA on the panel and re-point for dark. */
.auth-split #password-contain {
  display: block;
}

.auth-split #password-contain p.valid {
  color: var(--app-success-ink);
}

.auth-split #password-contain p.invalid {
  color: var(--app-danger-ink);
}

.auth-split .alert {
  border-radius: 0.5rem;
  font-size: 0.8125rem;
}

/* --- theme switcher ------------------------------------------------------
   Sits above the card, on the wash rather than on a surface, so it reads as a
   setting for the page rather than as one of the form's own controls. The bar
   carries the card's own width and pushes the pill to its inline-end — the left
   corner under RTL — so the control lands on the card's leading edge instead of
   out at the rim of a 1920px viewport with nothing around it.

   In flow rather than absolutely positioned: the card centres itself with
   margin-block:auto, so a control in the flow just narrows the space it centres
   in, whereas an absolute one would sit on top of the card on a short viewport.
   -------------------------------------------------------------------------- */
.auth-split__themebar {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: var(--auth-card-max);
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.auth-split__theme {
  display: flex;
  gap: 0.125rem;
  padding: 0.25rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--app-radius-full);
  background: var(--auth-card);
  box-shadow: 0 1px 2px rgba(var(--app-gray-900-rgb), 0.06);
}

.auth-split__themebtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--app-radius-full);
  background: transparent;
  color: var(--auth-muted);
  font-size: 0.9375rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.auth-split__themebtn:hover {
  background: var(--auth-panel);
  color: var(--auth-ink);
}

.auth-split__themebtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--app-brand-rgb), 0.25);
}

/* The chosen one gets the Surface Tint the spec assigns to a selected item, the
   same as the ticked row in the topbar menu and the active sidebar link. A flat
   fill, so the glyph on it has one contrast ratio. .active is written by
   assets/js/layout.js, not by the server. */
.auth-split__themebtn.active {
  background: var(--app-brand-soft);
  color: var(--app-brand-ink);
}

.auth-split__foot {
  margin: clamp(1.5rem, 4vw, 2rem) 0 0;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--auth-muted);
}

.auth-split__foot a {
  color: var(--auth-muted);
  font-weight: 600;
  text-decoration: none;
}

@media (min-width: 992px) {
  .auth-split__card {
    grid-template-columns: 1fr 1fr;
    min-height: 40rem;
  }
}

/* Below the split there is no side for the showcase to sit on, and stacking it
   puts a screen of marketing above the form. The card becomes the form alone. */
@media (max-width: 991.98px) {
  .auth-split__show {
    display: none;
  }

  .auth-split {
    --auth-card-max: 28rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-split__orbit {
    animation: none;
  }

  .auth-split__slide {
    transition: none;
  }
}

/* ==========================================================================
   Dark theme — docs/design-system.md §6.

   The shell's palette is the custom properties declared on .auth-split, and
   most of them read semantic identity tokens (--app-surface, --app-ink,
   --app-line, --app-canvas) that app-identity.css §7 already re-points for
   dark — so only the wash and the submit fill are restated here. What follows
   afterwards are the rules that step a surface differently on dark, plus the
   places the brand appears as ink rather than as a fill. No literal colour:
   every value is an identity token.

   The preference is read from localStorage by assets/js/layout.js, which runs
   in <head> on every page including this one, so a signed-out user meets the
   theme they left in rather than a white flash at the door.
   ========================================================================== */

[data-bs-theme="dark"] .auth-split {
  --auth-wash: var(--app-canvas);
  /* The submit button is near-black on the light shell — invisible on this
     one — so the brand fill takes its place and the hover goes a step deeper
     rather than a step brighter. */
  --auth-dark: var(--app-brand);
}

/* The card floats on a near-black wash, so the shadow has to be near-opaque
   to register at all — the identity's dark elevation tokens are. */
[data-bs-theme="dark"] .auth-split__card {
  box-shadow: var(--app-shadow-sm), var(--app-shadow-lg);
}

/* The showcase disc and its orbiting chips are raised above the panel, so on
   dark they go lighter than it rather than white. */
[data-bs-theme="dark"] .auth-split__disc,
[data-bs-theme="dark"] .auth-split__orbit {
  background: var(--app-surface-sunken);
  box-shadow: var(--app-shadow-lg);
}

[data-bs-theme="dark"] .auth-split__orbit {
  color: var(--app-teal-300);
}

/* Fields recess below the card here too, exactly as they do inside the app */
[data-bs-theme="dark"] .auth-split .form-control,
[data-bs-theme="dark"] .auth-split__ghost,
[data-bs-theme="dark"] .auth-split__rules {
  background: var(--app-canvas);
}

/* The brand as ink: the teal fill (#1A7C8C) is 3.6:1 on this card, under AA */
[data-bs-theme="dark"] .auth-split__forgot:hover,
[data-bs-theme="dark"] .auth-split__hint a,
[data-bs-theme="dark"] .auth-split__status {
  color: var(--app-teal-300);
}

[data-bs-theme="dark"] .auth-split .form-control:focus {
  border-color: var(--app-teal-300);
  box-shadow: 0 0 0 3px rgba(var(--app-brand-ink-rgb), 0.22);
}

[data-bs-theme="dark"] .auth-split__ghost:hover {
  border-color: var(--app-teal-300);
  color: var(--app-teal-300);
}

/* The submit already fills with the brand, so its hover deepens instead */
[data-bs-theme="dark"] .auth-split__submit:hover:not(:disabled) {
  background: var(--app-teal-600);
}

/* Same tone lift the sidebar and topbar lockups take on a dark surface */
[data-bs-theme="dark"] .auth-split__mark,
[data-bs-theme="dark"] .auth-split__centerlogo {
  filter: brightness(1.25);
}

/* The switcher floats on the wash, so on dark it steps LIGHTER than the wash the
   way the card does, rather than keeping a white pill. --auth-card and
   --auth-line are already re-pointed above; only the selected fill has to be
   restated, because the teal fill as ink is 3.6:1 on this surface. */
[data-bs-theme="dark"] .auth-split__theme {
  box-shadow: var(--app-shadow-sm);
}

[data-bs-theme="dark"] .auth-split__themebtn.active {
  background: var(--app-teal-tint-dark);
  color: var(--app-teal-300);
}

/* The hover fill and the selected fill must not converge: --auth-panel on dark
   is the canvas, close enough to the tint above that a hovered button and the
   chosen one would look alike. */
[data-bs-theme="dark"] .auth-split__themebtn:hover {
  background: var(--app-surface-sunken);
}
