:root {
  --bg-dark: #030712;
  --bg-panel: rgba(255, 255, 255, 0.035);
  --text-main: #f0f6ff;
  --text-muted: #8b9ec9;
  --accent-color: #00e5ff;
  --accent-gradient: linear-gradient(135deg, #00ffc8, #00e5ff, #7c3aed);
  --accent-violet: #7c3aed;
  --glass-border: rgba(0, 229, 255, 0.08);
  --glass-shadow: 0 8px 40px 0 rgba(0, 0, 0, 0.5);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: 'Courier New', 'Roboto Mono', monospace;
  --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Typography */
h1, h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 1rem;
}
h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.3;
  margin-bottom: 1rem;
}

a { color: var(--text-main); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-color); }

.text-gradient {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* Ambient Backgrounds */
.ambient-glow {
  position: fixed; border-radius: 50%; filter: blur(120px); opacity: 0.15; z-index: -2; pointer-events: none;
}
.glow-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: #06b6d4; animation: float 10s ease-in-out infinite alternate; }
.glow-2 { bottom: -10%; right: -10%; width: 60vw; height: 60vw; background: #10b981; animation: float 15s ease-in-out infinite alternate-reverse; }

.noise-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

@keyframes float { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(20px) scale(1.05); } }

/* Layout & Utils */
.site-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.wrapper { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: var(--glass-shadow);
}

/* Site Header */
.scroll-progress-container {
  width: 100%; height: 4px; background: rgba(255,255,255,0.05); position: absolute; top: 0; left: 0; z-index: 200;
}
.scroll-progress-bar {
  height: 100%; background: var(--accent-gradient); width: 0%; border-radius: 0 2px 2px 0; transition: width 0.1s;
}

.site-header {
  position: fixed; top: 0; left: 0; width: 100%; z-index: 100;
  padding: 1.5rem 0;
  transition: var(--transition);
}
.site-header.scrolled {
  padding: 1rem 0; background: rgba(7, 7, 10, 0.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}
.logo-text { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-accent { color: var(--accent-color); }
.site-nav { display: flex; gap: 2rem; }
.page-link { font-size: 1rem; font-weight: 500; font-family: var(--font-sans); }
.page-link:hover { color: var(--accent-color); }

/* Home & Hero */
.home { position: relative; }
#canvas-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
#canvas-container canvas { display: block; width: 100% !important; height: 100% !important; }

.hero-section {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 6rem 20px 4rem;
  position: relative;
}
.hero-content { position: relative; z-index: 10; max-width: 900px; }
.hero-eyebrow {
  display: inline-block; margin-bottom: 2rem;
  font-size: 0.9rem; font-weight: 500; letter-spacing: 3px; text-transform: uppercase;
  color: var(--accent-color); opacity: 0.8;
  border: 1px solid rgba(6,182,212,0.3); border-radius: 30px;
  padding: 0.4rem 1.2rem;
}
.hero-title { font-size: clamp(3.5rem, 9vw, 7rem); letter-spacing: -3px; margin-bottom: 1.5rem; line-height: 1; min-height: 1.2em; }
.hero-subtitle { font-size: clamp(1.1rem, 2.5vw, 1.4rem); color: var(--text-muted); max-width: 550px; margin: 0 auto 3rem; letter-spacing: 0.5px; }

.hero-scroll-hint {
  display: inline-flex; flex-direction: column; align-items: center; gap: 0.5rem;
  color: var(--text-muted); font-size: 0.85rem; letter-spacing: 2px; text-transform: uppercase;
  text-decoration: none; opacity: 0; transition: color 0.3s;
}
.hero-scroll-hint:hover { color: var(--accent-color); }
.scroll-arrow {
  font-size: 1.2rem;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* Projects Grid */
.projects-section { padding: 5rem 20px; position: relative; z-index: 1; }
.section-heading { font-size: 2.5rem; margin-bottom: 3rem; text-align: center; }
.projects-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 2rem;
}

/* Project Card */
.project-card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg-panel); border: 1px solid var(--glass-border); border-radius: 20px;
  overflow: hidden; transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.project-card:hover {
  transform: translateY(-8px); border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.2);
}
.project-card-image {
  width: 100%; height: 250px; position: relative; overflow: hidden;
  background: rgba(255,255,255,0.05); /* placeholder bg */
}
.project-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease; }
.project-card:hover .project-card-image img { transform: scale(1.05); }
.project-card-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.3s ease;
}
.project-card:hover .project-card-overlay { opacity: 1; }

/* Glitch action button */
.glitch-btn {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent-color);
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  animation: pulse-border 2.5s ease-in-out infinite;
  text-transform: uppercase;
  background: rgba(6,182,212,0.05);
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6,182,212,0); }
  50% { box-shadow: 0 0 0 6px rgba(6,182,212,0.15); }
}
.project-card-content { padding: 2rem; flex-grow: 1; display: flex; flex-direction: column; }
.project-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
.project-desc { color: var(--text-muted); font-size: 1rem; flex-grow: 1; margin-bottom: 1.5rem; }
.project-tag { display: inline-block; padding: 0.4rem 0.8rem; background: rgba(139, 92, 246, 0.15); color: #c4b5fd; border-radius: 20px; font-size: 0.85rem; font-weight: 600; align-self: flex-start;}

/* Cinematic Post Layout */
.post-wrapper { width: 100%; padding-bottom: 5rem; overflow-x: hidden; }
.post-hero {
  position: relative; width: 100%; height: 75vh; min-height: 500px;
  background-size: cover; background-position: center; background-attachment: fixed;
  display: flex; align-items: flex-end; justify-content: center;
  margin-bottom: 4rem;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(2,6,23,0.3) 0%, rgba(2,6,23,1) 100%);
}
.hero-content-inner {
  position: relative; z-index: 10; padding-bottom: 5rem; width: 100%; max-width: 1200px;
}
.post-title { font-size: clamp(3rem, 6vw, 5rem); letter-spacing: -2px; margin-bottom: 1rem; color: var(--text-main); }
.post-subtitle { font-size: 1.5rem; color: var(--text-muted); max-width: 800px; }

.post-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 4rem;
  align-items: start;
  min-height: 80vh;
}
.post-meta-sidebar { position: sticky; top: 120px; align-self: start; }
.meta-card { padding: 2rem; border-radius: 16px; background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.meta-heading { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; color: var(--text-main); }
.meta-item { margin-bottom: 1.5rem; }
.meta-item strong { display: block; color: var(--accent-color); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.5rem; }
.meta-item p { color: var(--text-muted); font-size: 1rem; margin: 0; }
.back-link { display: inline-block; margin-top: 1rem; color: var(--text-main); text-decoration: none; font-weight: 500; transition: color 0.2s; }
.back-link:hover { color: var(--accent-color); }

.editorial-content {
  max-width: 780px;
  font-size: 1.2rem;
  line-height: 1.8;
  color: #cbd5e1;
  overflow-wrap: break-word;
  word-break: break-word;
}
.editorial-content h2, .editorial-content h3 {
  color: var(--text-main); margin-top: 3.5rem; margin-bottom: 1.5rem;
}
.editorial-content p { margin-bottom: 2rem; }
.editorial-content p:first-of-type { font-size: 1.4rem; line-height: 1.9; color: var(--text-main); }
.editorial-content img, .editorial-content iframe { border-radius: 12px; margin: 3rem 0; max-width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.3); display: block;}
.editorial-content a { color: var(--accent-color); text-decoration: none; transition: var(--transition); border-bottom: 1px solid transparent; }
.editorial-content a:hover { border-bottom: 1px solid var(--accent-color); }

/* MacOS Terminal Code Blocks */
.editorial-content pre[class*="language-"] {
  border-radius: 12px !important;
  background: #0f111a !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  padding-top: 3rem !important;
  position: relative !important;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5) !important;
  margin: 3rem 0 !important;
}
.editorial-content pre[class*="language-"]::before {
  content: '';
  position: absolute;
  top: 16px; left: 16px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
}

@media (max-width: 992px) {
  .post-container { grid-template-columns: 1fr; gap: 2rem; }
  .post-meta-sidebar { position: static; margin-bottom: 2rem; }
}


/* Page Layout (About) — Sonar System Profile Design */
.page-wrapper { 
  padding-top: 6rem; padding-bottom: 5rem; 
  max-width: 860px; margin: auto; 
  position: relative; z-index: 1;
}

/* Sonar background rings */
.sonar-bg {
  position: fixed; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
}
.sonar-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(0, 229, 255, 0.06);
  animation: sonar-pulse 8s ease-out infinite;
}
.sonar-ring-1 { width: 400px; height: 400px; animation-delay: 0s; }
.sonar-ring-2 { width: 700px; height: 700px; animation-delay: 2.5s; }
.sonar-ring-3 { width: 1050px; height: 1050px; animation-delay: 5s; }
@keyframes sonar-pulse {
  0%   { opacity: 0; transform: scale(0.8); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.1); }
}

/* About card */
.about-card {
  padding: 3rem 3.5rem 2rem;
  border-radius: 20px;
  position: relative;
  border: 1px solid var(--glass-border);
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Pill header */
.about-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 3px;
  color: var(--accent-color);
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.25);
  padding: 0.35rem 1rem;
  border-radius: 30px;
  margin-bottom: 2rem;
  text-transform: uppercase;
}

/* Page text content */
.page-content { font-size: 1.2rem; line-height: 1.9; color: #b8cceb; }
.page-content p { margin-bottom: 1.75rem; }
.page-content p:first-of-type { font-size: 1.35rem; color: var(--text-main); }

/* Cyan highlight for "extreme data bias" — applied inline in about.md */
.data-bias {
  color: var(--accent-color);
  font-weight: 600;
}

/* Monospace metadata bar */
.about-meta-bar {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: rgba(0, 229, 255, 0.35);
  border-top: 1px solid rgba(0, 229, 255, 0.08);
  padding-top: 1.5rem;
  margin-top: 2.5rem;
  text-transform: uppercase;
}


/* Animations */
.cursor {
  display: inline-block;
  color: var(--accent-color);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.fade-in-up { animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes fadeInUp { 
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); } 
}

.reveal-on-scroll { opacity: 0; transform: translateY(40px); transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.reveal-on-scroll.is-visible { opacity: 1; transform: translateY(0); }
.project-card.reveal-on-scroll { transition-delay: calc(var(--animation-order) * 0.15s); }

/* Footer */
.social-icon-btn { font-size: 1.5rem; color: var(--text-muted); transition: var(--transition); }
.social-icon-btn:hover { color: var(--accent-color); transform: scale(1.1); }
.site-footer { padding: 4rem 0 2rem; border-top: 1px solid var(--glass-border); margin-top: auto; }
.footer-desc { color: var(--text-muted); max-width: 400px; }
.social-btn { font-weight: 500; font-family: var(--font-display); }
.footer-bottom { margin-top: 3rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* Helper classes */
.blur-bg { background: rgba(7, 7, 10, 0.7); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.05); border-radius: 24px;}

/* ============================================
   RESPONSIVE / MOBILE
   ============================================ */

/* Hamburger button — hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 200;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: var(--transition);
}
/* Animate hamburger → X */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 768px) {
  /* --- Nav --- */
  .nav-toggle { display: flex; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(3, 7, 18, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1.5rem 2rem;
    flex-direction: column;
    gap: 0;
  }
  .site-nav.open { display: flex; }
  .page-link {
    display: block;
    padding: 1rem 0;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }

  /* --- Global --- */
  .wrapper { padding: 0 16px; }

  /* --- Hero --- */
  .hero-section { padding: 5rem 16px 3rem; }
  .hero-title { letter-spacing: -2px; }
  .hero-eyebrow { font-size: 0.75rem; letter-spacing: 2px; }
  .hero-subtitle { font-size: 1rem; }
  .hero-scroll-hint { opacity: 1 !important; } /* always visible on mobile */

  /* --- Projects Grid --- */
  .projects-section { padding: 3rem 16px; }
  .projects-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .section-heading { font-size: 2rem; }

  /* --- Post Layout --- */
  .post-hero {
    height: 45vh;
    min-height: 260px;
    background-attachment: scroll;
    padding-top: 4rem; /* clear the fixed header */
  }
  .post-title { font-size: clamp(1.8rem, 7vw, 2.8rem); letter-spacing: -1px; }
  .post-subtitle { font-size: 1rem; }
  .hero-content-inner {
    padding-bottom: 2rem;
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Fix: post-container sits inside .wrapper which already adds 16px.
     Remove the double-padding and let wrapper handle horizontal spacing. */
  .post-container {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: unset;
    padding: 2rem 20px 0;  /* top gap + side padding for everything inside */
  }
  .post-meta-sidebar {
    position: static;
    margin-bottom: 1.5rem;
  }
  .meta-card { padding: 1.25rem; }

  /* Fix the editorial content overflowing the viewport */
  .post-content.editorial-content {
    width: 100%;
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.75;
    overflow-x: hidden;
  }
  .editorial-content p:first-of-type { font-size: 1.1rem; }
  .editorial-content img {
    margin: 1.5rem 0;
    border-radius: 8px;
    max-width: 100%;
  }
  .editorial-content iframe {
    margin: 1.5rem 0;
    border-radius: 8px;
  }
  /* Scrollable code blocks — don't clip them */
  .editorial-content pre,
  .editorial-content pre[class*="language-"] {
    margin: 1.5rem -20px !important;  /* bleed to edges for breathing room */
    border-radius: 0 !important;
    padding-top: 2.5rem !important;
    font-size: 0.82rem !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  /* iframes (Plotly, embeds) — full width on mobile */
  .editorial-content iframe,
  .post-figure iframe {
    width: 100% !important;
    min-height: 280px;
  }
  /* Fix any inline elements overflowing */
  .editorial-content * { max-width: 100%; }

  /* --- About Page --- */
  .page-wrapper {
    padding-top: 5rem;
    padding-bottom: 3rem;
    padding-left: 16px;
    padding-right: 16px;
  }
  .about-card {
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 16px;
  }
  .about-pill {
    font-size: 0.65rem;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
  }
  .page-content { font-size: 1.05rem; }
  .page-content p:first-of-type { font-size: 1.15rem; }
  .about-meta-bar {
    font-size: 0.65rem;
    letter-spacing: 1px;
    word-break: break-word;
  }

  /* --- Footer --- */
  .site-footer .footer-content {
    flex-direction: column;
    gap: 1.5rem;
    align-items: flex-start;
  }
  .footer-col.social-links { justify-content: flex-start !important; }
  .footer-bottom { margin-top: 2rem; }

  /* --- Reading ring — move to not overlap content --- */
  .reading-ring { bottom: 1rem; right: 1rem; width: 40px; height: 40px; }

  /* --- Glass panel --- */
  .glass-panel { padding: 1.5rem; border-radius: 12px; }
}

/* Extra-small screens */
@media (max-width: 480px) {
  .logo-text { font-size: 1.1rem; }
  .hero-title { letter-spacing: -1.5px; }
  .post-title { font-size: clamp(1.75rem, 9vw, 2.5rem); }
  .project-card-image { height: 200px; }
  .about-meta-bar { display: none; } /* too cramped on tiny screens */
}


/* Image Captions */
.post-figure { margin: 3rem 0; width: 100%; text-align: center; }
.post-figure img { margin: 0 0 1rem 0; max-width: 100%; height: auto; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.post-figure iframe { margin: 0 0 1rem 0; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.post-figcaption {
  font-size: 0.9rem; font-style: italic; color: #94a3b8; max-width: 80%; margin: 0.75rem auto 0; line-height: 1.5; display: block;
}

/* Circular Reading Progress Ring */
.reading-ring {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 200;
  width: 48px; height: 48px;
  transform: rotate(-90deg);
  opacity: 0; transition: opacity 0.4s;
}
.reading-ring.visible { opacity: 1; }
.ring-bg { stroke: rgba(255,255,255,0.08); }
.ring-progress { stroke: url(#ringGradient); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
