/* Login-first gate (js/auth-gate.js). <html>.auth-checking = token being validated (loader only);
   <html>.auth-locked = no session: the auth modal becomes a full page with the brand + CV bank panel.
   Colors come only from theme tokens so light and dark both read well. */

.auth-gate-brand, .auth-gate-aside, .auth-gate-loader { display: none; }

html.auth-locked #app, html.auth-checking #app,
html.auth-locked .guest-nudge, html.auth-checking .guest-nudge { display: none !important; }
html.auth-locked body, html.auth-checking body { background: var(--bg-base); overflow-x: hidden; }

/* ---- loader while the saved token is checked */
html.auth-checking .auth-gate-loader {
  display: flex; position: fixed; inset: 0; z-index: 100001; align-items: center; justify-content: center; gap: 0.75rem;
  background: var(--bg-base); color: var(--text-soft); font-weight: 600; padding: 16px; text-align: center;
}
html.auth-checking #modalAuthSubscription { display: none !important; }
.auth-gate-spinner {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  border: 3px solid var(--border-subtle); border-top-color: var(--primary); animation: authGateSpin 0.8s linear infinite;
}
@keyframes authGateSpin { to { transform: rotate(360deg); } }

/* ---- the login page */
html.auth-locked #modalAuthSubscription {
  display: grid !important; position: relative !important; inset: auto !important; z-index: 1 !important;
  width: auto !important; height: auto !important; min-height: 100vh; min-height: 100dvh; box-sizing: border-box;
  max-width: 1240px; margin: 0 auto; padding: 2rem 1.5rem !important; overflow: visible !important;
  background: transparent !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; animation: none !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 640px); grid-template-areas: "brand form" "aside form";
  grid-template-rows: auto 1fr; align-items: start !important; align-content: start; justify-content: stretch !important; gap: 1.25rem 2rem;
}
html.auth-locked #modalAuthSubscription > .modal-dialog {
  grid-area: form; width: 100% !important; max-width: 100% !important; max-height: none !important; margin: 0 !important;
  border-radius: var(--radius-xl) !important; border: 1px solid var(--border-subtle) !important; overflow: visible !important;
  animation: none !important; box-shadow: var(--shadow-sm, 0 10px 30px rgba(0, 0, 0, 0.12)) !important; min-width: 0;
}
html.auth-locked #modalAuthSubscription > .modal-dialog::before { display: none !important; }
html.auth-locked #modalAuthSubscription .modal-body { max-height: none !important; overflow: visible !important; }

/* No way out of the gate: no close button and no local "guest" session. */
html.auth-locked #btnCloseAuthModal,
html.auth-locked #formUserGuest,
html.auth-locked #btnQuickGuestStart,
html.auth-locked #authPane_guest .guest-banner-box,
html.auth-locked .auth-switch-helper p:has(#linkLoginToGuest) { display: none !important; }

html.auth-locked .auth-gate-brand { display: flex; grid-area: brand; align-items: center; gap: 0.85rem; min-width: 0; }
html.auth-locked .auth-gate-aside { display: flex; grid-area: aside; flex-direction: column; gap: 1rem; min-width: 0; }

.auth-gate-logo {
  width: 52px; height: 52px; border-radius: var(--radius-lg); flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  background: var(--primary-light, rgba(37, 99, 235, 0.12)); color: var(--tx-primary); border: 1px solid var(--border-glow);
}
.auth-gate-logo i, .auth-gate-logo svg { width: 26px; height: 26px; }
.auth-gate-brand-text { display: flex; flex-direction: column; min-width: 0; }
.auth-gate-brand-text strong { font-size: 1.5rem; font-weight: 800; color: var(--text-main); line-height: 1.3; }
.auth-gate-brand-text span { font-size: 0.95rem; color: var(--text-soft); overflow-wrap: anywhere; }

.auth-gate-cvb {
  background: var(--bg-card); border: 1px solid var(--border-glow); border-radius: var(--radius-xl);
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; color: var(--text-main);
}
.auth-gate-cvb-head { display: flex; align-items: center; gap: 0.7rem; }
.auth-gate-cvb-head h2 { margin: 0; font-size: 1.25rem; font-weight: 800; color: var(--tx-primary); }
.auth-gate-cvb-head .cvb-promo-icon { flex: 0 0 auto; }
.auth-gate-cvb-card {
  background: var(--bg-card-hover, var(--bg-surface)); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; min-width: 0;
}
.auth-gate-cvb-card > strong { font-size: 1.02rem; font-weight: 800; color: var(--text-main); line-height: 1.6; overflow-wrap: anywhere; }
.auth-gate-cvb-company > strong { font-size: 0.95rem; }
.auth-gate-cvb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.auth-gate-cvb-list li { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--text-soft); font-size: 0.9rem; line-height: 1.55; min-width: 0; }
.auth-gate-cvb-list li span { min-width: 0; overflow-wrap: anywhere; }
.auth-gate-cvb-list i, .auth-gate-cvb-list svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 3px; color: var(--tx-emerald); }
.auth-gate-cvb-btn {
  align-self: flex-start; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  max-width: 100%; min-height: 44px; white-space: normal; text-align: center; line-height: 1.4; font-weight: 700;
}
.auth-gate-cvb-btn i, .auth-gate-cvb-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.auth-gate-cvb-company .auth-gate-cvb-btn { color: var(--tx-purple); border-color: var(--tx-purple); }

.auth-gate-legal { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; font-size: 0.85rem; color: var(--text-faint); padding: 0 0.25rem; }
.auth-gate-legal a { color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; }
.auth-gate-legal a:hover { color: var(--tx-primary); }

/* Job opened from a /jobs/{id} link after login */
.auth-gate-job-focus { outline: 3px solid var(--primary); outline-offset: 3px; transition: outline-color 0.3s ease; }

@media (max-width: 900px) {
  html.auth-locked #modalAuthSubscription {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "form" "aside"; grid-template-rows: auto;
    padding: 1rem 16px 1.5rem !important; gap: 1rem;
  }
  .auth-gate-brand-text strong { font-size: 1.25rem; }
}
@media (max-width: 420px) {
  .auth-gate-cvb { padding: 1rem; }
  .auth-gate-cvb-btn { align-self: stretch; }
  html.auth-locked .modal-auth-box { width: 100% !important; }
}

/* Nothing else may open over (or under) the login page while locked. */
html.auth-locked .modal-backdrop.active:not(#modalAuthSubscription),
html.auth-locked .modal.active,
html.auth-locked .modal-overlay.active { display: none !important; }
