/* v2 auth card — sign-in, code entry, password reset, join, first run and the
   signed-out landing all share one centred card: logo mark, title over blurb,
   fields labelled above their inputs, and a full-width accent action. */

/* The session layout is a single centred column, not the app shell — undo
   layout.css's body grid so its <main> can centre the card. */
body.session {
  display: flex;
  flex-direction: column;
  min-block-size: 100dvh;
}

/* On a plain white body the card floats in a void, so the signed-out pages
   take the sidebar's warm paper tone. SaaS renders its signed-in settings and
   workspace pages through a session layout too, inside the workspace rail
   (.app-with-workspaces), and those keep the app's own background. */
body.session:not(.app-with-workspaces),
body.signup {
  background-color: var(--color-bg-side);
}

/* The SaaS wordmark above the card, tying the entry pages to the marketing site */
.auth-wordmark {
  display: block;
  margin-block-end: 24px;
}

.auth-wordmark__mark {
  block-size: 30px;
  display: block;
  inline-size: auto;
}

/* Its <main>: a full-height centred column with a little more breathing room
   once the viewport is wider than a phone. */
.session-main {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-block-size: 100dvh;
  padding: 16px;

  @media (min-width: 640px) {
    padding: 24px;
  }
}

/* Ground for cards that render inside the app layout (join, first run) —
   the session layout centres its own <main> instead. */
.auth-ground {
  display: flex;
  justify-content: center;
  padding: 48px 16px 80px;
}

.auth-card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  box-shadow: var(--shadow-overlay);
  inline-size: 420px;
  max-inline-size: calc(100vw - 2rem);
  padding: 32px 30px;
  text-align: start;
}

.auth-card__header {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.auth-card__logo {
  text-decoration: none;
}

.auth-card__logo img,
.auth-card__initial {
  block-size: 46px;
  border-radius: 13px;
  display: block;
  inline-size: 46px;
}

.auth-card__logo img {
  object-fit: cover;
}

/* No logo uploaded: the workspace initial on the accent, as in the sidebar */
.auth-card__initial {
  align-content: center;
  background-color: var(--color-accent-brand);
  color: var(--color-text-reversed);
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

/* SaaS sign-in, registration, invite, and workspace pages: the app mark
   centred above the panel. */
.auth-brand {
  display: flex;
  justify-content: center;
  margin-block-end: 24px;

  img {
    block-size: auto;
    border-radius: 8px;
    inline-size: 72px;
  }
}

/* The first screen speaks with display presence — assured, not apologetic */
.auth-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.auth-card__blurb {
  color: var(--color-text-muted);
  font-size: 0.84375rem;
  line-height: 1.55;
  margin: 5px 0 0;
  text-wrap: pretty;
}

/* Fields: label row above the input; the row also carries side links
   ("Forgot your password?") and the translate popup. */
.auth-card__field {
  margin-block-start: 16px;

  .auth-card__header + &,
  form > &:first-child {
    margin-block-start: 22px;
  }
}

.auth-card__label {
  align-items: center;
  color: var(--color-text-muted);
  display: flex;
  font-size: 0.78125rem;
  font-weight: 600;
  justify-content: space-between;
  margin-block-end: 6px;
}

.auth-card__label-link {
  color: var(--color-link);
  font-size: 0.78125rem;
  font-weight: 600;
  text-decoration: none;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      text-decoration: underline;
    }
  }
}

.auth-card__field .input {
  background-color: var(--color-bg);
  border-radius: 9px;
  inline-size: 100%;
  padding: 11px 13px;
}

/* First run's invite step: what just happened, above what to do next */
.auth-card__ready {
  align-items: center;
  color: var(--color-positive);
  display: flex;
  font-size: 0.8125rem;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  margin: 0 0 18px;
}

.auth-card__invite {
  margin-block-start: 22px;
}

.auth-card .auth-card__submit + .auth-card__action--quiet {
  margin-block-start: 8px;
}

/* Quiet line under a field */
.auth-card__hint {
  color: var(--color-text-muted);
  font-size: 0.78125rem;
  line-height: 1.5;
  margin: 6px 0 0;
}

/* Checkbox row agreeing to the terms, at the labels' size so it sits beneath
   the fields rather than outshouting them */
.auth-card__consent {
  color: var(--color-text-muted);
  font-size: 0.78125rem;
  line-height: 1.5;
}

/* Setup "kind" chooser: stacked radio cards (team vs community). Used on the
   self-hosted first-run form and the SaaS workspace-creation form. */
.kind-choice {
  border: 0;
  margin-block-start: 16px;
  padding: 0;
}

.kind-choice__legend {
  inline-size: 100%;
  padding: 0;
}

.kind-choice__fixed {
  color: var(--color-text-subtle);
  font-weight: 400;
}

.kind-choice__option {
  align-items: flex-start;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  margin-block-start: 8px;
  padding: 11px 13px;
}

.kind-choice__option:first-of-type {
  margin-block-start: 0;
}

/* First run's chooser: each option's name and description on one line */
.kind-choice--compact .kind-choice__text {
  align-items: baseline;
  column-gap: 8px;
  flex-flow: row wrap;
}

/* An option that acts as soon as it's chosen (the new-workspace page's demo)
   rather than picking a radio for the form below */
.kind-choice__option--action {
  color: inherit;
  font: inherit;
  inline-size: 100%;
  margin-block-end: 8px;
  text-align: start;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      border-color: var(--color-accent-brand);
    }
  }
}

.kind-choice__option:has(:checked) {
  background-color: var(--color-selected);
  border-color: var(--color-accent-brand);
}

.kind-choice__option input {
  margin-block-start: 2px;
}

.kind-choice__text {
  display: flex;
  flex-direction: column;
}

.kind-choice__text strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.kind-choice__text span {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* Primary action: accent, full width */
.auth-card .auth-card__submit {
  --btn-background: var(--color-accent-brand);
  --btn-border-color: var(--color-accent-brand);
  --btn-border-radius: 9px;
  --btn-color: var(--color-text-reversed);
  --btn-padding: 12px;

  font-size: 0.875rem;
  font-weight: 600;
  inline-size: 100%;
  justify-content: center;
  margin-block-start: 18px;
}

/* Quiet full-width action for terminal states (signed out, expired link) */
.auth-card .auth-card__action--quiet {
  --btn-background: transparent;
  --btn-border-color: var(--color-border);
  --btn-border-radius: 9px;
  --btn-color: var(--color-text-lighter);
  --btn-padding: 12px;
  --hover-color: transparent;
  --hover-filter: none;

  font-size: 0.875rem;
  font-weight: 600;
  inline-size: 100%;
  justify-content: center;
  margin-block-start: 18px;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      --btn-background: var(--color-bg-hover);
    }
  }
}

/* Centred small print under an action, and the footer's links */
.auth-card__note {
  color: var(--color-text-subtle);
  font-size: 0.78125rem;
  line-height: 1.55;
  margin: 14px 0 0;
  text-align: center;
  text-wrap: pretty;
}

:is(.auth-card__note, .auth-card__footer, .auth-card__consent) {
  :is(a, button) {
    color: var(--color-link);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;

    @media (hover: hover) and (pointer: fine) {
      &:hover {
        text-decoration: underline;
      }
    }
  }
}

/* "Send another" resends inline within the note sentence. */
.auth-card__resend {
  display: inline;
}

/* Members line on the join card ("124 members · 9 here now") */
.auth-card__meta {
  color: var(--color-text-muted);
  display: flex;
  font-size: 0.78125rem;
  gap: 0.5ch;
  justify-content: center;
  margin-block-start: 16px;
}

/* Development-only sign-in code between the blurb and the form. Dashed so it
   reads as scaffolding, never as product copy; the code selects as a unit. */
.auth-card__dev-code {
  border: 1px dashed var(--color-border-dark);
  border-radius: 10px;
  color: var(--color-text-muted);
  font-size: 0.78125rem;
  line-height: 1.55;
  margin-block-start: 18px;
  padding: 9px 13px;
  text-align: center;
  text-wrap: pretty;

  strong {
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    user-select: all;
  }
}

/* Hairline-topped footer ("New here? …") */
.auth-card__footer {
  border-block-start: 1px solid var(--color-border);
  color: var(--color-text-subtle);
  font-size: 0.78125rem;
  line-height: 1.55;
  margin-block-start: 22px;
  padding-block-start: 18px;
  text-align: center;
  text-wrap: pretty;
}

/* "← Back" under the card: the blurb's size, quieter than anything inside */
.auth-back {
  color: var(--color-text-subtle);
  font-size: 0.84375rem;
  text-decoration: none;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      color: var(--color-text-muted);
    }
  }
}

/* In-card alert/notice row (join flow renders flash inside the card) */
.auth-card__alert {
  border: 1px solid color-mix(in oklch, var(--color-negative) 32%, transparent);
  background-color: color-mix(in oklch, var(--color-negative) 7%, transparent);
  border-radius: 10px;
  color: var(--color-text-lighter);
  display: flex;
  font-size: 0.8125rem;
  gap: 9px;
  line-height: 1.5;
  margin-block-start: 20px;
  padding: 11px 13px;

  &::before {
    color: var(--color-negative);
    content: "●";
    flex-shrink: 0;
    font-size: 0.8em;
    line-height: 1.9;
  }
}

.auth-card__alert--positive {
  border-color: var(--color-border);
  background-color: var(--color-bg-sunk);

  &::before {
    color: var(--color-positive);
  }
}

/* Amber warning tone — e.g. an unverified address that still needs a step. */
.auth-card__alert--alert {
  border-color: color-mix(in oklch, var(--color-alert) 32%, transparent);
  background-color: color-mix(in oklch, var(--color-alert) 8%, transparent);

  &::before {
    color: var(--color-alert);
  }
}

/* First-run avatar row: preview + upload chip on a sunk card */
.auth-card__avatar-row {
  align-items: center;
  background-color: var(--color-bg-sunk);
  border: 1px solid var(--color-border);
  border-radius: 11px;
  display: flex;
  gap: 13px;
  margin-block-start: 22px;
  padding: 12px 13px;

  img {
    block-size: 44px;
    border-radius: 12px;
    display: block;
    inline-size: 44px;
    object-fit: cover;
  }
}

.auth-card__avatar-copy {
  flex: 1;
  min-inline-size: 0;

  strong {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
  }

  span {
    color: var(--color-text-muted);
    display: block;
    font-size: 0.75rem;
    margin-block-start: 2px;
  }
}

.auth-card .auth-card__chip-btn {
  --btn-background: transparent;
  --btn-border-color: var(--color-border);
  --btn-border-radius: 8px;
  --btn-color: var(--color-text-muted);
  --btn-padding: 6px 11px;
  --hover-color: transparent;
  --hover-filter: none;

  flex-shrink: 0;
  font-size: 0.78125rem;
  font-weight: 600;
  position: relative;

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      --btn-background: var(--color-bg-hover);
    }
  }

  input[type="file"] {
    cursor: pointer;
    inset: 0;
    opacity: 0;
    position: absolute;

    &::file-selector-button {
      cursor: pointer;
    }
  }
}

/* The one-time-code field is six discrete cells that behave as one input (the
   otp-input controller mirrors them into a hidden `code`). Each cell reuses the
   .input box; the active cell takes the accent from the shared focus outline. */
.auth-card .otp {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.auth-card .otp__cell {
  inline-size: 2.75rem;
  padding-inline: 0;
  font-family: var(--font-mono);
  font-size: max(16px, 1.375rem);
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
}

/* Numbered setup steps inside the card (connecting a self-hosted workspace to
   sabha.co): a quiet counter in the gutter, the step's text beside it. */
.auth-card__steps {
  counter-reset: auth-step;
  display: flex;
  flex-direction: column;
  font-size: 0.84375rem;
  gap: 12px;
  line-height: 1.55;
  list-style: none;
  margin: 20px 0 0;
  padding: 0;

  li {
    counter-increment: auth-step;
    padding-inline-start: 30px;
    position: relative;

    &::before {
      align-items: center;
      background-color: var(--color-bg-sunk);
      border: 1px solid var(--color-border);
      border-radius: 50%;
      block-size: 20px;
      color: var(--color-text-muted);
      content: counter(auth-step);
      display: flex;
      font-size: 0.6875rem;
      font-weight: 600;
      inline-size: 20px;
      inset-block-start: 1px;
      inset-inline-start: 0;
      justify-content: center;
      position: absolute;
    }
  }
}

/* A one-time secret to copy: the read-only value beside its copy chip */
.auth-card__secret {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-block-start: 8px;

  .input {
    border-radius: 9px;
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    min-inline-size: 0;
    padding: 9px 11px;
  }
}
