/* Login — Figma: ready screens / login, password - default, mobile / login */

/* ---------- background ---------- */
.login-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--color-bg);
}

/* The photo is portrait; the design rotates it 90° and zooms in.
   --vis-w is the rendered (post-rotation) width: 4096px at a 1440×1024 frame. */
.login-bg img {
  --vis-w: max(284.45vw, 400vh);
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--vis-w) * 0.6667);
  height: var(--vis-w);
  max-width: none;
  object-fit: cover;
  transform: translate(-50%, -50%) rotate(90deg);
}

/* ---------- language switch ---------- */
.login-lang {
  position: absolute;
  top: 24px;
  right: 60px;
  z-index: 2;
}

.login-lang .lang__list {
  background: none;
}

/* ---------- layout ---------- */
.login {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 96px 24px;
}

.login__form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 56px;
  width: min(506px, 100%);
}

.login__password {
  display: flex;
  flex-direction: column;
  gap: 40px;
  width: 100%;
}

.login__copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login__name {
  margin: 0;
  font-size: 18px;
  font-weight: var(--weight-bold);
}

.login__tags {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: var(--text-body);
}

.login__diamond {
  width: 4px;
  height: 4px;
  margin: 0 1px;
  background: var(--color-lime);
  transform: rotate(45deg);
}

/* ---------- password field — Figma: components / input ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.field__box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 24px;
  border: 1px solid var(--color-white);
  border-radius: var(--radius-pill);
  transition: border-color 0.15s ease;
}

.field__box:focus-within {
  border-color: var(--color-lime);
}

.field--error .field__box {
  border-color: var(--color-orange);
}

.field__input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--color-white);
  caret-color: var(--color-white);
  font: inherit;
  font-size: 16px;
}

/* Browser autofill (saved password): keep the browser's own pale fill off
   the field when the password is shown (the background is clipped to the
   text, which is painted white). The empty animation lets login.js notice
   the autofill. */
.field__input:-webkit-autofill,
.field__input:-webkit-autofill:hover,
.field__input:-webkit-autofill:focus {
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: var(--color-white);
  caret-color: var(--color-white);
  transition: background-color 600000s 0s, color 600000s 0s;
  animation: autofill-detect 1ms;
}

@keyframes autofill-detect {
  from { opacity: 1; }
  to { opacity: 1; }
}

/* Hidden password: the real input stays (for password managers and a11y)
   but is invisible; a row of shapes is drawn on top instead of dots. */
/* opacity 0 (not just transparent text) also hides the browser's autofill
   fill and its own dots; the input still takes focus, typing and autofill. */
.field--masked .field__input {
  color: transparent;
  caret-color: transparent;
  opacity: 0;
}

.field--masked .field__input::selection {
  background: transparent;
}

.field__mask {
  position: absolute;
  left: 24px;
  right: 64px;
  top: 50%;
  display: none;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  transform: translateY(-50%);
  pointer-events: none;
}

.field--masked .field__mask {
  display: flex;
}

/* Figma shape exports (js/shapes.js), each at its own size, 8px apart. */
.mask-shape {
  flex: none;
  color: var(--color-white);
}

/* New shape pops in: grows from nothing while turning 45° into place. */
.mask-shape--new {
  animation: shape-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes shape-pop {
  from { transform: scale(0) rotate(-45deg); }
  to   { transform: scale(1) rotate(0); }
}

.field__caret {
  flex: none;
  width: 1px;
  height: 18px;
  background: var(--color-white);
  animation: caret-blink 1s steps(1) infinite;
}

.field:not(:focus-within) .field__caret {
  display: none;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* eye toggle — Figma: desktop / icon (open eye, side-eye, closed eye) */
.field__toggle {
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

/* Three states from Figma, animated between:
   open (default) → side-eye (typing while hidden: iris glances up-right)
   → closed (password shown: upper lid folds down onto the lower one). */
.eye {
  --eye-ease: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--color-white);
  overflow: visible;
}

.eye__lid--upper {
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform var(--eye-ease);
}

.eye__iris {
  transition: transform var(--eye-ease);
}

.eye__iris-shape {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform var(--eye-ease), opacity var(--eye-ease);
}

.field--has-value.field--masked .field__box:focus-within .eye__iris {
  transform: translate(2.5px, -3px);
}

.field--revealed .eye__lid--upper {
  transform: scaleY(-1);
}

.field--revealed .eye__iris-shape {
  transform: scaleY(0);
  opacity: 0;
}

/* Error: the eye turns sad — the upper lid droops (same curve count, so the
   shape morphs smoothly) and the iris slides up-right under it.
   It stays a working show/hide toggle. */
.eye__lid--upper,
.eye__opening {
  transition: transform var(--eye-ease), d 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.eye__lid--lower {
  transition: d 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.field--error .eye__lid--upper {
  d: path("M3 12.4819C3.83333 10.1486 8.02629 3.32804 13.272 7.00003C23.272 14.0001 20.9386 10.1485 21.772 12.4818");
}

.field--error .eye__lid--lower {
  d: path("M3 12.4819C3.66667 14.8152 6.5 19.4819 12.5 19.4819C18.5 19.4819 21.1053 14.8151 21.772 12.4818");
}

.field--error .eye__opening {
  d: path("M3 12.4819C3.83333 10.1486 8.02629 3.32804 13.272 7.00003C23.272 14.0001 20.9386 10.1485 21.772 12.4818C21.1053 14.8151 18.5 19.4819 12.5 19.4819C6.5 19.4819 3.66667 14.8152 3 12.4819Z");
}

/* with the password shown the eye is normally closed — in an error it opens and
   turns sad too, the same as with the password hidden */
.field--error.field--revealed .eye__lid--upper {
  transform: none;
}

.field--error.field--revealed .eye__iris-shape {
  transform: none;
  opacity: 1;
}

/* the iris drops down-left; the opening clips it against the lower lid */
.field--error .field__box .eye .eye__iris {
  transform: translate(-5.1px, 3.64px);
  transition-duration: 0.4s;
}

/* helper / error text */
.field__help {
  padding: 0 24px;
  font-size: var(--text-helper);
}

/* the underline is always there but transparent, and fades in on hover */
.field__link {
  font-weight: var(--weight-bold);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px; /* 4px below the baseline (Satoshi's default sits ≈ on it) */
  transition: text-decoration-color 0.3s ease;
  cursor: copy;
}

.field__link:hover,
.field__link:focus-visible {
  text-decoration-color: currentColor;
}

/* error text stays white (orange on the sky is unreadable); the orange
   field border and the surprised eye carry the error */

/* ---------- mobile — Figma: mobile / login (375×812) ---------- */
@media (max-width: 767px) {
  .login-bg img {
    /* the mobile frame uses a tighter crop, shifted right, with a slight blur */
    width: 581.6vw;
    height: 872.3vw;
    filter: blur(1px);
    transform: translate(calc(-50% + 102.9vw), -50%) rotate(90deg);
  }

  .login-lang {
    top: 44px;
    right: 24px;
  }

  .login {
    display: block;
    padding: max(120px, 35.7dvh) var(--gutter-mobile) 48px;
  }

  .login__form {
    align-items: flex-end;
    gap: 40px;
    width: 100%;
  }

  .login__password {
    gap: 32px;
  }

  .login__tags {
    font-size: 16px;
  }

  .field {
    gap: 12px;
  }

  .field__input {
    font-size: 16px; /* 16px keeps iOS from zooming into the field */
  }

  /* 48×48 tap area around the 20px eye; the negative margin keeps the eye where it was */
  .field__toggle {
    width: 48px;
    height: 48px;
    margin: -14px;
  }

  /* "Get in touch." — taller tap area, same look */
  .field__link {
    display: inline-block;
    padding: 14px 0;
    margin: -14px 0;
  }

  .eye {
    width: 20px;
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field__caret,
  .mask-shape--new { animation: none; }

  .eye__opening,
  .eye__lid--upper,
  .eye__lid--lower,
  .eye__iris,
  .eye__iris-shape { transition: none; }
}
