/* Gangplan sign-in and invitation screens. Author: Lee Alderman. Loads after app.css and uses its tokens. */

.auth-root { min-height: 100dvh; display: flex; flex-direction: column; }
.auth-root > * { flex: 1 0 auto; }
.auth-loading { display: grid; place-items: center; min-height: 100dvh; }

/* ---------- the frame (phone first: art on top, card below) ---------- */
.auth {
  position: relative; isolation: isolate; min-height: 100dvh; display: flex; flex-direction: column;
  background: radial-gradient(900px 420px at 100% 100%, color-mix(in srgb, var(--sun) 13%, transparent), transparent 70%), radial-gradient(700px 400px at 0% 70%, color-mix(in srgb, var(--accent-2) 11%, transparent), transparent 70%), var(--bg);
}
.auth-stage {
  position: relative; isolation: isolate; overflow: hidden; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  min-height: clamp(330px, 50dvh, 460px);
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 76px max(22px, env(safe-area-inset-left));
}
.auth-art { --mx: 0; --my: 0; position: absolute; inset: 0; z-index: -1; overflow: hidden; background: #27456b; }
.auth-art .poster { position: absolute; inset: 0; transform: scale(1.02); }
.auth-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 18, 24, .4) 0%, rgba(8, 18, 24, 0) 24%), linear-gradient(0deg, rgba(8, 18, 24, .84) 0%, rgba(8, 18, 24, .5) 34%, rgba(8, 18, 24, 0) 72%);
}
/* A little life in the art: the glow breathes, clouds and birds drift, the northern lights shimmer.
   art.js marks these parts with stable classes (p-glow, p-cloud, p-birds, p-aurora) for exactly this. */
.auth-art .poster .p-glow { transform-box: fill-box; transform-origin: center; animation: auth-glow 8s ease-in-out infinite; }
@keyframes auth-glow { 50% { opacity: .74; transform: scale(1.07); } }
.auth-art .poster .p-cloud { animation: auth-drift 44s ease-in-out infinite alternate; }
.auth-art .poster .p-cloud:nth-of-type(even) { animation-duration: 58s; animation-direction: alternate-reverse; }
.auth-art .poster .p-birds { animation: auth-drift 30s ease-in-out infinite alternate; }
@keyframes auth-drift { from { transform: translateX(-16px); } to { transform: translateX(24px); } }
.auth-art .poster .p-aurora { animation: auth-aurora 11s ease-in-out infinite alternate; }
.auth-art .poster .p-aurora:nth-of-type(even) { animation-duration: 15s; animation-direction: alternate-reverse; }
@keyframes auth-aurora { from { transform: translateX(-18px); } 50% { opacity: .38; } to { transform: translateX(18px); } }

.auth-top { display: flex; align-items: center; }
.auth-top .logo { color: #fff; font-size: 1.36rem; text-shadow: 0 1px 12px rgba(0, 0, 0, .35); border-radius: 10px; }
.auth-top .logo img { box-shadow: 0 4px 14px rgba(0, 0, 0, .28); }

.auth-pitch { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.auth-kicker { font-size: .78rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #ffdf9e; text-shadow: 0 1px 10px rgba(0, 0, 0, .4); }
.auth-pitch h1 {
  font: 500 clamp(2.2rem, 9.6vw, 3.5rem)/1.02 var(--display); letter-spacing: -.035em; font-variation-settings: "SOFT" 60, "WONK" 0;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .38); text-wrap: balance; overflow-wrap: anywhere;
}
.auth-pitch h1 em { display: block; font-style: italic; font-weight: 400; color: #ffdf9e; font-variation-settings: "SOFT" 100, "WONK" 1; }
.auth-pitch h1.long { font-size: clamp(2rem, 8vw, 2.8rem); }

.auth-panel { position: relative; z-index: 1; width: min(480px, 100%); margin: -52px auto 0; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
.auth-card {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 26px;
  padding: 26px 22px 22px; box-shadow: var(--shadow-3);
}
.auth-steps { display: flex; flex-direction: column; }
.auth-step { display: flex; flex-direction: column; gap: 16px; min-width: 0; animation: auth-step .5s var(--ease); }
@keyframes auth-step { from { opacity: 0; transform: translateX(16px); } }
.auth-head { display: flex; flex-direction: column; gap: 6px; }
.auth-head h2 { font: 600 1.62rem/1.14 var(--display); letter-spacing: -.02em; font-variation-settings: "SOFT" 50; text-wrap: balance; }
.auth-head p { color: var(--muted); font-size: .96rem; text-wrap: pretty; }
.auth-head p strong, .auth-note strong { color: var(--ink); font-weight: 650; }
.auth-email { overflow-wrap: anywhere; }

.auth-step input[type="email"], .auth-step input[type="text"] { min-height: 52px; padding: 13px 15px; border-radius: 14px; font-size: 1.05rem; background: color-mix(in srgb, var(--surface-2) 34%, var(--surface)); }
.auth-step input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--bad) 16%, transparent); }
.auth-step .btn.big { padding: 15px 22px; }
.auth-step .btn .icon { transition: transform .25s var(--ease); }
.auth-step .btn.primary:hover:not(:disabled) .icon { transform: translateX(3px); }
.auth .btn:disabled { cursor: default; filter: saturate(.55); opacity: .62; box-shadow: none; }
.auth .btn:disabled:active { transform: none; }
.auth .btn.busy { opacity: .9; filter: none; }
.auth .btn.busy .icon { display: none; }
.auth .btn.busy::after, .auth-spin { content: ""; display: inline-block; width: 1.05em; height: 1.05em; flex: none; border-radius: 50%; border: 2.4px solid currentColor; border-right-color: transparent; animation: auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth .link-btn { border-radius: 6px; }
.auth .link-btn:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.auth .link-btn.quiet { color: var(--muted); }

.auth-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 60%, var(--ink)); font-size: .92rem; line-height: 1.4; }
.auth-note .icon { color: var(--accent); margin-top: .12em; font-size: 1.05rem; }
.auth-msg { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; font-weight: 500; line-height: 1.4; color: var(--muted); }
.auth-msg:empty { margin-top: -16px; }
.auth-msg.bad { color: var(--bad); animation: rise .3s var(--ease); }
.auth-msg .icon { margin-top: .14em; }
.auth-wait { display: flex; gap: 9px; align-items: flex-start; font-size: .86rem; line-height: 1.4; color: var(--muted); }
.auth-wait > span:last-of-type { flex: 1 1 auto; min-width: 0; }
.auth-wait .icon, .auth-wait .auth-spin { margin-top: .16em; }
.auth-wait .link-btn { font-size: inherit; white-space: nowrap; padding: 0; }
.auth-wait:empty { margin-top: -16px; }
.auth-wait .auth-spin { color: var(--accent); width: .95em; height: .95em; border-width: 2px; }
.auth-ts { margin-top: 0; }
.auth-ts.show { margin-top: 16px; }
.auth-ts[hidden] { display: none; }

/* ---------- the code: one real field, drawn as six boxes ---------- */
.auth-code { position: relative; }
.auth-slots { display: flex; align-items: stretch; gap: 7px; }
.auth-slots i { flex: 0 0 8px; align-self: center; height: 2.5px; border-radius: 2px; background: var(--line); }
.auth-slot {
  position: relative; flex: 1 1 0; min-width: 0; height: 60px; display: grid; place-items: center; border-radius: 14px;
  border: 1.5px solid var(--line); background: color-mix(in srgb, var(--surface-2) 34%, var(--surface));
  font: 600 1.8rem/1 var(--display); font-variant-numeric: tabular-nums lining-nums; color: var(--ink);
  transition: border-color .2s, box-shadow .2s, background .2s, transform .25s var(--ease);
}
.auth-slot.filled { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); animation: auth-digit .28s var(--ease); }
@keyframes auth-digit { from { transform: scale(.86); } }
.auth-code:focus-within .auth-slot.on { border-color: var(--accent-2); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.auth-code:focus-within .auth-slot.on:not(.filled)::after { content: ""; width: 2px; height: 26px; border-radius: 2px; background: var(--accent-2); animation: auth-caret 1.1s steps(1) infinite; }
@keyframes auth-caret { 50% { opacity: 0; } }
.auth .auth-code input.auth-code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 14px;
  background: transparent; color: transparent; caret-color: transparent; box-shadow: none; outline: 0;
  font: 600 1.8rem/1 var(--display); letter-spacing: .9em; text-align: left; cursor: text;
}
.auth-code-input::selection { background: transparent; color: transparent; }
.auth-code.checking .auth-slot { animation: auth-wait 1s ease-in-out infinite; animation-delay: calc(var(--n, 0) * 80ms); }
.auth-code.checking .auth-slot:nth-of-type(2) { --n: 1; } .auth-code.checking .auth-slot:nth-of-type(3) { --n: 2; }
.auth-code.checking .auth-slot:nth-of-type(4) { --n: 3; } .auth-code.checking .auth-slot:nth-of-type(5) { --n: 4; } .auth-code.checking .auth-slot:nth-of-type(6) { --n: 5; }
@keyframes auth-wait { 50% { opacity: .5; } }
.auth-code.good .auth-slot, .auth-code.good:focus-within .auth-slot.on { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); color: var(--good); box-shadow: none; animation: auth-good .5s var(--ease) backwards; animation-delay: calc(var(--n, 0) * 45ms); }
.auth-code.good .auth-slot:nth-of-type(2) { --n: 1; } .auth-code.good .auth-slot:nth-of-type(3) { --n: 2; }
.auth-code.good .auth-slot:nth-of-type(4) { --n: 3; } .auth-code.good .auth-slot:nth-of-type(5) { --n: 4; } .auth-code.good .auth-slot:nth-of-type(6) { --n: 5; }
@keyframes auth-good { 40% { transform: translateY(-6px) scale(1.05); } }
.auth-code.shake .auth-slots { animation: auth-shake .42s cubic-bezier(.36, .07, .19, .97); }
.auth-code.shake .auth-slot { border-color: var(--bad); box-shadow: none; }
@keyframes auth-shake { 15% { transform: translateX(-7px); } 35% { transform: translateX(6px); } 55% { transform: translateX(-4px); } 75% { transform: translateX(3px); } 90% { transform: translateX(-1px); } }

.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; padding-top: 2px; }
.auth-devbox:empty { display: none; }
.auth-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 11px 13px; border-radius: 14px; border: 1.5px dashed color-mix(in srgb, var(--sun) 70%, var(--line)); background: color-mix(in srgb, var(--sun) 11%, var(--surface)); font-size: .9rem; }
.auth-dev .tag { background: var(--sun); color: #3a2500; text-transform: uppercase; letter-spacing: .06em; font-size: .66rem; }
.auth-dev p { flex: 1 1 180px; color: var(--muted); }
.auth-dev strong { font: 600 1.05rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; color: var(--ink); }

.auth-face { display: flex; }
.auth-face .avatar.big { width: 64px; height: 64px; font-size: 1.3rem; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5.5px color-mix(in srgb, var(--c) 45%, transparent), var(--shadow-2); animation: pop .5s var(--ease); }
.auth-badge { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 20px; font-size: 1.6rem; color: var(--accent); background: var(--accent-soft); }
.auth-badge.warn { color: color-mix(in srgb, var(--sun) 50%, var(--ink)); background: color-mix(in srgb, var(--sun) 24%, var(--surface)); }
.auth-whoami { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.auth-home { align-self: center; }

/* ---------- reasons (below the card on a phone) ---------- */
.auth-reasons { list-style: none; display: flex; flex-direction: column; gap: 18px; width: min(480px, 100%); margin: 0 auto; padding: 32px 26px 6px; }
.auth-reasons li { display: flex; gap: 14px; align-items: flex-start; }
.auth-reason-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; font-size: 1.2rem; color: var(--accent); background: var(--accent-soft); }
.auth-reasons li:nth-child(2) .auth-reason-icon { color: var(--coral); background: color-mix(in srgb, var(--coral) 14%, var(--surface)); }
.auth-reasons li:nth-child(3) .auth-reason-icon { color: color-mix(in srgb, var(--sun) 62%, var(--ink)); background: color-mix(in srgb, var(--sun) 22%, var(--surface)); }
.auth-reason-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.auth-reason-text strong { font: 600 1.08rem/1.25 var(--display); letter-spacing: -.005em; }
.auth-reason-text span { color: var(--muted); font-size: .93rem; }
.auth-blurb { width: min(480px, 100%); margin: 0 auto; padding: 26px 28px 0; text-align: center; color: var(--muted); font-size: .93rem; text-wrap: balance; }
.auth-blurb strong { font: 600 1rem var(--display); color: var(--ink); }
.auth-credit { margin-top: auto; padding: 30px 20px max(22px, env(safe-area-inset-bottom)); text-align: center; color: var(--faint); font-size: .84rem; }
.auth-credit span { color: var(--muted); font-weight: 600; }

/* ---------- the invitation ---------- */
.auth-invited { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 14px rgba(0, 0, 0, .5); }
.auth-invited .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
.auth-invited strong { font-weight: 700; }
.auth-facts { list-style: none; display: flex; flex-direction: column; gap: 7px; margin-top: 4px; font-weight: 550; font-size: 1rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 14px rgba(0, 0, 0, .5); }
.auth-facts li { display: flex; align-items: center; gap: 10px; }
.auth-facts .icon { opacity: .9; }
.auth-facts small { font-size: 1em; font-weight: 400; opacity: .85; }
.auth-when { margin-top: 6px; text-shadow: none; }
.auth-when .pill { font-size: .84rem; padding: 6px 13px; backdrop-filter: blur(10px) saturate(1.4); -webkit-backdrop-filter: blur(10px) saturate(1.4); }
.auth-join .auth-stage { min-height: clamp(380px, 56dvh, 500px); }

.auth-end .auth-badge { margin-bottom: 4px; }
.auth-end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }

/* ---------- entrance ---------- */
.auth.enter .auth-art .poster { animation: auth-art-in 1.8s var(--ease); }
@keyframes auth-art-in { from { transform: scale(1.14); } }
.auth.enter .auth-top { animation: fade .8s both; }
.auth.enter .auth-pitch > * { animation: rise .8s var(--ease) backwards; }
.auth.enter .auth-pitch > :nth-child(1) { animation-delay: .08s; }
.auth.enter .auth-pitch > :nth-child(2) { animation-delay: .16s; }
.auth.enter .auth-pitch > :nth-child(3) { animation-delay: .26s; }
.auth.enter .auth-panel { animation: auth-card-in .8s var(--ease) .18s backwards; }
@keyframes auth-card-in { from { opacity: 0; transform: translateY(26px) scale(.98); } }
.auth.enter .auth-reasons li { animation: rise .7s var(--ease) backwards; animation-delay: calc(.34s + var(--i, 0) * .09s); }
.auth.enter .auth-blurb, .auth.enter .auth-credit { animation: fade 1s .5s backwards; }

/* ---------- wide: the poster fills the page, message on the left, card on the right ---------- */
@media (min-width: 900px) {
  .auth {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 452px); grid-template-rows: auto minmax(0, 1fr) auto auto;
    column-gap: clamp(36px, 6vw, 110px); row-gap: 0; color: #fff; background: #16242b;
    padding: clamp(24px, 3.2vw, 44px) max(clamp(28px, 5vw, 84px), calc((100vw - 1360px) / 2)) clamp(20px, 2.6vw, 34px);
  }
  .auth-stage, .auth-join .auth-stage { display: contents; }
  .auth-art .poster { inset: -14px; transform: scale(1.03) translate(calc(var(--mx) * -16px), calc(var(--my) * -10px)); transition: transform 1.2s var(--ease); }
  .auth-scrim { background: linear-gradient(180deg, rgba(8, 18, 24, .34) 0%, rgba(8, 18, 24, 0) 20%), radial-gradient(ellipse 74% 86% at 0% 100%, rgba(8, 18, 24, .74) 0%, rgba(8, 18, 24, .46) 44%, rgba(8, 18, 24, 0) 78%), linear-gradient(0deg, rgba(8, 18, 24, .4) 0%, rgba(8, 18, 24, 0) 34%); }
  .auth-top { grid-area: 1 / 1 / 2 / 3; }
  .auth-top .logo { font-size: 1.5rem; }
  .auth-pitch { grid-area: 2 / 1; align-self: end; gap: 16px; padding-top: 40px; max-width: 720px; }
  .auth-kicker { font-size: .84rem; }
  .auth-pitch h1 { font-size: clamp(3rem, 5vw, 4.9rem); line-height: 1; }
  .auth-pitch h1.long { font-size: clamp(2.6rem, 4.4vw, 4rem); }
  .auth-panel { grid-area: 2 / 2 / 4 / 3; align-self: center; width: 100%; margin: 0; padding: 28px 0; color: var(--ink); }
  .auth-card { padding: 36px 34px 30px; border-radius: 30px; border-color: rgba(255, 255, 255, .5); background: color-mix(in srgb, var(--surface) 93%, transparent); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); box-shadow: 0 2px 6px rgba(6, 16, 22, .2), 0 30px 80px rgba(6, 16, 22, .45); }
  .auth-head h2 { font-size: 1.86rem; }
  .auth-step { gap: 18px; }
  .auth-msg:empty, .auth-wait:empty { margin-top: -18px; }
  .auth-slot { height: 66px; font-size: 2rem; border-radius: 16px; }
  .auth-slots { gap: 8px; }

  .auth-reasons { grid-area: 3 / 1; width: auto; max-width: 560px; margin: 0; padding: 30px 0 0; gap: 16px; }
  .auth-reason-icon, .auth-reasons li:nth-child(2) .auth-reason-icon, .auth-reasons li:nth-child(3) .auth-reason-icon {
    color: #fff; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .3);
    backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4);
  }
  .auth-reason-text { text-shadow: 0 1px 14px rgba(0, 0, 0, .5); }
  .auth-reason-text strong { font-size: 1.14rem; }
  .auth-reason-text span { color: rgba(255, 255, 255, .86); font-size: .97rem; }
  .auth-blurb { grid-area: 3 / 1; width: auto; max-width: 520px; margin: 0; padding: 26px 0 0; text-align: left; color: rgba(255, 255, 255, .86); font-size: .97rem; text-shadow: 0 1px 14px rgba(0, 0, 0, .5); text-wrap: pretty; }
  .auth-blurb strong { color: #fff; }
  .auth-credit { grid-area: 4 / 1 / 5 / 3; margin: 0; padding: 30px 0 0; text-align: left; color: rgba(255, 255, 255, .7); text-shadow: 0 1px 10px rgba(0, 0, 0, .5); }
  .auth-credit span { color: rgba(255, 255, 255, .92); }

  .auth-invited { font-size: 1.14rem; }
  .auth-invited .avatar.small { width: 34px; height: 34px; font-size: .76rem; }
  .auth-facts { font-size: 1.1rem; gap: 9px; margin-top: 6px; }
}
@media (min-width: 900px) and (max-height: 700px) {
  .auth-pitch h1 { font-size: clamp(2.6rem, 4.6vw, 4rem); }
  .auth-reasons { gap: 11px; padding-top: 20px; }
}

@media (prefers-color-scheme: dark) {
  .auth-art .poster { filter: brightness(.86) saturate(.96); }
  .auth-card { border-color: color-mix(in srgb, var(--line) 80%, transparent); }
  .auth-kicker, .auth-pitch h1 em { color: #ffd98a; }
}
@media (prefers-color-scheme: dark) and (min-width: 900px) {
  .auth-card { border-color: rgba(255, 255, 255, .1); background: color-mix(in srgb, var(--surface) 90%, transparent); }
}

@media (max-width: 380px) {
  .auth-card { padding: 22px 18px 20px; }
  .auth-slots { gap: 5px; }
  .auth-slot { height: 54px; font-size: 1.6rem; border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth *, .auth *::before, .auth *::after { animation: none !important; transition: none !important; }
  .auth-art .poster { transform: none !important; }
}
