/*
 * Sign-in and first-run setup screens (public/auth.js). Full screen on the page ground
 * (true black in Dark), one narrow column, the bezel mark lit in the recovered green.
 * Uses only the shared tokens from styles.css, so the light theme follows automatically.
 * app.js links this file before it shows either screen.
 */

.auth-root {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(32px, calc(env(safe-area-inset-top) + 24px))
    max(20px, env(safe-area-inset-right))
    max(32px, calc(env(safe-area-inset-bottom) + 24px))
    max(20px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 392px;
}

/* ---------------------------------------------------------------- brand */

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.auth-brand .bezel-mark {
  width: 72px;
  height: 72px;
}

.auth-brand .bezel-mark .lit {
  stroke: var(--c-green);
  filter: drop-shadow(0 0 1.2px color-mix(in oklab, var(--c-green) 70%, transparent));
  animation: auth-tick 520ms ease-out both;
  animation-delay: calc(140ms + var(--i, 0) * 55ms);
}

.auth-brand .bezel-mark .dim {
  stroke: var(--axis);
}

.auth-brand .bezel-mark .face {
  stroke: var(--ink-3);
}

@keyframes auth-tick {
  from { stroke: var(--axis); filter: none; }
}

.auth-wordmark {
  font-size: 30px;
  font-weight: 700;
  font-stretch: 125%;
  letter-spacing: -0.015em;
  line-height: 1;
}

/* ----------------------------------------------------------------- text */

.auth-title {
  font-size: 24px;
  font-weight: 620;
  font-stretch: 105%;
  letter-spacing: -0.005em;
  line-height: 1.2;
  text-align: center;
}

.auth-lead {
  margin-top: -10px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  text-wrap: pretty;
}

.auth-fine {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  text-wrap: pretty;
}

.auth-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.auth-notice .icon {
  margin-top: 2px;
  color: var(--ink-2);
}

.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.auth-error .icon {
  margin-top: 2px;
  color: var(--status-critical);
}

/* ----------------------------------------------------------------- form */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}

.auth-input-wrap {
  position: relative;
}

.auth-input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--axis);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  touch-action: manipulation;
  transition: border-color 120ms ease;
}

.has-reveal .auth-input {
  padding-right: 52px;
}

.auth-input::placeholder {
  color: var(--ink-3);
}

.auth-input:hover {
  border-color: var(--ink-3);
}

.auth-input:focus-visible {
  border-color: var(--focus);
  outline: 1px solid var(--focus);
  outline-offset: 0;
}

.auth-input[aria-invalid="true"] {
  border-color: var(--status-critical);
}

.auth-code {
  letter-spacing: 0.08em;
  font-stretch: 110%;
}

.auth-reveal {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.auth-reveal:focus-visible {
  outline-offset: -4px;
}

.auth-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 13px;
}

.auth-hint.ok {
  color: var(--ink-2);
}

.auth-hint.ok .icon {
  color: var(--status-good);
}

.auth-where {
  margin-top: -6px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.55;
}

.auth-command {
  color: var(--ink);
  font-weight: 500;
  /* Keep the command on one line (it is copied as a whole); it only wraps on very narrow screens. */
  display: inline-block;
  white-space: nowrap;
  user-select: all;
  -webkit-user-select: all;
}

@media (max-width: 379.98px) {
  .auth-command {
    display: inline;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* -------------------------------------------------------------- buttons */

.auth-submit {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.auth-form .auth-submit {
  margin-top: 4px;
}

.auth-submit[aria-busy="true"] {
  opacity: 0.75;
  cursor: progress;
}

.auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: auth-spin 800ms linear infinite;
}

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

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

/* ------------------------------------------------------- bigger screens */

@media (min-width: 900px) and (min-height: 700px) {
  .auth-card {
    max-width: 408px;
    gap: 22px;
  }

  .auth-brand .bezel-mark {
    width: 84px;
    height: 84px;
  }

  .auth-wordmark {
    font-size: 34px;
  }

  .auth-title {
    font-size: 26px;
  }
}

/* Landscape phone: keep it all reachable without zooming. */
@media (max-height: 500px) {
  .auth-screen {
    place-items: start center;
  }

  .auth-brand {
    flex-direction: row;
    justify-content: center;
    margin-bottom: 0;
  }

  .auth-brand .bezel-mark {
    width: 44px;
    height: 44px;
  }
}

/* The tick glow is for the black ground; on light it reads as a smudge. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .auth-brand .bezel-mark .lit {
    filter: none;
  }
}

:root[data-theme="light"] .auth-brand .bezel-mark .lit {
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .auth-brand .bezel-mark .lit,
  .auth-spinner {
    animation: none;
  }
}
