/* ══════════════════════════════════════════════════════════════════════════
   auth.css — sign in and create account.

   Self-contained, like landing.css: login.html and signup.html load this
   file alone, so nothing here reaches the signed-in app and nothing there
   reaches these two screens.

   Layout: one centred glass card over the full-bleed sunset, with drifting
   embers and a slow push-in on the photo. The card is dark enough that no
   input ever sits directly on the picture.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --ink-900: #070403;
  --ink-850: #0b0705;
  --ink-800: #100b08;

  --ember: #ff8a1f;
  --ember-hi: #ffb454;
  --ember-deep: #f2560f;
  --gold: #ffd6a0;

  --text: #f9f1ea;
  --text-2: #d3c0b2;
  --muted: #a89284;
  --faint: #917e70;   /* lifted for contrast: it carries hint and meta text */

  --line: rgba(255, 228, 206, .10);
  --line-2: rgba(255, 228, 206, .17);
  --glass: rgba(255, 238, 222, .04);
  --glass-2: rgba(255, 238, 222, .07);

  --danger: #ff8f8f;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;

  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --photo: url("bg-sunset.png");
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.035em;
}
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

::selection { background: rgba(255, 138, 31, .32); color: #fff; }
:focus-visible { outline: 2px solid var(--ember-hi); outline-offset: 3px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════
   SHELL
   One centred card over the full-bleed sunset. Nothing on the sides: the
   photograph is the setting, the card is the only thing to look at.
   ══════════════════════════════════════════════════════════════════════════ */

/* The photograph, on its own fixed layer — share-page dimming wash, no
   drift, grain, embers, or bloom stacked on top of it. */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: var(--ink-900);
  background-image:
    linear-gradient(180deg,
      rgba(8, 4, 3, .48) 0%,
      rgba(8, 4, 3, .20) 30%,
      rgba(8, 4, 3, .34) 62%,
      rgba(8, 4, 3, .70) 100%),
    radial-gradient(1150px 760px at 50% 44%,
      rgba(10, 6, 5, .16) 0%, rgba(10, 6, 5, .34) 60%, rgba(10, 6, 5, .60) 100%),
    var(--photo);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  animation: none;
}
/* Scrim removed — plain photo only. */
.auth-bg::after {
  content: none;
  display: none;
}
/* Grain removed — plain photo only. */
body.auth-page::after {
  content: none;
  display: none;
}

/* Embers removed — plain photo only. */
.embers,
.embers span {
  display: none !important;
  animation: none !important;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(24px, 6vh, 64px) 20px;
}

.auth-panel {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 22px;
  width: 100%;
  max-width: 460px;
}
/* Card glow removed — plain photo only. */
.auth-panel::before {
  content: none;
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .10em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  color: #2b1403;
  background: linear-gradient(145deg, var(--ember-hi), var(--ember-deep));
  box-shadow: 0 6px 18px -8px rgba(255, 138, 31, .95),
              0 1px 0 rgba(255, 255, 255, .4) inset;
  transition: transform .5s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand-tld { color: var(--ember); }

.auth-card {
  position: relative;
  z-index: 1;
  align-self: center;
  width: 100%;
  max-width: 460px;
  padding: clamp(28px, 3.4vw, 40px);
  border: 1px solid var(--line-2);
  border-radius: 26px;
  /* Dark glass: the photograph shows through as colour and light only, so
     every field and label keeps full contrast. */
  background:
    linear-gradient(170deg, rgba(255, 238, 222, .06), rgba(255, 238, 222, .015)),
    rgba(12, 7, 5, .74);
  backdrop-filter: blur(24px) saturate(1.25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .08) inset,
    0 60px 120px -50px rgba(0, 0, 0, .95),
    0 0 90px -40px rgba(255, 138, 31, .75);
  animation: card-in 1s var(--ease) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(22px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
/* Ember hairline across the top edge of the card. */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 168, 90, .8), transparent);
}

/* The brand sits at the top of the card, centred. */
.auth-brand { display: flex; width: fit-content; margin: 0 auto 24px; }

/* A point of light that travels round the card's edge. The angle is a
   registered property so it can animate; without @property support the ring
   simply stays still, which is a fine fallback. */
@property --ring {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.auth-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--ring),
    transparent 0deg, transparent 250deg,
    rgba(255, 180, 84, .85) 320deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  pointer-events: none;
  animation: ring 7s linear infinite;
}
@keyframes ring { to { --ring: 360deg; } }

/* The card's contents arrive in sequence after the card itself. */
.auth-card > * { animation: rise .7s var(--ease) both; }
.auth-card > :nth-child(1) { animation-delay: .18s; }
.auth-card > :nth-child(2) { animation-delay: .24s; }
.auth-card > :nth-child(3) { animation-delay: .30s; }
.auth-card > :nth-child(4) { animation-delay: .36s; }
.auth-card > :nth-child(5) { animation-delay: .42s; }
.auth-card > :nth-child(6) { animation-delay: .48s; }
.auth-card > :nth-child(7) { animation-delay: .54s; }
.auth-card > :nth-child(8) { animation-delay: .60s; }
.auth-card > :nth-child(n+9) { animation-delay: .66s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.panel-foot { animation: rise .8s var(--ease) .7s both; }

/* ── segmented switch between the two screens ────────────────────────── */

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
}
.seg a {
  padding: 9px 10px;
  border-radius: 999px;
  text-align: center;
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .3s var(--ease), background-color .35s var(--ease);
}
.seg a:hover { color: var(--text); }
.seg a[aria-current="page"] {
  color: #2b1403;
  background: linear-gradient(180deg, var(--ember-hi), var(--ember));
  box-shadow: 0 6px 18px -10px rgba(255, 138, 31, .95);
}

.card-head { margin-bottom: 24px; }
.card-head h1 { font-size: 1.72rem; }
.card-head .sub { margin-top: 8px; color: var(--muted); font-size: .95rem; }

/* ── the error banner ───────────────────────────────────────────────────
   login.js / signup.js write textContent into this node, so it must carry
   no child elements: the icon is drawn with ::before. */
.alert {
  display: none;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 143, 143, .34);
  border-radius: var(--r);
  background: rgba(255, 90, 90, .10);
  color: #ffc7c7;
  font-size: .9rem;
  line-height: 1.5;
}
.alert.show { display: flex; animation: shake .45s var(--ease); }
.alert::before {
  content: "!";
  display: grid;
  place-items: center;
  flex: none;
  width: 18px; height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(255, 143, 143, .22);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
}
@keyframes shake {
  0%, 100%  { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  50%       { transform: translateX(4px); }
  75%       { transform: translateX(-2px); }
}

/* ── fields ──────────────────────────────────────────────────────────── */

/* Roomy enough that a hint or the strength meter reads as belonging to the
   field above it rather than to the one below. */
.field { margin-bottom: 18px; }
.field[hidden] { display: none; }

/* The box is what the label is positioned against; the hint can then sit
   outside it without dragging the floating label down with it. */
.field-box {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: rgba(0, 0, 0, .28);
  transition: border-color .3s var(--ease), background-color .3s var(--ease),
              box-shadow .3s var(--ease);
}
.field-box:hover { border-color: rgba(255, 228, 206, .26); }
.field-box:focus-within {
  border-color: rgba(255, 168, 90, .60);
  background: rgba(0, 0, 0, .40);
  box-shadow: 0 0 0 3px rgba(255, 138, 31, .14),
              0 0 36px -20px rgba(255, 138, 31, .9);
}

.field input {
  width: 100%;
  height: 62px;
  padding: 22px 46px 6px 46px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .98rem;
  outline: none;
}
.field input:-webkit-autofill {
  /* Chrome paints its own near-white fill over the field; a long inset
     shadow is the only way to keep the dark surface. */
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #140d09 inset;
  caret-color: var(--text);
}

.field label {
  position: absolute;
  left: 46px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .98rem;
  pointer-events: none;
  transition: transform .26s var(--ease), font-size .26s var(--ease), color .26s var(--ease);
  transform-origin: left center;
}
/* Floated once the field has focus or content. `:placeholder-shown` is why
   every input carries placeholder=" ". */
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-21px);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--gold);
}

.field-ico {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
  transition: color .3s var(--ease);
}
.field-box:focus-within .field-ico { color: var(--ember); }

.field-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: color .25s var(--ease), background-color .25s var(--ease);
}
.field-eye:hover { color: var(--text); background: rgba(255, 238, 222, .07); }
.field-eye .eye-closed { display: none; }
.field-eye[aria-pressed="true"] .eye-open { display: none; }
.field-eye[aria-pressed="true"] .eye-closed { display: block; }

.hint {
  margin: 7px 2px 0;
  font-size: .78rem;
  color: var(--faint);
}

/* The authenticator field is revealed by login.js, so it gets its own
   entrance — it must read as a second step, not as a field that was always
   there and somehow missed. */
#totpField:not([hidden]) { animation: step-in .5s var(--ease) both; }
#totpField input { letter-spacing: .34em; font-family: var(--font-mono); }
@keyframes step-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* ── buttons ─────────────────────────────────────────────────────────── */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 50px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: .98rem;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease),
              background-color .3s var(--ease), border-color .3s var(--ease), opacity .3s;
}
.btn-block { display: flex; width: 100%; }

.btn-primary {
  margin-top: 8px;
  color: #2b1403;
  background: linear-gradient(180deg, var(--ember-hi), var(--ember) 58%, #f87a10);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .45) inset,
    0 12px 32px -16px rgba(255, 138, 31, .95);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .55) inset,
    0 20px 46px -18px rgba(255, 138, 31, 1);
}
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -120%;
  width: 60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg);
  transition: left .7s var(--ease);
}
.btn-primary:hover:not(:disabled)::after { left: 130%; }

.btn-ghost {
  color: var(--text);
  background: var(--glass);
  border-color: var(--line-2);
}
.btn-ghost:hover { background: var(--glass-2); border-color: rgba(255, 168, 90, .40); }

.btn:disabled { opacity: .72; cursor: default; }

.cta-arrow { transition: transform .35s var(--ease); }
.btn:hover:not(:disabled) .cta-arrow { transform: translateX(3px); }

/* Busy state: the arrow gives way to a spinner, set by aria-busy in the
   page scripts. The label keeps its place so the button does not resize. */
.spinner {
  display: none;
  width: 17px; height: 17px;
  border: 2px solid rgba(43, 20, 3, .3);
  border-top-color: #2b1403;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn[aria-busy="true"] .spinner { display: block; }
.btn[aria-busy="true"] .cta-arrow { display: none; }

/* Discord keeps its own colour: it is a recognised button, and dressing it
   in ember would make it look like our primary action. */
.btn-discord {
  margin-top: 0;
  color: #e7e9ff;
  background: rgba(88, 101, 242, .16);
  border-color: rgba(88, 101, 242, .42);
}
.btn-discord:hover {
  background: rgba(88, 101, 242, .26);
  border-color: rgba(88, 101, 242, .7);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px -20px rgba(88, 101, 242, 1);
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 24px 0 20px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: "";
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
}

.auth-foot {
  margin-top: 22px;
  text-align: center;
  font-size: .92rem;
  color: var(--muted);
}
.auth-foot a {
  color: var(--gold);
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 214, 160, .34);
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.auth-foot a:hover { color: #fff; border-color: #fff; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  width: 100%;
  justify-content: center;
  font-size: .86rem;
  color: var(--faint);
  transition: color .3s var(--ease);
}
.back-link:hover { color: var(--text-2); }
.back-link svg { transition: transform .35s var(--ease); }
.back-link:hover svg { transform: translateX(-3px); }

.panel-foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 460px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: .78rem;
  color: var(--faint);
  text-align: center;
}
.panel-foot a {
  color: var(--muted);
  transition: color .3s var(--ease);
}
.panel-foot a:hover { color: var(--text-2); }

.legal {
  margin-top: 20px;
  text-align: center;
  font-size: .76rem;
  line-height: 1.6;
  color: var(--faint);
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   The layout is already a single centred column; small screens only need a
   tighter card.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 420px) {
  .auth-card { padding: 24px 20px; border-radius: 22px; }
  .card-head h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .embers { display: none; }
  .auth-bg { animation: none; }
  .auth-card > *, .panel-foot { opacity: 1 !important; transform: none !important; }
  /* The busy spinner is status, not decoration: it keeps turning. */
  .btn[aria-busy="true"] .spinner {
    animation: spin .8s linear infinite !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   PASSWORD STRENGTH METER (signup only)
   Advisory, never blocking: the server owns the actual rule (8 characters
   minimum) and this only tells you how much better than that you have done.
   Revealed by signup.js on first keystroke.
   ══════════════════════════════════════════════════════════════════════════ */

.meter {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 9px 2px 0;
  animation: step-in .35s var(--ease) both;
}
.meter[hidden] { display: none; }

.meter-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 238, 222, .10);
  overflow: hidden;
}
.meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--danger);
  transition: width .45s var(--ease), background-color .45s var(--ease);
}
.meter-label {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color .35s var(--ease);
}

.meter[data-level="1"] .meter-fill { width: 25%;  background: #ff7a7a; }
.meter[data-level="2"] .meter-fill { width: 50%;  background: #ffb454; }
.meter[data-level="3"] .meter-fill { width: 78%;  background: #ffd24d; }
.meter[data-level="4"] .meter-fill { width: 100%; background: #6ee7a8; }
.meter[data-level="1"] .meter-label { color: #ff9a9a; }
.meter[data-level="2"] .meter-label { color: var(--ember-hi); }
.meter[data-level="3"] .meter-label { color: #ffd98a; }
.meter[data-level="4"] .meter-label { color: #8ef0bd; }

/* Wordmark only — no icon, set in Outfit 800, lowercase. */
.brand-text {
  font-family: "Outfit", var(--font-display);
  font-weight: 800;
  text-transform: lowercase;
  letter-spacing: -.01em;
  font-size: 1.3rem;
}
