/* ==========================================================================
   Design System — phoganuci.com
   Dark-theme engineering blog stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  --bg-deep: #0F1117;
  --bg-mid: #1A1D27;
  --bg-surface: #1E2130;
  --bg-surface-hover: #252839;
  --border-subtle: rgba(255,255,255,0.06);
  --border-med: rgba(255,255,255,0.1);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255,255,255,0.6);
  --text-tertiary: rgba(255,255,255,0.35);
  --accent-gold: #E8A849;
  --accent-gold-dim: rgba(232,168,73,0.15);
  --accent-teal: #4ECDC4;
  --accent-teal-dim: rgba(78,205,196,0.12);
  --accent-rose: #E85D75;
  --accent-rose-dim: rgba(232,93,117,0.12);
  --accent-blue: #7B93DB;
  --accent-blue-dim: rgba(123,147,219,0.12);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-width: 1100px;
}

/* --------------------------------------------------------------------------
   Reset + Base
   -------------------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-gold);
  color: var(--bg-deep);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--accent-teal);
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  letter-spacing: -0.01em;
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

h4 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1rem 2rem;
  transition: background 0.3s var(--ease), backdrop-filter 0.3s var(--ease);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav.scrolled,
.nav.nav-scrolled {
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: -0.01em;
}

.nav-logo:hover {
  color: var(--accent-gold);
  opacity: 0.85;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s var(--ease);
}

.nav-links a:hover {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 80vh;
  padding: 8rem 2rem 4rem;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  pointer-events: none;
}

.hero-title {
  position: relative;
  margin-bottom: 1.5rem;
}

.hero-subtitle {
  position: relative;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Home Hero (with profile photo)
   -------------------------------------------------------------------------- */

.home-hero {
  min-height: 70vh;
  padding: 8rem 2rem 4rem;
}

.home-hero .hero-content {
  max-width: 640px;
}

.home-hero .subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.home-hero .intro {
  font-size: 1rem;
  color: var(--text-tertiary);
  line-height: 1.75;
  margin-bottom: 2rem;
}

.links-row {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.links-row a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-gold);
  text-decoration: none;
}

.links-row a:hover {
  color: var(--accent-teal);
}

.coming-soon {
  opacity: 0.5;
  cursor: default;
}

.coming-soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-subtle);
}

.hero-blog {
  min-height: 60vh;
  padding: 7rem 2rem 3rem;
}

.hero-blog .profile-image {
  margin-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   Profile Image
   -------------------------------------------------------------------------- */

.profile-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--border-med);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  object-fit: cover;
  margin: 0 auto 2rem;
}

/* --------------------------------------------------------------------------
   Section Layout
   -------------------------------------------------------------------------- */

.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 2rem;
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  margin-bottom: 0.75rem;
}

.section-heading {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
}

.section-prose {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   Stat Cards
   -------------------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
}

.stat {
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bg-surface);
}

.stat-number {
  display: block;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.75rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
              border-color 0.25s var(--ease);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: var(--border-med);
}

.card-gold {
  border-left: 3px solid var(--accent-gold);
}

.card-teal {
  border-left: 3px solid var(--accent-teal);
}

.card-rose {
  border-left: 3px solid var(--accent-rose);
}

.card-blue {
  border-left: 3px solid var(--accent-blue);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  border-bottom: 1px solid var(--border-med);
}

tbody td {
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

tbody tr:nth-child(even) {
  background: var(--bg-surface);
}

tbody tr:hover {
  background: var(--bg-surface-hover);
}

/* --------------------------------------------------------------------------
   Code Blocks
   -------------------------------------------------------------------------- */

pre {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

:not(pre) > code {
  color: var(--accent-teal);
  background: var(--accent-teal-dim);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Prism.js overrides — match dark theme */
pre[class*="language-"],
code[class*="language-"] {
  background: var(--bg-surface) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.875rem !important;
  line-height: 1.65 !important;
  text-shadow: none !important;
}

pre[class*="language-"] {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

/* File tree — tight line-height for connected box-drawing characters.
   Box-drawing chars (│├└) connect when line-height × font-size = cell height.
   At 0.85rem (~13.6px), line-height 1.2 = ~16.3px cell — close to glyph height. */
.file-tree {
  line-height: 1.25 !important;
  padding: 1rem 1.5rem !important;
  font-size: 0.85rem !important;
  letter-spacing: 0 !important;
}

.file-tree code {
  line-height: 1.25 !important;
  font-size: 0.85rem !important;
}

.file-tree .tree-dir {
  color: var(--accent-gold);
  font-weight: 500;
}

.file-tree .tree-file {
  color: var(--text-secondary);
}

.file-tree .tree-comment {
  color: var(--text-tertiary);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */

ul, ol {
  margin: 1rem 0 1.5rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

ul {
  list-style: none;
}

ul li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.5rem;
}

ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-gold);
}

ol li {
  margin-bottom: 0.5rem;
}

/* --------------------------------------------------------------------------
   Blockquote
   -------------------------------------------------------------------------- */

blockquote {
  border-left: 3px solid var(--accent-gold);
  padding: 0.75rem 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-tertiary);
}

blockquote p {
  color: var(--text-tertiary);
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Prose — strong / emphasis
   -------------------------------------------------------------------------- */

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

em, i {
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Mermaid Diagrams
   -------------------------------------------------------------------------- */

.diagram-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 2rem;
  margin: 2rem 0;
  overflow-x: auto;
}

.diagram-container svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.diagram-container .cluster-label .nodeLabel,
.diagram-container .nodeLabel {
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}

.diagram-container .edgeLabel {
  color: var(--text-secondary) !important;
  fill: var(--text-secondary) !important;
  background: var(--bg-surface) !important;
}

.diagram-container .cluster rect {
  fill: var(--bg-mid) !important;
  stroke: var(--border-med) !important;
}

/* --------------------------------------------------------------------------
   Fade-in Animation
   -------------------------------------------------------------------------- */

.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in-delay-1 { transition-delay: 0.1s; }
.fade-in-delay-2 { transition-delay: 0.2s; }
.fade-in-delay-3 { transition-delay: 0.3s; }
.fade-in-delay-4 { transition-delay: 0.4s; }

/* --------------------------------------------------------------------------
   Blog Post Layout
   -------------------------------------------------------------------------- */

.post-header {
  padding: 8rem 2rem 3rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
}

.post-header--hero {
  position: relative;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.post-header--hero .hero-content {
  position: relative;
  z-index: 1;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.scroll-indicator {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: bounce 2s infinite;
  z-index: 1;
}

.scroll-indicator span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-tertiary);
}

.scroll-indicator svg {
  stroke: var(--text-tertiary);
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
  40% { transform: translateX(-50%) translateY(-8px); }
  60% { transform: translateX(-50%) translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-canvas { display: none; }
  .scroll-indicator { animation: none; }
}

.post-header .hero-subtitle {
  text-align: center;
}

.post-header .section-label {
  text-align: center;
}

.post-header .section-prose {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.post-header h1 {
  max-width: var(--max-width);
  margin: 0 auto 1rem;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.post-meta span::before {
  content: '';
  display: none;
}

.post-meta .separator {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.post-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

article.case-study .post-body {
  max-width: none;
  padding: 0;
  margin-top: 1.5rem;
}

.post-body h2 {
  margin-top: 3rem;
  margin-bottom: 1rem;
}

.post-body h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-body img:not(.profile-image) {
  border-radius: 8px;
  margin: 2rem 0;
}

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Blog Index — Post Cards
   -------------------------------------------------------------------------- */

.post-list {
  display: grid;
  gap: 1.5rem;
}

.post-card {
  display: block;
  position: relative;
  background: linear-gradient(145deg, var(--bg-surface) 0%, var(--bg-mid) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 2rem;
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease),
              border-color 0.5s var(--ease);
  color: inherit;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-teal));
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.post-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: radial-gradient(ellipse at 70% 20%, rgba(232,168,73,0.04) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

a.post-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
              0 0 60px rgba(232, 168, 73, 0.06);
  border-color: rgba(232, 168, 73, 0.25);
  color: inherit;
}

.post-card:hover::before {
  opacity: 0.7;
}

.post-card:hover::after {
  opacity: 1;
}

.post-card:hover h3 {
  color: var(--accent-gold);
}

.post-card h3 {
  transition: color 0.5s var(--ease);
}

.post-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.post-card-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.75rem;
}

.post-card-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.post-card-content .post-meta {
  justify-content: flex-start;
  margin-bottom: 0.75rem;
}

.post-card-content .read-time {
  color: var(--text-tertiary);
}

.post-card-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0;
}

.post-card-content time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.post-card-excerpt {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.blog-header {
  margin-bottom: 2rem;
}

.blog-header .subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  padding: 3rem 2rem;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
}

.footer p {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Responsive — Tablet (768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .hero {
    min-height: 60vh;
    padding: 6rem 1.5rem 3rem;
  }

  .section {
    padding: 3rem 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .post-header {
    padding: 6rem 1.5rem 2rem;
  }

  .post-body {
    padding: 2rem 1.5rem 3rem;
  }

  .post-meta {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .profile-image {
    width: 96px;
    height: 96px;
  }
}

/* --------------------------------------------------------------------------
   Responsive — Mobile (480px)
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .nav {
    padding: 0.75rem 1rem;
  }

  .hero {
    padding: 5rem 1rem 2.5rem;
  }

  .section {
    padding: 2.5rem 1rem;
  }

  .stat {
    padding: 1.25rem 1rem;
  }

  .card {
    padding: 1.25rem;
  }

  .post-card {
    padding: 1.25rem;
  }

  .post-header {
    padding: 5rem 1rem 1.5rem;
  }

  .post-body {
    padding: 1.5rem 1rem 2.5rem;
  }

  pre {
    padding: 1rem;
    font-size: 0.8rem;
  }

  .diagram-container {
    padding: 1rem;
  }
}
