/* Login page: builds on styles.css (tokens, white card). Layout from Figma
   "Login — Mood picker" (node 53:714): logo, password bar and mood picker
   centered in the white card, copyright below the card on the grey. */

:root {
  /* Grey gap above the card = grey gap below it (where the copyright sits). */
  --login-gap: max(var(--card-margin), 32px);
  --error: #c8412f;
  --terracotta: #b85c38;                       /* Greek-pottery terracotta for the empty-field nudge */
}

body.is-leaving .card { opacity: 0; transform: translateY(8px); }

/* Card fills the screen above the copyright line. */
.login-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.login {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);       /* column never grows past the card */
  place-items: center;
  margin: var(--login-gap) var(--card-side) 0;
  padding: clamp(48px, 8vw, 96px) var(--pad-left);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.login__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(430px, 100%);
  text-align: center;
}

.login__logo {
  width: clamp(172px, 23.2vw, 223px);         /* 15% bigger than Figma's 194 */
  height: auto;
}

/* Password ---------------------------------------------------------------- */

.login__form {
  width: 100%;
  margin-top: 44px;                            /* logo → bar */
  text-align: left;
}

.field {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  padding: 0 6px 0 22px;
  border-radius: 50px;
  background: var(--card);                     /* white bar; the soft shadow sets it off the card */
  box-shadow: 4px 4px 20px 4px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease, transform 0.25s ease;
}

/* Keyboard focus: a 4px black ring around the bar, only for people using
   the keyboard (login.js adds .keyboard-nav after a Tab press and removes it
   on any click or tap). Mouse and touch users never see it. */
.keyboard-nav .field:has(.field__input:focus) {
  outline: 4px solid #000;
  outline-offset: 2px;
}

/* Hover: the bar eases in a touch, like it's ready to be pressed. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .field:hover { transform: scale(0.98); }
}

.field__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 400 17px/1 var(--font-sans);
}

.field__input::placeholder { color: #6f6a68; opacity: 1; }

.field__input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 40px var(--card) inset;
}

.field__toggle {
  flex: none;
  padding: 8px 10px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--intro-text);
  font: 400 13px/1 var(--font-sans);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
}

.field__toggle:hover { color: var(--text); }

.field__submit {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, opacity 0.25s ease, width 0.3s cubic-bezier(0.22, 1, 0.36, 1), margin 0.3s ease;
}

/* The arrow only appears once something is typed (Enter still works). */
.field__input:placeholder-shown ~ .field__submit {
  width: 0;
  margin-left: -4px;                           /* hide the gap too */
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

.field__submit:hover { opacity: 0.85; }
.field__submit:active { transform: scale(0.95); }

.field__spinner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
}

.login__form.is-loading .field__arrow { opacity: 0; }
.login__form.is-loading .field__spinner { opacity: 1; animation: spin 0.8s linear infinite; }

/* Text only, no outline: red for a wrong password, terracotta for an empty one. */
.login__error {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--error);
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}

.login__error.is-hint { color: var(--terracotta); }

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

/* Mood picker: right under the password bar ---------------------------------- */

.login__mood {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 25px;                            /* bar → swatches is 60px with the error line */
  text-align: center;
}

.login__mood-text {
  margin: 12px 0 0;                            /* half the old gap, under the swatches */
  color: var(--intro-text);
  font-size: 14px;
  line-height: 1.4;
}

.moods {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Copyright: centered in the grey gap below the card, smaller and lighter
   than the card text so it stays in the background. */
.login__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--login-gap);
  padding: 0 var(--card-margin);
}

.login__footer p {
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.72;                               /* as light as it can be and still pass 4.5:1 on every light mood */
}

/* Welcome first --------------------------------------------------------- */
/* It types out in the exact center of the white card. When it fades, the
   logo, password and mood picker fade in (logo: fade and slight drop only). */
.login .welcome-flash--hero {
  position: absolute;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  z-index: 1;
  max-width: none;
  color: var(--text);
  font-size: clamp(20px, 5.4vw, 36px);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.02em;
  white-space: nowrap;
  text-align: center;
  transform: translate(-50%, -50%);
}

.login .welcome-flash--hero.is-leaving { transform: translate(-50%, calc(-50% - 8px)); }

.welcome-intro .login__logo,
.welcome-intro .login__form,
.welcome-intro .login__mood {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;                        /* can't click what isn't shown yet */
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.welcome-intro .login__logo { transform: translateY(-6px); }

/* After the welcome fades: logo first, then the password bar, then the mood picker. */
.welcome-intro.welcome-done .login__logo,
.welcome-intro.welcome-done .login__form,
.welcome-intro.welcome-done .login__mood {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.welcome-intro.welcome-done .login__logo { transition-delay: 0.35s; }
.welcome-intro.welcome-done .login__form { transition-delay: 0.85s; }
.welcome-intro.welcome-done .login__mood { transition-delay: 1.35s; }

/* Phones */
@media (max-width: 420px) {
  .field { padding-left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .login, .mood { transition: none; }
  .field__submit { transition: opacity 0.25s ease; }
  .login .welcome-flash--hero.is-leaving { transform: translate(-50%, -50%); }
}
