/*
 * Sign-in: the shared Medical email + one-time-code pattern (login-*), as in design-ris and design-his.
 * Structure and values follow those products; literals are replaced with baseline and product tokens.
 * The code step (one sent line, resend under the field), the text countdown and the top-anchored page
 * are proposed upstream. Focus ring, field border and the unavailable look come from app.css.
 */
.login-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  block-size: 100vh;
  block-size: 100dvh;
  overflow: hidden;
}

.login-page__content {
  display: grid;
  min-block-size: 0;
  justify-items: center;
  align-content: start;
  padding: clamp(var(--space-6), 18vh, 10rem) var(--space-4) var(--space-6);
  overflow-y: auto;
}

.login-panel {
  display: grid;
  inline-size: 100%;
  max-inline-size: var(--orc-login-width);
  gap: var(--space-5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.login-brand__logo {
  display: inline-grid;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  flex: none;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--orc-brand-tile-bg);
  color: var(--orc-brand-tile-fg);
  box-shadow: var(--shadow-md);
}

.login-brand__text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
}

.login-brand__product {
  font-size: var(--orc-text-brand-size);
  font-weight: var(--orc-text-brand-weight);
  line-height: var(--orc-text-brand-leading);
}

.login-brand__module {
  color: var(--orc-brand-module-fg);
  font-size: var(--orc-text-module-size);
  font-weight: var(--orc-text-module-weight);
}

.login-card {
  display: grid;
  gap: var(--space-5);
}

.login-card__title {
  margin: 0;
  font-size: var(--orc-text-headline-size);
  font-weight: var(--orc-text-headline-weight);
  line-height: var(--orc-text-headline-leading);
}

.login-card__subtitle {
  margin: var(--space-2) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--orc-text-body-size);
  line-height: var(--orc-text-body-leading);
}

.login-form {
  display: grid;
  gap: var(--space-4);
}

.login-form .input {
  --input-height: var(--control-height-md);
  --input-font-size: 0.9375rem;
  --input-radius: var(--radius-md);
}

/* "Change email", right under the sent line; its text lines up with the line above */
.login-form__inline-action {
  --button-height: 1.5rem;
  --button-padding-x: var(--space-2);

  margin-block-start: var(--space-1);
  margin-inline-start: calc(-1 * var(--space-2));
  font-weight: var(--orc-text-emphasis-weight);
}

.login-form__step {
  display: grid;
  gap: var(--space-4);
}

/* The sent line: "We sent a 6-digit code to {email}." */
.login-code-sent {
  overflow-wrap: anywhere;
}

.login-code-sent strong {
  color: var(--color-text-primary);
  font-weight: var(--orc-text-label-weight);
}

/*
 * The code field: six fixed digit slots centred in the box. The field and the slot layer share one grid cell and the
 * same monospace metrics, so a typed digit lands exactly on the placeholder zero it replaces.
 */
.login-otp .input {
  --input-height: 3.25rem;

  display: grid;
}

.login-otp__control,
.login-otp__slots {
  --login-otp-spacing: 0.5em;

  grid-area: 1 / 1;
  padding-inline-start: max(0rem, calc(50% - (6ch + 5 * var(--login-otp-spacing)) / 2));
  font-family: var(--orc-font-family-code);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: var(--login-otp-spacing);
}

.login-otp__slots {
  overflow: hidden;
  /* Decorative and hidden from assistive tech: the baseline placeholder tone keeps the zeros apart from typed digits */
  color: var(--color-text-placeholder);
  pointer-events: none;
  user-select: none;
  white-space: pre;
}

.login-otp__filled {
  color: transparent;
}

/* Right under the code field: the spam note, then a fixed slot for the countdown or "Resend code" */
.login-resend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.login-resend .login-note {
  min-inline-size: 0;
  flex: 1 1 auto;
}

.login-resend__slot {
  display: inline-flex;
  min-inline-size: 8.5rem;
  min-block-size: var(--control-height-sm);
  flex: none;
  align-items: center;
  justify-content: flex-end;
}

.login-resend__action {
  font-weight: var(--orc-text-emphasis-weight);
}

/* Readable text, not a faded button; its end lines up with the button text that replaces it */
.login-resend__countdown {
  padding-inline-end: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--orc-text-meta-size);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  line-height: var(--orc-text-meta-leading);
}

.login-note {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--orc-text-meta-size);
  line-height: 1.5;
}

/* Notice sentences in the card are not bold, like the failed-turn text in the chat */
.login-card .inline-notice__title {
  font-weight: 500;
}

.login-footnote {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding-block-start: var(--space-4);
  border-block-start: var(--orc-hairline) solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--orc-text-meta-size);
  line-height: 1.5;
}

.login-footnote .icon {
  margin-block-start: 0.0625rem;
}

.login-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-block-end: var(--orc-hairline) solid var(--color-border);
  background: var(--color-page-bg);
  text-align: center;
}

@keyframes login-step-in {
  from {
    opacity: 0;
    transform: translateY(-0.25rem);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .login-form__step--otp {
    animation: login-step-in var(--orc-duration-base) var(--orc-ease-out);
  }
}

@media (any-pointer: coarse) {
  .login-form__inline-action,
  .login-resend__action {
    --button-height: var(--orc-touch-target);
  }

  .login-resend__slot {
    min-block-size: var(--orc-touch-target);
  }

  .login-form .input {
    --input-font-size: var(--orc-text-input-touch-size);
  }
}

/* Baseline gap: below 32rem the .inline-notice body drops under its icon (see app.css). */
@media (max-width: 32rem) {
  .login-card .inline-notice__body {
    flex-basis: 0;
  }
}

@media (width < 40rem) {
  .login-page__content {
    padding-inline: var(--space-3);
  }

  .login-card {
    --card-padding: var(--space-5);
  }

  .login-card__title {
    font-size: var(--orc-text-headline-size-compact);
  }

  .login-form .input {
    --input-font-size: var(--orc-text-input-touch-size);
  }
}

@media (max-height: 30rem) {
  .login-page__content {
    padding-block: var(--space-4);
  }

  .login-panel,
  .login-card {
    gap: var(--space-3);
  }
}
