/* ============================================
   cdewan.me — Design System
   Terminal/Hacker Aesthetic
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');
/* font-display:swap is handled by the Google Fonts &display=swap param above */

:root {
  --bg: #0a0a0a;
  --bg-raised: #111111;
  --bg-surface: #161616;
  --green: #00ff41;
  --green-dim: #00cc33;
  --green-glow: rgba(0, 255, 65, 0.15);
  --amber: #ffb000;
  --amber-dim: #cc8d00;
  --amber-glow: rgba(255, 176, 0, 0.15);
  --red: #ff3333;
  --text: #cccccc;
  --text-muted: #666666;
  --text-dim: #444444;
  --border: #1a1a1a;
  --border-bright: #2a2a2a;
  --font: 'JetBrains Mono', monospace;
  --line-height: 1.7;
  --max-width: 780px;
  --cursor-blink: cursor-blink 1s step-end infinite;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--bg);
  color-scheme: dark;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: var(--line-height);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- CRT Scanlines ---- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ---- CRT Vignette ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.35) 100%
  );
  pointer-events: none;
  z-index: 9998;
}

/* ---- CRT Flicker (subtle) ---- */
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.98; }
  94% { opacity: 1; }
}
body { animation: crt-flicker 8s infinite; }

/* ---- Boot sequence ---- */
@keyframes boot-in {
  from { opacity: 0; filter: brightness(2) saturate(0); }
  30% { opacity: 1; filter: brightness(1.5) saturate(0.5); }
  to { opacity: 1; filter: brightness(1) saturate(1); }
}
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  animation: boot-in 0.8s ease-out;
}

/* ---- Phosphor glow utility ---- */
.glow-green { text-shadow: 0 0 8px var(--green-glow), 0 0 20px rgba(0, 255, 65, 0.08); }
.glow-amber { text-shadow: 0 0 8px var(--amber-glow), 0 0 20px rgba(255, 176, 0, 0.08); }

/* ---- Navigation ---- */
.nav {
  border-bottom: 1px solid var(--border);
  padding: 1.2rem 0;
  margin-bottom: 3rem;
}
.nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.nav__home {
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  transition: text-shadow 0.3s;
}
.nav__home:hover {
  text-shadow: 0 0 12px var(--green-glow), 0 0 30px rgba(0, 255, 65, 0.1);
}
.nav__home::before { content: '~/'; color: var(--text-muted); }
.nav__links {
  display: flex;
  gap: 1.8rem;
  list-style: none;
}
.nav__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: color 0.2s, text-shadow 0.3s;
  position: relative;
}
.nav__links a::before {
  content: '$ ';
  color: var(--text-dim);
  font-weight: 300;
}
.nav__links a:hover,
.nav__links a.active {
  color: var(--green);
  text-shadow: 0 0 10px var(--green-glow);
}
/* Terminal cursor on nav hover */
.nav__links a::after {
  content: '';
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  transition: width 0.15s;
}
.nav__links a:hover::after {
  content: '█';
  width: 0.6em;
  color: var(--green);
  animation: var(--cursor-blink);
}

/* ---- Cursor blink ---- */
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.cursor::after {
  content: '█';
  color: var(--green);
  animation: var(--cursor-blink);
  margin-left: 2px;
}

/* ---- Section Headers ---- */
.section-header {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.section-header span { color: var(--green); }

/* ---- Terminal Line Animation ---- */
@keyframes line-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.line-in {
  opacity: 0;
  animation: line-in 0.3s ease forwards;
}
.line-in:nth-child(1) { animation-delay: 0.05s; }
.line-in:nth-child(2) { animation-delay: 0.1s; }
.line-in:nth-child(3) { animation-delay: 0.15s; }
.line-in:nth-child(4) { animation-delay: 0.2s; }
.line-in:nth-child(5) { animation-delay: 0.25s; }
.line-in:nth-child(6) { animation-delay: 0.3s; }
.line-in:nth-child(7) { animation-delay: 0.35s; }
.line-in:nth-child(8) { animation-delay: 0.4s; }
.line-in:nth-child(9) { animation-delay: 0.45s; }
.line-in:nth-child(10) { animation-delay: 0.5s; }

/* ---- Scroll reveal ---- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Post Content ---- */
.post-content {
  font-size: 0.9rem;
  line-height: 1.8;
}
.post-content h1,
.post-content h2,
.post-content h3 {
  color: var(--green);
  margin: 2rem 0 1rem;
  font-weight: 600;
}
.post-content h1 { font-size: 1.5rem; }
.post-content h2 { font-size: 1.15rem; }
.post-content h3 { font-size: 1rem; }
.post-content p { margin-bottom: 1rem; }
.post-content a {
  color: var(--amber);
  text-decoration: none;
  background-image: linear-gradient(var(--amber), var(--amber));
  background-size: 0% 1px;
  background-position: left bottom;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease, color 0.2s;
  text-underline-offset: 3px;
}
.post-content a:hover {
  background-size: 100% 1px;
}
.post-content code {
  background: var(--bg-surface);
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  font-size: 0.85em;
  color: var(--green);
}
.post-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}
.post-content pre::before {
  content: '>';
  position: absolute;
  top: 0.5rem;
  right: 0.8rem;
  color: var(--text-dim);
  font-size: 0.6rem;
}
.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}
.post-content blockquote {
  border-left: 2px solid var(--green);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
}
.post-content ul, .post-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.post-content li { margin-bottom: 0.3rem; }
.post-content img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin: 1.5rem 0;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.post-title {
  font-size: 1.6rem;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 20px var(--green-glow);
}

/* ---- Projects ---- */
.project-card {
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--bg-raised);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.project-card:hover {
  border-color: var(--green-dim);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.05), inset 0 0 20px rgba(0, 255, 65, 0.02);
  transform: translateY(-2px);
}
.project-card__name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 0.3rem;
  transition: text-shadow 0.3s;
}
.project-card:hover .project-card__name {
  text-shadow: 0 0 12px var(--green-glow);
}
.project-card__name::before {
  content: '▸ ';
  color: var(--amber);
}
.project-card__thesis {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.project-card__stack {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.stack-tag {
  font-size: 0.7rem;
  color: var(--green-dim);
  border: 1px solid var(--border-bright);
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
  transition: border-color 0.2s, color 0.2s;
}
.project-card:hover .stack-tag {
  border-color: var(--green-dim);
  color: var(--green);
}
.project-card__status {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.project-card__status span.active { color: var(--amber); }
.project-card__link {
  display: inline-block;
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: var(--amber);
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.3s;
}
.project-card__link:hover {
  text-shadow: 0 0 8px var(--amber-glow);
  text-decoration: underline;
}

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.3s;
}
.footer a:hover {
  color: var(--green);
  text-shadow: 0 0 8px var(--green-glow);
}
.footer__links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.8rem;
}
.footer__tagline {
  color: var(--green-dim);
  font-size: 0.65rem;
  margin-top: 0.6rem;
  opacity: 0.6;
  transition: opacity 0.3s;
  font-style: italic;
}
.footer:hover .footer__tagline { opacity: 1; }
.footer__push {
  color: var(--text-dim);
  font-size: 0.6rem;
  margin-top: 0.4rem;
}

/* ---- Mobile Nav Toggle ---- */
.nav__toggle {
  display: none;
  background: none;
  border: none;
  color: var(--green);
  font-family: var(--font);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

/* ---- Selection color ---- */
::selection {
  background: rgba(0, 255, 65, 0.2);
  color: var(--green);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  html { font-size: 14px; }
  .container { padding: 1.5rem 1rem; }

  .nav__toggle { display: block; }
  .nav__links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding-top: 1rem;
  }
  .nav__links.open { display: flex; }
  .nav__links li { padding: 0.6rem 0; border-top: 1px solid var(--border); }
  .nav__inner { flex-wrap: wrap; }

  /* Disable hover effects on touch */
  .nav__links a::after { display: none; }
  .project-card:hover { transform: none; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .container { animation: none; }
  .reveal { opacity: 1; transform: none; }
}
