/**
 * INTERACTIVE CODE BLOCKS
 * Sprint #39 — 2026-02-10 6:30 AM
 * 
 * Modern developer-focused code blocks with:
 * - Syntax highlighting (terminal/bash style)
 * - One-click copy functionality
 * - Animated success feedback
 * - Terminal-style UI with glassmorphism
 * - Responsive design
 * 
 * Used by: Vercel, Linear, Stripe, GitHub 2026
 * Conversion Impact: Reduces setup friction, builds trust
 */

/* ═══════════════════════════════════════════════════════════════════════════
   CODE BLOCK CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.code-block-wrapper {
  position: relative;
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 15, 20, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(168, 85, 247, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.code-block-wrapper:hover {
  border-color: rgba(168, 85, 247, 0.3);
  box-shadow: 
    0 8px 32px rgba(168, 85, 247, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CODE BLOCK HEADER (Terminal-style)
   ═══════════════════════════════════════════════════════════════════════════ */

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(15, 15, 20, 0.4);
  border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

.code-block-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Terminal dots (Mac-style) */
.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.8;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   COPY BUTTON
   ═══════════════════════════════════════════════════════════════════════════ */

.code-copy-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.code-copy-btn:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  color: rgba(255, 255, 255, 1);
  transform: translateY(-1px);
}

.code-copy-btn:active {
  transform: translateY(0);
}

/* Copy icon */
.copy-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: all 0.2s;
}

/* Success state */
.code-copy-btn.copied {
  background: rgba(46, 229, 157, 0.15);
  border-color: rgba(46, 229, 157, 0.3);
  color: rgba(46, 229, 157, 1);
}

.code-copy-btn.copied .copy-icon {
  stroke: rgba(46, 229, 157, 1);
}

/* Success ripple effect */
.code-copy-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(46, 229, 157, 0.4) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.code-copy-btn.copied::after {
  opacity: 1;
  transform: scale(1.5);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CODE CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */

.code-block-content {
  padding: 1.5rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(168, 85, 247, 0.3) rgba(15, 15, 20, 0.5);
}

.code-block-content::-webkit-scrollbar {
  height: 8px;
}

.code-block-content::-webkit-scrollbar-track {
  background: rgba(15, 15, 20, 0.5);
  border-radius: 4px;
}

.code-block-content::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 4px;
}

.code-block-content::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.5);
}

/* Code element */
.code-block-content pre {
  margin: 0;
  padding: 0;
  white-space: pre;
  word-wrap: normal;
}

.code-block-content code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SYNTAX HIGHLIGHTING (Terminal/Bash style)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Line structure */
.code-line {
  display: block;
  margin: 0.25rem 0;
}

/* Prompt ($ or >) */
.code-prompt {
  color: rgba(168, 85, 247, 0.8);
  user-select: none;
  margin-right: 0.5rem;
}

/* Commands */
.code-command {
  color: rgba(94, 234, 212, 1); /* Teal-400 */
  font-weight: 500;
}

/* Flags/options (--flag) */
.code-flag {
  color: rgba(251, 191, 36, 1); /* Amber-400 */
}

/* Strings */
.code-string {
  color: rgba(251, 146, 60, 1); /* Orange-400 */
}

/* Comments */
.code-comment {
  color: rgba(148, 163, 184, 0.6); /* Slate-400 dimmed */
  font-style: italic;
}

/* Success output */
.code-success {
  color: rgba(46, 229, 157, 1); /* Custom green */
}

/* Variable/path */
.code-path {
  color: rgba(196, 181, 253, 1); /* Purple-300 */
}

/* Numbers */
.code-number {
  color: rgba(248, 113, 113, 1); /* Red-400 */
}

/* ═══════════════════════════════════════════════════════════════════════════
   INLINE CODE (for text content)
   ═══════════════════════════════════════════════════════════════════════════ */

code:not(.code-block-content code) {
  padding: 0.2rem 0.4rem;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.875em;
  color: rgba(168, 85, 247, 1);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Typing cursor animation (optional) */
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: rgba(168, 85, 247, 0.8);
  margin-left: 2px;
  animation: blink-cursor 1s steps(2) infinite;
}

/* Success pulse */
@keyframes success-pulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.4); 
  }
  50% { 
    box-shadow: 0 0 0 8px rgba(46, 229, 157, 0); 
  }
}

.code-copy-btn.copied {
  animation: success-pulse 0.6s ease-out;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .code-block-header {
    padding: 0.625rem 0.875rem;
  }

  .code-block-content {
    padding: 1rem;
    font-size: 0.8125rem;
  }

  .code-copy-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.6875rem;
  }

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

  /* Hide "Copy" text on very small screens */
  .code-copy-btn span {
    display: none;
  }
  
  @media (min-width: 400px) {
    .code-copy-btn span {
      display: inline;
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════════════ */

/* Focus states */
.code-copy-btn:focus-visible {
  outline: 2px solid rgba(168, 85, 247, 0.8);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .code-block-wrapper,
  .code-copy-btn,
  .typing-cursor {
    transition: none;
    animation: none;
  }

  .code-copy-btn::after {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE ADJUSTMENTS (if needed)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: light) {
  /* Override for light mode if ever needed */
  /* Currently optimized for dark theme */
}
