/* Sign-in page (index.html) + the branded "signing you in" loader
   (js/login-loader.js, also used by picture-login.html). Builds on main.css tokens. */

/* ===================== Sign-in page ===================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  max-width: 1020px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(13, 19, 32, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(99, 102, 241, 0.08);
  overflow: hidden;
  animation: login-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ---- Left: brand panel ---- */
.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2.75rem;
  background:
    radial-gradient(90% 70% at 0% 0%, rgba(99, 102, 241, 0.55), transparent 60%),
    radial-gradient(80% 70% at 100% 100%, rgba(6, 182, 212, 0.4), transparent 60%),
    linear-gradient(160deg, #1e1b4b, #0f172a 55%, #082f49);
  overflow: hidden;
}

/* faint dot grid */
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
  pointer-events: none;
}

.login-brand > * { position: relative; }

.login-brand-top { display: flex; align-items: center; gap: 0.75rem; }
.login-brand-logo {
  width: 46px;
  height: 46px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.login-brand-school { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; color: rgba(255, 255, 255, 0.85); }

.login-brand-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #a5b4fc;
  margin-bottom: 0.75rem;
}
.login-brand-title {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 4.2vw, 3.1rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 1rem;
}
.login-brand-title span {
  background: linear-gradient(90deg, #a5b4fc, var(--accent-cyan), var(--accent-emerald));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.login-brand-text { color: rgba(226, 232, 240, 0.78); font-size: 0.98rem; line-height: 1.6; max-width: 34ch; }

.login-code-card {
  align-self: flex-start;
  padding: 0.9rem 1.1rem 1rem;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  transform: rotate(-2deg);
  animation: login-bob 5s ease-in-out infinite;
}
.login-code-card code { font-family: var(--font-code); font-size: 0.86rem; line-height: 1.7; color: #e2e8f0; }
.login-code-dots { display: flex; gap: 6px; margin-bottom: 0.6rem; }
.login-code-dots span { width: 9px; height: 9px; border-radius: 50%; background: #f43f5e; }
.login-code-dots span:nth-child(2) { background: #f59e0b; }
.login-code-dots span:nth-child(3) { background: #10b981; }
.tok-k { color: #c084fc; }
.tok-f { color: #67e8f9; }
.tok-s { color: #86efac; }
.login-caret {
  display: inline-block;
  width: 8px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--accent-cyan);
  animation: login-blink 1s steps(1) infinite;
}
@keyframes login-blink { 50% { opacity: 0; } }
@keyframes login-bob {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50% { transform: rotate(-1deg) translateY(-6px); }
}

.login-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; }
.login-chips span {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ---- Right: form panel ---- */
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2.75rem;
}
.login-panel-logo { display: none; }

.login-title { font-family: var(--font-heading); font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.login-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.75rem; }

.login-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin: 0 0 6px; }
.login-field {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(2, 6, 23, 0.55);
  overflow: hidden; /* clip an autofilled input's square fill to the rounded field */
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-field:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}
.login-field > svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-left: 14px;
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}
.login-field:focus-within > svg { stroke: var(--primary-light); }
.login-field input {
  flex: 1;
  min-width: 0;
  padding: 14px 14px 14px 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 1rem;
}
.login-field input::placeholder { color: var(--text-dim); }
/* Browser autofill paints its own pale-blue box + dark text; a huge inset shadow
   repaints the field dark, and the long transition stops the flash back to blue. */
.login-field input:-webkit-autofill,
.login-field input:-webkit-autofill:hover,
.login-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  caret-color: var(--text-main);
  -webkit-box-shadow: 0 0 0 1000px #080d1b inset;
  box-shadow: 0 0 0 1000px #080d1b inset;
  transition: background-color 9999s ease-out 0s;
}
.login-field input:autofill {
  -webkit-text-fill-color: var(--text-main);
  box-shadow: 0 0 0 1000px #080d1b inset;
}
.login-peek {
  margin-right: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.login-peek:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.12); }

.login-error {
  margin: -0.25rem 0 0.75rem;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
}
.login-error[hidden] { display: none; }

.login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 15px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), #4f46e5 45%, var(--accent-cyan));
  background-size: 200% 100%;
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.7);
  cursor: pointer;
  transition: background-position 0.4s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.login-submit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s ease; }
.login-submit:hover { background-position: 100% 0; transform: translateY(-2px); box-shadow: 0 16px 36px -10px rgba(6, 182, 212, 0.6); }
.login-submit:hover svg { transform: translateX(4px); }
.login-submit:disabled { opacity: 0.7; cursor: default; transform: none; }

.login-form.is-shake { animation: login-shake 0.4s ease; }
@keyframes login-shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.login-y1 {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-main);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.14), rgba(244, 63, 94, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.3);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.login-y1:hover { transform: translateY(-2px); border-color: rgba(245, 158, 11, 0.6); }
.login-y1-icon { font-size: 1.6rem; }
.login-y1-text { display: flex; flex-direction: column; flex: 1; font-size: 0.85rem; color: var(--text-muted); }
.login-y1-text strong { color: var(--text-main); font-size: 0.95rem; }
.login-y1-arrow { color: var(--accent-amber); font-weight: 700; transition: transform 0.2s ease; }
.login-y1:hover .login-y1-arrow { transform: translateX(4px); }

.login-help { margin: 1.5rem 0 0; text-align: center; font-size: 0.82rem; color: var(--text-dim); }

@media (max-width: 820px) {
  .login-page { align-items: flex-start; padding: 1.25rem 1rem; }
  .login-shell { grid-template-columns: 1fr; max-width: 480px; }
  .login-brand { display: none; }
  .login-panel { padding: 2.25rem 1.5rem; text-align: center; }
  .login-panel-logo {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    padding: 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
  }
  .login-form, .login-y1 { text-align: left; }
}

/* ===================== Loader ===================== */
.bh-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 45%, rgba(30, 27, 75, 0.9), transparent 70%),
    #070b14;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
  overflow: hidden;
}
.bh-loader.is-open,
html.bh-loading .bh-loader {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}
/* Before js/login-loader.js fills the box on a reload, keep the page behind hidden. */
html.bh-loading .login-shell { visibility: hidden; }

.bh-loader-glow {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  animation: bh-drift 8s ease-in-out infinite alternate;
}
.bh-loader-glow--a { background: var(--primary); top: -160px; left: -120px; }
.bh-loader-glow--b { background: var(--accent-cyan); bottom: -180px; right: -140px; animation-delay: -4s; }
@keyframes bh-drift { to { transform: translate(60px, 40px) scale(1.1); } }

.bh-loader-glyphs span {
  position: absolute;
  bottom: -40px;
  font-family: var(--font-code);
  font-weight: 600;
  color: rgba(165, 180, 252, 0.22);
  animation: bh-rise linear infinite;
}
.bh-loader-glyphs span:nth-child(1) { left: 8%;  font-size: 1.4rem; animation-duration: 9s; }
.bh-loader-glyphs span:nth-child(2) { left: 20%; font-size: 1rem;   animation-duration: 12s; animation-delay: -3s; }
.bh-loader-glyphs span:nth-child(3) { left: 33%; font-size: 1.2rem; animation-duration: 10s; animation-delay: -6s; }
.bh-loader-glyphs span:nth-child(4) { left: 47%; font-size: 0.9rem; animation-duration: 13s; animation-delay: -1s; }
.bh-loader-glyphs span:nth-child(5) { left: 61%; font-size: 1.3rem; animation-duration: 11s; animation-delay: -8s; }
.bh-loader-glyphs span:nth-child(6) { left: 72%; font-size: 1.6rem; animation-duration: 9.5s; animation-delay: -5s; }
.bh-loader-glyphs span:nth-child(7) { left: 84%; font-size: 1rem;   animation-duration: 12.5s; animation-delay: -2s; }
.bh-loader-glyphs span:nth-child(8) { left: 93%; font-size: 1.2rem; animation-duration: 10.5s; animation-delay: -7s; }
@keyframes bh-rise {
  from { transform: translateY(0) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  to { transform: translateY(-115vh) rotate(25deg); opacity: 0; }
}

.bh-loader-core {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 1.5rem;
}

.bh-loader-emblem {
  position: relative;
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  margin-bottom: 2rem;
}
.bh-loader-arc {
  position: absolute;
  border-radius: 50%;
  /* a conic stroke masked down to a ring */
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}
.bh-loader-arc--outer {
  inset: 0;
  background: conic-gradient(from 0deg, transparent 0 15%, var(--primary-light) 45%, var(--accent-cyan) 70%, transparent 72%);
  animation: bh-spin 1.6s linear infinite;
}
.bh-loader-arc--inner {
  inset: 16px;
  background: conic-gradient(from 180deg, transparent 0 30%, var(--accent-emerald) 60%, var(--accent-amber) 85%, transparent 87%);
  animation: bh-spin 2.4s linear infinite reverse;
}
@keyframes bh-spin { to { transform: rotate(360deg); } }

.bh-loader-orbit {
  position: absolute;
  inset: -26px;
  animation: bh-spin 9s linear infinite;
}
.bh-loader-orbit span {
  position: absolute;
  font-size: 1.35rem;
  animation: bh-spin 9s linear infinite reverse; /* keep each emoji upright */
}
.bh-loader-orbit span:nth-child(1) { top: -6px; left: calc(50% - 0.7rem); }
.bh-loader-orbit span:nth-child(2) { right: -6px; top: calc(50% - 0.7rem); }
.bh-loader-orbit span:nth-child(3) { bottom: -6px; left: calc(50% - 0.7rem); }
.bh-loader-orbit span:nth-child(4) { left: -6px; top: calc(50% - 0.7rem); }

/* The circle is a span BEHIND the crest, not a border-radius on the <img>, so
   the shield's square top corners can never be clipped by the curve. */
.bh-loader-logo {
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #312e81, #0f172a 75%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 50px rgba(99, 102, 241, 0.55);
  animation: bh-pulse 1.8s ease-in-out infinite;
}
.bh-loader-logo img {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
@keyframes bh-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 40px rgba(99, 102, 241, 0.45); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 70px rgba(6, 182, 212, 0.6); }
}

.bh-loader-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #a5b4fc;
  margin-bottom: 0.6rem;
}
.bh-loader-status {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
  color: #fff;
  min-height: 1.3em;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.bh-loader-status.is-swapping { opacity: 0; transform: translateY(6px); }
.bh-loader-sub { color: var(--text-muted); font-size: 0.95rem; min-height: 1.4em; margin-top: 0.35rem; }

.bh-loader-bar {
  position: relative;
  width: min(300px, 70vw);
  height: 6px;
  margin-top: 1.5rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bh-loader-bar span {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan), var(--accent-emerald));
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.7);
  transition: width 0.3s ease;
  overflow: hidden;
}
.bh-loader-bar span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-100%);
  animation: bh-shimmer 1.2s ease-in-out infinite;
}
@keyframes bh-shimmer { to { transform: translateX(100%); } }

/* "Welcome back" finish */
.bh-loader.is-done .bh-loader-arc { animation-duration: 0.6s; }
.bh-loader.is-done .bh-loader-logo { animation: bh-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes bh-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 0 90px rgba(16, 185, 129, 0.7); }
  100% { transform: scale(1.08); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 0 70px rgba(16, 185, 129, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .login-shell, .login-code-card, .login-caret, .login-form.is-shake,
  .bh-loader-glow, .bh-loader-glyphs span, .bh-loader-orbit, .bh-loader-orbit span,
  .bh-loader-logo, .bh-loader-bar span::after { animation: none; }
  .bh-loader-arc--outer { animation-duration: 3s; }
  .bh-loader-arc--inner { animation: none; }
}
