﻿@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* GlitchAuth - Lens (UI) x Lattice (background). Refs: design-systems-main. */

:root {
  color-scheme: dark;

  /* Lattice tokens */
  --lx-bg: #07080b;
  --lx-bg-2: #0d0f14;
  --lx-ink: #ece7da;
  --lx-text: #ece7da;
  --lx-text-dim: #9d988c;
  --lx-text-faint: #6c685f;
  --lx-hot: #ff5a1f;
  --lx-ice: #7fd8ff;
  --lx-line: rgb(236 231 218 / 0.14);
  --lx-line-strong: rgb(236 231 218 / 0.3);
  --lx-panel: rgb(7 8 11 / 0.78);
  --lx-pitch: 9px;

  /* Lens glass tokens */
  --lens-glass-bg: linear-gradient(135deg, rgba(236,231,218,0.10), rgba(236,231,218,0.03) 58%), rgba(13, 15, 20, 0.42);
  --lens-rim: rgba(236, 231, 218, 0.20);
  --lens-rim-strong: rgba(236, 231, 218, 0.38);
  --lens-highlight: inset 0 1px 0 rgba(255,255,255,0.14), inset 1px 0 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(255,255,255,0.04);
  --lens-blur: 22px;

  --duration-fast: 160ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 280px;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--lx-bg);
  color: var(--lx-text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* The living lattice canvas sits under everything. */
.lattice-field {
  position: absolute;
  z-index: -2;
  inset: 0;
  pointer-events: none;
}

/* Background - Lattice: one lattice of bone dots on Ink Night. */

.auth-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
  background: var(--lx-bg);
}

/* The static CSS dot layer is retired: the living canvas renders the
   one true lattice (a second static layer reads as a parallax offset). */
.background-grid { display: none; }

/* A single warm signal under the panel - earned light, one only. */
.ambient {
  position: absolute;
  z-index: -3;
  width: clamp(20rem, 44vw, 44rem);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(clamp(70px, 10vw, 140px));
  opacity: 0.13;
  pointer-events: none;
}

.ambient--warm {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 90, 31, 0.55), rgba(255, 90, 31, 0) 68%);
}

/* Subtle film grain to keep the ink from banding. */
.noise {
  position: absolute;
  z-index: 3;
  inset: 0;
  opacity: 0.03;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
}

/* Panel */

.auth-panel {
  --panel-gap: clamp(22px, 3.5vh, 34px);
  display: flex;
  width: min(680px, calc(100vw - 40px));
  flex-direction: column;
  align-items: center;
  gap: var(--panel-gap);
  padding: 28px 0;
  animation: panel-enter 900ms var(--ease) both;
}

.auth-panel h1 {
  margin: 0;
  color: var(--lx-text);
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  font-weight: 800;
  letter-spacing: -0.075em;
  line-height: 1;
  text-align: center;
}

/* Input - Lens glass slab. Focus lights the rim with Signal Orange. */

.token-field {
  position: relative;
  display: block;
  width: 100%;
  min-height: 76px;
  overflow: hidden;
  border: 1px solid var(--lens-rim);
  border-radius: 26px;
  background: var(--lens-glass-bg);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.35), var(--lens-highlight);
  -webkit-backdrop-filter: blur(var(--lens-blur)) saturate(140%);
  backdrop-filter: blur(var(--lens-blur)) saturate(140%);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}

/* Directional rim highlight: narrow, off-center, like glass catching light. */
.token-field::before {
  position: absolute;
  inset: 0 22% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(236, 231, 218, 0.34), transparent);
  content: "";
  pointer-events: none;
}

.token-field:focus-within {
  border-color: rgba(255, 90, 31, 0.55);
  background-color: rgba(13, 15, 20, 0.55);
  box-shadow:
    0 24px 90px rgba(0, 0, 0, 0.4),
    0 0 0 4px rgba(255, 90, 31, 0.07),
    0 0 34px rgba(255, 90, 31, 0.10),
    var(--lens-highlight);
}

.token-field input {
  display: block;
  -webkit-user-select: text;
  user-select: text;
  width: 100%;
  min-height: 74px;
  padding: 0 30px;
  border: 0;
  outline: 0;
  color: var(--lx-text);
  background: transparent;
  font: inherit;
  font-size: clamp(1rem, 2.2vw, 1.14rem);
  font-weight: 500;
  letter-spacing: 0.005em;
  caret-color: var(--lx-hot);
}

.token-field input::placeholder { color: var(--lx-text-faint); opacity: 1; transition: color 180ms ease; }
.token-field:focus-within input::placeholder { color: rgba(157, 152, 140, 0.75); }

/* Lens: the field re-forms along the control's outline on focus -
   an optical sweep across the rim highlight. */
.token-field::after {
  position: absolute;
  inset: -40% -150%;
  background: linear-gradient(100deg, transparent 42%, rgba(255, 122, 61, 0.10) 50%, transparent 58%);
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translateX(-38%);
  transition: opacity 260ms var(--ease);
}

.token-field:focus-within::after {
  animation: lens-sheen 2.6s var(--ease) infinite;
  opacity: 1;
}

/* Turnstile wrap */

.verification-wrap {
  display: flex;
  width: 100%;
  justify-content: center;
  min-height: 65px;
  max-height: 160px;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition:
    max-height 340ms var(--ease),
    min-height 340ms var(--ease),
    margin-bottom 340ms var(--ease),
    opacity 220ms ease,
    transform 340ms var(--ease);
}

.verification-wrap.is-collapsed {
  min-height: 0;
  max-height: 0;
  margin-bottom: calc(-1 * var(--panel-gap));
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

/* Status message */

.form-message {
  min-height: 1.25rem;
  margin: -14px 0 0;
  color: rgba(255, 196, 153, 0.92);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.form-message:empty { display: none; }

/* Button - Lens glass pill. */

.submit-button {
  min-width: 144px;
  min-height: 46px;
  padding: 0 28px;
  border: 1px solid var(--lens-rim);
  border-radius: 999px;
  color: var(--lx-text);
  background: var(--lens-glass-bg);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.24), var(--lens-highlight);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms var(--ease), border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.submit-button:hover:not(:disabled) {
  border-color: var(--lens-rim-strong);
  background-color: rgba(236, 231, 218, 0.05);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3), 0 0 24px rgba(255, 90, 31, 0.08), var(--lens-highlight);
}

.submit-button:active:not(:disabled) { transform: scale(0.97); }

.submit-button:focus-visible {
  outline: 3px solid rgba(255, 90, 31, 0.85);
  outline-offset: 4px;
}

.submit-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Jelly glass: transform is driven by motion.js via --jelly-matrix
   (stretch along motion, squish across, lift while pressed). */
.submit-button, .token-field {
  transform: var(--jelly-matrix, matrix(1, 0, 0, 1, 0, 0));
  transform-origin: center;
  will-change: transform;
}
.jelly-moving { will-change: transform; }

/* Cursor halo canvas. */
.lx-cursor {
  position: fixed;
  z-index: 9999;
  inset: 0;
  pointer-events: none;
}

/* Verification status */

.verification-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 16px;
  margin: -16px 0 -8px;
  color: var(--lx-text-dim);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.015em;
  line-height: 1.4;
  text-align: center;
  transition: color 220ms ease, opacity 220ms ease;
}

.status-indicator {
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.verification-status.is-progress .status-indicator {
  background: var(--lx-hot);
  box-shadow: 0 0 0 3px rgba(255, 90, 31, 0.12);
  animation: status-pulse 1.3s ease-in-out infinite;
}

.verification-status.is-success { color: var(--lx-ice); }
.verification-status.is-failed { color: rgba(255, 135, 145, 0.94); }

.form-message { margin-top: -8px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-copyright {
  position: fixed;
  z-index: 4;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  color: var(--lx-text-faint);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes lens-sheen {
  0% { transform: translateX(-38%); }
  60%, 100% { transform: translateX(38%); }
}

@media (max-width: 520px) {
  .auth-panel { --panel-gap: 24px; width: calc(100vw - 36px); gap: var(--panel-gap); }
  .token-field, .token-field input { min-height: 66px; }
  .token-field { border-radius: 21px; }
  .token-field input { padding-inline: 21px; }
  .verification-status { margin-top: -12px; margin-bottom: -8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}


/* WebGL stage (reference lattice) */
.lx-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
  display: block;
}

/* Lens polish: stronger glass hover/focus */
.submit-button:hover:not(:disabled) {
  border-color: var(--lens-rim-strong);
  background-color: rgba(236, 231, 218, 0.09);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 0 40px rgba(255, 90, 31, 0.16), var(--lens-highlight);
}
.token-field:focus-within {
  border-color: rgba(255, 90, 31, 0.6);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 90, 31, 0.10), 0 0 44px rgba(255, 90, 31, 0.14), var(--lens-highlight);
}

/* enable drag on jelly controls */
.submit-button, .token-field { touch-action: none; }

/* disable conflicting :active transform so jelly matrix controls motion */
.submit-button:active:not(:disabled) { transform: var(--jelly-matrix, matrix(1,0,0,1,0,0)); }
