/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
  --bg:          #0a0e12;
  --bg-card:     #0f1419;
  --bg-hover:    #141b24;
  --border:      #1e2d3d;
  --border-glow: #00b4d8;

  --cyan:        #00d4ff;
  --cyan-dim:    #00b4d8;
  --cyan-muted:  rgba(0, 212, 255, 0.12);
  --cyan-glow:   rgba(0, 212, 255, 0.25);

  --text:        #c9d1d9;
  --text-dim:    #6e7f8d;
  --text-bright: #e6edf3;

  --red:         #ff4757;
  --green:       #00ff87;
  --yellow:      #ffd700;

  --font-mono:   'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-sans:   'Syne', 'Segoe UI', sans-serif;

  --radius:      4px;
  --transition:  0.2s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  /* subtle scanline overlay */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 212, 255, 0.015) 2px,
      rgba(0, 212, 255, 0.015) 4px
    );
}

a { color: var(--cyan); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--cyan-dim); }

img { max-width: 100%; }

::selection { background: var(--cyan-muted); color: var(--cyan); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; padding: 60px 0; }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.navbar-brand {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.02em;
}

.navbar-brand .prompt { color: var(--cyan); }
.navbar-brand .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--cyan);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

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

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.navbar-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--cyan);
  border-color: var(--border);
  background: var(--cyan-muted);
}

.nav-icon { font-size: 0.75rem; opacity: 0.7; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-left { color: var(--text-dim); font-size: 0.8rem; }
.footer-left span { color: var(--cyan); }

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--text-dim);
  font-size: 0.8rem;
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--cyan); }

/* ============================================================
   HERO (Home)
   ============================================================ */
.hero {
  padding: 80px 0 60px;
  position: relative;
  overflow: visible;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cyan-muted);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--cyan);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border-radius: 2px;
  margin-bottom: 24px;
  text-transform: uppercase;
}

.hero-tag::before {
  content: '●';
  animation: blink 2s ease infinite;
}

.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.2;
  margin-bottom: 20px;
}

.hero-title .accent { color: var(--cyan); }

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-dim);
  max-width: 560px;
  margin-bottom: 36px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--cyan);
  color: var(--bg);
  font-weight: 700;
  border-color: var(--cyan);
}

.btn-primary:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan-dim);
  color: var(--bg);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--cyan-dim);
  background: var(--cyan-muted);
  color: var(--cyan);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--cyan);
}

.section-title::before { content: '// '; opacity: 0.5; }

.section-count {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.section-link {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.section-link:hover { color: var(--cyan); }

/* ============================================================
   CARDS (generic)
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--cyan);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
}

.card:hover {
  border-color: var(--border-glow);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.card:hover::before { transform: scaleX(1); }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-desc {
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 16px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: auto;
}

.card-link {
  font-size: 0.8rem;
  color: var(--cyan);
}

/* ============================================================
   TAGS / BADGES
   ============================================================ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  border-radius: 2px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.tag-default { background: rgba(110, 127, 141, 0.15); color: var(--text-dim); border: 1px solid var(--border); }
.tag-cyan    { background: var(--cyan-muted); color: var(--cyan); border: 1px solid rgba(0,212,255,0.3); }
.tag-red     { background: rgba(255, 71, 87, 0.1); color: var(--red); border: 1px solid rgba(255,71,87,0.3); }
.tag-green   { background: rgba(0, 255, 135, 0.1); color: var(--green); border: 1px solid rgba(0,255,135,0.3); }
.tag-yellow  { background: rgba(255, 215, 0, 0.1); color: var(--yellow); border: 1px solid rgba(255,215,0,0.3); }

/* Difficulty tags */
.diff-easy   { background: rgba(0,255,135,0.1); color: var(--green); border: 1px solid rgba(0,255,135,0.3); }
.diff-medium { background: rgba(255,215,0,0.1); color: var(--yellow); border: 1px solid rgba(255,215,0,0.3); }
.diff-hard   { background: rgba(255,71,87,0.1); color: var(--red); border: 1px solid rgba(255,71,87,0.3); }
.diff-insane { background: rgba(180,0,255,0.1); color: #c77dff; border: 1px solid rgba(180,0,255,0.3); }

/* ============================================================
   POST / WRITEUP CONTENT
   ============================================================ */
.post-header { margin-bottom: 48px; }

.post-title {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 16px;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 24px;
}

.post-meta-divider { color: var(--border); }

.post-content { max-width: 720px; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--font-mono);
  color: var(--text-bright);
  margin: 2.5em 0 0.8em;
  line-height: 1.3;
}

.post-content h2 {
  font-size: 1.3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.post-content h2::before { content: '## '; color: var(--cyan); opacity: 0.6; }
.post-content h3::before { content: '### '; color: var(--cyan); opacity: 0.6; font-size: 0.85em; }

.post-content p { margin-bottom: 1.4em; }

.post-content ul,
.post-content ol {
  margin: 0 0 1.4em 1.5em;
}

.post-content li { margin-bottom: 0.4em; }

.post-content blockquote {
  border-left: 3px solid var(--cyan);
  padding: 12px 20px;
  margin: 1.5em 0;
  background: var(--cyan-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
  font-style: italic;
}

.post-content a { border-bottom: 1px solid rgba(0,212,255,0.3); }
.post-content a:hover { border-color: var(--cyan); }

/* Code */
.post-content code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--cyan);
}

.post-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 1.5em 0;
  position: relative;
}

.post-content pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.88rem;
}

/* Rouge syntax highlighting */
.highlight .k, .highlight .kd { color: #ff79c6; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #f1fa8c; }
.highlight .c, .highlight .c1 { color: var(--text-dim); font-style: italic; }
.highlight .n { color: var(--text); }
.highlight .nf { color: #50fa7b; }
.highlight .o { color: #ff79c6; }
.highlight .mi { color: #bd93f9; }
.highlight .na { color: var(--cyan); }

/* ============================================================
   WRITEUP METADATA BOX
   ============================================================ */
.writeup-meta-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.meta-item { }
.meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.meta-value {
  font-size: 0.9rem;
  color: var(--text-bright);
}

/* ============================================================
   TOOLS PAGE
   ============================================================ */
.tool-card { }

.tool-lang {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-lang::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
}

/* ============================================================
   TERMINAL BLOCK (aesthetic element)
   ============================================================ */
.terminal {
  background: #050810;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 32px 0;
}

.terminal-bar {
  background: #0f1419;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.terminal-dot:nth-child(1) { background: #ff5f56; }
.terminal-dot:nth-child(2) { background: #ffbd2e; }
.terminal-dot:nth-child(3) { background: #27c93f; }

.terminal-title {
  margin-left: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.terminal-body {
  padding: 20px 24px;
  font-size: 0.85rem;
  line-height: 1.8;
}

.terminal-prompt { color: var(--cyan); }
.terminal-cmd { color: var(--text); }
.terminal-out { color: var(--text-dim); }

/* ============================================================
   LIST VIEW (blog / all writeups)
   ============================================================ */
.post-list { list-style: none; }

.post-list-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  transition: all var(--transition);
}

.post-list-item:hover .post-list-title { color: var(--cyan); }

.post-list-date {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  width: 90px;
}

.post-list-title {
  font-size: 0.95rem;
  color: var(--text-bright);
  transition: color var(--transition);
}

.post-list-tags {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 48px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: all var(--transition);
}

.pagination a:hover { border-color: var(--cyan); color: var(--cyan); }
.pagination .current { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .navbar-nav { display: none; }
  .navbar-nav.open { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 16px; }
  .nav-toggle { display: block; }

  .hero { padding: 48px 0 36px; }
  .cards-grid { grid-template-columns: 1fr; }

  .footer-inner { flex-direction: column; align-items: flex-start; }

  .post-list-item { flex-wrap: wrap; }
  .post-list-tags { display: none; }
  .writeup-meta-box { grid-template-columns: 1fr 1fr; }
}
