/* KavKlaw Writeups — Terminal Theme (matching kaveenk.com) */
:root {
  --bg: #0b0f14;
  --bg-surface: rgba(10, 14, 20, 0.85);
  --text: #d7fbe8;
  --text-muted: rgba(214, 255, 233, 0.7);
  --text-dim: rgba(214, 255, 233, 0.5);
  --accent: #7cf7c0;
  --accent-alt: #8bd3ff;
  --border: rgba(117, 255, 171, 0.2);
  --border-hover: rgba(117, 255, 171, 0.5);
  --glow: rgba(124, 247, 192, 0.35);
  --radius: 16px;
  --font: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #0f1722, #0b0f14 45%, #06080b);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }

/* Sparks background layer */
.sparks-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 12% 18%, rgba(124, 247, 192, 0.06) 0%, transparent 60%),
    radial-gradient(120% 90% at 85% 12%, rgba(139, 211, 255, 0.05) 0%, transparent 62%);
  mix-blend-mode: screen;
  animation: ambientDrift 28s ease-in-out infinite;
}

@keyframes ambientDrift {
  0% { transform: translateZ(0) scale(1); }
  50% { transform: translate3d(-4%, 3%, 0) scale(1.04); }
  100% { transform: translateZ(0) scale(1); }
}

/* App layout */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: clamp(2.5rem, 4vw, 3.5rem) clamp(1.2rem, 3.5vw, 4.5rem);
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
}

/* Terminal window */
.terminal-window {
  width: 100%;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), 0 0 30px rgba(63, 255, 178, 0.12);
  overflow: hidden;
  position: relative;
}

.terminal-window::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(11, 15, 20, 0), rgba(11, 15, 20, 0.08), rgba(11, 15, 20, 0));
  pointer-events: none;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem;
  background: rgba(15, 21, 30, 0.85);
  border-bottom: 1px solid rgba(117, 255, 171, 0.15);
  font-size: 0.85rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}
.dot.red { background: #ff6b6b; }
.dot.yellow { background: #ffd166; }
.dot.green { background: #69db7c; }

.terminal-title {
  margin-left: 0.6rem;
  color: rgba(214, 255, 233, 0.6);
  letter-spacing: 0.04em;
}

.terminal-body {
  padding: clamp(1.8rem, 3vw, 2.6rem);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
  z-index: 1;
}

/* Prompt styling */
.prompt {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.prompt-user { color: var(--accent); }
.prompt-path { color: var(--accent-alt); }
.prompt-sep { color: var(--text-dim); }

.hero-title {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.hero-title .accent { color: var(--accent); }

.hero-subtitle {
  max-width: 560px;
  color: var(--text-muted);
  line-height: 1.6;
}

.terminal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Sections */
.section {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.6rem, 3vw, 2.4rem);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.section-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: rgba(124, 247, 192, 0.7);
}

.section h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
}

/* Writeups grid */
.writeups-grid {
  display: grid;
  gap: 1.2rem;
}

/* Card */
.card {
  display: block;
  background: rgba(13, 18, 26, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  height: 2px;
  top: 0;
  background: linear-gradient(90deg, transparent, rgba(124, 247, 192, 0.55), transparent);
  opacity: 0;
  transform: translateY(-30%);
  animation: cardScan 6.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes cardScan {
  0% { opacity: 0; transform: translateY(-30%); }
  25% { opacity: 0.6; }
  55% { opacity: 0.15; }
  100% { opacity: 0; transform: translateY(140%); }
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(117, 255, 171, 0.45);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35), 0 0 22px rgba(63, 255, 178, 0.16);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.card h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.card-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(124, 247, 192, 0.35);
  border-radius: 999px;
  white-space: nowrap;
}

.card-description {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.78rem;
}

.card-tag {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(139, 211, 255, 0.25);
  color: rgba(139, 211, 255, 0.85);
  background: rgba(139, 211, 255, 0.08);
}

.card-tag.difficulty-easy { border-color: rgba(124, 247, 192, 0.4); color: var(--accent); background: rgba(124, 247, 192, 0.08); }
.card-tag.difficulty-medium { border-color: rgba(255, 209, 102, 0.4); color: #ffd166; background: rgba(255, 209, 102, 0.08); }
.card-tag.difficulty-hard { border-color: rgba(255, 107, 107, 0.4); color: #ff6b6b; background: rgba(255, 107, 107, 0.08); }
.card-tag.difficulty-insane { border-color: rgba(255, 68, 68, 0.5); color: #ff4444; background: rgba(255, 68, 68, 0.12); text-shadow: 0 0 8px rgba(255, 68, 68, 0.4); }

.card-date {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-left: auto;
}

/* Writeup page */
.writeup-page {
  max-width: 860px;
  margin: 0 auto;
}

.writeup-content {
  color: var(--text-muted);
  line-height: 1.7;
}

.writeup-content h1, .writeup-content h2, .writeup-content h3 {
  color: var(--text);
  margin: 1.8rem 0 0.8rem;
}

.writeup-content h1 { font-size: 1.8rem; }
.writeup-content h2 { font-size: 1.4rem; color: var(--accent); }
.writeup-content h3 { font-size: 1.15rem; color: var(--accent-alt); }

.writeup-content p { margin: 0.8rem 0; }

.writeup-content a {
  color: var(--accent-alt);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.writeup-content a:hover { color: var(--accent); }

.writeup-content code {
  background: rgba(6, 10, 15, 0.8);
  border: 1px solid rgba(124, 247, 192, 0.2);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-size: 0.88em;
  color: var(--accent);
}

.writeup-content pre {
  background: #060a0f;
  border: 1px solid rgba(124, 247, 192, 0.2);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1rem 0;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.writeup-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.writeup-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  background: rgba(124, 247, 192, 0.05);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
}

.writeup-content ul, .writeup-content ol {
  margin: 0.8rem 0;
  padding-left: 1.5rem;
}

.writeup-content li { margin: 0.4rem 0; }

.writeup-content img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.writeup-content .flag-box {
  background: rgba(124, 247, 192, 0.08);
  border: 1px solid rgba(124, 247, 192, 0.4);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin: 1.5rem 0;
  text-align: center;
}

.writeup-content .flag-box .flag-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.writeup-content .flag-box .flag-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

/* Back button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
  margin-bottom: 1rem;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding-top: 1rem;
}

.footer-link { color: var(--accent-alt); }
.footer-link:hover { color: var(--accent); }

.footer-build {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.build-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--glow);
  animation: statusFlash 1.2s ease-in-out infinite;
}

@keyframes statusFlash {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* Term tooltips */
.term {
  color: var(--accent);
  border-bottom: 1px dashed rgba(124, 247, 192, 0.4);
  cursor: help;
  position: relative;
}
.term:hover { border-bottom-color: var(--accent); }

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0d1117;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 300px;
  min-width: 180px;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 12px rgba(124, 247, 192, 0.15);
  white-space: normal;
  text-align: left;
}
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent);
}

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 2rem 1.1rem; }
  .hero-title { font-size: clamp(1.8rem, 7vw, 2.6rem); }
  .terminal-body { padding: 1.4rem; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .card-date { margin-left: 0; }
  .footer { flex-direction: column; gap: 0.6rem; text-align: center; }
}
