/* =============================================================================
 * ChefStack Design System - Auth pages
 * =============================================================================
 * Split layout for sign in, sign up, password reset and email verification:
 * a brand panel on the left and the form column on the right. Loaded only by
 * AuthAsset (views/layouts/auth.php), after Bootstrap 4, tokens and base.
 * Colours come from the --cs-auth-* and intent tokens in tokens.css.
 *
 * Deliberate exception to components.css: auth controls use an 8px radius
 * and a 38px height to match the approved sign-in mockup, not
 * --cs-radius-control. They are scoped under .cs-auth so nothing leaks.
 * ========================================================================== */

html,
body.cs-auth-body {
  height: 100%;
  background-color: var(--cs-neutral-0);
  color: var(--cs-neutral-900);
  color-scheme: light;
}

body.cs-auth-body {
  margin: 0;
  font-size: var(--cs-text-base);
}

.cs-auth {
  display: flex;
  min-height: 100vh;
}

/* --- Brand panel ---------------------------------------------------------- */

.cs-auth__brand {
  position: relative;
  flex: 0 0 45%;
  max-width: 45%;
  display: flex;
  flex-direction: column;
  padding: 48px 48px 56px;
  color: var(--cs-neutral-0);
  overflow: hidden;
  background-color: var(--cs-auth-brand-mid);
  background-image:
    linear-gradient(160deg,
      color-mix(in srgb, var(--cs-auth-brand-from) 88%, transparent) 0%,
      color-mix(in srgb, var(--cs-auth-brand-mid) 82%, transparent) 50%,
      color-mix(in srgb, var(--cs-auth-brand-to) 92%, transparent) 100%),
    var(--cs-auth-hero-image, none);
  background-size: cover;
  background-position: center;
}

/* Soft light blooms so the panel has depth without a photo. */
.cs-auth__brand::before,
.cs-auth__brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(10px);
}

.cs-auth__brand::before {
  width: 520px;
  height: 520px;
  top: -180px;
  right: -200px;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.45), transparent 65%);
}

.cs-auth__brand::after {
  width: 460px;
  height: 460px;
  bottom: -200px;
  left: -160px;
  background: radial-gradient(circle, rgba(62, 198, 192, 0.18), transparent 65%);
}

.cs-auth__brand > * {
  position: relative;
  z-index: 1;
}

/* Photo slideshow behind the brand panel (params auth.heroImages). Slides
 * crossfade; the brand gradient is laid over them so the copy stays legible. */
.cs-auth__brand > .cs-auth__slides {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.cs-auth__slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 2400ms ease-in-out, transform 12000ms ease-out;
}

.cs-auth__slide.is-active {
  opacity: 1;
  transform: scale(1);
}

/* Purple-to-green scrim, plus a darker band behind the copy on the left. */
.cs-auth__slides::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg,
      color-mix(in srgb, var(--cs-auth-scrim-purple) 55%, transparent) 0%,
      transparent 75%),
    linear-gradient(170deg,
      color-mix(in srgb, var(--cs-auth-brand-mid) 92%, transparent) 0%,
      color-mix(in srgb, var(--cs-auth-scrim-purple) 88%, transparent) 42%,
      color-mix(in srgb, var(--cs-auth-scrim-green) 92%, transparent) 100%);
}

/* Per-slide copy: all slides share one grid cell so the panel never jumps
 * in height; the active one fades and rises in after the photo starts. */
.cs-auth__pitch--slides {
  display: grid;
}

.cs-auth__pitch-slide {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 900ms ease, transform 900ms ease, visibility 0s linear 900ms;
}

.cs-auth__pitch-slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 1200ms ease 700ms, transform 1200ms ease 700ms, visibility 0s;
}

.cs-auth__brand .cs-auth__headline,
.cs-auth__brand .cs-auth__tagline {
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

/* A shadow would show through the transparent gradient-clipped fill. */
.cs-auth__brand .cs-auth__headline-accent {
  text-shadow: none;
}

.cs-auth__brand > .cs-auth__dots {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-auth__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--cs-neutral-0) 45%, transparent);
  cursor: pointer;
  transition: width 300ms ease, background-color 300ms ease;
}

.cs-auth__dot:hover {
  background-color: color-mix(in srgb, var(--cs-neutral-0) 75%, transparent);
}

.cs-auth__dot.is-active {
  width: 24px;
  background-color: var(--cs-neutral-0);
}

.cs-auth__dot:focus-visible {
  outline: 2px solid var(--cs-neutral-0);
  outline-offset: 2px;
}

.cs-auth__logo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -6px; /* the mark's SVG carries side padding */
  font-family: var(--cs-font-sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.cs-auth__logo:hover {
  text-decoration: none;
}

.cs-auth__logo--light,
.cs-auth__logo--light:hover {
  color: var(--cs-neutral-0);
}

.cs-auth__pitch {
  margin-top: auto;
  margin-bottom: auto;
  max-width: 400px;
}

.cs-auth__headline {
  margin: 0 0 22px;
  font-family: var(--cs-font-sans);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--cs-neutral-0);
}

.cs-auth__headline-accent {
  background: linear-gradient(90deg, var(--cs-auth-accent-from), var(--cs-auth-accent-to));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--cs-auth-accent-to); /* fallback where background-clip:text is unsupported */
}

.cs-auth__tagline {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--cs-auth-accent-text);
}

/* --- Form column ----------------------------------------------------------- */

.cs-auth__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 32px 40px 24px;
}

.cs-auth__content {
  width: 100%;
  max-width: 340px;
  margin: auto;
  padding: 32px 0;
}


.cs-auth__logo--mobile {
  display: none;
  margin-bottom: 28px;
  color: var(--cs-neutral-900);
}

.cs-auth__title {
  margin: 0 0 12px;
  font-family: var(--cs-font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--cs-neutral-900);
}

.cs-auth__lead {
  margin: 0 0 24px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--cs-neutral-800);
}

/* Sign in / Sign up segmented tabs */
.cs-auth__tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 24px;
  padding: 2px;
  border-radius: 8px;
  background: var(--cs-auth-segment-bg);
}

.cs-auth__tab {
  flex: 1 1 0;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--cs-auth-tab-text);
  text-decoration: none;
  transition: color 120ms ease, background-color 120ms ease;
}

.cs-auth__tab:hover {
  color: var(--cs-neutral-700);
  text-decoration: none;
}

.cs-auth__tab.is-active {
  background: var(--cs-neutral-0);
  color: var(--cs-auth-tab-active-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* Fields */
.cs-auth .form-group {
  margin-bottom: 16px;
}

.cs-auth .form-control {
  height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--cs-auth-control-border);
  border-radius: 8px;
  background-color: var(--cs-neutral-0);
  font-size: 0.8125rem;
  color: var(--cs-neutral-900);
  box-shadow: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.cs-auth .form-control::placeholder {
  color: var(--cs-auth-muted);
  opacity: 1;
}

.cs-auth .form-control:focus {
  border-color: var(--cs-auth-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-auth-primary) 18%, transparent);
  outline: none;
}

.cs-auth .form-control.is-invalid,
.cs-auth .was-validated .form-control:invalid {
  border-color: var(--cs-danger);
  background-image: none;
  padding-right: 12px;
}

.cs-auth .form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--cs-danger-soft-hover);
}

.cs-auth .form-control.is-valid {
  border-color: var(--cs-auth-control-border);
  background-image: none;
  padding-right: 12px;
}

.cs-auth .invalid-feedback {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--cs-danger-text);
}

.cs-auth .form-text,
.cs-auth .hint-block {
  margin-top: 6px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--cs-auth-muted);
}


/* Remember me + Lost password row */
.cs-auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 40px;
}

.cs-auth__row .form-group {
  margin-bottom: 0;
}

.cs-auth__check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--cs-auth-muted);
  cursor: pointer;
}

.cs-auth__check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--cs-auth-primary);
  cursor: pointer;
}

.cs-auth__link {
  font-size: 0.8125rem;
  color: var(--cs-auth-muted);
  text-decoration: none;
}

.cs-auth__link:hover,
.cs-auth__link:focus {
  color: var(--cs-auth-primary);
  text-decoration: underline;
}

/* Buttons */
.cs-auth__submit,
.cs-auth__secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.cs-auth__submit {
  width: 100%;
  border: 0;
  background: var(--cs-auth-primary);
  color: var(--cs-neutral-0);
}

.cs-auth__submit:hover,
.cs-auth__submit:focus {
  background: var(--cs-auth-primary-hover);
  color: var(--cs-neutral-0);
  text-decoration: none;
}

.cs-auth__submit:focus-visible,
.cs-auth__secondary:focus-visible,
.cs-auth__tab:focus-visible {
  outline: 2px solid var(--cs-auth-primary);
  outline-offset: 2px;
}

.cs-auth__secondary {
  border: 1px solid var(--cs-auth-control-border);
  background: var(--cs-neutral-0);
  color: var(--cs-neutral-800);
}

.cs-auth__secondary:hover,
.cs-auth__secondary:focus {
  border-color: var(--cs-auth-control-border-hover);
  color: var(--cs-neutral-900);
  text-decoration: none;
}

.cs-auth__actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.cs-auth__actions .cs-auth__submit {
  flex: 1 1 auto;
  width: auto;
}

.cs-auth__alt {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--cs-auth-muted);
}

/* Status screens (email sent, link expired, ...) */
.cs-auth__status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
}

.cs-auth__status-icon--success {
  background: var(--cs-tertiary-soft);
  color: var(--cs-tertiary-text);
}

.cs-auth__status-icon--error {
  background: var(--cs-danger-soft);
  color: var(--cs-danger-text);
}

.cs-auth__qr {
  display: block;
  width: 140px;
  margin: 8px 0 0;
  padding: 8px;
  border: 1px solid var(--cs-auth-control-border);
  border-radius: 8px;
}

/* Flash messages and error summaries */
.cs-auth__flash,
.cs-auth .error-summary,
.cs-auth .alert {
  margin: 0 0 20px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.cs-auth__flash--error,
.cs-auth .error-summary,
.cs-auth .alert-danger {
  border-color: var(--cs-danger-border);
  background: var(--cs-danger-soft);
  color: var(--cs-danger-text);
}

.cs-auth__flash--success {
  border-color: var(--cs-tertiary-border);
  background: var(--cs-tertiary-soft);
  color: var(--cs-tertiary-text);
}

.cs-auth__flash--warning,
.cs-auth .alert-warning {
  border-color: var(--cs-warning-border);
  background: var(--cs-warning-soft);
  color: var(--cs-warning-text);
}

.cs-auth__flash--info {
  border-color: var(--cs-primary-border);
  background: var(--cs-primary-soft);
  color: var(--cs-primary-text);
}

.cs-auth .error-summary ul,
.cs-auth .alert ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* Footer */
.cs-auth__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 0.6875rem;
  color: var(--cs-auth-muted);
}

.cs-auth__legal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cs-auth__legal a {
  color: var(--cs-auth-muted);
  text-decoration: none;
}

.cs-auth__legal a:hover {
  color: var(--cs-auth-primary);
  text-decoration: underline;
}

/* --- Narrow screens: form only, logo moves above the heading --------------- */

@media (max-width: 991.98px) {
  .cs-auth__brand {
    display: none;
  }

  .cs-auth__logo--mobile {
    display: inline-flex;
  }
}

@media (max-width: 575.98px) {
  .cs-auth__main {
    padding: 24px 16px 20px;
  }

  .cs-auth__content {
    padding: 8px 0 24px;
  }

  .cs-auth__footer {
    justify-content: center;
    text-align: center;
  }

  .cs-auth__row {
    margin-bottom: 32px;
  }
}

/* --- Submit loading state ---------------------------------------------------
 * Set by views/site/login.php once client validation passes. The label stays
 * in the DOM (visually hidden) so screen readers still announce the button. */
.cs-auth__submit {
  position: relative;
}

.cs-auth__submit.is-loading {
  pointer-events: none;
}

.cs-auth__submit.is-loading .cs-auth__submit-label {
  visibility: hidden;
}

.cs-auth__submit.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid color-mix(in srgb, var(--cs-neutral-0) 35%, transparent);
  border-top-color: var(--cs-neutral-0);
  border-radius: 50%;
  animation: cs-auth-spin 700ms linear infinite;
}

@keyframes cs-auth-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cs-auth__submit.is-loading::after {
    animation-duration: 2s;
  }

  .cs-auth__slide,
  .cs-auth__pitch-slide,
  .cs-auth__pitch-slide.is-active,
  .cs-auth__dot {
    transition: none;
    transform: none;
  }
}
