/* Shared auth panel — themed per site via .theme-game / .theme-portal / .theme-admin */

.wq-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem max(0.75rem, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}

.wq-auth-gate[hidden] {
  display: none !important;
}

/* Keep the auth card in view without the document scrolling behind it */
html.wq-auth-open,
html.wq-auth-open body {
  overflow: hidden !important;
  height: 100%;
}

#app.wq-auth-pending {
  visibility: hidden !important;
  pointer-events: none !important;
}

.wq-auth {
  width: 100%;
  max-width: 420px;
  font-size: 1rem;
}

.wq-auth * { box-sizing: border-box; }

.wq-auth h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.wq-auth .wq-auth-lead {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.wq-auth form {
  display: grid;
  gap: 0.75rem;
}

.wq-auth label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
}

.wq-auth input[type="text"],
.wq-auth input[type="email"],
.wq-auth input[type="password"],
.wq-auth textarea,
.wq-auth select {
  width: 100%;
  font: inherit;
  min-height: 48px;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
}

.wq-auth textarea {
  min-height: 88px;
  resize: vertical;
}

.wq-auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.wq-auth button {
  font: inherit;
  cursor: pointer;
  min-height: 48px;
  border-radius: 999px;
  padding: 0.55rem 1rem;
}

.wq-auth button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.wq-auth-error {
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
}

.wq-auth-error[hidden],
.wq-auth-ok[hidden] {
  display: none !important;
}

.wq-auth-ok {
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
}

.wq-auth-switch {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  text-align: center;
}

.wq-auth-switch button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: underline;
  border-radius: 0;
}

.wq-auth-social {
  display: none;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.wq-auth-social.is-on {
  display: grid;
}

.wq-auth-or {
  display: none;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0.85rem 0 0;
}

.wq-auth-social.is-on + .wq-auth-or,
.wq-auth-or.is-on {
  display: block;
}

.wq-auth-type {
  display: grid;
  gap: 0.4rem;
}

.wq-auth-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wq-auth-type-row button {
  flex: 1;
  min-width: 7rem;
}

.wq-auth-type-row button[aria-pressed="true"] {
  font-weight: 650;
}

.wq-auth-school-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  border-radius: 12px;
}

.wq-auth-school-list button {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  text-align: left;
  padding: 0.45rem 0.7rem;
}

.wq-auth-school-list .meta {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
}

.wq-auth-hint {
  font-size: 0.82rem;
  line-height: 1.4;
}

.wq-auth-waitlist-perks {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  line-height: 1.55;
  font-size: 0.92rem;
}

.wq-auth-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

.wq-auth a.primary.wq-auth-link-btn {
  background: inherit;
}

.wq-auth.theme-portal a.primary.wq-auth-link-btn,
.wq-auth.theme-admin a.primary.wq-auth-link-btn {
  background: #0ea5e9;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
}

.wq-auth.theme-game a.primary.wq-auth-link-btn {
  background: linear-gradient(135deg, #38bdf8, #a78bfa);
  color: #0f172a;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
}

.wq-auth-denied {
  max-width: 420px;
  text-align: center;
}

.wq-auth-denied p {
  line-height: 1.45;
}

/* —— Learner app (dark glass) —— */
.wq-auth-gate.theme-game {
  flex-direction: column;
  gap: 0.35rem;
  background-color: #070a12;
  background-repeat: no-repeat;
  color: #fff;
  font-family: Inter, system-ui, sans-serif;
  /* Prefer a single viewport; only the gate scrolls if the form is taller */
  min-height: 100%;
  min-height: 100dvh;
  justify-content: center;
}

/* Shimmer placeholders while isolated assets assemble */
@keyframes wq-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.wq-auth-gate.theme-game.wq-asset-pending {
  background-image: linear-gradient(
    110deg,
    #070a12 20%,
    #1e293b 40%,
    #334155 50%,
    #1e293b 60%,
    #070a12 80%
  ) !important;
  background-size: 220% 100% !important;
  animation: wq-shimmer 1.35s ease-in-out infinite;
}

.wq-auth-mascot-wrap {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 0.4rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(168, 85, 247, 0.75);
  box-shadow:
    0 0 0 3px rgba(15, 23, 42, 0.65),
    0 10px 22px rgba(0, 0, 0, 0.45);
  background-color: #1e293b;
}

.wq-auth-mascot-wrap.wq-asset-pending {
  background-image: linear-gradient(
    110deg,
    #1e293b 20%,
    #334155 37%,
    #64748b 50%,
    #334155 63%,
    #1e293b 80%
  );
  background-size: 220% 100%;
  animation: wq-shimmer 1.2s ease-in-out infinite;
}

/* Auth boot — Ernie + indeterminate bar while Firebase session resolves */
.wq-auth-boot {
  text-align: center;
  padding: 0.35rem 0 0.15rem;
}

.wq-auth-ernie-boot-art {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 110px;
  margin: 0 auto 0.65rem;
}

.wq-auth-ernie-boot-art.wq-asset-pending {
  background-image: linear-gradient(
    110deg,
    rgba(30, 41, 59, 0.35) 20%,
    rgba(51, 65, 85, 0.55) 50%,
    rgba(30, 41, 59, 0.35) 80%
  );
  background-size: 220% 100%;
  animation: wq-shimmer 1.2s ease-in-out infinite;
  border-radius: 16px;
}

.wq-auth-ernie-boot-img {
  display: block;
  width: 88px;
  height: auto;
  max-height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  animation: wq-ernie-bob 1.1s ease-in-out infinite;
}

@keyframes wq-ernie-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.wq-auth-boot-title {
  margin: 0 0 0.25rem;
  font-family: Fredoka, Inter, sans-serif;
  font-size: 1.15rem;
  font-weight: 650;
}

.wq-auth-ernie-bar {
  position: relative;
  width: min(100%, 14rem);
  height: 8px;
  margin: 0.85rem auto 0.15rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.28);
}

.wq-auth-ernie-bar-fill {
  display: block;
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #a78bfa, #fbbf24);
  animation: wq-ernie-bar 1.15s ease-in-out infinite;
}

@keyframes wq-ernie-bar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.wq-auth.theme-portal .wq-auth-boot-title {
  color: #fff;
}

.wq-auth.theme-game .wq-auth-boot-title {
  color: #f8fafc;
}

.wq-auth-mascot-wrap .wq-auth-mascot {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  /* Artwork has padded dark margins — zoom so Ernie fills the circle */
  object-fit: cover;
  object-position: center 42%;
  transform: scale(1.55);
  transform-origin: center center;
}

.wq-auth-gate.theme-game .wq-auth-brand {
  text-align: center;
  z-index: 1;
  margin-bottom: 0.15rem;
}

/* Circle chrome lives on the wrap; do not restyle the img (would leave empty padding). */
.wq-auth-gate.theme-game .wq-auth-mascot-wrap {
  margin: 0 auto 0.65rem;
}

.wq-auth-gate.theme-game .wq-auth-mascot-wrap .wq-auth-mascot {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: cover;
  object-position: center 42%;
  transform: scale(1.55);
}

.wq-auth-gate.theme-game .wq-auth-brand-name {
  margin: 0;
  font-family: Fredoka, Inter, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.wq-auth-gate.theme-game .wq-auth-brand-tag {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #cbd5e1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.wq-auth.theme-game {
  background: rgba(15, 23, 42, 0.94);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  padding: 1.4rem 1.35rem 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.wq-auth.theme-game h1 {
  font-family: Fredoka, Inter, sans-serif;
}

.wq-auth.theme-game .wq-auth-lead,
.wq-auth.theme-game .wq-auth-hint,
.wq-auth.theme-game .wq-auth-or {
  color: #cbd5e1;
}

.wq-auth.theme-game input,
.wq-auth.theme-game textarea,
.wq-auth.theme-game select {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wq-auth.theme-game button.primary {
  background: #a855f7;
  border: 0;
  color: #fff;
}

.wq-auth.theme-game button.ghost,
.wq-auth.theme-game .wq-auth-type-row button {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wq-auth.theme-game .wq-auth-type-row button[aria-pressed="true"] {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #070a12;
}

.wq-auth.theme-game .wq-auth-switch button {
  color: #38bdf8;
}

.wq-auth.theme-game .wq-auth-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.wq-auth.theme-game .wq-auth-ok {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #86efac;
}

.wq-auth.theme-game .wq-auth-school-list {
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wq-auth.theme-game .wq-auth-school-list button {
  background: #1e293b;
  border: 1px solid transparent;
  color: #fff;
}

/* —— Portal (WordQuest dark public surface) —— */
.wq-auth-gate.theme-portal {
  background: transparent;
  position: static;
  padding: 0;
  z-index: auto;
}

.wq-auth.theme-portal {
  max-width: none;
  color: #fff;
  font-family: Inter, system-ui, sans-serif;
}

.wq-auth.theme-portal h1 {
  font-family: Fredoka, Inter, sans-serif;
  color: #fff;
}

.wq-auth.theme-portal .wq-auth-lead,
.wq-auth.theme-portal .wq-auth-hint,
.wq-auth.theme-portal .wq-auth-or {
  color: #cbd5e1;
}

.wq-auth.theme-portal .wq-auth-switch-warn {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  color: #fde68a;
  margin: 0 0 0.75rem;
}

.wq-auth.theme-portal input,
.wq-auth.theme-portal textarea,
.wq-auth.theme-portal select {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wq-auth.theme-portal button.primary {
  background: linear-gradient(135deg, #38bdf8 0%, #3b82f6 55%, #8b5cf6 100%);
  border: 0;
  color: #fff;
  font-weight: 650;
}

.wq-auth.theme-portal button.ghost,
.wq-auth.theme-portal .wq-auth-type-row button {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wq-auth.theme-portal .wq-auth-type-row button[aria-pressed="true"] {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #070a12;
}

.wq-auth.theme-portal .wq-auth-switch button {
  color: #38bdf8;
}

.wq-auth.theme-portal .wq-auth-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.wq-auth.theme-portal .wq-auth-ok {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #86efac;
}

.wq-auth.theme-portal .wq-auth-school-list {
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wq-auth.theme-portal .wq-auth-school-list button {
  background: #1e293b;
  border: 1px solid transparent;
  color: #fff;
}

.wq-auth.theme-portal .wq-auth-type span {
  color: #94a3b8;
  font-size: 0.88rem;
}

/* —— Admin (light ops) —— */
.wq-auth-gate.theme-admin {
  background:
    radial-gradient(700px 320px at 10% -10%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(180deg, #f4f7fb 0%, #e8eef6 100%);
  color: #0f172a;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

.wq-auth.theme-admin {
  background: #ffffff;
  border: 1px solid #d7dee8;
  border-radius: 16px;
  padding: 1.35rem 1.3rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

.wq-auth.theme-admin h1 {
  font-family: Inter, system-ui, sans-serif;
  color: #0f172a;
}

.wq-auth.theme-admin .wq-auth-lead,
.wq-auth.theme-admin .wq-auth-hint {
  color: #64748b;
}

.wq-auth.theme-admin .wq-auth-switch-warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  color: #9a3412;
  margin: 0 0 0.75rem;
}

.wq-auth.theme-admin input,
.wq-auth.theme-admin textarea {
  background: #f8fafc;
  border: 1px solid #d7dee8;
  color: #0f172a;
}

.wq-auth.theme-admin button.primary {
  background: #0ea5e9;
  border: 0;
  color: #fff;
  font-weight: 650;
}

.wq-auth.theme-admin button.ghost {
  background: #fff;
  border: 1px solid #d7dee8;
  color: #0f172a;
}

.wq-auth.theme-admin .wq-auth-switch button {
  color: #0284c7;
}

.wq-auth.theme-admin .wq-auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.wq-auth.theme-admin .wq-auth-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.wq-auth-denied.theme-admin {
  color: #0f172a;
}

.wq-auth-denied.theme-admin p { color: #64748b; }

/* Honeypot — hidden from humans, visible to naive bots */
.wq-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.wq-uk-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(7, 10, 18, 0.72);
  backdrop-filter: blur(4px);
}

.wq-uk-modal[hidden] {
  display: none !important;
}

.wq-uk-modal__card {
  width: 100%;
  max-width: 420px;
  padding: 1.25rem 1.35rem;
  border-radius: 1rem;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.wq-uk-modal__card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.wq-uk-modal__card p {
  margin: 0 0 0.75rem;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.45;
}

.wq-uk-modal .wq-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.wq-uk-modal .wq-field input {
  font: inherit;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #070a12;
  color: #fff;
}

.theme-admin .wq-uk-modal__card {
  background: #fff;
  color: #0f172a;
  border-color: #d7dee8;
}

.theme-admin .wq-uk-modal__card p { color: #64748b; }
.theme-admin .wq-uk-modal .wq-field input {
  background: #fff;
  color: #0f172a;
  border-color: #d7dee8;
}

