/* ============================================
   TERMINAL WEBSITE - CLICKHOUSE DESIGN SYSTEM
   Fixed: Cursor works, Terminal window frame
   ============================================ */

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Colors from DESIGN.md */
  --primary: #faff69;
  --primary-active: #e6eb52;
  --primary-disabled: #3a3a1f;
  --ink: #ffffff;
  --body: #cccccc;
  --body-strong: #e6e6e6;
  --muted: #888888;
  --muted-soft: #5a5a5a;
  --hairline: #2a2a2a;
  --hairline-strong: #3a3a3a;
  --canvas: #0a0a0a;
  --surface-soft: #121212;
  --surface-card: #1a1a1a;
  --surface-elevated: #242424;
  --on-primary: #0a0a0a;
  --on-dark: #ffffff;
  --accent-emerald: #22c55e;
  --accent-rose: #ef4444;
  --accent-blue: #3b82f6;

  /* Typography */
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Border Radius */
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ============================================
   Base Reset & Body
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--body);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
  overflow-x: hidden;
  position: relative;
}

/* ============================================
   Terminal Window Frame
   ============================================ */
.terminal-window {
  max-width: 1000px;
  margin: 20px auto;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.terminal-titlebar {
  background: var(--surface-elevated);
  padding: 10px 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--hairline-strong);
  user-select: none;
}

.terminal-buttons {
  display: flex;
  gap: 8px;
  margin-right: 15px;
}

.terminal-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.terminal-button:hover {
  opacity: 0.8;
}

.btn-close {
  background: #ef4444;
}

.btn-minimize {
  background: #f59e0b;
}

.btn-maximize {
  background: var(--accent-emerald);
}

.terminal-title {
  color: var(--muted);
  font-size: 12px;
  flex: 1;
  text-align: center;
  font-family: var(--font-sans);
}

.terminal-content {
  padding: var(--space-md) var(--space-lg);
  min-height: calc(100vh - 140px);
  position: relative;
  z-index: 10;
}

/* ============================================
   CRT Scanline Effect
   ============================================ */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.04) 2px,
    rgba(0, 0, 0, 0.04) 4px
  );
  pointer-events: none;
  z-index: 1000;
}

/* Circuit Board Background Animation */
#circuit-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
}

/* ============================================
   Selection
   ============================================ */
::selection {
  color: var(--on-primary);
  background-color: var(--primary);
}

::-moz-selection {
  color: var(--on-primary);
  background-color: var(--primary);
}

/* ============================================
   Terminal Container
   ============================================ */
#terminal {
  max-width: 100%;
  margin: 0;
  padding: var(--space-md) 0;
  min-height: calc(100vh - 120px);
  position: relative;
  z-index: 10;
}

/* ============================================
   Text Elements - SMOOTH ANIMATIONS
   ============================================ */
p {
  display: block;
  line-height: 1.6;
  margin: 0 0 var(--space-xxs) 0;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: smoothFadeIn 0.4s ease-out forwards;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--body);
  opacity: 0;
}

p br {
  display: block;
  content: "";
  margin-top: var(--space-xs);
}

/* ============================================
   Smooth Animations - No Jitter
   ============================================ */
@keyframes smoothFadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.no-animation {
  animation: none;
  opacity: 1;
}

/* ============================================
   Color Classes (ClickHouse Palette)
   ============================================ */
.color2 {
  color: var(--muted);
}

.command {
  color: var(--primary);
  font-weight: 600;
  text-shadow: 0 0 6px rgba(250, 255, 105, 0.25);
}

.error {
  color: var(--accent-rose);
}

.white {
  color: var(--ink);
}

.inherit,
a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

a:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-color: var(--primary);
}

a:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.terminal {
  color: var(--primary);
  font-weight: 600;
}

.index {
  color: var(--ink);
  font-weight: 600;
}

.margin {
  margin-left: var(--space-md);
}

/* ============================================
   ASCII Art & Banner - FIXED ALIGNMENT
   ============================================ */
#terminal p:first-of-type,
#terminal p:nth-of-type(2),
#terminal p:nth-of-type(3),
#terminal p:nth-of-type(4),
#terminal p:nth-of-type(5),
#terminal p:nth-of-type(6),
#terminal p:nth-of-type(7),
#terminal p:nth-of-type(8),
#terminal p:nth-of-type(9),
#terminal p:nth-of-type(10) {
  line-height: 1.2;
  font-size: 11px;
  color: var(--primary);
  text-shadow: 0 0 8px rgba(250, 255, 105, 0.4);
  white-space: pre;
  animation: smoothFadeIn 0.6s ease-out forwards;
}

/* ============================================
   Command Input Area
   ============================================ */
#command {
  cursor: text;
  margin-top: var(--space-lg);
  position: relative;
}

textarea {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}

/* ============================================
   Liner (Command Line Display)
   ============================================ */
#liner {
  line-height: 1.6;
  margin-top: var(--space-xs);
  color: var(--body);
  font-family: var(--font-mono);
  font-size: 14px;
  animation: smoothFadeIn 0.5s ease-out forwards;
  animation-delay: 0.3s;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
  min-height: 20px;
  position: relative;
}

#liner::before {
  content: "guest@web:~$ ";
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(250, 255, 105, 0.2);
  flex-shrink: 0;
}

#liner.admin::before {
  content: "admin@web:~# ";
  color: var(--accent-rose);
  font-weight: 700;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

#liner.password::before {
  content: "Password: ";
  color: var(--accent-rose);
}

/* ============================================
   Cursor - FIXED: Simple block, works with flexbox
   ============================================ */
.cursor {
  font-size: 14px;
  color: var(--primary);
  background-color: var(--primary);
  display: inline-block;
  width: 8px;
  height: 1.2em;
  animation: smoothBlinker 1.2s step-end infinite;
  box-shadow: 0 0 6px rgba(250, 255, 105, 0.3);
  margin-left: 0;
  vertical-align: middle;
}

/* ============================================
   Command Output Styling
   ============================================ */
#terminal p[class*="color2"] {
  color: var(--muted);
  border-left: 2px solid var(--hairline);
  padding-left: var(--space-sm);
}

#terminal p[class*="command"] {
  color: var(--primary);
}

#terminal p[class*="error"] {
  color: var(--accent-rose);
  border-left: 2px solid var(--accent-rose);
  padding-left: var(--space-sm);
}

/* ============================================
   Skills Section (Categorized Lists)
   ============================================ */
#terminal p:has(span.terminal) {
  margin-top: var(--space-sm);
  margin-bottom: var(--space-xs);
}

#terminal p:not([class]):not(:has(span)) {
  padding-left: var(--space-md);
  color: var(--body);
}

/* ============================================
   Projects Section
   ============================================ */
#terminal p a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

#terminal p a:hover {
  background: var(--primary);
  color: var(--on-primary);
}

/* ============================================
   Table Styling (for help command)
   ============================================ */
#terminal p:has(> span:first-child) {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
}

/* ============================================
   Matrix Canvas
   ============================================ */
#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.1;
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--canvas);
}

::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-soft);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .terminal-window {
    margin: 10px auto;
  }

  .terminal-content {
    padding: var(--space-sm) var(--space-md);
  }

  #terminal {
    max-width: 100%;
  }

  p {
    font-size: 13px;
  }

  #terminal p:first-of-type,
  #terminal p:nth-of-type(2),
  #terminal p:nth-of-type(3),
  #terminal p:nth-of-type(4),
  #terminal p:nth-of-type(5),
  #terminal p:nth-of-type(6),
  #terminal p:nth-of-type(7),
  #terminal p:nth-of-type(8) {
    font-size: 9px;
  }
}

@media (min-width: 1440px) {
  .terminal-window {
    max-width: 1200px;
  }
}

/* ============================================
   Boot Animation (Smooth)
   ============================================ */
.terminal-content {
  animation: smoothFadeIn 0.8s ease-out forwards;
}

/* ============================================
   Glow Effects (Terminal Aesthetic) - Subtle
   ============================================ */
#liner::before,
.command,
.terminal {
  text-shadow: 0 0 6px rgba(250, 255, 105, 0.2);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--muted);
}

.text-yellow {
  color: var(--primary);
}

.bg-dark {
  background: var(--surface-card);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
}

/* ============================================
   Neofetch Styling
   ============================================ */
#neofetch-uptime {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   Tips Section
   ============================================ */
#terminal p:has(span.command) + p.color2,
#terminal p:has(span.color2) {
  padding-left: var(--space-md);
  font-size: 13px;
}

/* ============================================
   Guestbook Styling
   ============================================ */
.guestbook-entry {
  animation: smoothSlideIn 0.5s ease-out forwards;
  opacity: 0;
  padding: var(--space-sm);
  border-left: 2px solid var(--primary);
  margin-bottom: var(--space-sm);
}

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

/* ============================================
   Visitor Counter
   ============================================ */
.visitor-count {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================
   Animations Canvas
   ============================================ */
#particles-canvas,
#stars-canvas,
#rain-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.15;
}
