/* Shared public authentication presentation. No framework or remote font dependency. */
:root {
  color-scheme: light;
  --auth-maroon: #800000;
  --auth-maroon-dark: #5b1018;
  --auth-gold: #e7c382;
  --auth-ink: #202839;
  --auth-muted: #647084;
  --auth-border: #d6dce5;
  --auth-surface: #f5f6f8;
  --auth-radius: 12px;
  /* Pointer position for the backdrop highlight; JS updates these, the defaults centre it. */
  --auth-px: 50%;
  --auth-py: 32%;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: #43070d; }
body { margin: 0; min-height: 100vh; min-height: 100svh; min-height: 100dvh; overflow-x: hidden; color: var(--auth-ink); background: #43070d; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: var(--auth-maroon); text-underline-offset: 4px; }
button, a { touch-action: manipulation; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid #af7b28; outline-offset: 4px; }
[hidden] { display: none !important; }
.auth-skip { position: fixed; top: 12px; left: 12px; z-index: 10; padding: 12px 18px; border-radius: 8px; color: var(--auth-maroon); background: white; transform: translateY(-160%); }
.auth-skip:focus { transform: translateY(0); }

/* ---------------------------------------------------------------- backdrop
   Three fixed layers over a maroon base: a faint grid, a slow flowing wave,
   and a highlight that follows the pointer. Only transform and opacity animate. */
.auth-backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(158deg, #6d0d14 0%, #4f0a11 48%, #2f060b 100%); }
.auth-backdrop span { position: absolute; display: block; }
.auth-grid { inset: -10%; background-image: linear-gradient(rgb(255 255 255 / 6%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 6%) 1px, transparent 1px); background-size: 54px 54px; -webkit-mask-image: radial-gradient(120% 90% at var(--auth-px) var(--auth-py), #000 10%, transparent 72%); mask-image: radial-gradient(120% 90% at var(--auth-px) var(--auth-py), #000 10%, transparent 72%); }
.auth-wave { inset: -35% -25%; background: radial-gradient(45% 38% at 22% 28%, rgb(190 60 70 / 42%) 0%, transparent 62%), radial-gradient(42% 44% at 78% 62%, rgb(120 12 22 / 55%) 0%, transparent 66%), radial-gradient(38% 30% at 58% 12%, rgb(231 195 130 / 12%) 0%, transparent 70%); animation: auth-drift 34s ease-in-out infinite alternate; will-change: transform; }
.auth-glow { inset: 0; background: radial-gradient(38% 42% at var(--auth-px) var(--auth-py), rgb(255 226 178 / 16%) 0%, rgb(255 226 178 / 5%) 38%, transparent 72%); transition: background 420ms ease-out; }
@keyframes auth-drift {
  from { transform: translate3d(-2.5%, -1.5%, 0) scale(1.04); }
  to { transform: translate3d(2.5%, 2%, 0) scale(1.1); }
}

/* ---------------------------------------------------------------- layout */
.auth-shell { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(14px, 2.6dvh, 26px); min-height: 100vh; min-height: 100svh; min-height: 100dvh; padding: clamp(18px, 4dvh, 44px) max(24px, env(safe-area-inset-right)) clamp(16px, 3dvh, 32px) max(24px, env(safe-area-inset-left)); }
.auth-identity { display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.5dvh, 14px); text-align: center; }
.auth-logo { position: relative; display: block; width: clamp(64px, 9dvh, 88px); height: clamp(64px, 9dvh, 88px); border: 0; background: none; padding: 0; filter: drop-shadow(0 8px 20px rgb(0 0 0 / 45%)); transition: transform 420ms cubic-bezier(.22, .8, .3, 1), filter 420ms ease; }
.auth-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-logo::after { content: ""; position: absolute; inset: 0; opacity: 0; background: linear-gradient(112deg, transparent 38%, rgb(255 255 255 / 78%) 50%, transparent 62%) 130% 0 / 260% 100% no-repeat; -webkit-mask: var(--auth-logo) center / contain no-repeat; mask: var(--auth-logo) center / contain no-repeat; pointer-events: none; }
.auth-logo:hover, .auth-logo:focus-within { transform: translateY(-2px) scale(1.035); filter: drop-shadow(0 10px 26px rgb(0 0 0 / 50%)) drop-shadow(0 0 18px rgb(255 214 160 / 45%)); }
.auth-logo:hover::after, .auth-logo:focus-within::after { opacity: 1; animation: auth-shine 1150ms cubic-bezier(.3, .7, .3, 1); }
@keyframes auth-shine { from { background-position: 130% 0; } to { background-position: -30% 0; } }
.auth-crest-fallback { display: grid; place-items: center; width: 100%; height: 100%; color: white; font-weight: 800; font-size: 22px; letter-spacing: .05em; }
.auth-university { margin: 0; color: white; font-size: 17px; font-weight: 650; line-height: 1.4; letter-spacing: -.01em; }
.auth-identity-caption { display: block; margin-top: 4px; color: #f0d6d9; font-size: 12.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.auth-main { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* ---------------------------------------------------------------- card */
.auth-card { width: 100%; max-width: 432px; padding: clamp(24px, 3.4dvh, 34px) 34px clamp(22px, 3.2dvh, 32px); background: white; border: 1px solid rgb(255 255 255 / 55%); border-radius: 18px; box-shadow: 0 28px 64px -34px rgb(10 2 4 / 75%), 0 2px 6px rgb(10 2 4 / 12%); animation: auth-enter 260ms ease-out both; }
.auth-title { margin: 0 0 6px; font-size: 25px; font-weight: 700; line-height: 1.25; letter-spacing: -.03em; }
.auth-intro { margin: 0 0 26px; color: var(--auth-muted); font-size: 13.5px; line-height: 1.6; }
.auth-field { margin-bottom: 18px; }
.auth-field label { display: block; margin: 0 0 7px; color: #364154; font-size: 13px; font-weight: 600; }
.auth-control-wrap { position: relative; }
.auth-control-icon { position: absolute; top: 15px; left: 14px; width: 18px; height: 18px; color: #7b8596; pointer-events: none; transition: color 150ms ease; }
.auth-input { display: block; width: 100%; min-height: 48px; padding: 12px 14px; color: var(--auth-ink); background: #fcfcfd; border: 1px solid var(--auth-border); border-radius: 10px; transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease; }
.auth-control-wrap .auth-input { padding-left: 42px; }
.auth-input::placeholder { color: #8b94a3; opacity: 1; }
.auth-input:hover { border-color: #a4adbb; }
.auth-input:focus { background: white; border-color: var(--auth-maroon); outline: none; box-shadow: 0 0 0 3px rgb(128 0 0 / 12%); }
.auth-control-wrap:focus-within .auth-control-icon { color: var(--auth-maroon); }
.auth-input:user-invalid { border-color: #b42318; background: #fffbfb; }
.auth-input:user-invalid:focus { box-shadow: 0 0 0 3px rgb(180 35 24 / 12%); }
.auth-password-input { padding-right: 72px !important; }
.auth-password-toggle { position: absolute; top: 2px; right: 3px; min-width: 60px; min-height: 44px; padding: 8px 10px; border: none; border-radius: 8px; color: #4b5566; background: transparent; font-size: 12px; font-weight: 600; cursor: pointer; transition: color 150ms ease, background 150ms ease; }
.auth-password-toggle:hover { color: var(--auth-maroon); background: #f8f1f2; }
.auth-help { margin: 7px 0 0; color: var(--auth-muted); font-size: 12px; line-height: 1.55; }
.auth-options { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin: -4px 0 20px; }
.auth-remember { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: #556174; font-size: 12.5px; cursor: pointer; }
.auth-remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--auth-maroon); }
.auth-text-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; font-size: 12.5px; font-weight: 600; text-decoration: none; }
.auth-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; padding: 12px 18px; border: 1px solid var(--auth-maroon); border-radius: 10px; color: white; background: linear-gradient(180deg, #8d0a0a 0%, var(--auth-maroon) 100%); font-size: 13.5px; font-weight: 650; text-align: center; text-decoration: none; cursor: pointer; transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
.auth-button svg { flex-shrink: 0; width: 18px; height: 18px; }
.auth-button .auth-submit-icon { transition: transform 200ms ease; }
.auth-button:hover { color: white; background: linear-gradient(180deg, #7a0505 0%, #660000 100%); border-color: #660000; box-shadow: 0 8px 18px -8px rgb(128 0 0 / 55%); text-decoration: none; }
.auth-button:hover .auth-submit-icon { transform: translateX(3px); }
.auth-button:active { transform: translateY(1px); background: #520000; }
.auth-button:disabled { opacity: .65; cursor: wait; box-shadow: none; transform: none; }
.auth-button-secondary { border-color: var(--auth-border); color: #364154; background: white; font-weight: 600; }
.auth-button-secondary:hover { color: var(--auth-ink); border-color: #a4adbb; background: #f8f9fb; box-shadow: none; }
.auth-divider { display: flex; align-items: center; gap: 13px; margin: 22px 0; color: #697587; font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #e7eaf0; }
.auth-provider-note { margin: 10px 0 0; text-align: center; color: var(--auth-muted); font-size: 11px; }
.auth-feedback { margin-bottom: 22px; padding: 14px 16px; border: 1px solid #eab4af; border-radius: 10px; color: #92241d; background: #fff5f4; box-shadow: inset 0 0 0 1px rgb(180 35 24 / 5%); font-size: 13px; overflow-wrap: anywhere; }
.auth-feedback strong { display: block; margin-bottom: 3px; font-weight: 650; }
.auth-feedback p { margin: 0; }
.auth-feedback-success { color: #16603d; border-color: #b9dfc9; background: #f0faf4; box-shadow: inset 0 0 0 1px rgb(35 128 82 / 5%); }
.auth-return { margin-top: 18px; text-align: center; }
.auth-return svg { width: 16px; height: 16px; }
.auth-footer { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 14px; width: 100%; max-width: 432px; margin-top: 16px; color: #e8ccd0; text-align: center; font-size: 11.5px; }
.auth-footer a { display: inline-flex; align-items: center; min-height: 44px; color: #f6e2e5; font-weight: 500; text-decoration: none; }
.auth-footer a:hover { color: white; text-decoration: underline; }
.auth-busy-spinner { width: 16px; height: 16px; border: 2px solid rgb(255 255 255 / 40%); border-top-color: white; border-radius: 50%; animation: auth-spin .7s linear infinite; }
.auth-button:not([aria-busy="true"]) .auth-busy-spinner { display: none; }
.auth-button[aria-busy="true"] .auth-submit-icon { display: none; }
@keyframes auth-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (max-height: 900px) {
  .auth-card { padding: 26px 30px 24px; }
  .auth-intro { margin-bottom: 16px; }
  .auth-field { margin-bottom: 14px; }
  .auth-options { margin-bottom: 14px; }
  .auth-divider { margin: 16px 0; }
  .auth-feedback { margin-bottom: 14px; padding: 12px 14px; }
  .auth-footer { margin-top: 8px; }
}
@media (max-height: 820px) {
  .auth-shell { gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .auth-identity { gap: 5px; }
  .auth-logo { width: 56px; height: 56px; }
  .auth-university { font-size: 14px; line-height: 1.25; }
  .auth-identity-caption { margin-top: 2px; font-size: 10.5px; }
  .auth-card { padding: 18px 26px 16px; }
  .auth-title { margin-bottom: 3px; font-size: 21px; }
  .auth-intro { margin-bottom: 9px; font-size: 12.5px; line-height: 1.4; }
  .auth-field { margin-bottom: 9px; }
  .auth-field label { margin-bottom: 3px; }
  .auth-input { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .auth-control-icon { top: 13px; }
  .auth-options { margin: -2px 0 7px; }
  .auth-button { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .auth-divider { margin: 9px 0; }
  .auth-provider-note { margin-top: 5px; }
  .auth-footer { margin-top: 0; }
}

@media (max-width: 760px) {
  .auth-shell { gap: clamp(10px, 2dvh, 18px); padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .auth-logo { width: clamp(56px, 8dvh, 72px); height: clamp(56px, 8dvh, 72px); }
  .auth-university { font-size: 15.5px; }
  .auth-card { padding: 22px 24px 20px; }
  .auth-title { font-size: 23px; }
  .auth-intro { margin-bottom: 14px; }
  .auth-field { margin-bottom: 12px; }
  .auth-options { margin: -2px 0 10px; }
  .auth-divider { margin: 12px 0; }
  .auth-provider-note { margin-top: 6px; }
  .auth-footer { margin-top: 4px; }
  .auth-input { font-size: 16px; }
}
@media (max-width: 380px) {
  .auth-shell { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .auth-card { padding: 20px 18px 18px; border-radius: 14px; }
  .auth-password-input { padding-right: 58px !important; }
  .auth-password-toggle { min-width: 52px; padding-right: 6px; padding-left: 6px; }
  .auth-footer { gap: 0 10px; }
}
/* Preserve 44px touch targets while fitting the core sign-in flow on compact
   phones such as 320x568. Extra feedback, zoom, and the software keyboard can
   still extend the document and scroll normally. */
@media (max-width: 719px) and (max-height: 720px) {
  .auth-shell { justify-content: center; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .auth-identity { gap: 4px; text-align: center; }
  .auth-logo { width: 44px; height: 44px; }
  .auth-university { font-size: 13.5px; line-height: 1.2; }
  .auth-identity-caption { margin-top: 2px; font-size: 10.5px; }
  .auth-card { padding-top: 16px; padding-bottom: 14px; }
  .auth-title { margin-bottom: 3px; font-size: 21px; }
  .auth-intro { margin-bottom: 9px; font-size: 12.5px; line-height: 1.4; }
  .auth-field { margin-bottom: 9px; }
  .auth-field label { margin-bottom: 3px; }
  .auth-input { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .auth-control-icon { top: 13px; }
  .auth-options { margin: -2px 0 7px; }
  .auth-button { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .auth-divider { margin: 9px 0; }
  .auth-provider-note { display: none; }
  .auth-footer { margin-top: 0; }
}
@media (max-width: 380px) and (max-height: 600px) {
  .auth-logo { width: 40px; height: 40px; }
  .auth-intro { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
