/* Sign-in, closed registration, pending approval and secure-link pages.
   One card, one title, one field and one button style, in both themes.
   Tokens come from design-theme.css; the fallbacks keep the page readable alone. */
@font-face {
  font-family: 'Instrument Serif';
  src: url('/landing-assets/InstrumentSerif-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --auth-bg: var(--design-bg, #080909);
  --auth-panel: var(--design-panel, #141616);
  --auth-border: var(--design-border, #353d39);
  --auth-hairline: var(--design-hairline, #1f2724);
  --auth-text: var(--design-text, #f3f5f4);
  --auth-muted: var(--design-muted, #aeb8b4);
  --auth-accent: var(--design-accent, #8df0cc);
  --auth-on-accent: var(--design-on-accent, #09251b);
  --auth-fill: rgb(118 118 128 / .24);
  --auth-fill-hover: rgb(118 118 128 / .32);
  --auth-danger: #f87171;
  --auth-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, sans-serif;
  --auth-display: 'Instrument Serif', Georgia, serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --auth-bg: var(--design-bg, #f7f8f7);
  --auth-panel: var(--design-panel, #ffffff);
  --auth-border: var(--design-border, #c9d2cd);
  --auth-hairline: var(--design-hairline, #e3e9e5);
  --auth-text: var(--design-text, #18211d);
  --auth-muted: var(--design-muted, #52625b);
  --auth-accent: var(--design-accent, #176448);
  --auth-on-accent: var(--design-on-accent, #ffffff);
  --auth-fill: rgb(118 118 128 / .12);
  --auth-fill-hover: rgb(118 118 128 / .18);
  --auth-danger: #b91c1c;
}

*, *::before, *::after { box-sizing: border-box; }

body.auth-page {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 88px 24px 32px;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: var(--auth-sans);
  font-size: 15px;
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--auth-muted) var(--auth-bg);
}

.auth-page ::selection { background: var(--auth-accent); color: var(--auth-on-accent); }

.auth-card {
  width: min(100%, 400px);
  padding: 24px;
  border: 1px solid var(--auth-border);
  border-radius: var(--design-radius-panel, 20px);
  background: var(--auth-panel);
}

.auth-card__header { margin-bottom: 24px; text-align: center; }
.auth-card__header:last-child { margin-bottom: 0; }

.auth-card__logo {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: var(--design-radius-control, 12px);
  object-fit: contain;
}

.auth-card__title {
  margin: 0;
  font-family: var(--auth-display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.auth-card form { margin: 0; }
.auth-card form[hidden] { display: none; }

.auth-field { margin: 0 0 20px; }

.auth-label {
  display: block;
  margin: 0 0 8px;
  color: var(--auth-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.auth-input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--auth-border);
  border-radius: var(--design-radius-control, 12px);
  background: var(--auth-bg);
  color: var(--auth-text);
  caret-color: var(--auth-accent);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
}

.auth-input::placeholder { color: var(--auth-muted); opacity: 1; }

/* One ring: the outline sits on the border instead of beside it. */
.auth-page .auth-input:focus,
.auth-page .auth-input:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: -2px;
}

.auth-actions { display: grid; gap: 12px; }
.auth-field + .auth-button { margin-top: 4px; }

.auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 20px;
  border: 0;
  border-radius: var(--design-radius-pill, 999px);
  background: var(--auth-fill);
  color: var(--auth-text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s ease-out, transform .2s ease-out;
}

.auth-button:hover:not(:disabled) { background: var(--auth-fill-hover); }
.auth-button:active:not(:disabled) { transform: scale(.98); }
.auth-button:disabled { opacity: .5; cursor: not-allowed; }

.auth-button--primary { background: var(--auth-accent); color: var(--auth-on-accent); }
.auth-button--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--auth-accent) 88%, #fff); }

.auth-page :is(a, button):focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

/* The busy indicator takes the label's colour and fits the 44px control. */
/* The busy indicator is a flex item with no line box, so it centres on the label. */
.auth-button > #spinner { align-items: center; line-height: 0; }
.auth-button .loading-indicator { gap: 8px; color: inherit; line-height: 0; }
.auth-button .loading-indicator__grid { width: 16px; height: 16px; flex-basis: 16px; gap: 2px; }
.auth-button .loading-indicator__cell { border-radius: 1px; background: currentColor; }

/* Status and error text under the action it belongs to; no gap while empty. */
:is(.auth-message, .message, .pending__message) {
  margin: 16px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}
:is(.auth-message, .message, .pending__message):empty { margin: 0; }
.auth-message--error,
.message--error,
.pending__message--error { color: var(--auth-danger); }
.message .loading-indicator { display: flex; }
.message .loading-indicator__grid { width: 24px; height: 24px; flex-basis: 24px; gap: 2px; }

.auth-card__footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--auth-hairline);
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.auth-card__footer p { margin: 0; }
.auth-card__footer a { color: var(--auth-text); font-weight: 500; text-decoration: none; text-underline-offset: 4px; }
.auth-card__footer a:hover { text-decoration: underline; }

.auth-page .auth-theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--auth-fill);
  color: var(--auth-text);
  cursor: pointer;
  transition: background-color .2s ease-out;
}
.auth-page .auth-theme-toggle:hover { background: var(--auth-fill-hover); }

@media (max-width: 640px) {
  body.auth-page { padding: 88px 16px 24px; }
  .auth-card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-button, .auth-page .auth-theme-toggle { transition: none; }
  .auth-button:active:not(:disabled) { transform: none; }
}

/* In the iOS app these pages run under the status bar and home indicator
   (viewport-fit=cover): keep the theme button and the card clear of both. */
@supports (padding: env(safe-area-inset-top)) {
  .auth-page .auth-theme-toggle { top: calc(24px + env(safe-area-inset-top)); right: calc(24px + env(safe-area-inset-right)); }
  body.auth-page { padding-top: calc(88px + env(safe-area-inset-top)); padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}
