/* ==========================================================================
   Login page ??? built on the shared tokens in style.css (:root). Only this
   page loads this file, so it stays out of the weight every other page pays.
   ========================================================================== */

.authbody {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 19px;
}

.authcard {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 27px 24px 24px;
}

.authbrand {
  display: flex;
  align-items: baseline;
  gap: 7px;
  text-decoration: none;
  margin-bottom: 22px;
}
.authbrand:hover { text-decoration: none; }

.authbrand__mark {
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--navy-700);
  font-size: 14px;
}

.authbrand__text {
  font-weight: 650;
  color: var(--ink);
  font-size: 14px;
}

.authcard__title {
  font-size: 18.5px;
  margin-bottom: 4px;
}

.authcard__lede {
  margin-bottom: 18px;
}

.authalert {
  background: var(--tag-red-bg);
  color: var(--tag-red-fg);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 15px;
}

.authnotice {
  background: var(--tag-green-bg);
  color: var(--tag-green-fg);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 15px;
}

.authform {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.authfield {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
}

.authfield input {
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  background: var(--surface);
}

.authfield input:focus-visible {
  outline: 2px solid var(--navy-600);
  outline-offset: 1px;
}

.authform__submit {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
  position: relative;
  gap: 7px;
}

.authform__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 13px;
}
.authform__meta .authinline { display: contents; }

.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--navy-600);
  cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

.authcard__foot {
  margin-top: 21px;
  padding-top: 15px;
  border-top: 1px solid var(--line-2);
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: center;
}

/* ---- loading spinner: shown inside the submit button while a form with
   data-loading-form is submitting ---- */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: authspin .7s linear infinite;
}

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

.authform__submit[data-loading] { pointer-events: none; opacity: .85; }
.authform__submit[data-loading] .btn__label { visibility: hidden; }
.authform__submit[data-loading] .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -8px 0 0 -8px;
}
/* ==========================================================================
   Game-style sign-in (login route only — register keeps the classic card
   above). Layered over assets/img/bg.png with the title.png lockup and an
   intro → email → otp state machine driven by [data-state] on .login-page.
   Only transforms/opacity animate, so everything stays on the GPU.
   ========================================================================== */

.login-page {
  /* local design tokens — sampled from the bg.png / title.png artwork */
  --lg-red: #d3131d;
  --lg-red-hi: #f04844;
  --lg-red-deep: #a80f18;
  --lg-red-dark: #7a0b12;
  --lg-charcoal: #2b1618;
  --lg-cream: #fff9ee;
  --lg-gold: #ffc93c;
  --lg-ease: cubic-bezier(.22, 1, .36, 1);
}

/* Full-bleed stage: no scrolling, the artwork IS the viewport. */
.authbody--game {
  margin: 0;
  padding: 0;
  display: block;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #17090b;
}

.login-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: -2%;
  background: url("../img/bg.png") center / cover no-repeat;
  animation: loginBgSettle 12s ease-out both;
  will-change: transform;
}

/* The PHP view only adds this class after the WebP file exists. That keeps
   the original PNG as a real fallback during deployment, rather than risking
   a blank background if CSS reaches the server before conversion finishes. */
.login-page--webp .login-bg {
  background-image: url("../img/bg.webp");
}

@keyframes loginBgSettle {
  from { transform: scale(1.07); }
  to { transform: scale(1); }
}

/* Vignette darkens the edges so the cream card and title always read. */
.login-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 42%, rgba(23, 9, 11, 0) 38%, rgba(23, 9, 11, .45) 100%),
    linear-gradient(180deg, rgba(23, 9, 11, .3), rgba(23, 9, 11, 0) 28%, rgba(23, 9, 11, 0) 62%, rgba(23, 9, 11, .38));
  pointer-events: none;
}

.login-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3.4vh, 36px);
  padding: 24px;
}

/* ---- the title.png lockup ---------------------------------------------- */

.login-title {
  width: clamp(300px, 38vw, 600px);
  height: auto;
  user-select: none;
  filter: drop-shadow(0 14px 26px rgba(23, 9, 11, .5));
  transition: transform .8s var(--lg-ease);
  will-change: transform;
}

/* Intro: oversized idle pulse until the first touch anywhere; the resting
   size after that is the pre-1.5 look below. */
.login-page[data-state="intro"] .login-title {
  transform: scale(1.5);
  animation: loginTitlePulse 2.4s ease-in-out infinite;
}

@keyframes loginTitlePulse {
  0%, 100% { transform: scale(1.5); }
  50% { transform: scale(1.56); }
}

.login-page:not([data-state="intro"]) .login-title {
  transform: scale(.86) translateY(-6px);
}

/* ---- touch-to-begin invite ------------------------------------------------
   Bare text floating under the lockup — absolutely positioned so it never
   affects flow when it fades out and the card takes over. The generous gap
   clears the 1.5x-scaled artwork's overflow below its layout box. */
.login-head { position: relative; }
.login-page[data-state="intro"] { cursor: pointer; }

.login-tap {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + clamp(58px, 11vh, 104px));
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  width: 100%;
  text-align: center;
  font-size: clamp(13px, 1.25vw, 17px);
  font-weight: 800;
  letter-spacing: .32em;
  text-indent: .32em; /* rebalances the trailing tracking */
  text-transform: uppercase;
  color: var(--lg-charcoal);
  text-shadow: 0 1px 0 rgba(255, 249, 238, .5), 0 0 14px rgba(255, 249, 238, .9), 0 2px 6px rgba(23, 9, 11, .4);
  animation: loginTapBreathe 1.9s ease-in-out infinite;
  pointer-events: none;
}

.login-tap::before,
.login-tap::after {
  content: "";
  width: clamp(16px, 2.4vw, 30px);
  height: 2px;
  background: currentColor;
  box-shadow: 0 0 8px rgba(255, 249, 238, .9);
  flex: none;
}

@keyframes loginTapBreathe {
  0%, 100% { opacity: .62; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.045); }
}

/* The breathe animation owns opacity while intro runs; only once it stops
   can the fade-out transition take over. */
.login-page:not([data-state="intro"]) .login-tap {
  animation: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .45s ease, visibility 0s linear .45s;
}

/* ---- the arcade card ---------------------------------------------------- */

.login-card {
  position: relative;
  width: min(clamp(320px, 24vw, 400px), 92vw);
  background: var(--lg-cream);
  border: 3px solid var(--lg-charcoal);
  border-radius: 20px;
  padding: 22px 24px 20px;
  box-shadow:
    0 9px 0 rgba(43, 22, 24, .85),
    0 30px 60px rgba(23, 9, 11, .5);
  transition: opacity .55s ease, transform .65s var(--lg-ease);
  will-change: transform, opacity;
}

/* Riveted silver header strip — the beveled game-UI treatment. */
.login-card::before {
  content: "";
  display: block;
  height: 12px;
  margin: -22px -24px 18px;
  border-radius: 16px 16px 0 0;
  border-bottom: 3px solid var(--lg-charcoal);
  background: repeating-linear-gradient(180deg, #fbfbff 0 3px, #d7d8e2 3px 6px);
}

/* The card waits out the ~3s logo intro below the fold, then the JS state
   flip reveals it with a scale-up + translate-up. Taken clean out of flow
   while it's invisible — otherwise its reserved flex space biases the
   column's justify-content: center upward, so the title lockup never sits
   on the viewport's true vertical center during intro. */
.login-page[data-state="intro"] .login-card {
  position: absolute;
  opacity: 0;
  transform: translateY(48px) scale(.92);
  pointer-events: none;
}

/* ---- panels + state switching ------------------------------------------- */

.login-panel[hidden] { display: none; }

.login-page:not([data-state="intro"]) .login-panel:not([hidden]) {
  animation: loginPanelIn .6s var(--lg-ease) both;
}

@keyframes loginPanelIn {
  from { opacity: 0; transform: translateY(26px) scale(.94); }
  to { opacity: 1; transform: none; }
}

/* ---- inline animated messages ------------------------------------------- */

.login-messages { display: flex; flex-direction: column; gap: 8px; }
.login-messages:not(:empty) { margin-bottom: 14px; }

.login-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  animation: loginMsgIn .35s var(--lg-ease) both;
}

@keyframes loginMsgIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.login-msg--error { background: #fbdcdc; color: #b0261d; border-color: #e8a5a0; }
.login-msg--notice { background: #e2f5e9; color: #15723d; border-color: #a9d8bc; }

.is-shake { animation: loginShakeX .45s ease both !important; }

@keyframes loginShakeX {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* ---- inputs: inset-bevel game fields ------------------------------------- */

.login-input,
.login-code-native {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: clamp(14px, 1vw, 16px);
  color: var(--ink);
  padding: 12px 14px;
  background: #fff;
  border: 2px solid var(--lg-charcoal);
  border-radius: 12px;
  box-shadow: inset 0 3px 5px rgba(43, 22, 24, .14);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.login-input::placeholder { color: var(--ink-3); }

.login-input:focus-visible,
.login-code-native:focus-visible {
  outline: none;
  border-color: var(--lg-red);
  box-shadow: inset 0 3px 5px rgba(43, 22, 24, .1), 0 0 0 4px rgba(211, 19, 29, .22);
}

.login-code-native { margin: 0 0 4px; text-align: center; font-weight: 700; }

/* buildOtpBoxes() hides this field once the six boxes exist; the display
   declaration above would otherwise beat the UA's [hidden] rule. */
.login-code-native[hidden] { display: none; }

/* ---- dimensional red buttons --------------------------------------------- */

.btn-game {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  font-family: inherit;
  font-size: clamp(14px, 1.05vw, 16.5px);
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #fff7ec;
  text-shadow: 0 2px 0 rgba(74, 5, 9, .55);
  background: linear-gradient(180deg, var(--lg-red-hi) 0%, var(--lg-red) 52%, var(--lg-red-deep) 100%);
  border: 2px solid var(--lg-charcoal);
  border-radius: 14px;
  cursor: pointer;
  box-shadow:
    0 6px 0 var(--lg-red-dark),
    0 10px 18px rgba(23, 9, 11, .35),
    inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
}

.btn-game:hover { filter: brightness(1.07); }
.btn-game:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 var(--lg-red-dark),
    0 4px 8px rgba(23, 9, 11, .3),
    inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-game:focus-visible { outline: 3px solid var(--lg-gold); outline-offset: 3px; }
.btn-game:disabled { cursor: default; filter: saturate(.7) brightness(.95); }

/* Button spinner stays dormant until a real submit is in flight — author
   display declarations otherwise resurrect it over the UA's [hidden] rule. */
.btn-game .spinner[hidden] { display: none; }

.btn-game.is-loading .btn-game__label { visibility: hidden; }
.btn-game.is-loading .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
}

/* ---- 6-digit code boxes --------------------------------------------------- */

.otp-row {
  display: flex;
  justify-content: center;
  gap: clamp(6px, .55vw, 10px);
  margin: 2px 0 4px;
}

.otp-box {
  width: clamp(40px, 3.2vw, 52px);
  height: clamp(50px, 4.2vw, 64px);
  padding: 0;
  text-align: center;
  font-family: inherit;
  font-size: clamp(22px, 1.9vw, 30px);
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--lg-charcoal);
  border-radius: 12px;
  box-shadow: inset 0 3px 5px rgba(43, 22, 24, .14);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.otp-box:focus-visible {
  outline: none;
  border-color: var(--lg-red);
  box-shadow: 0 0 0 4px rgba(211, 19, 29, .22);
}

/* ---- masked-address line + resend ----------------------------------------- */

.login-maskedline {
  margin: 0 0 14px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-2);
}

.login-maskedline a { color: var(--lg-red-deep); font-weight: 700; }
.login-maskedline a:hover { color: var(--lg-red-dark); }

.login-masked {
  color: var(--lg-charcoal);
  font-weight: 800;
  letter-spacing: .02em;
}

.login-panel__meta {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.login-panel__meta form { display: contents; }

.linkbtn-game {
  background: none;
  border: none;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--lg-red-deep);
  cursor: pointer;
  text-decoration: underline dotted;
}
.linkbtn-game:hover { color: var(--lg-red-dark); }
.linkbtn-game:focus-visible { outline: 2px solid var(--lg-gold); outline-offset: 2px; }
.linkbtn-game:disabled { opacity: .6; cursor: default; }

/* ---- success flash + "code sent" interstitial ------------------------------- */

.login-panel--success,
.login-panel--sent { text-align: center; padding: 6px 0 2px; }

.login-check {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 4px auto;
  border-radius: 50%;
  background: linear-gradient(180deg, #2fd06a, #15723d);
  border: 3px solid var(--lg-charcoal);
  box-shadow: 0 5px 0 rgba(43, 22, 24, .8);
}

.login-page[data-state="success"] .login-check,
.login-page[data-state="sent"] .login-check {
  animation: loginPop .5s cubic-bezier(.34, 1.56, .64, 1) both;
}

.login-check::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 13px;
  width: 17px;
  height: 29px;
  border: solid #fff;
  border-width: 0 5px 5px 0;
  transform: rotate(45deg);
}

@keyframes loginPop {
  from { opacity: 0; transform: scale(.3); }
  to { opacity: 1; transform: scale(1); }
}

/* "Code sent" is a quick beat on the way to the OTP boxes, not a terminal
   state like success — smaller mark, label underneath, done in under a
   second so it reads as confirmation rather than a stall. */
.login-panel--sent .login-check {
  width: 52px;
  height: 52px;
}
.login-panel--sent .login-check::after {
  left: 14px;
  top: 10px;
  width: 14px;
  height: 24px;
  border-width: 0 4px 4px 0;
}

.login-sent-text {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lg-charcoal);
}

/* ---- busy chip (sending / authenticating) ----------------------------------- */

.login-busy {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(16px, 3vh, 32px);
  pointer-events: none;
}
.login-busy[hidden] { display: none; }

.login-busy__chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(23, 9, 11, .85);
  border: 2px solid rgba(255, 201, 60, .7);
  color: #ffe9c9;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  animation: loginMsgIn .3s var(--lg-ease) both;
}

.spinner--gold {
  width: 15px;
  height: 15px;
  border-width: 2px;
  border-color: rgba(255, 201, 60, .4);
  border-top-color: #ffc93c;
  flex: none;
}

/* ---- reduced motion + small-viewport fallbacks ------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .login-bg,
  .login-title,
  .login-card,
  .login-panel,
  .login-msg,
  .login-tap,
  .login-busy__chip,
  .login-page[data-state="success"] .login-check {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 640px), (max-height: 600px) {
  .authbody--game { overflow-y: auto; }
  .login-page { position: relative; inset: auto; min-height: 100vh; }
  .login-content { height: auto; min-height: 100vh; padding: 36px 16px; }
  .login-busy { position: fixed; }
}

/* The lockup, on a narrow screen.
 *
 * Its resting width has a 300px floor, and the intro state scales that to
 * 1.5x (1.56x at the top of the pulse) — 468px of artwork inside a 390px
 * phone, so the wordmark arrived cropped at both ends on the first screen
 * anybody sees. Cap the width against the viewport and open the intro at a
 * gentler scale instead of shrinking the resting size to fit the pulse: the
 * lockup still enters larger than it settles, which is the whole gesture,
 * and every letter of it is on screen.
 *
 * Width only, deliberately — the block above also fires on short landscape
 * windows, where the height is what is short and the artwork has room to be
 * its full size. */
@media (max-width: 640px) {
  .login-title { width: min(78vw, 300px); }

  .login-page[data-state="intro"] .login-title {
    transform: scale(1.12);
    animation-name: loginTitlePulseNarrow;
  }

  @keyframes loginTitlePulseNarrow {
    0%, 100% { transform: scale(1.12); }
    50% { transform: scale(1.16); }
  }

  .login-page:not([data-state="intro"]) .login-title {
    transform: scale(1) translateY(-4px);
  }

  /* The invite's own gap is left alone: it is measured from the lockup's
     layout box, not from the scaled artwork, so a smaller intro scale only
     clears it further — and where it lands is plain pavement rather than the
     busy steps a tighter gap would put it on. */
}
