/* Login — layout auth (body.auth) */

body.auth {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--gradient-auth-bg);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* —— Hero —— */
.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  color: var(--text);
  overflow: hidden;
  isolation: isolate;
}

.auth-hero__atmosphere {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 12% 18%, rgba(2, 132, 199, 0.22), transparent 55%),
    radial-gradient(ellipse 55% 45% at 88% 78%, rgba(14, 165, 233, 0.14), transparent 50%),
    linear-gradient(155deg, transparent 40%, rgba(255, 255, 255, 0.28) 100%);
}

.auth-hero__atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(2, 132, 199, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(2, 132, 199, 0.07) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 75% 70% at 40% 45%, #000 20%, transparent 75%);
}

.auth-hero__atmosphere::after {
  content: "";
  position: absolute;
  width: min(52vw, 28rem);
  height: min(52vw, 28rem);
  border-radius: 50%;
  border: 1px solid rgba(2, 132, 199, 0.18);
  top: 58%;
  left: -12%;
  box-shadow:
    0 0 0 28px rgba(2, 132, 199, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.auth-hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  padding: clamp(2rem, 4vw, 3.25rem);
  min-height: 100%;
}

.auth-hero__brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
}

.auth-hero__logo-img {
  display: block;
  max-width: min(240px, 70%);
  width: auto;
  height: auto;
}

.auth-hero__product {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 1.35rem + 1.4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--primary-text);
}

.auth-hero__headline {
  max-width: 22rem;
  margin-block: auto;
  padding-block: 2rem;
}

.auth-hero__headline h1 {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin: 0 0 0.65rem;
  color: var(--text);
}

.auth-hero__headline p {
  margin: 0;
  font-size: var(--text-md);
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-hero__footer {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-soft);
}

/* —— Panel / form —— */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background: transparent;
}

.auth-panel-inner {
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-mobile-brand {
  display: none;
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-mobile-brand__logo {
  display: block;
  max-width: 180px;
  width: 100%;
  height: auto;
  margin: 0 auto 0.65rem;
}

.auth-mobile-brand__product {
  margin: 0 0 0.25rem;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary-text);
}

.auth-mobile-brand__tagline {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.45;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1.5rem, 2.5vw, 2rem);
}

.login-card__title {
  font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.login-card__subtitle {
  color: var(--text-muted);
  font-size: var(--text-base);
  margin: 0 0 1.5rem;
  line-height: 1.45;
}

.login-card__error {
  margin-bottom: 1.15rem;
}

.login-card__error strong {
  display: block;
  margin-bottom: 0.15rem;
}

.login-card__captcha {
  min-height: 4.25rem;
}

.login-card__captcha .cf-turnstile {
  margin-block: 0.15rem;
}

.login-card__switch {
  text-align: center;
  margin-top: 1.15rem;
  margin-bottom: 0;
  font-size: var(--text-sm);
  color: var(--text-soft);
}

/* Register — choose then form */
.login-card--register .login-card__subtitle {
  margin-bottom: 0;
}

.login-card__subtitle--spaced {
  margin-bottom: 1.25rem;
}

.register-choice {
  display: grid;
  gap: 0.75rem;
}

.register-choice__card {
  appearance: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  margin: 0;
  padding: 1rem 1.05rem;
  text-align: start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.register-choice__card:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  box-shadow: var(--shadow-sm);
}

.register-choice__card:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.register-choice__card:active {
  transform: translateY(1px);
}

.register-choice__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--primary-text);
}

.register-choice__card:hover .register-choice__icon {
  background: var(--surface);
}

.register-choice__icon .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.register-choice__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.register-choice__title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.register-choice__desc {
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text-muted);
}

.register-choice__chevron {
  color: var(--text-soft);
}

.register-choice__chevron .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.register-form-head {
  margin-bottom: 1rem;
}

.register-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.65rem;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.register-back .icon {
  width: 1rem;
  height: 1rem;
}

.register-back:hover:not(:disabled) {
  color: var(--primary-text);
}

.register-back:focus-visible {
  outline: none;
  color: var(--primary-text);
  box-shadow: 0 0 0 2px var(--primary-ring);
  border-radius: var(--radius-sm);
}

.register-back:disabled {
  opacity: 0.55;
  cursor: default;
}

.register-phone {
  display: flex;
  gap: 0.55rem;
  align-items: stretch;
}

.register-phone__cc {
  flex: 0 0 10.5rem;
  max-width: 44%;
}

.register-phone__local {
  flex: 1;
  min-width: 0;
}

@media (max-width: 420px) {
  .register-phone {
    flex-direction: column;
  }

  .register-phone__cc {
    flex-basis: auto;
    max-width: none;
  }
}

.register-section {
  margin: 0;
}

.register-section__title {
  margin: 0 0 0.65rem;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.login-card--register .form-label {
  margin-bottom: 0.35rem;
  font-size: var(--text-sm);
  font-weight: 600;
}

.login-card--register .form-text {
  margin-top: 0.35rem;
  font-size: var(--text-xs);
}

.login-card--register textarea.form-control {
  min-height: 4.25rem;
  resize: vertical;
}

.register-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.register-actions--dock {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-inline: -0.15rem;
  padding-inline: 0.15rem;
  padding-bottom: 0.15rem;
  box-shadow: 0 -0.65rem 1.1rem -0.85rem rgba(15, 23, 42, 0.18);
}

html[data-theme="dark"] .register-actions--dock {
  box-shadow: 0 -0.65rem 1.1rem -0.85rem rgba(0, 0, 0, 0.45);
}

.register-actions__captcha {
  min-height: 0;
}

.register-actions__submit {
  width: 100%;
}

.register-success .login-card__subtitle {
  margin-top: 0.75rem;
}

@media (min-width: 992px) {
  /* Fixed viewport shell — only the form panel scrolls */
  .auth-layout--register {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .auth-layout--register > .auth-hero,
  .auth-layout--register > .auth-panel--register {
    min-height: 0;
    max-height: 100%;
  }

  .auth-panel--register {
    /* flex-start + margin:auto on inner: short forms stay centered, tall forms scroll from the top */
    align-items: flex-start;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-block: clamp(1.25rem, 2.5vh, 2rem);
    padding-inline: clamp(1.25rem, 2.5vw, 2rem);
  }

  .auth-panel-inner--register {
    max-width: 40rem;
    width: 100%;
    margin-block: auto;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }

  .login-card--register {
    padding: 1.25rem 1.35rem 1.15rem;
  }

  .login-card--register .login-card__error {
    margin-bottom: 0.85rem;
  }

  .login-card--register .login-card__switch {
    margin-top: 0.95rem;
  }

  .login-card--register .login-card__footer {
    margin-top: 0.85rem;
  }

  .register-choice {
    gap: 0.85rem;
  }

  .register-choice__card {
    padding: 1.1rem 1.15rem;
  }

  .register-form-head {
    margin-bottom: 0.85rem;
  }

  .register-actions {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
  }

  .register-actions__captcha {
    flex: 1;
    min-width: 0;
  }

  .register-actions__submit {
    width: auto;
    min-width: 12.5rem;
    flex-shrink: 0;
  }
}

.login-card__footer {
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 0;
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.login-card__switch + .login-card__footer {
  margin-top: 0.85rem;
}

.login-card__legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: var(--text-xs);
  color: var(--text-soft);
}

/* Password toggle */
.login-password {
  position: relative;
}

.login-password__input {
  padding-inline-end: 2.75rem;
}

.login-password__toggle {
  position: absolute;
  inset-inline-end: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.login-password__toggle:hover:not(:disabled),
.login-password__toggle:focus-visible {
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.login-password__toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.login-password__toggle:disabled {
  opacity: 0.5;
  cursor: default;
}

.login-password__toggle .icon {
  width: 1.1rem;
  height: 1.1rem;
}

/* Motion */
.auth-reveal {
  animation: auth-reveal-in 0.55s ease both;
}

.auth-reveal--1 {
  animation-delay: 0.05s;
}

.auth-reveal--2 {
  animation-delay: 0.14s;
}

.auth-reveal--3 {
  animation-delay: 0.22s;
}

@keyframes auth-reveal-in {
  from {
    opacity: 0;
    transform: translateY(0.65rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html[data-motion="reduce"] .auth-reveal {
  animation: none;
}

html[data-theme="dark"] .auth-hero__atmosphere {
  background:
    radial-gradient(ellipse 80% 60% at 12% 18%, rgba(56, 189, 248, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 45% at 88% 78%, rgba(14, 165, 233, 0.1), transparent 50%),
    linear-gradient(155deg, transparent 35%, rgba(15, 23, 42, 0.35) 100%);
}

html[data-theme="dark"] .auth-hero__atmosphere::before {
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.08) 1px, transparent 1px);
}

html[data-theme="dark"] .auth-hero__atmosphere::after {
  border-color: rgba(56, 189, 248, 0.2);
  box-shadow:
    0 0 0 28px rgba(56, 189, 248, 0.04),
    inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

/* Mobile */
@media (max-width: 991.98px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  /* Register desktop shell uses fixed height — restore normal document scroll on mobile */
  .auth-layout--register {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .auth-layout--register > .auth-panel--register {
    max-height: none;
    overflow: visible;
  }

  .auth-hero {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: flex-start;
    padding:
      max(1.25rem, env(safe-area-inset-top, 0px))
      max(1rem, env(safe-area-inset-right, 0px))
      max(1.5rem, env(safe-area-inset-bottom, 0px))
      max(1rem, env(safe-area-inset-left, 0px));
  }

  .auth-panel-inner {
    margin-block: auto;
    padding-block: 0.5rem;
  }

  .auth-mobile-brand {
    display: block;
  }

  .login-card {
    border-radius: var(--radius);
  }

  .register-actions--dock {
    position: static;
    box-shadow: none;
    margin-inline: 0;
    padding-inline: 0;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
  .auth-hero__content {
    padding: 2rem;
  }

  .auth-hero__logo-img {
    max-width: 200px;
  }
}
