/* ==========================================================================
   MyPlace — sign in, register, password reset, account
   The sign-in page: a frosted card over a tilted collage of Chișinău
   photographs, rows drifting slowly in alternate directions.
   ========================================================================== */

.auth-page {
  --card-w: 452px;
  --tile: clamp(240px, 23vw, 380px);
  --gap: clamp(16px, 1.8vw, 28px);
  --drift: 210s;
  --cream: #efe4d6;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 0;
  background: var(--cream);
  color: var(--text);
}
.auth-page main { position: relative; z-index: 2; }

/* Background ----------------------------------------------------------------------
   Warm morning light, the drifting photographs, then a soft haze that melts them
   into the light at the edges. Every visual effect is static: the colour, blur
   and glow are in the image files (tools/build_collage.py) and the light and
   haze are plain gradients, so while the rows drift the browser only moves
   ready-made layers (transform, on the compositor) and never recomputes a blur
   or a filter, and never fetches or swaps an image. */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 55% 45% at 82% 6%, rgb(255 226 186 / .7), rgb(255 226 186 / 0) 70%),
    radial-gradient(ellipse 60% 50% at 12% 96%, rgb(226 196 166 / .55), rgb(226 196 166 / 0) 70%),
    linear-gradient(160deg, #f6ede2 0%, #efe3d4 45%, #e8d7c4 100%);
}
.collage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
.collage__plane {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: var(--gap);
  transform: translate(-50%, -50%) rotate(-9deg);
}
.collage__row { contain: layout style; }
.collage__track {
  display: flex;
  gap: var(--gap);
  width: max-content;
  /* Rows start at different points of the loop, so their tiles never line up. */
  animation: drift-left calc(var(--drift) + var(--row) * 14s) linear calc(var(--row) * -12s) infinite;
  will-change: transform;
  backface-visibility: hidden;
}
.collage__row--right .collage__track { animation-name: drift-right; }
.collage.is-paused .collage__track { animation-play-state: paused; }  /* while the page isn't visible */
/* Each row is two copies of its photos; a loop moves it by exactly one copy
   (half the track plus half a gap), centred on the screen, so the row always
   reaches past both edges and never runs out, and the loop's end looks exactly
   like its start. */
@keyframes drift-left {
  from { transform: translate3d(calc(25% + var(--gap) / 4), 0, 0); }
  to { transform: translate3d(calc(-25% - var(--gap) / 4), 0, 0); }
}
@keyframes drift-right {
  from { transform: translate3d(calc(-25% - var(--gap) / 4), 0, 0); }
  to { transform: translate3d(calc(25% + var(--gap) / 4), 0, 0); }
}

.collage__tile {
  position: relative;
  flex: none;
  margin: 0;                         /* figures come with default margins */
  width: var(--tile);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: clamp(18px, 1.9vw, 30px);
  background: #dcc7b1;               /* the tile's own warm tone until its photo is there */
  box-shadow: 0 18px 36px -20px rgb(86 58 30 / .5), 0 2px 8px -2px rgb(86 58 30 / .12);
}
.collage__tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Only as many tiles as the screen needs: a copy must reach across it. The ones
   left out are lazy images, so a screen that hides them never fetches them. */
@media (max-width: 1600px) {
  .collage__tile:nth-child(7n+6),
  .collage__tile:nth-child(7n) { display: none; }
}
@media (min-width: 1601px) and (max-width: 2200px) {
  .collage__tile:nth-child(7n) { display: none; }
}

.auth-shade {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* The photographs melt into the warm light towards the edges; the card stays
     the focus. A still gradient over the moving rows: nothing to recompute. */
  background:
    radial-gradient(ellipse 72% 78% at 50% 50%, rgb(239 228 214 / 0) 52%, rgb(239 228 214 / .55) 82%, rgb(239 228 214 / .88) 100%),
    linear-gradient(180deg, rgb(246 237 226 / .35), rgb(246 237 226 / 0) 18%, rgb(246 237 226 / 0) 82%, rgb(232 215 196 / .4));
}

@media (prefers-reduced-motion: reduce) {
  .collage__track { animation: none; }
}

/* Top bar: back to the site, language. */
.auth-top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
}
.auth-top__home,
.auth-top .lang__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border: 1px solid rgb(255 255 255 / .22);
  border-radius: 999px;
  background: rgb(38 31 24 / .6);      /* still glass: no blur recomputed behind it while the rows move */
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .18s var(--ease);
}
.auth-top .lang__toggle { padding: 0 12px 0 14px; }
.auth-top__home:hover,
.auth-top .lang__toggle:hover { background: rgb(38 31 24 / .72); }
.auth-top .lang__chevron { color: rgb(255 255 255 / .75); }
.auth-top__home:focus-visible,
.auth-top .lang__toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* The card ---------------------------------------------------------------------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 84px 24px 64px;
}
.auth-card {
  position: relative;
  width: min(100%, var(--card-w));
  padding: 50px 48px 40px;
  border: 1px solid rgb(255 255 255 / .7);
  border-radius: 36px;
  /* Frosted glass: the same white over the photographs' colours, blurred. The
     blur is in the image (frost.webp, tools/build_collage.py), so nothing behind
     the card is re-blurred on every frame of the drifting rows. */
  background: linear-gradient(180deg, rgb(255 255 255 / .86), rgb(247 247 248 / .8)), var(--frost, none) center / cover, #f2ece5;
  box-shadow: 0 50px 110px -30px rgb(0 0 0 / .7), 0 1px 0 rgb(255 255 255 / .9) inset;
  color: var(--ink);
}
.auth-card__logo {
  display: block;
  width: 148px;
  margin: 0 auto;
  border-radius: 8px;
}
.auth-card__logo img { display: block; width: 100%; height: auto; }
.auth-card__logo:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; }
.auth-card__tagline {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14.5px;
  text-align: center;
}
.auth-card__title {
  margin-top: 30px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.015em;
  text-align: center;
}
.auth-card__text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}
.auth-card__badge {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 30px auto 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
}
.auth-card__badge + .auth-card__title { margin-top: 16px; }

.auth-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 22px;
  padding: 11px 14px;
  border-radius: 12px;
  background: #ecf7f0;
  color: #17633a;
  font-size: 14px;
  line-height: 1.4;
}
.auth-notice .icon { flex: none; margin-top: 1px; }
.auth-alert {
  margin-top: 22px;
  padding: 11px 14px;
  border-radius: 12px;
  background: #fdeeec;
  color: #b42318;
  font-size: 14px;
  line-height: 1.4;
}

/* Tabs */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 32px;
  border-bottom: 1px solid rgb(15 17 20 / .1);
}
.auth-tabs__tab {
  padding: 4px 8px 12px;
  color: #8a8e96;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -.01em;
  text-align: center;
  transition: color .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.auth-tabs__tab:hover { color: var(--ink); }
.auth-tabs__tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.auth-tabs__tab:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 8px; }
.auth-tabs__line {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 50%;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform .32s var(--ease);
}
.auth-tabs:has([data-auth-tab="register"][aria-selected="true"]) .auth-tabs__line { transform: translateX(100%); }

/* Forms */
.auth-panels { position: relative; }
.auth-form { display: grid; }
.auth-form[hidden] { display: none; }
.auth-form > .auth-field:first-of-type,
.auth-alert + .auth-field { margin-top: 24px; }
.auth-alert[hidden] + .auth-field { margin-top: 24px; }
.auth-field + .auth-field,
.auth-field__error + .auth-field,
.auth-field__hint + .auth-field { margin-top: 18px; }

.auth-field {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-field__icon {
  position: absolute;
  left: 17px;
  color: #3b3f46;
  pointer-events: none;
}
.auth-field__input {
  width: 100%;
  height: 52px;
  padding: 0 16px 0 51px;
  border: 1px solid #e1e2e6;
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  box-shadow: 0 1px 2px rgb(15 17 20 / .03);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.auth-field__input::placeholder { color: #8a8e96; opacity: 1; }
.auth-field__input:hover { border-color: var(--line-strong); }
.auth-field__input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgb(15 17 20 / .08); }
.auth-field:has(.auth-field__toggle) .auth-field__input { padding-right: 52px; }
.auth-field.is-invalid .auth-field__input { border-color: #d92d20; }
.auth-field.is-invalid .auth-field__input:focus { box-shadow: 0 0 0 3px rgb(217 45 32 / .12); }
.auth-field--readonly .auth-field__input { background: var(--surface-muted); color: var(--muted); }
.auth-field__toggle {
  position: absolute;
  right: 4px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #3b3f46;
  cursor: pointer;
}
.auth-field__toggle:hover { color: var(--ink); background: var(--surface-hover); }
.auth-field__toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
.auth-field__eye-off,
.auth-field__toggle[aria-pressed="true"] .auth-field__eye { display: none; }
.auth-field__toggle[aria-pressed="true"] .auth-field__eye-off { display: block; }
.auth-field__error,
.auth-field__hint { margin: 6px 2px 0; font-size: 13px; line-height: 1.35; }
.auth-field__error { color: #b42318; }
.auth-field__hint { color: var(--muted); }

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 14px;
}
.auth-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}
.auth-check input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; }
.auth-check__box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid #c4c7cd;
  border-radius: 5px;
  background: #fff;
  color: #fff;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.auth-check__box .icon { opacity: 0; transition: opacity .12s var(--ease); }
.auth-check input:checked + .auth-check__box { border-color: var(--ink); background: var(--ink); }
.auth-check input:checked + .auth-check__box .icon { opacity: 1; }
.auth-check input:focus-visible + .auth-check__box { outline: 2px solid var(--ink); outline-offset: 2px; }
.auth-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.auth-link:hover { text-decoration-thickness: 2px; }

.auth-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  margin-top: 22px;
  border: 0;
  border-radius: 12px;
  background: #121519;
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgb(15 17 20 / .6);
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.auth-submit:hover { background: #24282f; }
.auth-submit:active { transform: scale(.99); }
.auth-submit:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.auth-submit__arrow { transition: transform .2s var(--ease); }
.auth-submit:hover .auth-submit__arrow { transform: translateX(3px); }
.auth-submit__spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgb(255 255 255 / .35);
  border-top-color: #fff;
  border-radius: 999px;
  opacity: 0;
}
.auth-submit.is-busy { pointer-events: none; }
.auth-submit.is-busy .auth-submit__label,
.auth-submit.is-busy .auth-submit__arrow { opacity: 0; }
.auth-submit.is-busy .auth-submit__spinner { opacity: 1; animation: spin .8s linear infinite; }
.auth-submit--link { margin-top: 26px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 20px;
  color: #6b6f77;
  font-size: 14px;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: rgb(15 17 20 / .1); }
.auth-social {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 92px));
  justify-content: center;
  gap: 20px;
}
.auth-social__button {
  display: grid;
  place-items: center;
  height: 58px;
  padding: 0;
  border: 1px solid #ececef;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(15 17 20 / .04), 0 6px 16px -10px rgb(15 17 20 / .2);
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.auth-social__button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.auth-social__button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.auth-switch {
  margin-top: 26px;
  color: #3b3f46;
  font-size: 14.5px;
  text-align: center;
}
.auth-switch a {
  margin-left: 4px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Tab change: the new form fades in while the card eases to its height. */
.auth-form.is-entering { animation: auth-enter .32s var(--ease); }
@keyframes auth-enter { from { opacity: 0; transform: translateY(6px); } }

/* Laptop-height screens: a little less air, so the register form fits too. */
@media (min-width: 600px) and (max-height: 960px) {
  .auth { padding-top: 72px; padding-bottom: 40px; }
  .auth-card { padding-top: 40px; padding-bottom: 32px; }
  .auth-tabs { margin-top: 26px; }
  .auth-form > .auth-field:first-of-type,
  .auth-alert + .auth-field,
  .auth-alert[hidden] + .auth-field { margin-top: 20px; }
  .auth-field + .auth-field,
  .auth-field__error + .auth-field,
  .auth-field__hint + .auth-field { margin-top: 14px; }
  .auth-submit { margin-top: 20px; }
  .auth-divider { margin: 22px 0 16px; }
  .auth-switch { margin-top: 20px; }
}

/* Phones: smaller tiles, the card fills the width. */
@media (max-width: 599px) {
  .auth-page { --tile: 180px; --gap: 12px; --drift: 120s; }
  /* Four tiles of each row reach across a phone. */
  .collage__tile:nth-child(7n+5) { display: none; }
  .auth-top { padding: 12px 16px; }
  .auth-top__home span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .auth-top__home { width: 40px; padding: 0; justify-content: center; }
  .auth { padding: 68px 16px 72px; place-items: start center; }
  .auth-card { padding: 34px 22px 28px; border-radius: 28px; }
  .auth-card__logo { width: 120px; }
  .auth-card__tagline { font-size: 14px; }
  .auth-tabs { margin-top: 26px; }
  .auth-tabs__tab { font-size: 17px; }
  .auth-social { gap: 12px; }
  .collage__tile { border-radius: 16px; box-shadow: 0 12px 24px -14px rgb(86 58 30 / .5), 0 1px 4px -1px rgb(86 58 30 / .12); }
}
@media (max-width: 359px) {
  .auth-card { padding: 30px 16px 24px; }
  .auth-row { flex-wrap: wrap; gap: 0 12px; }
}
