/* ═══════════════════════════════════════════════════════════════
   SyncNote — Gate CSS
   Terminal-style authentication page with Matrix binary rain
   ═══════════════════════════════════════════════════════════════ */

/* ── Layout ────────────────────────────────────────────────────── */
.gate-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport — avoids address bar jank on mobile */
  overflow: hidden;
  background: #000000;
}

/* ── Matrix Rain Canvas ────────────────────────────────────────── */
#matrix-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
}

/* ── Terminal Window ───────────────────────────────────────────── */
.terminal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 580px;
  margin: var(--space-4);
  background: rgba(8, 8, 12, 0.92);
  border: 1px solid rgba(0, 255, 65, 0.2);
  border-radius: 6px;
  box-shadow:
    0 0 30px rgba(0, 255, 65, 0.06),
    0 0 80px rgba(0, 255, 65, 0.03),
    0 20px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  animation: terminalBoot 0.6s ease-out both;
}

/* CRT Scanline overlay */
.terminal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.008) 2px,
    rgba(0, 255, 65, 0.008) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* ── Terminal Header (Linux style) ─────────────────────────────── */
.terminal-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: rgba(20, 20, 28, 0.95);
  border-bottom: 1px solid rgba(0, 255, 65, 0.12);
  user-select: none;
}

.terminal-header-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.terminal-dot--close {
  background: #3c3c46;
  border-color: rgba(255, 80, 80, 0.3);
}

.terminal-dot--close:hover {
  background: #ff5f56;
  border-color: #ff5f56;
}

.terminal-dot--minimize {
  background: #3c3c46;
  border-color: rgba(255, 200, 40, 0.3);
}

.terminal-dot--minimize:hover {
  background: #ffbd2e;
  border-color: #ffbd2e;
}

.terminal-dot--maximize {
  background: #3c3c46;
  border-color: rgba(0, 255, 65, 0.3);
}

.terminal-dot--maximize:hover {
  background: #27c93f;
  border-color: #27c93f;
}

.terminal-header-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(0, 255, 65, 0.5);
  letter-spacing: 0.04em;
  flex: 1;
  text-align: center;
  padding-right: 40px; /* compensate for dots width on right */
}

/* ── Terminal Body ─────────────────────────────────────────────── */
.terminal-body {
  padding: var(--space-6) var(--space-5);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
}

/* ── Terminal Lines ────────────────────────────────────────────── */
.terminal-line {
  color: rgba(0, 255, 65, 0.7);
  white-space: nowrap;
  overflow: hidden;
}

/* Staggered typing animation for info lines */
.terminal-line--system {
  animation: typingReveal 0.5s steps(35) 0.3s both;
}

.terminal-line--status {
  animation: typingReveal 0.4s steps(20) 0.8s both;
}

.terminal-line--info {
  animation: typingReveal 0.6s steps(40) 1.2s both;
}

.terminal-separator {
  color: rgba(0, 255, 65, 0.15);
  animation: typingReveal 0.3s steps(37) 1.7s both;
  margin: var(--space-2) 0;
}

/* ── Terminal Prefix ───────────────────────────────────────────── */
.terminal-prefix {
  color: #00ff41;
  font-weight: 700;
  margin-right: var(--space-2);
}

.terminal-prefix::before {
  content: '[';
  color: rgba(0, 255, 65, 0.4);
}

.terminal-prefix::after {
  content: ']';
  color: rgba(0, 255, 65, 0.4);
}

/* ── Status: LOCKED ────────────────────────────────────────────── */
.terminal-locked {
  color: #ff4444;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 68, 68, 0.5);
  animation: lockedPulse 2s ease-in-out infinite;
}

.terminal-line--error {
  color: #ff4444;
  margin: var(--space-2) 0;
  overflow: hidden;
  animation: errorAppear 0.35s ease-out both;
}

@keyframes errorAppear {
  from {
    max-height: 0;
    opacity: 0;
    margin: 0;
  }
  to {
    max-height: 3em;
    opacity: 1;
    margin: var(--space-2) 0;
  }
}

.terminal-prefix--error {
  color: #ff4444;
  font-weight: 700;
}

.terminal-prefix--error::before {
  content: '[';
  color: rgba(255, 68, 68, 0.5);
}

.terminal-prefix--error::after {
  content: ']';
  color: rgba(255, 68, 68, 0.5);
}

/* ── Form ──────────────────────────────────────────────────────── */
.terminal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: typingReveal 0.4s steps(20) 2s both;
}

/* ── Prompt Line (input row) ───────────────────────────────────── */
.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: var(--space-2);
}

.terminal-prompt {
  color: #00ff41;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: var(--space-2);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.3);
}

/* ── Password Input ────────────────────────────────────────────── */
.terminal-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #00ff41;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  caret-color: #00ff41;
  letter-spacing: 0.05em;
  padding: var(--space-1) 0;
}

.terminal-input::placeholder {
  color: rgba(0, 255, 65, 0.25);
  font-style: italic;
}

.terminal-input:focus {
  box-shadow: none;
  outline: none;
}

/* ── Decorative Cursor ──────────────────────────────────────────── */
/* Hidden — native input caret (caret-color: #00ff41) handles the
   blinking cursor. Keeping the span in HTML for potential future use. */
.terminal-cursor {
  display: none;
}

/* ── Submit Button ─────────────────────────────────────────────── */
.terminal-action-line {
  margin-top: var(--space-2);
}

.terminal-submit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: 1px solid rgba(0, 255, 65, 0.3);
  border-radius: 3px;
  color: #00ff41;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: all 200ms ease;
  letter-spacing: 0.04em;
  text-shadow: 0 0 4px rgba(0, 255, 65, 0.2);
}

.terminal-submit:hover {
  background: rgba(0, 255, 65, 0.08);
  border-color: rgba(0, 255, 65, 0.6);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.15), inset 0 0 15px rgba(0, 255, 65, 0.05);
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
  transform: translateX(2px);
}

.terminal-submit:active {
  transform: translateX(2px) scale(0.97);
  background: rgba(0, 255, 65, 0.12);
}

.terminal-submit .terminal-prompt {
  font-size: 0.85rem;
}

/* ── Animations ────────────────────────────────────────────────── */

@keyframes terminalBoot {
  0% {
    opacity: 0;
    transform: translateY(16px);
    filter: brightness(1.8);
  }
  60% {
    opacity: 1;
    filter: brightness(1.2);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: brightness(1);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes typingReveal {
  from {
    max-width: 0;
    opacity: 0;
  }
  to {
    max-width: 100%;
    opacity: 1;
  }
}

@keyframes lockedPulse {
  0%, 100% {
    opacity: 1;
    text-shadow: 0 0 8px rgba(255, 68, 68, 0.5);
  }
  50% {
    opacity: 0.7;
    text-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
  }
}

/* ── Soft pulse for rate-limiter "retry" line ──────────────────── */
.terminal-line--pulse {
  animation: softPulse 2.5s ease-in-out infinite;
}

@keyframes softPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════════
   Boot Sequence — shown after successful gate password
   ═══════════════════════════════════════════════════════════════ */

/* ── ACCESS GRANTED line ───────────────────────────────────────── */
.terminal-line--granted {
  color: #00ff41;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.6);
  animation: grantedFlash 0.6s ease-out both;
}

@keyframes grantedFlash {
  0% {
    opacity: 0;
    text-shadow: 0 0 30px rgba(0, 255, 65, 1);
    filter: brightness(2);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 20px rgba(0, 255, 65, 0.8);
    filter: brightness(1.5);
  }
  100% {
    opacity: 1;
    text-shadow: 0 0 12px rgba(0, 255, 65, 0.6);
    filter: brightness(1);
  }
}

/* ── Boot lines (appear sequentially) ──────────────────────────── */
.terminal-line--boot {
  color: rgba(0, 255, 65, 0.6);
  opacity: 0;
  animation: bootLineIn 0.15s ease-out forwards;
}

@keyframes bootLineIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Boot [OK] badge */
.terminal-boot-ok {
  color: #00ff41;
  font-weight: 700;
}

/* Boot [FAIL] badge (unused for now, just in case) */
.terminal-boot-fail {
  color: #ff4444;
  font-weight: 700;
}

/* Dots progress (e.g., "loading modules......") */
.terminal-boot-dots {
  color: rgba(0, 255, 65, 0.25);
  letter-spacing: 0.15em;
}

/* ── Screen flash + fade before redirect ───────────────────────── */
.gate-container--flash {
  animation: screenFlash 0.8s ease-out forwards;
}

@keyframes screenFlash {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(3); }
  100% { filter: brightness(0); opacity: 0; }
}


@media (max-width: 640px) {
  /* Kill the base.css animate-slideUp that conflicts */
  .terminal.animate-slideUp {
    animation: terminalFadeIn 0.5s ease-out both !important;
  }

  .terminal {
    max-width: none;
    margin: var(--space-2);
    border-radius: 4px;
    animation: terminalFadeIn 0.5s ease-out both;
  }

  @keyframes terminalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* Disable typing animations on mobile — they cause layout reflow */
  .terminal-line--system,
  .terminal-line--status,
  .terminal-line--info,
  .terminal-separator,
  .terminal-form {
    animation: none !important;
    opacity: 1 !important;
    max-width: none !important;
  }

  /* Smooth error on mobile — no shake, just gentle fade */
  .terminal-line--error {
    animation: mobileErrorFade 0.3s ease-out both !important;
  }

  @keyframes mobileErrorFade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .terminal-body {
    padding: var(--space-4) var(--space-3);
    font-size: 0.8rem;
  }

  .terminal-prompt {
    font-size: 0.8rem;
  }

  .terminal-input {
    font-size: 0.8rem;
  }

  .terminal-submit {
    font-size: 0.78rem;
    width: 100%;
    justify-content: center;
  }

  .terminal-separator {
    display: none;
  }

  .terminal-header-title {
    font-size: 0.68rem;
    padding-right: 30px;
  }

  .terminal-line {
    white-space: normal;
    word-break: break-word;
  }
}

@media (max-width: 380px) {
  .terminal-body {
    padding: var(--space-3) var(--space-2);
    font-size: 0.75rem;
  }

  .terminal-prompt {
    font-size: 0.75rem;
  }

  .terminal-input {
    font-size: 0.75rem;
  }

  .terminal-header-dots {
    gap: 4px;
  }

  .terminal-dot {
    width: 8px;
    height: 8px;
  }
}
