/* Auth pages (Devise: sign in, confirmation).
   Linked only by layouts/devise. Same visual system as the user pages —
   navy hero, row-group card, icon-tile field rows, one pill action — with
   the values copied from account/_account_styles and layouts/application_user
   rather than rendering those partials: an auth page has two fields and
   must not carry the account page's 400 lines. Keep the numbers in step. */

:root {
  --phoenix-primary: #123273;
  --phoenix-primary-rgb: 18, 50, 115;
  --phoenix-primary-soft: #e8ecf4;
  --phoenix-primary-500: #0e265c;
}

/* ── Page: one focused column, top-aligned at every width: on phones so the
   hero does not jump when the keyboard opens, on desktop so it does not
   jump when the email form opens (centring would re-centre the column). ── */
.auth-layout { background-color: #f5f7fa; }
.auth-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.25rem 1rem 2.5rem;
}
.auth-col {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}
@media (min-width: 992px) {
  .auth-main { padding: clamp(2rem, 12vh, 7rem) 1.5rem 3rem; }
}

/* ── Hero: the account page's identity block, here carrying the brand and
   the page title. The Medacta mark returns large and faint in the corner —
   the one decorative element on these pages, and it is the client's own. ── */
.auth-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
  padding: 1.35rem 1.25rem 1.3rem;
  border-radius: 1rem;
  color: #fff;
  background: linear-gradient(135deg, #16397f 0%, #123273 45%, #0e265c 100%);
  box-shadow: 0 8px 24px rgba(18, 50, 115, 0.22);
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 85% -10%, rgba(255, 255, 255, 0.16), transparent 60%);
  pointer-events: none;
}
.auth-hero-mark {
  position: absolute;
  right: -22px;
  bottom: -30px;
  width: 176px;
  height: auto;
  opacity: 0.09;
  pointer-events: none;
}
.auth-hero-mark path { fill: #fff; }
.auth-hero-inner { position: relative; z-index: 1; }
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.auth-brand:hover,
.auth-brand:focus-visible { color: #fff; text-decoration: none; }
.auth-brand-mark { width: auto; height: 22px; }
.auth-brand-mark path { fill: #fff; }
.auth-title {
  margin: 1.1rem 0 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
}
.auth-lead {
  margin: 0.4rem 0 0;
  max-width: 36ch;
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.74);
}

/* ── Card: a row group. Hairlines only where two rows meet. ── */
.auth-card {
  overflow: hidden;
  border: 1px solid rgba(18, 50, 115, 0.08);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(18, 50, 115, 0.05);
}
.auth-body { padding: 1rem; }
.auth-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
}
.auth-row + .auth-row,
.auth-row + .auth-body,
.auth-body + .auth-row,
.auth-body + .auth-form,
.auth-callout + .auth-form { border-top: 1px solid rgba(18, 50, 115, 0.06); }

/* Icon tile — lights up navy while its field has focus */
.auth-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 0.65rem;
  background: #e8ecf4;
  color: #123273;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.auth-row:focus-within .auth-ico { background: #123273; color: #fff; }

/* Field: sentence-case label, soft-filled 16px input (no iOS zoom) */
.auth-field { flex: 1 1 auto; min-width: 0; }
.auth-label {
  display: block;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #5c6478;
}
.auth-input {
  display: block;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(18, 50, 115, 0.12);
  border-radius: 0.6rem;
  background-color: #f5f7fa;
  color: #31374a;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-input:focus {
  outline: none;
  border-color: #123273;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(18, 50, 115, 0.12);
}
.auth-input::placeholder { color: #a5adc2; }
.auth-row--invalid .auth-ico { background: rgba(220, 53, 69, 0.12); color: #dc3545; }
.auth-row--invalid .auth-input {
  border-color: rgba(220, 53, 69, 0.55);
  background-color: rgba(220, 53, 69, 0.04);
}
.auth-row--invalid .auth-input:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.14);
}
.auth-hint {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #5c6478;
}

/* The one solid action per screen: navy pill with the action dock's shadow */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: 1px solid #123273;
  border-radius: 50rem;
  background: #123273;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(18, 50, 115, 0.22);
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.auth-btn:hover,
.auth-btn:focus-visible {
  background: #0e265c;
  border-color: #0e265c;
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(18, 50, 115, 0.28);
}
.auth-btn:active { transform: none; box-shadow: 0 4px 12px rgba(18, 50, 115, 0.22); }
.auth-btn svg { flex: 0 0 auto; width: 18px; height: 18px; }

/* Validation callout: first row of the card, above the fields it refers to */
.auth-callout {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: rgba(220, 53, 69, 0.04);
}
.auth-callout-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 0.65rem;
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
  font-size: 0.9rem;
}
.auth-callout-body { min-width: 0; padding-top: 0.45rem; }
.auth-callout-msg {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  color: #9f2a36;
}
.auth-callout-msg + .auth-callout-msg { margin-top: 0.3rem; }

/* Quiet footer: the way back, or the one way out of a failed sign-in */
.auth-links { margin-top: 1rem; text-align: center; }
.auth-back {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  color: #5c6478;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.auth-back:hover,
.auth-back:focus-visible { color: #123273; text-decoration: underline; }
/* Flash toasts (partials/messages) sit between the hero and the card */
.auth-main .flash-toast-stack { margin-bottom: 1rem; }

/* One visible keyboard focus ring, as on the user pages */
.auth-main a:focus-visible,
.auth-main button:focus-visible {
  outline: 2px solid #123273;
  outline-offset: 2px;
}

/* Secondary pill: the guide's "Got it", next to no other solid action */
.auth-btn--quiet {
  background: transparent;
  color: #123273;
  box-shadow: none;
}
.auth-btn--quiet:hover,
.auth-btn--quiet:focus-visible {
  background: #e8ecf4;
  border-color: #123273;
  color: #123273;
  box-shadow: none;
}

/* ── "Trouble signing in?" (devise/shared/_login_help): a quiet link under
   the SSO button opening a native <dialog> — a bottom sheet on phones, a
   centred card from 576px — that walks through two yes/no questions. ── */
.auth-help-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 0.6rem;
  background: none;
  color: #5c6478;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-help-trigger:hover,
.auth-help-trigger:focus-visible { color: #123273; text-decoration: underline; }

.login-help {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 1.5rem);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 1.25rem 1.25rem 0 0;
  background: #fff;
  color: #31374a;
  box-shadow: 0 -10px 32px rgba(14, 38, 92, 0.22);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.login-help::backdrop { background: rgba(14, 38, 92, 0.45); }
.login-help[open] { animation: login-help-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes login-help-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
body:has(.login-help[open]) { overflow: hidden; }

.login-help-sheet { padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); }
/* Grab handle: says "sheet" on phones */
.login-help-sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto 0.4rem;
  border-radius: 2px;
  background: #d5dbe8;
}
@media (min-width: 576px) {
  .login-help {
    margin: auto;
    border-radius: 1rem;
    box-shadow: 0 16px 48px rgba(14, 38, 92, 0.25);
  }
  .login-help-sheet { padding: 0.9rem 1.5rem 1.5rem; }
  .login-help-sheet::before { display: none; }
}

/* Back · title · close. The back button keeps its place while hidden, so the
   title never shifts sideways between steps. */
.login-help-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.login-help-kicker {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5c6478;
}
.login-help-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f5f7fa;
  color: #31374a;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.login-help-icon-btn:hover,
.login-help-icon-btn:focus-visible { background: #e8ecf4; color: #123273; }
/* Not [hidden]: Bootstrap makes that display: none !important */
.login-help-icon-btn.is-hidden { visibility: hidden; }

/* Full padding shorthand: the theme pads every <section> */
.login-help-step { padding: 0.75rem 0 0; text-align: center; }
.login-help-ico {
  flex-basis: 52px;
  width: 52px;
  height: 52px;
  margin-bottom: 0.9rem;
  border-radius: 0.95rem;
  font-size: 1.2rem;
}
/* Questions get the soft tile, answers the solid one */
.login-help-ico--answer { background: #123273; color: #fff; }
.login-help-title {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.25;
  color: #1c2a4f;
}
.login-help-title:focus { outline: none; }
.login-help-text {
  max-width: 36ch;
  margin: 0 auto 1.25rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #5c6478;
}

/* First step: name side by side, then the first question under a hairline */
.login-help-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0 0 1.1rem;
  text-align: left;
}
.login-help-field { display: block; min-width: 0; margin: 0; }
.login-help-field--wide { grid-column: 1 / -1; }
.login-help-fields .auth-input:user-invalid {
  border-color: rgba(220, 53, 69, 0.55);
  background-color: rgba(220, 53, 69, 0.04);
}
.login-help-question {
  margin: 0 0 0.3rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(18, 50, 115, 0.08);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  color: #1c2a4f;
}
.login-help-question + .login-help-text { margin-bottom: 1rem; }

.login-help-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.login-help-choice {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(18, 50, 115, 0.14);
  border-radius: 0.9rem;
  background: #f5f7fa;
  color: #123273;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.login-help-choice:hover,
.login-help-choice:focus-visible { background: #e8ecf4; border-color: rgba(18, 50, 115, 0.35); }
.login-help-choice:active { background: #dfe5f0; }

.login-help-example {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  background: #e8ecf4;
  text-align: left;
}
.login-help-example-label {
  display: block;
  font-size: 0.78rem;
  color: #5c6478;
}
.login-help-example-value {
  display: block;
  margin-top: 0.1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #123273;
  overflow-wrap: anywhere;
}

/* Motion: one reveal on load (hero, card, footer). `backwards` fill, not
   `both`: the end state equals the base styles, and a forwards-filled
   transform would keep every wrapper a stacking context. */
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.auth-reveal {
  animation: auth-rise 0.38s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@media (prefers-reduced-motion: reduce) {
  .auth-reveal, .login-help[open] { animation: none; }
  .auth-btn, .auth-ico, .auth-input, .login-help-choice, .login-help-icon-btn { transition: none; }
  .auth-btn:hover,
  .auth-btn:focus-visible { transform: none; }
}
