/*
 * Jotsey auth screens (login, sign-up, verify) — plain CSS port of the React/Tailwind version.
 * Shared by every auth page; page-specific bits live at the bottom.
 */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Lora', Georgia, Cambria, 'Times New Roman', Times, serif;

  --color-brand-navy: #0C1A30;
  --color-brand-slate: #1E293B;
  --color-brand-light: #F8FAFC;

  --color-accent-teal: #00A499;
  --color-accent-cyan: #00E5D0;
  --color-accent-lavender: #6C63FF;

  --color-surface-card: #FFFFFF;
  --color-surface-subtle: #F1F5F9;
  --color-border-subtle: #E2E8F0;
  --color-border-focus: #CBD5E1;
  --color-surface-raised: #FFFFFF;

  --color-danger: #DC2626;

  --color-ink: #0C1A30;
  --color-emphasis: #0C1A30;
}

/* Dark theme: page surfaces, borders and text roles flip; brand navy and accents stay. */
[data-theme="dark"] {
  color-scheme: dark;
  --color-brand-light: #0A1322;
  --color-brand-slate: #CBD5E1;
  --color-surface-card: #0F1A2C;
  --color-surface-subtle: #0C1626;
  --color-surface-raised: #15233A;
  --color-danger: #F87171;
  --color-border-subtle: #1C2A40;
  --color-border-focus: #2A3A55;
  --color-ink: #F1F5F9;
  --color-emphasis: #1D3557;
}

/* Added by theme.js during a theme switch so every colour eases over together. */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition-property: background-color, border-color, color, fill, stroke, box-shadow, opacity !important;
  transition-duration: 400ms !important;
  transition-timing-function: ease !important;
}

/* ---------- Reset (matches Tailwind preflight) ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0 solid;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  min-width: 320px;
  background: var(--color-brand-light);
  color: var(--color-brand-slate);
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}

h1, p { overflow-wrap: break-word; }
h1 { font-size: inherit; font-weight: inherit; }
ul, ol { list-style: none; }
img, svg { display: block; vertical-align: middle; }
img { max-width: 100%; }
a { color: inherit; text-decoration: inherit; }

button,
input {
  font: inherit;
  font-feature-settings: inherit;
  letter-spacing: inherit;
  color: inherit;
  background-color: transparent;
  border-radius: 0;
}

button,
a {
  transition: opacity 160ms ease, transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover,
a:hover {
  opacity: 0.82;
}

button:active,
a:active {
  transform: translateY(1px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

[hidden] { display: none !important; }

/* ---------- Layout: brand panel + form column ---------- */
.auth {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--color-brand-light);
}

.auth-panel {
  position: relative;
  isolation: isolate;
  display: none;
  overflow: hidden;
  padding: 40px;
  background: var(--color-brand-navy);
  color: #fff;
}

.auth-panel__photo {
  position: absolute;
  inset: 0;
  z-index: -10;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.auth-panel__scrim {
  position: absolute;
  inset: 0;
  z-index: -10;
  background: linear-gradient(
    to top,
    var(--color-brand-navy),
    color-mix(in oklab, var(--color-brand-navy) 70%, transparent),
    color-mix(in oklab, var(--color-brand-navy) 30%, transparent)
  );
}

.auth-panel__logo {
  display: inline-flex;
}

/* the "Clinical AI" tag is hard to read over the photo */
.auth-panel__logo .tw-font-mono {
  color: rgb(255 255 255 / 0.8);
}

.auth-panel__eyebrow {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-accent-cyan);
}

.auth-panel__title {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.auth-panel__description {
  margin-top: 16px;
  max-width: 28rem;
  font-size: 15px;
  line-height: 28px;
  color: rgb(255 255 255 / 0.75);
}

.auth-panel__cards {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 28rem;
}

.auth-panel__card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.1);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.auth-panel__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in oklab, var(--color-accent-cyan) 15%, transparent);
  color: var(--color-accent-cyan);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--color-accent-cyan) 30%, transparent);
}

.auth-panel__icon svg {
  width: 18px;
  height: 18px;
}

.auth-panel__card-title {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.auth-panel__card-detail {
  display: block;
  font-size: 12px;
  line-height: 16px;
  color: rgb(255 255 255 / 0.65);
}

.auth-main {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

/* ---------- Top bar ---------- */
.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}


.auth-topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-topbar__back {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: color-mix(in oklab, var(--color-brand-slate) 75%, transparent);
}

.auth-topbar__back:hover {
  color: var(--color-ink);
}

/* ---------- Theme toggle (sun and moon rotate through each other) ---------- */
.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--color-ink) 15%, transparent);
  border-radius: 9999px;
  color: var(--color-ink);
  transition: color 300ms, border-color 300ms, background-color 300ms, opacity 160ms ease, transform 160ms ease;
}

[data-theme="dark"] .theme-toggle {
  border-color: rgb(255 255 255 / 0.3);
  color: #fff;
}

.theme-toggle svg {
  position: absolute;
  width: 20px;
  height: 20px;
  transition: all 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle__sun { transform: rotate(-90deg) scale(0.5); opacity: 0; }
.theme-toggle__moon { transform: rotate(0) scale(1); opacity: 1; }
[data-theme="dark"] .theme-toggle__sun { transform: rotate(0) scale(1); opacity: 1; }
[data-theme="dark"] .theme-toggle__moon { transform: rotate(90deg) scale(0.5); opacity: 0; }

/* ---------- Form card ---------- */
.auth-stage {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 28px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 24px;
  background: var(--color-surface-raised);
  box-shadow: 0 25px 50px -12px color-mix(in oklab, var(--color-brand-navy) 10%, transparent);
}

.auth-card__title {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}

.auth-card__subtitle {
  margin-top: 8px;
  font-size: 15px;
  line-height: 24px;
  color: color-mix(in oklab, var(--color-brand-slate) 70%, transparent);
}

.auth-card__body {
  margin-top: 28px;
}

.auth-footnote {
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  color: color-mix(in oklab, var(--color-brand-slate) 55%, transparent);
}

.link-accent {
  font-weight: 600;
  color: var(--color-accent-teal);
}

.link-accent:hover {
  text-decoration: underline;
}

/* ---------- Onboarding steps (sign-up / verify panel) ---------- */
.auth-steps {
  position: relative;
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 28rem;
}

/* the thread linking the step badges */
.auth-steps__thread {
  position: absolute;
  top: 28px;
  bottom: 28px;
  left: 30px;
  width: 1px;
  background: linear-gradient(
    to bottom,
    color-mix(in oklab, var(--color-accent-cyan) 60%, transparent),
    rgb(255 255 255 / 0.1)
  );
}

.auth-step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.06);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  transition: color 500ms, background-color 500ms, border-color 500ms;
}

.auth-step.is-current {
  border-color: color-mix(in oklab, var(--color-accent-cyan) 45%, transparent);
  background: rgb(255 255 255 / 0.15);
  box-shadow: 0 0 30px -12px var(--color-accent-cyan);
}

.auth-step__badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--color-brand-navy) 60%, transparent);
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgb(255 255 255 / 0.5);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.2);
  transition: color 500ms, background-color 500ms, box-shadow 500ms;
}

.auth-step.is-current .auth-step__badge {
  background: var(--color-brand-navy);
  color: var(--color-accent-cyan);
  box-shadow: 0 0 0 1px var(--color-accent-cyan), 0 0 16px var(--color-accent-cyan);
}

.auth-step.is-done .auth-step__badge {
  background: var(--color-accent-teal);
  color: var(--color-brand-navy);
  box-shadow: 0 0 0 1px var(--color-accent-teal);
}

.auth-step__badge svg {
  width: 16px;
  height: 16px;
}

.auth-step:not(.is-current):not(.is-done) .auth-step__text {
  opacity: 0.6;
}

.auth-step__now {
  margin-left: auto;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--color-accent-cyan) 15%, transparent);
  font-size: 10px;
  line-height: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent-cyan);
}

/* ---------- Form controls ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-alert {
  padding: 12px 16px;
  border: 1px solid color-mix(in oklab, var(--color-danger) 30%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--color-danger) 10%, transparent);
  font-size: 14px;
  line-height: 20px;
  color: var(--color-danger);
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--color-ink);
}

.field__control {
  position: relative;
}

.field__input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 12px;
  background: var(--color-surface-card);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-ink);
  outline: none;
  transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.field__input::placeholder {
  color: color-mix(in oklab, var(--color-brand-slate) 40%, transparent);
}

.field__input[aria-invalid="true"] {
  border-color: color-mix(in oklab, var(--color-danger) 70%, transparent);
}

.field__input:focus {
  border-color: var(--color-accent-teal);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--color-accent-teal) 15%, transparent);
}

.field__input--trailing {
  padding-right: 48px;
}

.field__trailing {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 8px;
  display: flex;
  align-items: center;
}

.field__error {
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-danger);
}

.password-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: color-mix(in oklab, var(--color-brand-slate) 60%, transparent);
}

.password-toggle:hover {
  color: var(--color-ink);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

/* the slash through the eye shows while the password is visible */
.password-toggle .eye-slash { display: none; }
.password-toggle[aria-pressed="true"] .eye-slash { display: inline; }

.btn-primary {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--color-accent-teal);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--color-brand-navy);
  text-align: center;
  box-shadow:
    0 10px 15px -3px color-mix(in oklab, var(--color-accent-teal) 25%, transparent),
    0 4px 6px -4px color-mix(in oklab, var(--color-accent-teal) 25%, transparent);
}

.btn-primary:disabled {
  cursor: wait;
  opacity: 0.7;
}

a.btn-primary {
  display: block;
  box-shadow: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in oklab, var(--color-brand-navy) 30%, transparent);
  border-top-color: var(--color-brand-navy);
  border-radius: 9999px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Login page ---------- */
.forgot {
  margin-top: 8px;
  text-align: right;
}

.forgot a {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent-teal);
}

.forgot a:hover {
  text-decoration: underline;
}

/* ---------- Sign-up page ---------- */
.field__hint {
  margin-top: 6px;
  font-size: 13px;
  color: color-mix(in oklab, var(--color-brand-slate) 65%, transparent);
}

.strength {
  display: flex;
  align-items: center;
  gap: 12px;
}

.strength__bars {
  display: flex;
  flex: 1;
  gap: 4px;
}

.strength__bar {
  flex: 1;
  height: 4px;
  border-radius: 9999px;
  background: var(--color-border-subtle);
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.strength__bar.is-danger { background: var(--color-danger); }
.strength__bar.is-warning { background: oklch(76.9% 0.188 70.08); }
.strength__bar.is-good { background: var(--color-accent-teal); }

.form-note {
  text-align: center;
  font-size: 12px;
  line-height: 20px;
  color: color-mix(in oklab, var(--color-brand-slate) 60%, transparent);
}

/* ---------- Breakpoints ---------- */
@media (min-width: 640px) {
  .auth-main { padding: 24px 40px; }
  .auth-card { padding: 36px; }
}

@media (min-width: 1024px) {
  .auth {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  }

  .auth-panel {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    height: 100svh;
  }

  /* the brand panel already shows the logo */
  .auth-topbar__home { visibility: hidden; }
}

@media (min-width: 1280px) {
  .auth-panel__title { font-size: 48px; }
}

/* ---------- Reset / verify pages (not in the HTML export) ---------- */
.form-alert[hidden] { display: none; }
.form-alert a, .form-alert span[onclick] { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; color: inherit; }

.form-alert--info,
.form-alert--success {
  border-color: color-mix(in oklab, var(--color-accent-teal) 35%, transparent);
  background: color-mix(in oklab, var(--color-accent-teal) 10%, transparent);
  color: var(--color-ink);
}

.form-alert--warning {
  border-color: color-mix(in oklab, oklch(76.9% 0.188 70.08) 40%, transparent);
  background: color-mix(in oklab, oklch(76.9% 0.188 70.08) 12%, transparent);
  color: var(--color-ink);
}

.form-alert__title {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 600;
}

.field__input--code {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.4em;
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  font-size: 14px;
  color: color-mix(in oklab, var(--color-brand-slate) 70%, transparent);
}
