/* --- Variables --- */
:root {
  --bg-dark: #0a0b0d;
  --bg-card: #0d1117;
  --bg-elevated: #161b22;
  --border: #21262d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --text-bright: #f0f6fc;
  --neon-green: #00ff88;
  --neon-cyan: #00d4ff;
  --neon-magenta: #ff00aa;
  --neon-yellow: #ffeb3b;
  --glow-green: 0 0 20px rgba(0, 255, 136, 0.4);
  --glow-cyan: 0 0 20px rgba(0, 212, 255, 0.4);
  --glow-magenta: 0 0 20px rgba(255, 0, 170, 0.3);
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-dark);
  overflow-x: hidden;
}

/* --- Background effects --- */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.grid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* --- Boot overlay --- */
.boot-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.boot-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.boot-terminal {
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 2rem;
  max-width: 480px;
}

.boot-line {
  opacity: 0;
  animation: boot-fade-in 0.25s ease forwards;
}

.boot-line.delay-1 { animation-delay: 0.15s; }
.boot-line.delay-2 { animation-delay: 0.3s; }
.boot-line.delay-3 { animation-delay: 0.45s; }
.boot-line.delay-4 { animation-delay: 0.6s; }

@keyframes boot-fade-in {
  to { opacity: 1; }
}

.boot-line .prompt { color: var(--neon-green); margin-right: 0.5rem; }
.boot-line .success { color: var(--neon-green); margin-right: 0.5rem; }
.cursor-blink { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.boot-hint {
  margin-top: 3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  animation: boot-hint-pulse 2s ease-in-out infinite;
}

@keyframes boot-hint-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 11, 13, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-bright);
  text-decoration: none;
}

.logo-accent { color: var(--neon-green); }

.nav {
  display: flex;
  gap: 2rem;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav a:hover { color: var(--neon-green); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text);
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
}

.hero-terminal {
  margin-bottom: 2rem;
  max-width: 520px;
  width: 100%;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.term-dot.red { background: #ff5f56; }
.term-dot.yellow { background: #ffbd2e; }
.term-dot.green { background: #27c93f; }

.term-title {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.term-body {
  padding: 1rem 1.25rem;
  background: rgba(13, 17, 23, 0.9);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.term-line {
  margin: 0.25rem 0;
}

.term-line .prompt {
  color: var(--neon-green);
  margin-right: 0.5rem;
}

.term-line .output {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.2;
  margin: 0 0 1rem;
}

.hero-title .line { display: block; }
.hero-title .accent {
  color: var(--neon-green);
  text-shadow: var(--glow-green);
}

.hero-desc {
  max-width: 540px;
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.8rem;
  background: transparent;
  border: 2px solid var(--neon-green);
  color: var(--neon-green);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
}

.cta-btn:hover {
  background: var(--neon-green);
  color: var(--bg-dark);
  box-shadow: var(--glow-green);
}

/* --- Sections --- */
section {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 1.5rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--neon-cyan);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 600;
  margin: 0 0 2rem;
  color: var(--text-bright);
}

/* --- Problem --- */
.problem-intro {
  color: var(--text-muted);
  margin: 0 0 2rem;
  max-width: 640px;
  line-height: 1.6;
}

.problem-intro strong { color: var(--neon-green); }

.problem-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.problem-card {
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.problem-card:hover,
.glitch-hover:hover {
  border-color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-2px);
}

.problem-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--neon-magenta);
  margin-bottom: 0.75rem;
  display: block;
}

/* --- Services --- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.service-card {
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.service-card:hover {
  border-color: var(--neon-green);
  box-shadow: var(--glow-green);
  transform: translateY(-4px);
}

.service-icon {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--neon-green);
  margin-bottom: 1rem;
}

.service-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--text-bright);
}

.service-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Process (Git flow) --- */
.process-intro {
  color: var(--text-muted);
  margin: -1rem 0 2rem;
  max-width: 560px;
}

.process-intro code { color: var(--neon-cyan); padding: 0 0.25rem; }

.process-disclaimer {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: -1rem 0 2rem;
  opacity: 0.9;
}

.git-graph {
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.git-graph-art {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.git-graph-art code { color: var(--text); }

/* Timeline: vertical trunk + colored branches, no horizontal shift */
.process-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.process-timeline .process-trunk {
  position: absolute;
  left: 11px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--border);
  pointer-events: none;
}

.process-step {
  display: flex;
  align-items: center;
  gap: 0;
  padding-left: 0;
  margin-bottom: 1rem;
}

.process-step:last-child { margin-bottom: 0; }

.process-node {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--branch-color, var(--neon-green));
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--branch-color, var(--neon-green));
  z-index: 1;
}

.process-branch-line {
  flex-shrink: 0;
  width: 20px;
  height: 2px;
  background: var(--branch-color, var(--neon-green));
}

:root {
  --branch-cyan: #22d3ee;
  --branch-blue: #3b82f6;
  --branch-magenta: #d946ef;
  --branch-green: #22c55e;
  --branch-yellow: #eab308;
  --branch-orange: #f97316;
}

.process-card.commit-node {
  flex: 1;
  margin-left: 0;
  margin-bottom: 0;
}

.process-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.process-date {
  font-family: var(--font-mono);
  color: var(--neon-cyan);
}

.process-participants {
  font-style: italic;
}

.commit-node {
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.commit-node:hover {
  border-color: var(--neon-green);
  box-shadow: var(--glow-green);
}

.commit-hash {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--neon-green);
  display: block;
  margin-bottom: 0.25rem;
}

.commit-msg {
  font-weight: 500;
  color: var(--text-bright);
}

.commit-detail {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.commit-detail strong { color: var(--neon-cyan); }
.commit-detail ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
.commit-detail li { margin: 0.25rem 0; }
.commit-detail li b { color: var(--neon-cyan); }

/* --- Floating mini terminal --- */
.mini-terminal {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 380px;
  max-height: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
}

.mini-terminal.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mini-terminal.term-minimized {
  display: none !important;
}

.mini-terminal[data-collapsed="true"] .mini-term-body {
  display: none;
}

/* Fullscreen terminal mode - whole landing becomes terminal */
body.terminal-mode .header,
body.terminal-mode main,
body.terminal-mode .footer {
  visibility: hidden;
  pointer-events: none;
}

body.terminal-mode .mini-terminal {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100vh;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
}

body.terminal-mode .mini-terminal .mini-term-body {
  max-height: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.terminal-mode .mini-terminal .mini-term-output {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  font-size: 0.9rem;
}

.mini-term-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}

.mini-term-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mini-term-minimize {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.25rem;
}

.mini-term-minimize:hover { color: var(--neon-green); }

.term-restore {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--neon-green);
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.term-restore.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.term-restore:hover {
  border-color: var(--neon-green);
  box-shadow: var(--glow-green);
}

.mini-term-body {
  display: flex;
  flex-direction: column;
  max-height: 260px;
}

.mini-term-output {
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-card);
}

.mini-term-output::-webkit-scrollbar {
  width: 6px;
}

.mini-term-output::-webkit-scrollbar-track {
  background: var(--bg-card);
  border-radius: 3px;
}

.mini-term-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.mini-term-output::-webkit-scrollbar-thumb:hover {
  background: var(--neon-green);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

.mini-term-output .term-line { margin: 0.2rem 0; }
.mini-term-output .output-line { color: var(--text-muted); }

.mini-term-body .term-input-line {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem 0.75rem;
  margin: 0;
}

.term-input-line .prompt {
  color: var(--neon-green);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.term-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.term-mirror-before,
.term-mirror-after {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  white-space: pre;
}

.term-cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--neon-green);
  animation: cursor-blink 1s step-end infinite;
  vertical-align: text-bottom;
  flex-shrink: 0;
}

@keyframes cursor-blink {
  50% { opacity: 0; }
}

.term-input-line input {
  position: absolute;
  inset: 0;
  width: 100%;
  background: none;
  border: none;
  color: transparent;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  caret-color: transparent;
  padding: 0;
}

.term-input-line input::placeholder {
  color: transparent;
}

.output-line { color: var(--text-muted); }
.output-line code {
  color: var(--neon-cyan);
  padding: 0 0.2rem;
}

.term-cmd {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.term-cmd:hover {
  color: var(--neon-green);
}

.term-cmd-header {
  background: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}

/* --- Terminal section shortcuts --- */
.terminal-desc { color: var(--text-muted); margin: -1rem 0 1rem; }
.terminal-desc code { color: var(--neon-cyan); padding: 0 0.25rem; }

.terminal-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.term-shortcut {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.term-shortcut:hover {
  border-color: var(--neon-green);
  color: var(--neon-green);
}

/* --- Why --- */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.why-item {
  text-align: center;
}

.why-value {
  display: block;
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--neon-green);
  text-shadow: var(--glow-green);
  margin-bottom: 0.5rem;
}

.why-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- Portfolio --- */
.portfolio-placeholder {
  padding: 4rem;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 8px;
  text-align: center;
}

.placeholder-content .placeholder-icon {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.5;
  display: block;
  margin-bottom: 1rem;
}

.placeholder-note {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--neon-cyan);
}

/* --- Contact form --- */
.contact-form {
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--neon-green);
}

.contact-form select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.contact-form textarea { resize: vertical; min-height: 100px; }

.form-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
}

.telegram-link {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.telegram-link a {
  color: var(--neon-cyan);
  text-decoration: none;
}

.telegram-link a:hover { text-decoration: underline; }

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  padding: 3rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer p { margin: 0.25rem 0; color: var(--text-muted); font-size: 0.9rem; }
.footer-tagline { font-family: var(--font-mono); color: var(--neon-green); opacity: 0.8; }

/* --- Animations on scroll --- */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.service-card, .problem-card, .commit-node { transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.3s, box-shadow 0.3s; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav { display: none; }
  .nav-toggle { display: flex; }

  .header.nav-open .nav {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    padding: 1rem;
    gap: 1rem;
  }

  .form-row { grid-template-columns: 1fr; }

  .process-step { padding-left: 0; }
  .process-timeline .process-trunk { left: 8px; }
  .process-node { margin-left: 2px; width: 12px; height: 12px; }
  .process-branch-line { width: 14px; }
  .process-card.commit-node { min-width: 0; }

.mini-terminal {
  left: 1rem;
  right: 1rem;
  width: auto;
  max-height: none;
}

  .mini-terminal:not(.term-has-output) .mini-term-output {
    display: none;
  }

  .mini-terminal:not(.term-has-output) .mini-term-body {
    padding: 0;
  }

  .mini-terminal:not(.term-has-output) .term-input-line {
    border-top: none;
    padding: 0.4rem 0.75rem 0.75rem;
  }

  .mini-terminal.term-has-output {
    max-height: 70vh;
  }

  .term-restore {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
  }

  .git-graph-art { font-size: 0.75rem; }
}
