/* ================================================================
   CODESAGO — SIGN IN
   Layout only. Tokens, buttons, inputs and chips come from style.css,
   which this page loads first. Nothing here redefines a token.
   ================================================================ */

/* The workspace shell is fixed-height; an auth page scrolls. */
html, body { height: auto; overflow: auto; }
body { background: var(--canvas); }

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* ── LEFT: the pitch ──────────────────────────────────────────
   A deep indigo field. This is the one place the brand colour is
   used as a surface rather than as an action — it is the product
   statement, not a control, and the page needs one moment with
   presence or it reads as a form on an empty page. */
.auth-pitch {
  position: relative;
  overflow: hidden;
  background: var(--brand);
  color: #fff;
  padding: var(--s-11) var(--s-10);
  display: flex; flex-direction: column; justify-content: center;
  gap: var(--s-7);
}
/* One soft light source, top-left, so the field has depth instead of
   reading as a flat colour block. Not a decorative gradient. */
.auth-pitch::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(
    72% 58% at 18% 12%,
    rgba(255, 255, 255, .20) 0%,
    rgba(255, 255, 255, .05) 42%,
    transparent 74%);
  pointer-events: none;
}
.auth-pitch > * { position: relative; }

.auth-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.visitor-counter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: #fff;
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sig-clear);
  box-shadow: 0 0 8px var(--sig-clear);
}

.auth-brand { display: flex; align-items: center; gap: var(--s-3); }
.auth-brand .brand-mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: #fff; color: var(--brand);
  border-radius: 10px;
  font-family: var(--display); font-weight: 800; font-size: var(--t-md);
}
.auth-brand .brand-name {
  font-family: var(--display); font-weight: 800;
  font-size: var(--t-md); color: #fff; letter-spacing: -.02em;
}

.auth-pitch h1 {
  font-size: var(--t-3xl);
  color: #fff;
  max-width: 13ch;
  margin-bottom: var(--s-4);
}
.auth-lede {
  font-size: var(--t-md);
  color: rgba(255, 255, 255, .82);
  max-width: 46ch;
  line-height: 1.65;
}

/* ── THE LADDER — the signature ───────────────────────────────
   Three gates the student cannot skip. Cleared fills solid, current
   wears a ring, locked stays hollow behind a dashed connector. The
   gate state is the product, so it is drawn, not described. */
.ladder { display: flex; flex-direction: column; }

.ladder-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: var(--s-1) var(--s-4);
  padding-bottom: var(--s-6);
  position: relative;
}
.ladder-step:last-child { padding-bottom: 0; }

.ladder-node {
  grid-row: 1 / span 2;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  font-family: var(--display); font-size: var(--t-base); font-weight: 800;
  border: 2px solid rgba(255, 255, 255, .38);
  color: rgba(255, 255, 255, .72);
  background: transparent;
}
.ladder-node svg { width: 18px; height: 18px; stroke-width: 2.5; }

/* The connector between gates. */
.ladder-step::after {
  content: ""; position: absolute;
  left: 19px; top: 46px; bottom: 6px; width: 2px; border-radius: 2px;
}
.ladder-step:last-child::after { display: none; }

.ladder-step[data-state="cleared"] .ladder-node {
  background: #fff; color: var(--brand); border-color: #fff;
}
.ladder-step[data-state="cleared"]::after { background: rgba(255, 255, 255, .85); }

.ladder-step[data-state="locked"] .ladder-node {
  border-style: dashed; border-color: rgba(255, 255, 255, .34);
  color: rgba(255, 255, 255, .5);
}
.ladder-step[data-state="locked"]::after,
.ladder-step[data-state="cleared"] + .ladder-step[data-state="locked"]::after {
  background: repeating-linear-gradient(
    to bottom, rgba(255,255,255,.34) 0 4px, transparent 4px 9px);
}
.ladder-step:has(+ .ladder-step[data-state="locked"])::after {
  background: repeating-linear-gradient(
    to bottom, rgba(255,255,255,.34) 0 4px, transparent 4px 9px);
}

.ladder-title {
  font-size: var(--t-md); font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  letter-spacing: -.012em;
}
.ladder-state {
  font-size: var(--t-xs); font-weight: 600;
  padding: 3px var(--s-3); border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .16); color: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .2);
}
.ladder-step[data-state="locked"] .ladder-title { color: rgba(255, 255, 255, .74); }
.ladder-body {
  grid-column: 2;
  font-size: var(--t-sm); color: rgba(255, 255, 255, .72);
  max-width: 44ch; line-height: 1.6;
}

.auth-note {
  font-size: var(--t-sm); color: rgba(255, 255, 255, .72);
  border-top: 1px solid rgba(255, 255, 255, .18);
  padding-top: var(--s-5); max-width: 46ch;
}
.auth-note strong { color: #fff; font-weight: 600; }

/* ── RIGHT: the form ──────────────────────────────────────────── */
.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-9) var(--s-8);
  background: var(--canvas);
}
.auth-card { width: 100%; max-width: 400px; }

.auth-card h2 { font-size: var(--t-xl); margin-bottom: var(--s-2); }
.auth-subtitle { font-size: var(--t-base); color: var(--ink-3); margin-bottom: var(--s-7); }

.oauth-buttons { display: flex; flex-direction: column; gap: var(--s-3); }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s-3);
  width: 100%; min-height: 46px; padding: 0 var(--s-5);
  font: inherit; font-size: var(--t-base); font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast),
              transform var(--fast), background var(--fast);
}
.oauth-btn:hover {
  border-color: var(--brand-line); background: var(--brand-wash);
  box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.oauth-btn:disabled { opacity: .6; cursor: wait; transform: none; }
.oauth-btn svg, .oauth-btn img { width: 19px; height: 19px; flex: none; }

/* Guest is a real door, not a lesser one — but it is secondary to
   signing in, so it is quieter rather than dashed-and-broken looking. */
#guestBtn {
  background: transparent; box-shadow: none;
  border-color: var(--line); color: var(--ink-2);
}
#guestBtn:hover { background: var(--surface); color: var(--ink); }

.auth-divider {
  display: flex; align-items: center; gap: var(--s-4);
  margin: var(--s-6) 0;
  font-size: var(--t-xs); font-weight: 600; color: var(--ink-3);
  letter-spacing: .04em; text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* Segmented tabs, matching the workbench nav in style.css. */
.auth-tabs {
  display: flex; gap: var(--s-1); padding: var(--s-1);
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: var(--s-6);
}
.auth-tab {
  flex: 1; min-height: 38px; padding: 0 var(--s-4);
  font: inherit; font-size: var(--t-sm); font-weight: 600;
  color: var(--ink-3); background: transparent;
  border: 0; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.auth-tab:hover { color: var(--ink-2); }
.auth-tab.active {
  background: var(--surface); color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.input-group { margin-bottom: var(--s-5); }
.input-group label {
  display: block; margin-bottom: var(--s-2);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
}
.input-group input { width: 100%; min-height: 46px; }

.form-options {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); margin-bottom: var(--s-6); flex-wrap: wrap;
}
.remember-me {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-sm); color: var(--ink-2); cursor: pointer;
}
.remember-me input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.forgot-pwd {
  font-size: var(--t-sm); font-weight: 600; color: var(--brand);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.forgot-pwd:hover { color: var(--brand-hover); text-decoration: underline; }

.submit-btn {
  width: 100%; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font: inherit; font-size: var(--t-base); font-weight: 700;
  color: var(--brand-on); background: var(--brand);
  border: 1px solid var(--brand); border-radius: var(--r);
  box-shadow: var(--shadow-brand); cursor: pointer;
  transition: background var(--fast), box-shadow var(--fast), transform var(--fast);
}
.submit-btn:hover:not(:disabled) {
  background: var(--brand-hover); transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(69, 48, 217, .28), 0 10px 24px rgba(69, 48, 217, .34);
}
.submit-btn:disabled { opacity: .7; cursor: wait; transform: none; }
.arrow-icon { transition: transform var(--fast); }
.submit-btn:hover:not(:disabled) .arrow-icon { transform: translateX(3px); }

/* Messages state what happened. They do not apologise. */
.auth-message {
  margin-top: var(--s-5); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm); font-size: var(--t-sm); font-weight: 500;
  border: 1px solid transparent;
}
.auth-message-error {
  color: var(--sig-fault); background: var(--sig-fault-wash);
  border-color: var(--sig-fault-line);
}
.auth-message-success {
  color: var(--sig-clear); background: var(--sig-clear-wash);
  border-color: var(--sig-clear-line);
}

.auth-foot {
  margin-top: var(--s-6); font-size: var(--t-sm); color: var(--ink-3); text-align: center;
}

/* ── FOCUS ────────────────────────────────────────────────────
   style.css sets the global ring in --focus-ring (indigo). That ring
   would vanish against the indigo pitch panel, so anything focusable
   sitting on that field switches to a white ring instead. */
.oauth-btn:focus-visible,
.auth-tab:focus-visible,
.submit-btn:focus-visible,
.forgot-pwd:focus-visible,
.input-group input:focus-visible,
.remember-me input:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--focus-halo);
}
.auth-pitch a:focus-visible,
.auth-pitch button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--brand);
}

/* The fade the script runs on a successful sign-in. */
.success-flash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--canvas); opacity: 0;
  pointer-events: none;
  animation: flash-in .8s ease forwards;
}
@keyframes flash-in { to { opacity: 1; } }

/* ── RESPONSIVE ───────────────────────────────────────────────
   Below 900px the pitch stops being a column and becomes a header:
   the headline and one line of context survive, the ladder does not,
   because on a phone the job is to sign in. */
@media (max-width: 899px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-pitch {
    padding: var(--s-7) var(--s-6) var(--s-8);
    gap: var(--s-5);
  }
  .auth-pitch h1 { font-size: var(--t-2xl); max-width: 18ch; }
  .ladder, .auth-note { display: none; }
  .auth-panel { padding: var(--s-8) var(--s-6) var(--s-9); }
  .auth-card { max-width: 460px; }
}

@media (max-width: 420px) {
  .auth-pitch { padding: var(--s-6) var(--s-5) var(--s-7); }
  .auth-pitch h1 { font-size: var(--t-xl); }
  .auth-lede { font-size: var(--t-base); }
  .auth-panel { padding: var(--s-7) var(--s-5) var(--s-8); }
  .form-options { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
}

@media (prefers-reduced-motion: reduce) {
  .oauth-btn:hover, .submit-btn:hover:not(:disabled) { transform: none; }
  .success-flash { animation-duration: .001ms; }
}

/* ── SCREEN CAPTURE & PRIVACY PROTECTION ── */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
}

@media print {
  html, body {
    display: none !important;
    visibility: hidden !important;
  }
}

.screenshot-shield {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(11, 15, 28, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.screen-protected .auth-page {
  filter: blur(20px);
  transition: filter 0.2s ease;
}

body.screen-protected .screenshot-shield {
  opacity: 1;
  pointer-events: auto;
}

.screenshot-shield-card {
  max-width: 380px;
  margin: var(--s-4);
  padding: var(--s-6);
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.screenshot-shield-card h3 {
  font-family: var(--sans);
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--s-2);
}

.screenshot-shield-card p {
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.5;
}
