/* Modern Premium Reset & Base Styles */
:root {
  --rgb-text: 255, 255, 255;
  --bg-color: #0b0c10;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-color: #a855f7;
  --accent-glow: rgba(168, 85, 247, 0.4);
  --accent-secondary: #c084fc;
  --card-bg: #16181d;
  --card-border: #1f2937;
  --card-hover-border: #374151;
  --nav-height: 70px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  --rgb-text: 17, 24, 39;
  --bg-color: #FAFAFA;
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --card-bg: rgba(0, 0, 0, 0.03);
  --card-border: rgba(0, 0, 0, 0.1);
  --card-hover-border: rgba(0, 0, 0, 0.2);
}

html {
  font-size: var(--base-font-size, 16px);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Site Header Navbar */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  background: rgba(11, 12, 16, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  z-index: 1000;
  transition: all 0.3s ease;
}

.site-header a.logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  color: #FAFAFA !important;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-header .back-link {
  color: #A1A1AA !important;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.site-header .back-link:hover {
  color: #FAFAFA !important;
}

.site-header .btn-secondary {
  color: #FAFAFA !important;
  border-color: rgba(255,255,255,0.2) !important;
  background: rgba(255,255,255,0.05) !important;
}

.site-header .btn-secondary:hover {
  background: rgba(255,255,255,0.1) !important;
}

/* Progress Bar */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 1001;
}

#progress-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
  width: 0%;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Hero Section */
.hero {
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 2rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.hero-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 100px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-color);
  margin-bottom: 2rem;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.hero h1 {
  font-size: clamp(3rem, 6vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  font-weight: 800;
  background: linear-gradient(180deg, var(--text-primary) 0%, #A1A1AA 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 3rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-color);
  border: 1px solid transparent;
}

.btn-primary:hover {
  background: #E4E4E7;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(var(--rgb-text), 0.15);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  background: rgba(var(--rgb-text), 0.05);
  border-color: var(--card-hover-border);
}

/* Tech Marquee */
.tech-marquee {
  position: absolute;
  bottom: 2rem;
  left: 0;
  width: 100%;
  overflow: hidden;
  padding: 1.5rem 0;
  background: linear-gradient(90deg, var(--bg-color) 0%, transparent 10%, transparent 90%, var(--bg-color) 100%);
  border-top: 1px solid rgba(var(--rgb-text),0.03);
  border-bottom: 1px solid rgba(var(--rgb-text),0.03);
  display: flex;
}

.marquee {
  display: flex;
  width: fit-content;
  animation: scroll 30s linear infinite;
}

.marquee-content {
  display: flex;
  align-items: center;
  gap: 3rem;
  padding: 0 1.5rem;
}

.marquee span {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.9rem;
  opacity: 0.6;
  white-space: nowrap;
}

@keyframes scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Portfolio Section */
.portfolio-section {
  padding: 8rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  margin-bottom: 4rem;
}

.section-header h2 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.portfolio-item {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.portfolio-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(var(--rgb-text),0.1), transparent);
  -webkit-mask: linear-gradient(var(--text-primary) 0 0) content-box, linear-gradient(var(--text-primary) 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.portfolio-item:hover {
  transform: translateY(-4px);
  background: rgba(var(--rgb-text), 0.03);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.portfolio-item:hover::before {
  opacity: 1;
}

.portfolio-thumbnail {
  height: 180px;
  background: #0A0A0B;
  border-bottom: 1px solid var(--card-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumbnail-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.2) !important;
  padding: 1rem;
  white-space: pre-wrap;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 40%, rgba(0,0,0,0));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 40%, rgba(0,0,0,0));
}

.thumbnail-icon {
  z-index: 1;
  color: #FAFAFA !important;
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(var(--rgb-text),0.1);
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.portfolio-item:hover .thumbnail-icon {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.5);
  color: var(--accent-color);
}

.portfolio-content {
  padding: 1.5rem;
  flex-grow: 1;
}

.portfolio-content h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.portfolio-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Dossier Article Layout */
.dossier-theme {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.blogs-page {
  display: grid;
  grid-template-columns: 1fr 240px;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: calc(var(--nav-height) + 4rem);
  gap: 6rem;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Sidebar Rail */
.section-rail {
  position: sticky;
  top: calc(var(--nav-height) + 2rem);
  height: calc(100vh - var(--nav-height) - 4rem);
  overflow-y: auto;
  padding-left: 2rem;
  border-left: 1px solid var(--card-border);
}

/* Custom Scrollbar for rail */
.section-rail::-webkit-scrollbar { width: 4px; }
.section-rail::-webkit-scrollbar-track { background: transparent; }
.section-rail::-webkit-scrollbar-thumb { background: rgba(var(--rgb-text),0.1); border-radius: 4px; }

.rail-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  display: flex;
  justify-content: space-between;
}

.section-rail nav#toc {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-rail a {
  display: flex;
  gap: 1rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.2s;
  padding: 0.5rem 0;
}

.section-rail a:hover {
  color: var(--text-primary);
}

.section-rail a.is-active {
  color: var(--accent-color);
  font-weight: 500;
}

.section-rail a span {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding-top: 0.1rem;
}

.section-rail a.is-active span {
  color: var(--accent-color);
}

.section-rail a strong {
  font-weight: 500;
}

/* Main Article */
.article {
  max-width: 850px;
  padding: 0 0 8rem 0;
  background: transparent;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .article {
    padding: 2rem 1.5rem 6rem;
  }
}

.dossier-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 3rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dossier-banner span {
  display: flex;
  align-items: center;
}

.dossier-banner .dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  margin-right: 0.5rem;
}

.article-header h2 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  line-height: 1.1;
  color: var(--text-primary);
}

.article-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 4rem;
  line-height: 1.6;
}

.prose-section {
  margin-bottom: 4rem;
  position: relative;
}

.section-content {
  min-width: 0;
}


.section-content h3 {
  font-size: 1.875rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-weight: 700;
  padding-top: 2rem;
  margin-top: 3rem;
  border-top: 1px solid var(--card-border);
}

.section-content h4 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.section-content p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.section-content ul {
  padding-left: 1.5rem;
  margin-bottom: 2rem;
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 1.1rem;
}

.section-content li { margin-bottom: 0.75rem; }

.section-content a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--accent-color);
  text-underline-offset: 4px;
  transition: color 0.2s;
}
.section-content a:hover { color: var(--accent-color); }

/* Code Blocks */

.prose-section p code, .prose-section li code {
  font-family: var(--font-mono);
  background: rgba(var(--rgb-text), 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text-primary);
}

/* Syntax Highlighting Mock Colors */
.token-keyword { color: #c678dd; }
.token-function { color: #61afef; }
.token-string { color: #98c379; }
.token-comment { color: #5c6370; font-style: italic; }
.token-operator { color: #56b6c2; }
.token-type { color: #e5c07b; }
.token-property { color: #d19a66; }

/* Tables */
.section-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2.5rem 0;
  font-size: 0.95rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.section-content th {
  background: rgba(var(--rgb-text), 0.03);
  padding: 1.25rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--card-border);
}

.section-content td {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(var(--rgb-text), 0.03);
  color: var(--text-secondary);
  line-height: 1.6;
  vertical-align: top;
}

.section-content tr:last-child td {
  border-bottom: none;
}

.section-content tr:hover td {
  background: rgba(var(--rgb-text),0.01);
}

/* Responsive */
@media (max-width: 1024px) {
  .blogs-page {
    grid-template-columns: 1fr;
    padding: calc(var(--nav-height) + 2rem) 1.5rem;
  }
  .section-rail {
    display: none;
  }
  .prose-section {
    margin-bottom: 3rem;
  }
}

@media (max-width: 768px) {
  .hero h1 { font-size: 2.5rem; }
  .article-header h2 { font-size: 2.25rem; }
}

/* Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

main {
  position: relative;
  z-index: 1;
}

/* Enlarged Mermaid Diagrams */
.mermaid {
  margin: 3rem 0;
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  background: rgba(var(--rgb-text), 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.mermaid { font-family: 'Inter', sans-serif !important; }
.mermaid * { font-family: 'Inter', sans-serif !important; }
.mermaid svg {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

@media (max-width: 1024px) {
  .mermaid {
    width: 100%;
    margin: 2rem 0;
    padding: 1rem;
  }
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--card-border);
  margin-top: 2rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.site-footer p {
  margin: 0;
}

.footer-subtitle {
  color: #6b7280;
  font-size: 0.75rem;
}

/* UI Controls */
.reading-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-right: 1.5rem;
}
.control-btn {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  color: #A1A1AA;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  font-family: var(--font-mono);
}
.control-btn:hover {
  background: rgba(255,255,255,0.05);
  color: #FAFAFA;
}

/* Reader Mode */
body.reader-mode-active #bg-canvas {
  display: none !important;
}
body.reader-mode-active .section-rail {
  display: none !important;
}
body.reader-mode-active .blogs-page {
  display: block;
}
body.reader-mode-active .article {
  margin: 0 auto;
  max-width: 900px;
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}

/* Fix Mermaid in Light Mode */
[data-theme="light"] .mermaid .node rect,
[data-theme="light"] .mermaid .node circle,
[data-theme="light"] .mermaid .node polygon,
[data-theme="light"] .mermaid .cluster rect {
  fill: #1f2937 !important;
  stroke: #374151 !important;
}

[data-theme="light"] .mermaid .nodeLabel,
[data-theme="light"] .mermaid .nodeLabel *,
[data-theme="light"] .mermaid text,
[data-theme="light"] .mermaid .edgeLabel,
[data-theme="light"] .mermaid .edgeLabel * {
  fill: #ffffff !important;
  color: #ffffff !important;
}

[data-theme="light"] .mermaid .edgePath .path {
  stroke: #374151 !important;
}

[data-theme="light"] .mermaid .marker {
  fill: #374151 !important;
  stroke: #374151 !important;
}

/* Callouts */
.callout {
  margin: 2rem 0;
  border-left: 4px solid var(--accent-color);
  background: #17153B;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
}

[data-theme="light"] .callout {
  background: rgba(49, 46, 129, 0.05);
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #fff;
  padding: 1.25rem 1.25rem 0.5rem;
  font-size: 1.1rem;
}

.callout-header svg {
  color: #818cf8;
}

.callout-content {
  padding: 0 1.25rem 1.25rem;
  color: #d1d5db;
  font-size: 0.95rem;
  line-height: 1.6;
}
.callout-content a {
  color: #a5b4fc;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.callout.tip {
  border-left-color: #6366f1;
  background: #17153B;
}
[data-theme="light"] .callout.tip {
  background: rgba(49, 46, 129, 0.05);
}
.callout.tip .callout-header svg {
  color: #818cf8;
}

.callout.warning {
  border-left-color: #4f46e5;
  background: #17153B;
}
[data-theme="light"] .callout.warning {
  background: rgba(49, 46, 129, 0.05);
}
.callout.warning .callout-header svg {
  color: #818cf8;
}

/* Code Blocks Container */
.code-block-container {
  margin: 2rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: #0b0c10;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.code-block-header {
  background: #16181d;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
}
.code-filename {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #9ca3af;
}
.copy-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: #9ca3af;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}
.copy-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.copy-btn svg {
  width: 14px;
  height: 14px;
}
.code-block-container pre {
  margin: 0;
}
.code-block-container .hljs {
  background: transparent !important;
  border: none !important;
  padding: 1.25rem 1.5rem !important;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}
