/* ============================================================
   CTF Blog — Style System
   Theme: Minimal Hacker / Cybersecurity
   Palette: Deep blacks, neon green (#00ff66), cyan (#00e5ff)
   Fonts: JetBrains Mono (headings/code), Inter (body)
   ============================================================ */

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

/* ---------- Design Tokens ---------- */
:root {
  --bg-primary: #0a0b0d;
  --bg-secondary: #101216;
  --bg-card: rgba(16, 18, 22, 0.7);
  --bg-card-hover: rgba(22, 25, 30, 0.85);
  --bg-code: #0d0f13;
  --bg-terminal: #060709;

  --accent-green: #00ff66;
  --accent-green-dim: #00cc52;
  --accent-cyan: #00e5ff;
  --accent-yellow: #f0c040;
  --accent-red: #ff4060;
  --accent-purple: #a78bfa;

  --text-primary: #e0e2e8;
  --text-secondary: #8b8f9a;
  --text-muted: #555a65;
  --text-link: #00e5ff;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(0, 255, 102, 0.15);

  --glow-green: 0 0 20px rgba(0, 255, 102, 0.15), 0 0 60px rgba(0, 255, 102, 0.05);
  --glow-cyan: 0 0 20px rgba(0, 229, 255, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --content-max: 820px;
  --sidebar-width: 240px;
}

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

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-green-dim) var(--bg-secondary);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb {
  background: var(--accent-green-dim);
  border-radius: 3px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.75;
  font-size: 16px;
  font-weight: 400;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---------- Background Grid Overlay ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 102, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 102, 0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Reading Progress Bar ---------- */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
  z-index: 10000;
  transition: width 0.1s linear;
  box-shadow: var(--glow-green);
}

/* ---------- Navigation ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 11, 13, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.navbar .logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-green);
  text-decoration: none;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar .logo .cursor-blink {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--accent-green);
  animation: blink 1s steps(1) infinite;
}

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

.nav-links {
  display: flex;
  gap: 6px;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  letter-spacing: 0.3px;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent-green);
  background: rgba(0, 255, 102, 0.06);
}

/* ---------- Layout ---------- */
.page-wrapper {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 80px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Sidebar TOC --- */
.sidebar {
  position: sticky;
  top: 80px;
  align-self: flex-start;
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 24px 0 24px 24px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-list a {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.toc-list a.active {
  color: var(--accent-green);
  border-left-color: var(--accent-green);
  background: rgba(0, 255, 102, 0.04);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  max-width: var(--content-max);
  padding: 24px 40px 100px 40px;
  min-width: 0;
}

/* ---------- Hero ---------- */
.hero {
  margin-bottom: 56px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-green);
  background: rgba(0, 255, 102, 0.06);
  border: 1px solid rgba(0, 255, 102, 0.15);
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
}

.hero-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.hero h1 {
  font-family: var(--font-mono);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.hero h1 span {
  color: var(--accent-green);
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  line-height: 1.7;
}

.hero-meta {
  margin-top: 20px;
  display: flex;
  gap: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.hero-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Section Styling ---------- */
.blog-section {
  margin-bottom: 56px;
  scroll-margin-top: 80px;
}

.blog-section h2 {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.blog-section h2 .section-icon {
  font-size: 1.2rem;
  opacity: 0.7;
}

.blog-section h3 {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 32px;
  margin-bottom: 8px;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  margin-bottom: 20px;
  display: block;
}

p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

em {
  color: var(--text-secondary);
  font-style: italic;
}

/* ---------- Links ---------- */
a {
  color: var(--text-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}
a:hover {
  border-bottom-color: var(--text-link);
}

/* ---------- Lists ---------- */
ul, ol {
  margin-bottom: 16px;
  padding-left: 20px;
  color: var(--text-secondary);
}

li {
  margin-bottom: 6px;
  line-height: 1.7;
}

li strong {
  color: var(--accent-green);
}

/* ---------- Horizontal Rule ---------- */
hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 48px 0;
}

/* ---------- Code Blocks ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(0, 255, 102, 0.06);
  color: var(--accent-green);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(0, 255, 102, 0.08);
}

.code-block-wrapper {
  position: relative;
  margin: 20px 0;
}

.code-block-wrapper .code-lang {
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 12px;
  border-radius: var(--radius-md) 0 var(--radius-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

.code-block-wrapper .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 2;
}

.code-block-wrapper .copy-btn:hover {
  color: var(--accent-green);
  background: rgba(0, 255, 102, 0.08);
  border-color: rgba(0, 255, 102, 0.2);
}

.code-block-wrapper .copy-btn.copied {
  color: var(--accent-green);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 36px 20px 20px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--accent-green);
  scrollbar-width: thin;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ---------- Callout / Tip Boxes ---------- */
.callout {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-green);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 24px 0;
  backdrop-filter: blur(8px);
}

.callout.callout-yellow {
  border-left-color: var(--accent-yellow);
}

.callout.callout-cyan {
  border-left-color: var(--accent-cyan);
}

.callout.callout-red {
  border-left-color: var(--accent-red);
}

.callout .callout-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.callout.callout-yellow .callout-title { color: var(--accent-yellow); }
.callout.callout-cyan .callout-title { color: var(--accent-cyan); }
.callout.callout-red .callout-title { color: var(--accent-red); }
.callout .callout-title { color: var(--accent-green); }

.callout p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

/* ---------- Room Cards ---------- */
.room-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 20px 0;
}

.room-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  transition: all var(--transition-normal);
  backdrop-filter: blur(8px);
  text-decoration: none;
  display: block;
}

.room-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  box-shadow: var(--glow-green);
  transform: translateY(-2px);
}

.room-card .room-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-green);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-card .room-name .arrow {
  opacity: 0;
  transition: all var(--transition-fast);
  transform: translateX(-4px);
}

.room-card:hover .room-name .arrow {
  opacity: 1;
  transform: translateX(0);
}

.room-card .room-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.room-card .room-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.room-card .room-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--border-subtle);
}

/* ---------- Workflow Steps ---------- */
.workflow-list {
  list-style: none;
  padding-left: 0;
  counter-reset: workflow;
}

.workflow-list li {
  counter-increment: workflow;
  position: relative;
  padding-left: 44px;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.workflow-list li::before {
  content: counter(workflow);
  position: absolute;
  left: 0;
  top: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0, 255, 102, 0.2);
  background: rgba(0, 255, 102, 0.05);
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.workflow-list li code {
  font-size: 0.82em;
}

/* ---------- Interactive Terminal Widget ---------- */
.terminal-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid rgba(0, 255, 102, 0.2);
  color: var(--accent-green);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  box-shadow: var(--glow-green);
}

.terminal-toggle:hover {
  transform: scale(1.08);
  border-color: var(--accent-green);
}

.terminal-widget {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 998;
  width: 440px;
  max-height: 380px;
  background: var(--bg-terminal);
  border: 1px solid rgba(0, 255, 102, 0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    var(--glow-green);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-slow);
}

.terminal-widget.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-dots {
  display: flex;
  gap: 7px;
}

.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dots span:nth-child(1) { background: #ff5f57; }
.terminal-dots span:nth-child(2) { background: #febc2e; }
.terminal-dots span:nth-child(3) { background: #28c840; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.terminal-body {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  scrollbar-width: thin;
}

.terminal-body .t-line { margin-bottom: 2px; }
.terminal-body .t-line.t-green { color: var(--accent-green); }
.terminal-body .t-line.t-cyan { color: var(--accent-cyan); }
.terminal-body .t-line.t-yellow { color: var(--accent-yellow); }
.terminal-body .t-line.t-red { color: var(--accent-red); }
.terminal-body .t-line.t-muted { color: var(--text-muted); }
.terminal-body .t-line.t-bold { font-weight: 600; }

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  gap: 8px;
}

.terminal-input-row .prompt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-green);
  white-space: nowrap;
}

.terminal-input-row input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  caret-color: var(--accent-green);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.footer-socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0;
}

.footer-link {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: none;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
}

.footer-link:hover {
  color: var(--accent-green);
  border-color: rgba(0, 255, 102, 0.25);
  background: rgba(0, 255, 102, 0.05);
  box-shadow: var(--glow-green);
}

.footer-divider {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.footer .footer-warning {
  color: var(--accent-yellow);
  font-style: italic;
  margin-top: 8px;
  font-size: 0.75rem;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.blog-section {
  animation: fadeInUp 0.6s ease both;
}

.blog-section:nth-child(2) { animation-delay: 0.05s; }
.blog-section:nth-child(3) { animation-delay: 0.1s; }
.blog-section:nth-child(4) { animation-delay: 0.15s; }
.blog-section:nth-child(5) { animation-delay: 0.2s; }
.blog-section:nth-child(6) { animation-delay: 0.25s; }
.blog-section:nth-child(7) { animation-delay: 0.3s; }
.blog-section:nth-child(8) { animation-delay: 0.35s; }
.blog-section:nth-child(9) { animation-delay: 0.4s; }
.blog-section:nth-child(10) { animation-delay: 0.45s; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar { display: none; }
  .main-content { padding: 24px 20px 80px 20px; }
  .hero h1 { font-size: 2rem; }
  .terminal-widget {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
  }
}

@media (max-width: 600px) {
  .navbar { padding: 0 16px; }
  .nav-links { display: none; }
  .hero h1 { font-size: 1.6rem; }
  .hero-subtitle { font-size: 1rem; }
  .main-content { padding: 16px 16px 80px 16px; }
}
