/* ============================================================
   CLARITY — Gate Overlay Stylesheet
   clarity.nexirt.com / clarity-gate.css
   Tokens from clarity.css — do NOT import; they share :root.
   ============================================================ */

/* ── Gate overlay (full-viewport fixed, above everything) ──── */
#clarity-gate[data-clarity-gate] {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0A0B10;
  transition: opacity 400ms ease;
  overflow: hidden;
}

#clarity-gate[data-clarity-gate].gate-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Canvas fills the overlay */
#clarity-gate-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* aria-hidden set in JS */
}

/* ── WebGL fallback: static CSS core ───────────────────────── */
#clarity-gate-fallback {
  display: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 50% 50%, rgba(91,225,245,0.12) 0%, transparent 65%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(139,124,255,0.10) 0%, transparent 55%);
}
.no-webgl #clarity-gate-fallback { display: block; }

/* Fallback pulse ring */
#clarity-gate-fallback::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 60vw);
  height: min(320px, 60vw);
  border-radius: 50%;
  border: 1px solid rgba(91,225,245,0.25);
  box-shadow:
    0 0 40px rgba(91,225,245,0.08) inset,
    0 0 80px rgba(91,225,245,0.06);
}

/* ── Gate UI layer (sits above canvas) ─────────────────────── */
#clarity-gate-ui {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1.5rem;
  gap: 2rem;
  /* Center card vertically, acrostic near bottom */
  min-height: 100vh;
  min-height: 100dvh;
}

/* Fade-in for the UI on load */
#clarity-gate-ui {
  animation: gate-ui-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

@keyframes gate-ui-enter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Lock card — translucent glass so orbit glow bleeds through */
.gate-card {
  width: min(420px, calc(100vw - 3rem));
  /*
   * Dark-glass treatment: semi-transparent so the 3D core glows
   * through/around it — the card sits IN the orbit, not hiding it.
   * Reduced opacity + stronger backdrop blur + no opaque fill.
   */
  background: rgba(10, 11, 18, 0.55);
  border: 1px solid rgba(91, 225, 245, 0.14);
  border-radius: 18px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  backdrop-filter: blur(20px) saturate(180%) brightness(0.9);
  -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(0.9);
  box-shadow:
    0 0 0 0.5px rgba(91,225,245,0.12) inset,
    0 8px 48px rgba(0,0,0,0.55),
    0 0 60px rgba(91,225,245,0.07),
    0 0 120px rgba(139,124,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  /* Ensure the card renders above the canvas but doesn't hide the orbit halos */
  isolation: isolate;
}

/* Card top accent line */
.gate-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16%;
  right: 16%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(91,225,245,0.5), rgba(139,124,255,0.5), transparent);
  border-radius: 1px;
}

/* Subtle outer orbit glow ring around the card — echoes the 3D rings */
.gate-card::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  border: 1px solid rgba(91,225,245,0.08);
  pointer-events: none;
}

/* Card header */
.gate-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.gate-eyebrow {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5BE1F5;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

/* Blinking dot */
.gate-eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5BE1F5;
  box-shadow: 0 0 8px rgba(91,225,245,0.8);
  animation: gate-dot-blink 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes gate-dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.gate-title {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  color: #EDEFF5;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* ── Password form ─────────────────────────────────────────── */
.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.gate-label {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9AA3B7;
  display: block;
  margin-bottom: 0.375rem;
}

.gate-input-wrap {
  position: relative;
}

.gate-input[data-clarity-gate-input] {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 3rem 0.75rem 1rem;
  background: rgba(10, 11, 16, 0.7);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  color: #EDEFF5;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.9375rem;
  letter-spacing: 0.12em;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
  /* Disable autofill styling */
  -webkit-text-security: disc;
}

.gate-input[data-clarity-gate-input]:focus {
  border-color: rgba(91,225,245,0.45);
  box-shadow: 0 0 0 3px rgba(91,225,245,0.12);
}

.gate-input[data-clarity-gate-input]::placeholder {
  color: #5C6478;
  letter-spacing: 0.04em;
}

/* Error state for input */
.gate-input[data-clarity-gate-input].has-error {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
  animation: gate-shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-8px); }
  30%       { transform: translateX(7px); }
  45%       { transform: translateX(-6px); }
  60%       { transform: translateX(5px); }
  75%       { transform: translateX(-3px); }
  90%       { transform: translateX(2px); }
}

/* Lock icon inside input */
.gate-input-icon {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: #5C6478;
  pointer-events: none;
  transition: color 150ms ease;
  width: 18px;
  height: 18px;
}

.gate-input-wrap:focus-within .gate-input-icon {
  color: #5BE1F5;
}

/* Submit button */
.gate-submit[data-clarity-gate-submit] {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(110deg, #5BE1F5, #8B7CFF);
  color: #0A0B10;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    opacity 150ms ease,
    transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 150ms ease;
}

.gate-submit[data-clarity-gate-submit]:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(91,225,245,0.22);
}

.gate-submit[data-clarity-gate-submit]:active {
  transform: scale(0.98) translateY(0);
}

.gate-submit[data-clarity-gate-submit]:focus-visible {
  outline: 2px solid #5BE1F5;
  outline-offset: 3px;
}

.gate-submit[data-clarity-gate-submit].is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Shimmer sweep on submit */
.gate-submit[data-clarity-gate-submit]::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}

.gate-submit[data-clarity-gate-submit]:hover::after {
  left: 160%;
}

/* ── Error message ─────────────────────────────────────────── */
.gate-error[data-clarity-gate-error] {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.6875rem;
  color: #F87171;
  letter-spacing: 0.04em;
  min-height: 1.2em;
  opacity: 0;
  transition: opacity 200ms ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gate-error[data-clarity-gate-error].is-visible {
  opacity: 1;
}

.gate-error[data-clarity-gate-error]::before {
  content: '//';
  opacity: 0.6;
}

/* ── Card dissolve on unlock ───────────────────────────────── */
.gate-card.is-dissolving {
  animation: gate-card-dissolve 0.45s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes gate-card-dissolve {
  from {
    opacity: 1;
    transform: scale(1);
    filter: blur(0px);
  }
  to {
    opacity: 0;
    transform: scale(1.12) translateY(-16px);
    filter: blur(14px);
  }
}

/* ── Acrostic strip ────────────────────────────────────────── */
.gate-acrostic {
  display: flex;
  align-items: center;
  gap: clamp(0.375rem, 1.5vw, 0.875rem);
  position: absolute;
  bottom: clamp(1.5rem, 4vw, 2.5rem);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.gate-acrostic-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  animation: gate-acrostic-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Stagger each letter */
.gate-acrostic-item:nth-child(1)  { animation-delay: 0.55s; }
.gate-acrostic-item:nth-child(2)  { animation-delay: 0.65s; }
.gate-acrostic-item:nth-child(3)  { animation-delay: 0.75s; }
.gate-acrostic-item:nth-child(4)  { animation-delay: 0.85s; }
.gate-acrostic-item:nth-child(5)  { animation-delay: 0.95s; }
.gate-acrostic-item:nth-child(6)  { animation-delay: 1.05s; }
.gate-acrostic-item:nth-child(7)  { animation-delay: 1.15s; }
/* Dots between letters */
.gate-acrostic-dot {
  color: rgba(91,225,245,0.25);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  animation: gate-acrostic-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.gate-acrostic-dot:nth-child(2)  { animation-delay: 0.60s; }
.gate-acrostic-dot:nth-child(4)  { animation-delay: 0.70s; }
.gate-acrostic-dot:nth-child(6)  { animation-delay: 0.80s; }
.gate-acrostic-dot:nth-child(8)  { animation-delay: 0.90s; }
.gate-acrostic-dot:nth-child(10) { animation-delay: 1.00s; }
.gate-acrostic-dot:nth-child(12) { animation-delay: 1.10s; }

@keyframes gate-acrostic-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gate-acrostic-letter {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: clamp(1rem, 2.5vw, 1.375rem);
  font-weight: 600;
  background: linear-gradient(110deg, #5BE1F5, #8B7CFF);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  line-height: 1;
}

.gate-acrostic-word {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: clamp(0.4rem, 1vw, 0.5625rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5C6478;
  line-height: 1;
}

/* ── Warp overlay (fullscreen on unlock) ───────────────────── */
#clarity-gate-warp {
  position: absolute;
  inset: 0;
  z-index: 2;       /* Sits above the 3D canvas + UI during warp */
  pointer-events: none;
  opacity: 0;       /* Hidden until beginWarp() activates it */
  /* No transition — instant switch to opaque when activated */
}

#clarity-gate-warp.is-active {
  pointer-events: none;  /* Keep pass-through; skip handled by JS event */
  /* opacity set inline by JS to 1 immediately */
}

/* ── Reduced motion overrides ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #clarity-gate-ui {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .gate-acrostic-item,
  .gate-acrostic-dot {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .gate-eyebrow::before {
    animation: none;
  }
  .gate-card.is-dissolving {
    animation: none;
    transition: opacity 400ms ease;
    opacity: 0;
  }
  .gate-input[data-clarity-gate-input].has-error {
    animation: none;
  }
}

/* ── Mobile responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
  .gate-card {
    border-radius: 14px;
  }

  .gate-acrostic-word {
    display: none; /* just show letters on very small screens */
  }

  .gate-acrostic {
    gap: 0.5rem;
    bottom: 1.25rem;
  }
}

/* Ensure no horizontal scroll from gate */
#clarity-gate[data-clarity-gate] {
  max-width: 100vw;
  overflow: hidden;
}
