/*
 * Terminal Styles — BlackLabel 47
 * Full terminal UI layout, prompt, output, animations
 */

/* ============================================
   TERMINAL LAYOUT
   ============================================ */

#terminal {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  transition: background var(--transition-normal), color var(--transition-normal);
}

#terminal-output-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

#terminal-spacer {
  flex: 1 0 0;
  min-height: 0;
}

#terminal-output {
  flex-shrink: 0;
  padding: var(--terminal-padding);
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ============================================
   PROMPT AREA
   ============================================ */

#terminal-prompt-area {
  flex-shrink: 0;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--terminal-padding) var(--terminal-padding);
  box-sizing: border-box;
  background: var(--bg);
  transition: background var(--transition-normal);
}

.divider {
  height: 1px;
  border: none;
  border-top: 1px dotted var(--border-dot);
  margin: 8px 0;
}

.prompt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}

.prompt-char {
  color: var(--accent);
  font-weight: 700;
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  animation: cursorPulse 2s ease-in-out infinite;
}

#terminal-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  caret-color: var(--accent);
  outline: none;
  transition: color var(--transition-normal);
}

#terminal-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

#terminal-input:read-only {
  caret-color: transparent;
}

/* ============================================
   COMMAND OUTPUT
   ============================================ */

.command-echo {
  padding: 6px 0 2px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.prompt-echo {
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

.command-output {
  padding: 12px 0 20px;
  border-left: 2px solid var(--border);
  padding-left: 20px;
  margin: 4px 0 8px;
  margin-left: 2px;
  transition: border-color var(--transition-normal);
}

/* ============================================
   OUTPUT SECTIONS
   ============================================ */

.output-section {
  /* content container within command-output */
}

.section-header {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.section-meta {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: 20px;
}

.section-title {
  font-weight: 700;
  font-size: var(--font-size-lg);
  margin-bottom: 16px;
  color: var(--text-primary);
}

.section-body p {
  margin-bottom: 14px;
  max-width: 60ch;
}

.section-body p:last-child {
  margin-bottom: 0;
}

.tagline {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-top: 8px;
  letter-spacing: 0.02em;
}

/* ============================================
   SERVICES TABLE
   ============================================ */

.services-table {
  margin-top: 16px;
}

.services-header {
  display: grid;
  grid-template-columns: 40px 1fr 130px;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.service-row {
  display: grid;
  grid-template-columns: 40px 1fr 130px;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 4px;
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}

.service-row:hover {
  background: var(--highlight-bg);
}

.service-row.active {
  background: var(--highlight-bg);
  border-left-color: var(--accent);
}

.service-row .col-id {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.service-row .col-name {
  font-weight: 500;
}

.service-row .col-cat {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  text-align: right;
}

.service-detail {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 14px 0 56px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  border-left: 2px solid var(--accent);
  margin-left: 14px;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.service-detail.visible {
  max-height: 120px;
  opacity: 1;
  padding: 10px 14px 10px 56px;
}

.service-detail p {
  line-height: 1.6;
}

/* ============================================
   STACK TABLE
   ============================================ */

.stack-table {
  margin-top: 16px;
}

.stack-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  padding: 8px 14px;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.stack-row:hover {
  background: var(--highlight-bg);
}

.stack-category {
  color: var(--accent);
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-transform: lowercase;
}

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

/* ============================================
   CONTACT FORM
   ============================================ */

.step-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 0;
}

.step {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.step.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.step-arrow {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ============================================
   TEXT UTILITIES
   ============================================ */

.output-line {
  padding: 2px 0;
}

.text-muted { color: var(--text-secondary); }
.accent-text { color: var(--accent); }
.success-text { color: var(--success); }
.error-text { color: var(--error); }

.cmd-name {
  color: var(--accent);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 2px;
  transition: background var(--transition-fast);
}

.cmd-name:hover {
  background: var(--accent-glow);
  text-decoration: underline;
}

/* ============================================
   HELP COMMAND
   ============================================ */

.help-list {
  margin-top: 8px;
}

.help-list .output-line {
  padding: 4px 0;
  font-size: var(--font-size-sm);
}

/* ============================================
   COMMAND HINTS
   ============================================ */

#terminal-hints {
  padding-top: 10px;
}

.hints-label {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: 10px;
}

.hints-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 16px;
}

.hint {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 0;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

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

.hint-key {
  color: var(--text-primary);
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border);
  font-size: 11px;
  transition: all var(--transition-fast);
}

.hint:hover .hint-key {
  border-color: var(--accent);
  color: var(--accent);
}

.hint-desc {
  margin-left: 5px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered animation for command output children */
.command-output > .output-section > *,
.command-output > .output-line,
.command-output > .output-section > .section-body > *,
.command-output > .output-section > .help-list > *,
.command-output > .output-section > .stack-table > *,
.command-output > .output-section > .services-table > * {
  animation: fadeSlideIn 0.25s ease backwards;
}

/* Generate stagger delays */
.command-output > .output-section > *:nth-child(1),
.command-output > .output-section > .section-body > *:nth-child(1),
.command-output > .output-section > .help-list > *:nth-child(1),
.command-output > .output-section > .stack-table > *:nth-child(1),
.command-output > .output-section > .services-table > *:nth-child(1) { animation-delay: 0ms; }

.command-output > .output-section > *:nth-child(2),
.command-output > .output-section > .section-body > *:nth-child(2),
.command-output > .output-section > .help-list > *:nth-child(2),
.command-output > .output-section > .stack-table > *:nth-child(2),
.command-output > .output-section > .services-table > *:nth-child(2) { animation-delay: 40ms; }

.command-output > .output-section > *:nth-child(3),
.command-output > .output-section > .section-body > *:nth-child(3),
.command-output > .output-section > .help-list > *:nth-child(3),
.command-output > .output-section > .stack-table > *:nth-child(3),
.command-output > .output-section > .services-table > *:nth-child(3) { animation-delay: 80ms; }

.command-output > .output-section > *:nth-child(4),
.command-output > .output-section > .section-body > *:nth-child(4),
.command-output > .output-section > .help-list > *:nth-child(4),
.command-output > .output-section > .stack-table > *:nth-child(4),
.command-output > .output-section > .services-table > *:nth-child(4) { animation-delay: 120ms; }

.command-output > .output-section > *:nth-child(5),
.command-output > .output-section > .section-body > *:nth-child(5),
.command-output > .output-section > .help-list > *:nth-child(5),
.command-output > .output-section > .stack-table > *:nth-child(5),
.command-output > .output-section > .services-table > *:nth-child(5) { animation-delay: 160ms; }

.command-output > .output-section > *:nth-child(6),
.command-output > .output-section > .section-body > *:nth-child(6),
.command-output > .output-section > .help-list > *:nth-child(6),
.command-output > .output-section > .stack-table > *:nth-child(6),
.command-output > .output-section > .services-table > *:nth-child(6) { animation-delay: 200ms; }

.command-output > .output-section > *:nth-child(7),
.command-output > .output-section > .section-body > *:nth-child(7),
.command-output > .output-section > .help-list > *:nth-child(7),
.command-output > .output-section > .stack-table > *:nth-child(7),
.command-output > .output-section > .services-table > *:nth-child(7) { animation-delay: 240ms; }

.command-output > .output-section > *:nth-child(n+8),
.command-output > .output-section > .section-body > *:nth-child(n+8),
.command-output > .output-section > .help-list > *:nth-child(n+8),
.command-output > .output-section > .stack-table > *:nth-child(n+8),
.command-output > .output-section > .services-table > *:nth-child(n+8) { animation-delay: 280ms; }

/* Echo line animation */
.command-echo {
  animation: fadeSlideIn 0.15s ease backwards;
}

/* Dynamic output lines (from terminal.echo()) */
#terminal-output > .output-line {
  animation: fadeSlideIn 0.2s ease backwards;
}

/* ============================================
   MATRIX RAIN CANVAS
   ============================================ */

#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  pointer-events: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  :root {
    --terminal-padding: 16px;
    --font-size-base: 13px;
    --font-size-xl: 18px;
    --font-size-xxl: 20px;
  }

  .hints-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .services-header,
  .service-row {
    grid-template-columns: 30px 1fr;
  }

  .services-header .col-cat,
  .service-row .col-cat {
    display: none;
  }

  .service-detail {
    padding-left: 42px !important;
  }

  .service-detail.visible {
    padding-left: 42px !important;
  }

  .stack-row {
    grid-template-columns: 100px 1fr;
  }

  .step-flow {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  :root {
    --terminal-padding: 12px;
    --font-size-base: 12px;
  }

  .hints-grid {
    grid-template-columns: 1fr;
  }

  .stack-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .stack-category {
    font-size: var(--font-size-base);
  }
}
