/* ============================================================
   Super Hi-Fi · Auth Gate + Tuning Loader
   Themed to match the deck (ink + cream + orange dial motif).
   ============================================================ */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  background: var(--ink, #0E0E0E);
  color: var(--white, #fff);
  font-family: 'Montserrat', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* State machine via data attribute */
.auth-gate[data-state="login"]   .auth-login   { display: flex; }
.auth-gate[data-state="login"]   .auth-loading { display: none; }
.auth-gate[data-state="loading"] .auth-login   { display: none; }
.auth-gate[data-state="loading"] .auth-loading { display: flex; }
.auth-gate[data-state="done"]                  { display: none; }

/* ── Background dial (echoes the cover) ─────────────────── */
.auth-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  animation: auth-bg-in 1400ms cubic-bezier(.2,.8,.2,1) 100ms forwards;
}
.auth-bg svg {
  width: 1400px;
  height: 1400px;
  max-width: 130vmin;
  max-height: 130vmin;
}
.auth-bg-arc {
  transform-box: fill-box;
  transform-origin: center;
  animation: auth-arc-spin 90s linear infinite;
}

@keyframes auth-bg-in {
  to { opacity: 0.55; }
}
@keyframes auth-arc-spin {
  to { transform: rotate(360deg); }
}

/* Film grain over the gate */
.auth-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  background-size: 240px 240px;
  opacity: 0.06;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 1;
}
.auth-gate::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 50%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

.auth-gate > * { position: relative; z-index: 2; }

/* ── Corner mark (matches deck cover treatment) ────────── */
.auth-corner {
  position: absolute;
  top: 36px;
  left: 36px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  opacity: 0.5;
  display: flex;
  gap: 10px;
  z-index: 3;
}
.auth-corner .x { color: var(--orange, #fc8a14); opacity: 0.8; }
.auth-corner .sep { color: var(--orange, #fc8a14); opacity: 0.6; }

/* ── LOGIN PANEL ─────────────────────────────────────── */
.auth-login {
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 64px;
  opacity: 0;
  animation: auth-panel-in 700ms cubic-bezier(.2,.8,.2,1) 200ms forwards;
}
.auth-login.is-leaving {
  animation: auth-panel-out 360ms cubic-bezier(.4,0,.6,1) forwards;
}

.auth-logo {
  width: 320px;
  height: auto;
  opacity: 0.95;
  filter: drop-shadow(0 0 24px rgba(252,138,20,0.08));
}

.auth-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0.85;
}
.auth-eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange, #fc8a14);
  box-shadow: 0 0 12px rgba(252,138,20,0.7);
}
.auth-eyebrow .sep { color: var(--orange, #fc8a14); opacity: 0.7; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 26px;
  width: min(420px, 84vw);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  opacity: 0.55;
}

.auth-field input {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(245,239,228,0.22);
  color: var(--white, #fff);
  font-family: inherit;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 8px 0 10px;
  caret-color: var(--orange, #fc8a14);
  transition: border-color 220ms ease;
}
.auth-field input:focus {
  outline: none;
  border-bottom-color: var(--orange, #fc8a14);
}
.auth-field input::placeholder { color: rgba(245,239,228,0.25); }

.auth-error {
  min-height: 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ff7a55;
  text-align: center;
  margin-top: -8px;
}

.auth-submit {
  appearance: none;
  background: transparent;
  border: 0;
  margin-top: 8px;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--white, #fff);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  border-top: 1px solid rgba(245,239,228,0.18);
  border-bottom: 1px solid rgba(245,239,228,0.18);
  transition: color 220ms ease, border-color 220ms ease, padding 220ms ease;
}
.auth-submit:hover {
  color: var(--orange, #fc8a14);
  border-color: var(--orange, #fc8a14);
  padding: 16px 6px;
}
.auth-submit:focus-visible { outline: none; }
.auth-submit svg {
  width: 22px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.4;
  fill: none;
  transition: transform 240ms ease, stroke 220ms ease;
}
.auth-submit:hover svg { transform: translateX(6px); }

/* Shake on bad creds */
.auth-gate.is-shaking .auth-form {
  animation: auth-shake 480ms cubic-bezier(.36,.07,.19,.97);
}

@keyframes auth-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}

@keyframes auth-panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes auth-panel-out {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ── LOADING PANEL — "Tuning In" ──────────────────────── */
.auth-loading {
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 56px;
  padding: 64px;
  opacity: 0;
  animation: auth-panel-in 500ms ease forwards;
}

.auth-loading-eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  opacity: 0.85;
}
.auth-loading-eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange, #fc8a14);
  box-shadow: 0 0 12px rgba(252,138,20,0.7);
  animation: auth-dot-pulse 1100ms ease-in-out infinite;
}
.auth-loading.is-locked .auth-loading-eyebrow .dot {
  animation: none;
  background: var(--orange, #fc8a14);
  box-shadow: 0 0 18px rgba(252,138,20,0.9);
}

@keyframes auth-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.7); }
}

/* Frequency readout */
.auth-loading-freq {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}
.auth-loading-freq .freq-num {
  font-size: 132px;
  font-weight: 900;
  letter-spacing: -0.045em;
  color: var(--orange, #fc8a14);
  line-height: 0.9;
  text-shadow: 0 0 60px rgba(252,138,20,0.32);
}
.auth-loading-freq .freq-unit {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  opacity: 0.55;
}

/* Lock pulse — radial flare on signal acquired */
.auth-lock-pulse {
  position: absolute;
  left: 50%; top: 50%;
  width: 240px; height: 240px;
  margin: -120px 0 0 -120px;
  border-radius: 50%;
  border: 1px solid rgba(252,138,20,0.7);
  opacity: 0;
  pointer-events: none;
}
.auth-loading.is-locked .auth-lock-pulse {
  animation: auth-lock-pulse 800ms cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes auth-lock-pulse {
  0%   { transform: scale(0.4); opacity: 0.7; border-width: 2px; }
  100% { transform: scale(3.2); opacity: 0;   border-width: 1px; }
}

/* FM band rail */
.auth-loading-rail {
  position: relative;
  width: min(620px, 80vw);
  height: 64px;
}
.auth-loading-rail .rail {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(245,239,228,0.22);
  transform: translateY(-0.5px);
}
.auth-loading-rail .ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.auth-loading-rail .ticks .t {
  width: 1px;
  height: 12px;
  background: rgba(245,239,228,0.28);
}
.auth-loading-rail .ticks .t.major {
  height: 26px;
  background: rgba(245,239,228,0.55);
}
.auth-loading-rail .band-labels {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream, #F5EFE4);
  opacity: 0.45;
  pointer-events: none;
}
.auth-loading-rail .band-labels span {
  position: absolute;
  bottom: -4px;
  transform: translateX(-50%);
}
.auth-loading-rail .band-labels span:first-child { left: 0;   transform: translateX(0); }
.auth-loading-rail .band-labels span:last-child  { left: 100%; transform: translateX(-100%); }

.auth-loading-rail .needle {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 2px;
  background: var(--orange, #fc8a14);
  box-shadow: 0 0 18px rgba(252,138,20,0.85);
  animation: auth-needle 2400ms cubic-bezier(.55,.05,.25,1) forwards;
}
.auth-loading-rail .needle::before,
.auth-loading-rail .needle::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 8px; height: 8px;
  background: var(--orange, #fc8a14);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 14px rgba(252,138,20,0.85);
}
.auth-loading-rail .needle::before { top: -5px; }
.auth-loading-rail .needle::after  { bottom: -5px; }

/* Hunt across the band, overshoot, settle on 98.7 (≈53.5%) */
@keyframes auth-needle {
  0%   { left: 0%; }
  18%  { left: 92%; }
  36%  { left: 8%; }
  54%  { left: 78%; }
  70%  { left: 32%; }
  82%  { left: 62%; }
  92%  { left: 50%; }
  100% { left: 53.5%; }
}

/* Progress hairline */
.auth-loading-progress {
  position: relative;
  width: min(520px, 70vw);
  height: 1px;
  background: rgba(245,239,228,0.14);
  overflow: hidden;
}
.auth-loading-progress::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: var(--orange, #fc8a14);
  box-shadow: 0 0 12px rgba(252,138,20,0.6);
  transform-origin: 0 50%;
  transform: scaleX(0);
  animation: auth-progress 2400ms cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes auth-progress {
  0%   { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* Whole-gate exit */
.auth-gate.is-leaving {
  animation: auth-gate-out 700ms cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes auth-gate-out {
  to { opacity: 0; pointer-events: none; }
}
