/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* ── Palette ── */
  --clr-primary:        #0066ff;
  --clr-primary-light:  #4d94ff;
  --clr-primary-dark:   #0044cc;
  --clr-primary-bg:     #ebf3ff;

  --clr-bg:             #f0f4f8;
  --clr-surface:        #ffffff;
  --clr-text:           #1a2030;
  --clr-text-muted:     #6b7a90;
  --clr-border:         #dde3ec;
  --clr-border-focus:   var(--clr-primary);
  --clr-error:          #e5384f;
  --clr-error-bg:       #fdedef;
  --clr-success:        #12b76a;
  --clr-warning:        #f79009;

  /* ── Typography ── */
  --ff-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* ── Spacing ── */
  --sp-xs:  0.25rem;
  --sp-sm:  0.5rem;
  --sp-md:  1rem;
  --sp-lg:  1.5rem;
  --sp-xl:  2rem;
  --sp-2xl: 3rem;

  /* ── Radii ── */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 100px;

  /* ── Shadows ── */
  --shadow-card:
    0 4px 6px -1px rgba(0, 60, 150, 0.06),
    0 12px 24px -4px rgba(0, 60, 150, 0.08),
    0 32px 64px -8px rgba(0, 60, 150, 0.06);

  --shadow-input:
    0 1px 2px rgba(0, 40, 120, 0.04);

  --shadow-btn:
    0 4px 14px -3px rgba(0, 102, 255, 0.45);

  /* ── Transitions ── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 0.5s;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--ff-body);
  color: var(--clr-text);
  min-height: 100vh;
  background:
    linear-gradient(135deg, #e8f0fe 0%, #f0f4f8 40%, #f8f0fb 100%);
  overflow-x: hidden;
}

a {
  color: var(--clr-primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--clr-primary-dark); }

/* ============================================================
   DECORATIVE ORBS
   ============================================================ */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 18s ease-in-out infinite alternate;
}

.orb--1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #a5c8ff, transparent 70%);
  top: -120px;
  right: -80px;
  animation-duration: 20s;
}

.orb--2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #c4b5fd, transparent 70%);
  bottom: -100px;
  left: -60px;
  animation-duration: 24s;
  animation-delay: -6s;
}

.orb--3 {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, #93e9be, transparent 70%);
  top: 50%;
  left: 55%;
  animation-duration: 22s;
  animation-delay: -10s;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -40px) scale(1.08); }
  100% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ============================================================
   PORTAL (CENTERING)
   ============================================================ */
.portal {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-lg);
  position: relative;
  z-index: 1;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  width: 100%;
  max-width: 460px;
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: cardEntry 0.7s var(--ease-out) both;
}

@keyframes cardEntry {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  position: relative;
  border-bottom: 2px solid var(--clr-border);
}

.tabs__btn {
  flex: 1;
  padding: var(--sp-md) var(--sp-lg);
  font: 600 0.95rem/1 var(--ff-body);
  color: var(--clr-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s;
  position: relative;
  z-index: 1;
}

.tabs__btn--active {
  color: var(--clr-primary);
}

.tabs__indicator {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50%;
  height: 2px;
  background: var(--clr-primary);
  border-radius: 2px;
  transition: transform var(--duration) var(--ease-out);
}

.tabs__indicator--right {
  transform: translateX(100%);
}

/* ============================================================
   FORM SLIDER
   ============================================================ */
.form-viewport {
  overflow: hidden;
}

.form-slider {
  display: flex;
  width: 200%;
  transition: transform var(--duration) var(--ease-out);
}

.form-slider--signup {
  transform: translateX(-50%);
}

.form {
  width: 50%;
  padding: var(--sp-xl) var(--sp-xl) var(--sp-2xl);
  flex-shrink: 0;
}

/* ── Title / Subtitle ── */
.form__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-xs);
  color: var(--clr-text);
}

.form__subtitle {
  font-size: 0.9rem;
  color: var(--clr-text-muted);
  margin-bottom: var(--sp-xl);
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
.field {
  margin-bottom: var(--sp-lg);
}

.field__label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: var(--sp-sm);
  letter-spacing: 0.02em;
}

.field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: var(--clr-text-muted);
  pointer-events: none;
  transition: fill 0.25s;
}

.field__input {
  width: 100%;
  padding: 0.78rem 0.9rem 0.78rem 2.7rem;
  font: 400 0.92rem/1.4 var(--ff-body);
  color: var(--clr-text);
  background: var(--clr-bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-input);
  outline: none;
  transition:
    border-color 0.25s,
    background-color 0.25s,
    box-shadow 0.25s;
}

.field__input::placeholder {
  color: var(--clr-text-muted);
  opacity: 0.6;
}

.field__input:focus {
  background: var(--clr-surface);
  border-color: var(--clr-primary);
  box-shadow:
    0 0 0 3px rgba(0, 102, 255, 0.1),
    var(--shadow-input);
}

.field__input:focus ~ .field__icon,
.field__input:focus + .field__icon {
  fill: var(--clr-primary);
}

/* When the wrap has focus-within, color the icon */
.field__input-wrap:focus-within .field__icon {
  fill: var(--clr-primary);
}

/* ── Error state ── */
.field--error .field__input {
  border-color: var(--clr-error);
  background: var(--clr-error-bg);
}

.field--error .field__input:focus {
  box-shadow:
    0 0 0 3px rgba(229, 56, 79, 0.12),
    var(--shadow-input);
}

.field__error {
  display: block;
  min-height: 1.2rem;
  font-size: 0.78rem;
  color: var(--clr-error);
  padding-top: var(--sp-xs);
  transition: opacity 0.2s;
}

/* ── Success state ── */
.field--success .field__input {
  border-color: var(--clr-success);
}

/* ── Password toggle ── */
.field__toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field__toggle svg {
  width: 20px;
  height: 20px;
  fill: var(--clr-text-muted);
  transition: fill 0.2s;
}

.field__toggle:hover svg {
  fill: var(--clr-primary);
}

/* ============================================================
   PASSWORD STRENGTH METER
   ============================================================ */
.strength-meter {
  height: 4px;
  background: var(--clr-border);
  border-radius: 4px;
  margin-top: var(--sp-sm);
  overflow: hidden;
}

.strength-meter__bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.4s var(--ease-out), background-color 0.4s;
}

.strength-meter__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 4px;
  min-height: 1rem;
  transition: color 0.3s;
}

/* ============================================================
   FORM OPTIONS (remember + forgot)
   ============================================================ */
.form__options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-lg);
}

.form__link {
  font-size: 0.82rem;
  font-weight: 500;
}

/* ── Custom checkbox ── */
.checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox__mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--clr-border);
  border-radius: 5px;
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.checkbox__mark::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--clr-primary);
  transform: scale(0);
  transition: transform 0.2s var(--ease-out);
}

.checkbox input:checked + .checkbox__mark {
  border-color: var(--clr-primary);
}

.checkbox input:checked + .checkbox__mark::after {
  transform: scale(1);
}

/* ============================================================
   BUTTON
   ============================================================ */
.btn {
  width: 100%;
  padding: 0.85rem var(--sp-lg);
  font: 600 0.95rem/1 var(--ff-body);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  position: relative;
  overflow: hidden;
  transition:
    background 0.3s,
    box-shadow 0.3s,
    transform 0.15s;
}

.btn--primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-dark));
  box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--clr-primary-light), var(--clr-primary));
  box-shadow:
    0 6px 20px -4px rgba(0, 102, 255, 0.5);
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0) scale(0.99);
}

/* ── Ripple effect ── */
.btn__ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ── Loader (shown during submit) ── */
.btn__loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin 0.6s linear infinite;
}

.btn--loading .btn__text { opacity: 0.6; }
.btn--loading .btn__loader { display: inline-block; }
.btn--loading { pointer-events: none; }

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

/* ============================================================
   FORM FOOTER / SWITCH LINK
   ============================================================ */
.form__footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  margin-top: var(--sp-xl);
}

.form__switch {
  background: none;
  border: none;
  color: var(--clr-primary);
  font: 600 0.85rem var(--ff-body);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.form__switch:hover {
  color: var(--clr-primary-dark);
  text-decoration: underline;
}

/* ============================================================
   SUCCESS TOAST (shown after submit)
   ============================================================ */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--clr-surface);
  border-left: 4px solid var(--clr-success);
  border-radius: var(--radius-sm);
  padding: var(--sp-md) var(--sp-lg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--clr-text);
  opacity: 0;
  transform: translateX(40px);
  transition: all 0.4s var(--ease-out);
  z-index: 100;
  pointer-events: none;
}

.toast--visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 520px) {
  .portal {
    padding: var(--sp-md);
  }

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

  .form {
    padding: var(--sp-lg) var(--sp-md) var(--sp-xl);
  }

  .form__title {
    font-size: 1.35rem;
  }

  .tabs__btn {
    font-size: 0.88rem;
    padding: 0.85rem var(--sp-md);
  }

  .orb { display: none; }
}

@media (max-width: 380px) {
  .form {
    padding: var(--sp-md) var(--sp-sm) var(--sp-lg);
  }

  .form__options {
    flex-direction: column;
    gap: var(--sp-sm);
    align-items: flex-start;
  }
}

/* ============================================================
   PARTICLES CANVAS
   ============================================================ */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ============================================================
   CARD TILT & GLOW
   ============================================================ */
.card {
  transition:
    transform 0.15s ease-out,
    box-shadow 0.3s;
  will-change: transform;
}

.card__glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* Ensure form content sits above the glow */
.tabs,
.form-viewport {
  position: relative;
  z-index: 1;
}

/* ============================================================
   INPUT FOCUS PULSE
   ============================================================ */
.field__input-wrap {
  position: relative;
  overflow: hidden;
}

.input-pulse {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--clr-primary);
  opacity: 0.5;
  animation: inputPulse 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes inputPulse {
  0% {
    opacity: 0.5;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.04);
  }
}

/* ============================================================
   TYPEWRITER CURSOR BLINK
   ============================================================ */
.form__subtitle {
  min-height: 1.4em;
}

/* ============================================================
   RESPONSIVE – Disable heavy animations on mobile
   ============================================================ */
@media (max-width: 520px) {
  #particles-canvas {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  #particles-canvas {
    display: none;
  }
}

