/**
 * FM-POLISH-005 — Welcome Experience Refinement
 * Restore preferred centered-card composition; polish light, space, and calm motion.
 */

:root {
  --fm-p5-deep: #102E24;
  --fm-p5-green: #1E4A38;
  --fm-p5-graphite: #454B48;
  --fm-p5-sage: #83978D;
  --fm-p5-soft: #D9DEDA;
  --fm-p5-glow: rgba(245, 241, 232, 0.35);
  --fm-p5-ivory: #F6F2E9;
  --fm-p5-ink: #24302B;
  --fm-p5-muted: #5C6861;
  --fm-p5-word-f: #454B48;
  --fm-p5-word-m: #1E4A38;
  --fm-p5-cream-text: #FFFDF7;
  --fm-p5-btn-top: #2D5D46;
  --fm-p5-btn-bot: #214B39;
  --fm-p5-btn-border: rgba(16, 46, 36, 0.60);
  --fm-p5-sec-border: #2B5A43;
  --fm-p5-sec-text: #214B39;
  --fm-p5-sec-hover: #EDF3EE;
}

body.fm-polish-005-auth {
  --fm-auth-primary: var(--fm-p5-btn-bot);
}

/* Atmospheric canvas — frames the card */
body.fm-polish-005-auth #auth-session-overlay.fm-ds-001c-overlay,
body.fma-applicant-auth-only.fm-polish-005-auth #auth-session-overlay {
  position: fixed !important;
  inset: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: var(--fm-p5-deep) !important;
  background-image:
    linear-gradient(165deg, var(--fm-p5-deep) 0%, var(--fm-p5-green) 38%, #3a4741 68%, var(--fm-p5-graphite) 100%),
    linear-gradient(28deg, rgba(69, 75, 72, 0.42) 0%, transparent 50%),
    linear-gradient(210deg, rgba(131, 151, 141, 0.22) 0%, transparent 48%) !important;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)) !important;
  z-index: 10050 !important;
}

body.fm-polish-005-auth.fm-ds-001c-auth #sidebar,
body.fm-polish-005-auth.fm-ds-001c-auth #main,
body.fm-polish-005-auth.fm-ds-001c-auth #sb-resize,
body.fm-polish-005-auth.fm-ds-001c-auth #cal-dock {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.fm-polish-005-auth #auth-session-overlay.fm-ds-001c-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(16, 46, 36, 0.28) 0%, transparent 30%),
    linear-gradient(0deg, rgba(16, 46, 36, 0.32) 0%, transparent 28%),
    linear-gradient(90deg, rgba(16, 46, 36, 0.26) 0%, transparent 24%),
    linear-gradient(270deg, rgba(69, 75, 72, 0.22) 0%, transparent 24%);
  z-index: 0;
}

/* Soft warm bloom behind card — diffuse, not a spotlight */
body.fm-polish-005-auth #auth-session-overlay.fm-ds-001c-overlay::after {
  content: '';
  position: fixed;
  left: 50%;
  top: 48%;
  width: min(680px, 88vw);
  height: min(520px, 62vh);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(ellipse at center, var(--fm-p5-glow) 0%, rgba(245, 241, 232, 0.12) 42%, transparent 72%);
  filter: blur(32px);
  opacity: 0.9;
  z-index: 0;
}

#fm-ds-001c-root.fm-polish-005-root {
  position: relative;
  z-index: 1;
  width: min(650px, 100%);
  max-height: none;
}

/* Optional near-invisible watermark */
.fm-polish-005-watermark {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(420px, 70vw);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.018;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  object-fit: contain;
}

.fm-polish-005-stage {
  position: relative;
  z-index: 1;
}

/* Neutralize DS-002 experimental oversized mark / narrow root */
body.fm-polish-005-auth #fm-ds-001c-root.fm-ds-002-root,
body.fm-polish-005-auth #fm-ds-001c-root.fm-polish-005-root {
  width: min(650px, 100%) !important;
}
body.fm-polish-005-auth .fm-ds-002-watermark {
  opacity: 0 !important;
  display: none !important;
}
body.fm-polish-005-auth .fm-ds-002-trust {
  display: none !important;
}

/* Premium paper card — balanced, not full-height */
body.fm-polish-005-auth .fm-auth-card {
  background: #F6F2E9 !important;
  border: 1px solid rgba(53, 83, 67, 0.22) !important;
  border-radius: 30px !important;
  padding: 36px 40px 28px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 28px 80px rgba(14, 35, 27, 0.20) !important;
  overflow: visible;
  max-height: none;
  backdrop-filter: none !important;
}
body.fm-polish-005-auth .fm-auth-card::before {
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(131, 151, 141, 0.65) 22%, rgba(30, 74, 56, 0.8) 50%, rgba(69, 75, 72, 0.55) 78%, transparent);
}

/* Brand / logo — prominent, not dominating */
body.fm-polish-005-auth .fm-auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 0;
}
body.fm-polish-005-auth .fm-auth-mark {
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}
body.fm-polish-005-auth .fm-auth-mark img {
  height: clamp(110px, 14vw, 130px) !important;
  max-height: none !important;
  max-width: min(168px, 42vw) !important;
  width: auto !important;
  object-fit: contain !important;
  display: block;
  background: transparent !important;
}

body.fm-polish-005-auth .fm-auth-name {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(34px, 3.2vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 14px 0 0;
}
body.fm-polish-005-auth .fm-auth-name .wm-f { color: var(--fm-p5-word-f); }
body.fm-polish-005-auth .fm-auth-name .wm-m { color: var(--fm-p5-word-m); }

body.fm-polish-005-auth .fm-auth-tagline {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  font-weight: 400;
  color: #6a766f;
  margin: 8px 0 0;
  letter-spacing: 0.01em;
}

body.fm-polish-005-auth .fm-auth-title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(1.55rem, 2.4vw, 1.85rem);
  font-weight: 700;
  color: var(--fm-p5-ink);
  margin: 38px 0 0;
  text-align: center;
  letter-spacing: -0.02em;
}
body.fm-polish-005-auth .fm-auth-title-sub {
  display: none !important;
}

body.fm-polish-005-auth .fm-auth-purpose {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fm-p5-muted);
  margin: 16px auto 0;
  max-width: 34em;
  text-align: center;
}

body.fm-polish-005-auth .fm-auth-actions {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 32px;
  width: 100%;
}

body.fm-polish-005-auth .fm-auth-btn {
  width: 100%;
  min-height: 64px;
  height: auto;
  padding: 16px 20px;
  border-radius: 20px;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  font-size: 18px;
  font-weight: 650;
  transition: transform 170ms ease, box-shadow 170ms ease, background 170ms ease, border-color 170ms ease;
}

body.fm-polish-005-auth .fm-auth-btn-primary {
  background: linear-gradient(180deg, var(--fm-p5-btn-top) 0%, var(--fm-p5-btn-bot) 100%);
  border: 1px solid var(--fm-p5-btn-border);
  color: var(--fm-p5-cream-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 8px 20px rgba(22, 60, 44, 0.18);
}
body.fm-polish-005-auth .fm-auth-btn-primary:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #33684e 0%, #1c4232 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 24px rgba(22, 60, 44, 0.24);
}
body.fm-polish-005-auth .fm-auth-btn-primary:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.16);
}
body.fm-polish-005-auth .fm-auth-btn-primary:focus-visible {
  outline: 2px solid var(--fm-p5-ivory);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(33, 75, 57, 0.45);
}

body.fm-polish-005-auth .fm-auth-btn-secondary {
  background: var(--fm-p5-ivory);
  border: 1.5px solid var(--fm-p5-sec-border);
  color: var(--fm-p5-sec-text);
  box-shadow: none;
}
body.fm-polish-005-auth .fm-auth-btn-secondary:hover {
  background: var(--fm-p5-sec-hover);
}
body.fm-polish-005-auth .fm-auth-btn-secondary:focus-visible {
  outline: 2px solid var(--fm-p5-sec-border);
  outline-offset: 2px;
}

/* Compact institutional footer */
body.fm-polish-005-auth .fm-auth-legal-footer {
  margin-top: 30px;
  text-align: center;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #6a766f;
}
body.fm-polish-005-auth .fm-auth-legal-org,
body.fm-polish-005-auth .fm-auth-legal-loc {
  margin: 0;
  color: #6a766f;
}
body.fm-polish-005-auth .fm-auth-legal-footer .fm-auth-legal-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
body.fm-polish-005-auth .fm-auth-legal-footer a,
body.fm-polish-005-auth .fm-auth-legal-footer button {
  background: none;
  border: 0;
  color: #3d5648;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 2px 4px;
}
body.fm-polish-005-auth .fm-auth-legal-footer a:hover,
body.fm-polish-005-auth .fm-auth-legal-footer button:hover {
  color: var(--fm-p5-green);
}
body.fm-polish-005-auth .fm-auth-legal-sep {
  color: #9aa59e;
}
body.fm-polish-005-auth .fm-auth-legal-copy {
  display: none;
}

/* Forms share visual language; not full Welcome height */
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-signin"],
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-create"],
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-forgot"],
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-reset"] {
  padding: 28px 32px 24px;
}
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-signin"] .fm-auth-mark img,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-create"] .fm-auth-mark img,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-forgot"] .fm-auth-mark img,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-reset"] .fm-auth-mark img {
  height: clamp(88px, 12vw, 108px) !important;
}
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-signin"] .fm-auth-title,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-create"] .fm-auth-title,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-forgot"] .fm-auth-title,
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-reset"] .fm-auth-title {
  margin-top: 22px;
}
body.fm-polish-005-auth [data-testid="fm-polish-005-signin-trust"] {
  display: block !important;
  text-align: center;
  margin: 14px 0 18px;
}
body.fm-polish-005-auth [data-testid="fm-polish-005-signin-trust"] .fm-polish-005-trust-line {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a766f;
}
body.fm-polish-005-auth [data-testid="fm-polish-005-signin-trust"] .fm-polish-005-trust-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: #7a8680;
}
/* Welcome must never show security trust lines */
body.fm-polish-005-auth .fm-auth-card[data-testid="fm-ds-001c-welcome"] [data-testid="fm-polish-005-signin-trust"] {
  display: none !important;
}

/* Entrance motion — calm, short travel */
@keyframes fmPolish005Fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fmPolish005Up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  body.fm-polish-005-auth .fm-auth-card.fm-polish-005-enter-card {
    animation: fmPolish005Fade 280ms ease both;
  }
  body.fm-polish-005-auth .fm-polish-005-enter {
    opacity: 0;
    animation: fmPolish005Up 280ms ease both;
  }
  body.fm-polish-005-auth .fm-polish-005-enter-1 { animation-delay: 80ms; }
  body.fm-polish-005-auth .fm-polish-005-enter-2 { animation-delay: 160ms; }
  body.fm-polish-005-auth .fm-polish-005-enter-3 { animation-delay: 260ms; }
  body.fm-polish-005-auth .fm-polish-005-enter-4 { animation-delay: 360ms; }
  body.fm-polish-005-auth .fm-polish-005-enter-5 { animation-delay: 460ms; }
  body.fm-polish-005-auth .fm-polish-005-enter-6 { animation-delay: 560ms; }
}

@media (prefers-reduced-motion: reduce) {
  body.fm-polish-005-auth .fm-polish-005-enter,
  body.fm-polish-005-auth .fm-auth-card.fm-polish-005-enter-card {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

body.fm-polish-005-auth.fma-applicant-shell.fm-ds-001c-applicant:not(.fma-crm-ready) #main,
body.fm-polish-005-auth.fm-ds-001c-applicant:not(.fma-crm-ready) #main {
  background-color: var(--fm-p5-deep) !important;
  background-image:
    linear-gradient(165deg, var(--fm-p5-deep) 0%, var(--fm-p5-green) 50%, var(--fm-p5-graphite) 100%) !important;
}

body.fm-polish-005-auth #fm-ds-001c-wizard .fm-wiz-card {
  background: var(--fm-p5-ivory);
  border-color: rgba(53, 83, 67, 0.22);
  border-radius: 24px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 20px 56px rgba(14, 35, 27, 0.16);
}
body.fm-polish-005-auth #fm-ds-001c-wizard .fm-auth-btn-primary {
  background: linear-gradient(180deg, var(--fm-p5-btn-top) 0%, var(--fm-p5-btn-bot) 100%);
  color: var(--fm-p5-cream-text);
}

html[dir="rtl"] body.fm-polish-005-auth .fm-auth-legal-footer .fm-auth-legal-links,
html[dir="rtl"] body.fm-polish-005-auth .fm-auth-links {
  flex-direction: row-reverse;
}

@media (max-width: 900px) {
  #fm-ds-001c-root.fm-polish-005-root {
    width: calc(100% - 64px);
  }
  body.fm-polish-005-auth .fm-auth-mark img {
    height: clamp(96px, 14vw, 112px) !important;
  }
  body.fm-polish-005-auth .fm-auth-name {
    font-size: clamp(30px, 4vw, 36px);
  }
}

@media (max-width: 640px) {
  #fm-ds-001c-root.fm-polish-005-root {
    width: calc(100% - 28px);
  }
  body.fm-polish-005-auth .fm-auth-card {
    padding: 26px 18px 20px;
    border-radius: 24px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      0 16px 40px rgba(14, 35, 27, 0.16);
  }
  body.fm-polish-005-auth .fm-auth-mark img {
    height: clamp(82px, 22vw, 96px) !important;
  }
  body.fm-polish-005-auth .fm-auth-name {
    font-size: clamp(26px, 7vw, 32px);
    margin-top: 12px;
  }
  body.fm-polish-005-auth .fm-auth-title {
    margin-top: 28px;
    font-size: 1.55rem;
  }
  body.fm-polish-005-auth .fm-auth-btn {
    min-height: 58px;
    font-size: 17px;
    border-radius: 18px;
  }
  body.fm-polish-005-auth .fm-auth-legal-footer {
    font-size: 13px;
    margin-top: 24px;
  }
  .fm-polish-005-watermark {
    opacity: 0.015;
    width: 120vw;
  }
}
