/* Auth shell — login/register (unauthenticated pages only).
   Extracted from main.css in Slice 1 of docs/AUTH_ACCOUNTS_UX_PLAN.md.
   Existing class names (.login-card, .login-form, .check-row, …) are kept for
   backward compatibility; new auth-* classes extend them. Loaded from base.html
   only when body.auth-shell renders. */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 36%, rgba(255, 250, 240, 0.6), rgba(246, 240, 227, 0) 64%),
    linear-gradient(rgba(246, 240, 227, 0.92), rgba(246, 240, 227, 0.92)),
    repeating-linear-gradient(90deg, #eadbbe 0, #eadbbe 1px, transparent 1px, transparent 36px);
}

.auth-page {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.auth-page > .flash-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(100% - 36px, 560px);
  margin-bottom: 0;
}

/* margin auto (not place-items center) so a card taller than the viewport
   stays scrollable from the top instead of clipping. */
.login-card {
  width: min(100%, 430px);
  margin: auto;
  padding: 36px 34px 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 18px;
}

.login-brand h1 {
  margin: 4px 0 8px;
}

.login-brand .brand-mark.large {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  font-size: 1.7rem;
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--line);
}

.auth-wordmark {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brown);
}

.login-copy {
  margin: 0;
  color: var(--gray);
  line-height: 1.55;
}

.auth-tagline {
  font-size: 0.98rem;
}

/* Hairline rule with a small gold diamond ornament. */
.auth-rule {
  position: relative;
  overflow: visible;
  width: 82%;
  height: 1px;
  margin: 0 auto 22px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}

.auth-rule::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--paper);
  border: 1px solid var(--gold);
}

.login-form {
  display: grid;
  gap: 14px;
  font-family: var(--font-ui);
}

.login-form label {
  color: var(--brown);
  font-weight: 600;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--brown);
  padding: 10px 12px;
  font: inherit;
  font-size: 1rem;
}

.login-form input:focus-visible {
  outline: 2px solid var(--brown-soft);
  outline-offset: 1px;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(182, 139, 60, 0.22);
}

.field-help {
  margin: -4px 0 4px;
  color: var(--gray);
  font-size: 0.86rem;
  line-height: 1.35;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 104px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--brown-soft);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

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

.password-toggle:focus-visible {
  outline: 2px solid var(--brown-soft);
  outline-offset: -2px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 0;
  cursor: pointer;
}

.check-row input {
  min-height: auto;
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--brown);
}

.auth-remember .field-help {
  margin: 0 0 0 30px;
}

/* Inline form-level states, rendered above the primary button. */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 0;
  padding: 12px 14px;
  border-radius: 6px;
  line-height: 1.45;
}

.auth-alert svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.auth-alert-error {
  background: rgba(139, 47, 37, 0.07);
  border: 1px solid rgba(139, 47, 37, 0.28);
  color: var(--danger);
}

.auth-alert-notice {
  background: rgba(114, 118, 77, 0.09);
  border: 1px solid rgba(114, 118, 77, 0.34);
  color: var(--brown);
}

.auth-alert-notice svg {
  color: var(--olive);
}

.login-form button[type="submit"] {
  min-height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 6px;
  background: var(--brown);
  color: var(--paper);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 160ms ease, transform 120ms ease;
}

.login-form button[type="submit"]:hover {
  background: #3f2c1e;
}

.login-form button[type="submit"]:active {
  transform: translateY(1px);
}

.login-form button[type="submit"]:focus-visible {
  outline: 2px solid var(--brown-soft);
  outline-offset: 2px;
}

.login-form button[type="submit"].is-busy,
.login-form button[type="submit"][disabled] {
  opacity: 0.78;
  cursor: progress;
  transform: none;
}

/* Quiet links under the card body. */
.auth-links {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(220, 204, 174, 0.6);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  text-align: center;
}

.auth-links a,
.auth-switch a {
  color: var(--brown-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-links a {
  display: inline-block;
  padding: 9px 8px;
}

.auth-links a:hover,
.auth-switch a:hover {
  color: var(--brown);
}

.auth-links a:focus-visible {
  outline: 2px solid var(--brown-soft);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Honest placeholder for the Slice 4 reset route (Bibliotheca disabled-sort convention). */
.auth-link-soon {
  padding: 9px 8px 0;
  color: var(--gray);
  cursor: help;
}

.auth-link-soon small {
  font-size: 0.82em;
  font-style: italic;
}

.auth-switch {
  margin-top: 18px;
  text-align: center;
}

/* Register page (restyled in Slice 3; keep its existing blocks working). */
.optional-fields {
  display: grid;
  gap: 10px;
  margin: 4px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(246, 240, 227, 0.42);
}

.optional-fields summary {
  color: var(--brown-soft);
  cursor: pointer;
  font-weight: 700;
}

.optional-fields .field-help {
  margin: 0 0 2px;
}

/* Mobile: full-bleed card, coin as hero, one-thumb reach. */
@media (max-width: 900px) {
  .auth-page {
    padding: 0;
  }

  .login-card {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: clamp(28px, 8vw, 48px) clamp(20px, 6vw, 36px) 34px;
    display: flex;
    flex-direction: column;
  }

  .login-card > * {
    flex: none;
  }

  /* Auto margins center the content but collapse when it overflows,
     so tall forms stay scrollable from the top (justify-content would clip). */
  .login-card > :first-child {
    margin-top: auto;
  }

  .login-card > :last-child {
    margin-bottom: auto;
  }

  .login-brand .brand-mark.large {
    width: 78px;
    height: 78px;
    font-size: 2.1rem;
  }

  .auth-wordmark {
    font-size: 2rem;
  }

  .auth-page > .flash-stack {
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-form button[type="submit"] {
    transition: none;
  }

  .login-form button[type="submit"]:active {
    transform: none;
  }
}

/* ------------------------------------------------------------------ */
/* Slice 3 — registration redesign: inline field errors, program choice
   cards, consent row, and the post-submit confirmation card. */

/* Per-field error, rendered directly under the offending input. Icon +
   color so color is never the only signal. */
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.4;
  font-weight: 600;
}

.field-error svg {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.field-error a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-form input[aria-invalid="true"] {
  border-color: rgba(139, 47, 37, 0.55);
}

/* Program choice: two generous radio cards, whole card tappable. */
.track-fieldset {
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.track-fieldset legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--brown);
  font-weight: 600;
}

.track-options {
  display: grid;
  gap: 10px;
}

.track-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 240, 227, 0.42);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.track-option:hover {
  border-color: var(--gold);
}

.track-option input[type="radio"] {
  flex: none;
  width: 20px;
  height: 20px;
  min-height: auto;
  margin-top: 2px;
  accent-color: var(--brown);
}

.track-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(182, 139, 60, 0.09);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.track-option:has(input:focus-visible) {
  outline: 2px solid var(--brown-soft);
  outline-offset: 2px;
}

.track-option-text {
  display: grid;
  gap: 2px;
}

.track-option-title {
  color: var(--brown);
  font-weight: 700;
}

.track-option-desc {
  color: var(--gray);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Consent row: sentence-weight label with links; error sits under it. */
.auth-consent {
  gap: 8px;
}

.consent-row {
  align-items: flex-start;
  cursor: default;
}

.consent-row input {
  margin-top: 2px;
}

.consent-row label {
  font-weight: 400;
  color: var(--brown);
  line-height: 1.5;
  cursor: pointer;
}

.consent-row a {
  color: var(--brown-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

.consent-row a:hover {
  color: var(--brown);
}

/* Confirmation card ("Recibimos tu solicitud"). */
.confirm-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin: 2px auto 18px;
  border-radius: 50%;
  border: 1px solid rgba(114, 118, 77, 0.45);
  background: rgba(114, 118, 77, 0.1);
  color: var(--olive);
}

.confirm-seal svg {
  width: 28px;
  height: 28px;
}

.confirm-body {
  display: grid;
  gap: 12px;
  text-align: center;
}

.confirm-email {
  color: var(--brown);
  overflow-wrap: anywhere;
}

.confirm-note {
  font-size: 0.92rem;
}

@media (prefers-reduced-motion: reduce) {
  .track-option {
    transition: none;
  }
}

/* ------------------------------------------------------------------ */
/* Slice 4 — forgot/reset password flow. */

/* Muted seal variant for the invalid/expired-link page: gold instead of the
   confirmation olive, so it reads as "time passed", not "error". */
.confirm-seal.seal-muted {
  border-color: rgba(182, 139, 60, 0.5);
  background: rgba(182, 139, 60, 0.1);
  color: var(--gold);
}

/* Anchor styled as the primary action, for pages whose main move is a link
   (e.g. "Pedir un enlace nuevo" on the invalid-token page). */
.auth-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 18px;
  border-radius: 6px;
  background: var(--brown);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color 160ms ease;
}

.auth-cta:hover {
  background: #3f2c1e;
}

.auth-cta:focus-visible {
  outline: 2px solid var(--brown-soft);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .auth-cta {
    transition: none;
  }
}

/* Slice 2: the legal footer shares the first viewport with the card instead of
   forcing a scrollbar — the body becomes a column and the auth page yields its
   fixed 100dvh to flex sizing. The mobile full-bleed card stretches to the space
   above the footer so the paper surface still reaches it edge to edge. */
.auth-shell {
  display: flex;
  flex-direction: column;
}

.auth-shell .auth-page {
  flex: 1 0 auto;
  min-height: 0;
}

@media (max-width: 900px) {
  .auth-shell .login-card {
    min-height: 0;
    align-self: stretch;
  }
}
