/* ============================================
   RAZEEL.DEV — Design System
   Rails-Inspired Technology Blog
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* Accent colors — consistent across themes */
  --ruby-red: #D30001;
  --ruby-red-glow: #FF1A1A;
  --ruby-dark: #8B0000;
  --ember: #FF6B35;
  --gold: #FFD700;

  /* Typography */
  --font-heading: 'Source Serif 4', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Sizing */
  --content-width: 72ch;
  --book-content-width: 80ch;
  --sidebar-width: 260px;
  --nav-height: 60px;
  --radius: 8px;
  --radius-lg: 16px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.3s;
}

/* Dark theme (default) */
[data-theme="dark"] {
  --ruby-red: #FF3333;
  --ruby-red-glow: #FF6666;
  --coal: #0D0D0D;
  --charcoal: #1A1A1A;
  --graphite: #2A2A2A;
  --silver: #8A8A8A;
  --chalk: #E8E8E8;
  --white: #F5F5F5;
  --nav-bg: rgba(26, 26, 26, 0.85);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-shadow: rgba(0, 0, 0, 0.5);
  --card-border: rgba(255, 255, 255, 0.06);
  --overlay-bg: rgba(0, 0, 0, 0.7);
}

/* Light theme */
[data-theme="light"] {
  --coal: #FAFAFA;
  --charcoal: #F0F0F0;
  --graphite: #E2E2E2;
  --silver: #555555;
  --chalk: #2A2A2A;
  --white: #1A1A1A;
  --ruby-red-glow: #B80000;
  --nav-bg: rgba(240, 240, 240, 0.88);
  --nav-border: rgba(0, 0, 0, 0.08);
  --nav-shadow: rgba(0, 0, 0, 0.12);
  --card-border: rgba(0, 0, 0, 0.08);
  --overlay-bg: rgba(255, 255, 255, 0.7);
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-gutter: stable;
  scroll-padding-top: 3rem;
}

body {
  font-family: var(--font-body);
  background: var(--coal);
  color: var(--chalk);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--ruby-red);
  color: var(--white);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--coal); }
::-webkit-scrollbar-thumb { background: var(--graphite); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ruby-red); }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--white);
  line-height: 1.25;
  font-weight: 700;
}

h1 { font-size: 2.75rem; margin-bottom: 1rem; letter-spacing: -0.02em; }
h2 { font-size: 2rem; margin: 2.5rem 0 1rem; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; margin: 2rem 0 0.75rem; }
h4 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }

p { margin-bottom: 1.25rem; }

a {
  color: var(--ruby-red);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--ruby-red-glow); }

strong { color: var(--white); font-weight: 600; }
em { font-style: italic; }

blockquote {
  border-left: 3px solid var(--ruby-red);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--charcoal);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--silver);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.7;
}
blockquote p:last-child { margin-bottom: 0; }

hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--graphite), transparent);
  margin: 3rem 0;
}

ul, ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
li { margin-bottom: 0.5rem; line-height: 1.7; }
li::marker { color: var(--ruby-red); }

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Image Layout Variants */
img.full-width {
  width: 100%;
  max-width: 100%;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  display: block;
}



table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--graphite);
}
th {
  color: var(--white);
  font-weight: 600;
  background: var(--charcoal);
}

/* --- Layout --- */
.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* --- Reading Progress Bar --- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ruby-red), var(--ember));
  z-index: 1000;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--ruby-red-glow);
}

/* ============================================
   NAVIGATION — Floating Pill Bar
   ============================================ */
.nav-pill {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--nav-border);
  border-radius: 100px;
  padding: 0.4rem 0.5rem;
  z-index: 950;
  transition: all var(--duration) var(--ease);
  box-shadow: 0 8px 32px var(--nav-shadow);
}

.nav-pill.minimized {
  bottom: 1.5rem;
  right: 1.5rem;
  left: auto;
  transform: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  animation: pill-pulse 2s ease-in-out 0.4s 3;
  box-shadow: 0 4px 20px var(--nav-shadow);
}

@keyframes pill-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 20px var(--nav-shadow); }
  50% { transform: scale(1.12); box-shadow: 0 0 18px rgba(211, 0, 1, 0.35); }
}
.nav-pill.minimized .nav-item span,
.nav-pill.minimized .nav-cmd { display: none; }
.nav-pill.minimized .nav-item { display: none; }
.nav-pill.minimized .nav-theme { display: none; }
.nav-pill.minimized .nav-divider { display: none; }
.nav-pill.minimized .nav-logo { display: flex; }

.nav-logo {
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--ruby-red);
  font-size: 1.2rem;
}
.site-logo {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.logo-name { color: var(--white); font-weight: 700; }
.logo-dot { color: var(--ember); font-weight: 700; }
.logo-tld { color: var(--silver); font-weight: 400; }

.hero-badge .site-logo { font-size: 0.85rem; }
.nav-logo .site-logo { font-size: 0.7rem; }

/* Scroll header — floating badge, same style as hero-badge */
.scroll-header {
  position: fixed;
  top: 0.75rem;
  left: 1.25rem;
  z-index: 940;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration) var(--ease);
}
.scroll-header.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 1rem;
  background: rgba(211, 0, 1, 0.12);
  border: 1.5px solid rgba(211, 0, 1, 0.45);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ruby-red-glow);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}
.scroll-header-link::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--ruby-red);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--ruby-red-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.scroll-header-link:hover {
  background: rgba(211, 0, 1, 0.2);
  border-color: rgba(211, 0, 1, 0.6);
  color: var(--ruby-red-glow);
}

/* Theme toggle */
.nav-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: 1px solid transparent;
  color: var(--silver);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.nav-theme:hover {
  color: var(--white);
  background: rgba(211, 0, 1, 0.12);
  border-color: var(--ruby-red);
}
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--silver);
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--white);
  background: rgba(211, 0, 1, 0.15);
}
.nav-item.active {
  color: var(--white);
  background: var(--ruby-red);
}
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--graphite);
  margin: 0 0.25rem;
}

.nav-cmd {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--silver);
  background: var(--graphite);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.nav-cmd:hover {
  background: rgba(211, 0, 1, 0.2);
  color: var(--white);
  border-color: var(--ruby-red);
}
.nav-cmd kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* --- Command Palette Overlay --- */
.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration) var(--ease);
}
.cmd-palette.open {
  opacity: 1;
  visibility: visible;
}

.cmd-palette-box {
  width: 90%;
  max-width: 560px;
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: translateY(-20px) scale(0.96);
  transition: transform var(--duration) var(--ease);
}
.cmd-palette.open .cmd-palette-box {
  transform: translateY(0) scale(1);
}

.cmd-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--graphite);
}
.cmd-search svg { color: var(--silver); width: 18px; height: 18px; flex-shrink: 0; }
.cmd-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--white);
}
.cmd-search input::placeholder { color: var(--silver); }

.cmd-results {
  padding: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.cmd-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--chalk);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background var(--duration) var(--ease);
}
.cmd-result-item:hover,
.cmd-result-item.selected {
  background: rgba(211, 0, 1, 0.12);
  color: var(--white);
}
.cmd-result-item svg { width: 16px; height: 16px; color: var(--silver); flex-shrink: 0; }
.cmd-result-meta {
  font-size: 0.75rem;
  color: var(--silver);
  margin-left: auto;
  font-family: var(--font-mono);
}

.cmd-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--graphite);
  font-size: 0.7rem;
  color: var(--silver);
  font-family: var(--font-mono);
}
.cmd-footer kbd {
  padding: 0.15rem 0.4rem;
  background: var(--graphite);
  border-radius: 4px;
  font-size: 0.65rem;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
  padding: 2rem 0 3rem;
  text-align: left;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1.1rem;
  background: rgba(211, 0, 1, 0.12);
  border: 1.5px solid rgba(211, 0, 1, 0.45);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ruby-red-glow);
  margin-bottom: 1.5rem;
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}
.hero-badge:hover {
  background: rgba(211, 0, 1, 0.2);
  border-color: rgba(211, 0, 1, 0.6);
}
.hero-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--ruby-red);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--ruby-red-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--white) 0%, var(--chalk) 60%, var(--silver) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--silver);
  max-width: 50ch;
  line-height: 1.7;
}

/* ============================================
   TERMINAL CARD — Blog Teaser
   ============================================ */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2rem 0 6rem;
}

.terminal-card {
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration) var(--ease);
  position: relative;
  text-decoration: none;
  display: block;
}
.terminal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, var(--ruby-red) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
  pointer-events: none;
}
.terminal-card:hover::before { opacity: 1; }
.terminal-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(211, 0, 1, 0.1);
  border-color: transparent;
}

/* Scanline hover effect */
.terminal-card:hover .terminal-body::after {
  animation: scanline 3s linear infinite;
}
.terminal-body::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(211, 0, 1, 0.15), transparent);
  opacity: 0;
  pointer-events: none;
}

@keyframes scanline {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--graphite);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}
.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dots span:nth-child(1) { background: #FF5F57; }
.terminal-dots span:nth-child(2) { background: #FFBD2E; }
.terminal-dots span:nth-child(3) { background: #28CA42; }

.terminal-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--silver);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-body {
  padding: 1.25rem 1.5rem;
  position: relative;
}

.terminal-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--silver);
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.terminal-meta-item {
  display: flex;
  gap: 0.3rem;
}
.terminal-meta-key { color: var(--ember); }
.terminal-meta-val { color: var(--chalk); }

.terminal-card-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.terminal-excerpt {
  font-size: 0.92rem;
  color: var(--silver);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.terminal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  background: rgba(255, 107, 53, 0.1);
  color: var(--ember);
  border: 1px solid rgba(255, 107, 53, 0.2);
  transition: all var(--duration) var(--ease);
}
.terminal-card:hover .tag {
  background: rgba(255, 107, 53, 0.18);
  border-color: rgba(255, 107, 53, 0.4);
}

/* ============================================
   SECTION HEADINGS
   ============================================ */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ruby-red);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-label::before {
  content: '>';
  color: var(--ember);
}

/* ============================================
   POST LAYOUT
   ============================================ */
.post-header {
  padding: 2rem 0 2rem;
  border-bottom: 1px solid var(--graphite);
  margin-bottom: 2.5rem;
}

.post-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 1.5rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--silver);
}
.post-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.post-meta-item .key { color: var(--ember); }
.post-meta-item .val { color: var(--chalk); }

.post-content {
  padding-bottom: 4rem;
  font-size: 1.08rem;
  line-height: 1.8;
}

/* Inline code */
.post-content code:not([class*="language-"]):not(.highlight code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.45em;
  background: var(--graphite);
  border-radius: 4px;
  color: var(--ember);
}

/* Code blocks — style the outermost wrapper only */
.post-content .highlighter-rouge {
  background: var(--graphite);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}
/* Reset inner .highlight so it doesn't double-apply styles */
.post-content .highlighter-rouge .highlight {
  background: none;
  border: none;
  border-radius: 0;
  margin: 0;
  overflow: visible;
}
/* Standalone pre (not inside .highlighter-rouge) */
.post-content pre:not(.highlight) {
  background: var(--graphite);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}
.post-content pre {
  padding: 1.25rem 1.5rem;
}
.post-content pre code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--chalk);
  background: none;
  padding: 0;
}

/* Code block language label */
.post-content .highlighter-rouge::before {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--silver);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
}

/* --- Table of Contents --- */
.toc {
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}
.toc-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ruby-red);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.toc li { margin-bottom: 0.35rem; }
.toc a {
  font-size: 0.88rem;
  color: var(--silver);
  transition: color var(--duration) var(--ease);
}
.toc a:hover { color: var(--ruby-red-glow); }
.toc ul ul { padding-left: 1.25rem; }

/* --- Post Navigation --- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 2rem 0 6rem;
  border-top: 1px solid var(--graphite);
}
.post-nav-item {
  padding: 1.25rem;
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}
.post-nav-item:hover {
  border-color: var(--ruby-red);
  transform: translateY(-2px);
}
.post-nav-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--silver);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.post-nav-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--white);
}
.post-nav-item.next { text-align: right; }

/* ============================================
   MEDIA — Audio & Video
   ============================================ */
.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--charcoal);
  border: 1px solid var(--graphite);
}
.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.audio-player {
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}
.audio-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ember);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.audio-title::before {
  content: '♪';
  color: var(--ruby-red);
}
.audio-player audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius);
}

/* ============================================
   ARCHIVE PAGE
   ============================================ */
.archive-year {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--ruby-red);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--graphite);
}

.archive-list {
  list-style: none;
  padding: 0;
}
.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.5);
}
.archive-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--silver);
  flex-shrink: 0;
  min-width: 5rem;
}
.archive-title a {
  font-size: 1rem;
  color: var(--chalk);
}
.archive-title a:hover { color: var(--ruby-red-glow); }

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  padding: 2rem 1.5rem 6rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--silver);
}
.site-footer a { color: var(--ruby-red); }
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.6s var(--ease) forwards;
  opacity: 0;
}
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }

/* ============================================
   BOOKS COLLECTION
   ============================================ */

/* Books index page */
.books-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2rem 0 6rem;
}

.book-card {
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  gap: 1.5rem;
  text-decoration: none;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
}
.book-card-cover {
  width: 130px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 4px 6px 15px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.book-card-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

@media (max-width: 600px) {
  .book-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
.book-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--ruby-red), var(--ember));
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.book-card:hover::after { opacity: 1; }
.book-card:hover {
  transform: translateY(-3px);
  border-color: var(--ruby-red);
  box-shadow: 0 8px 32px rgba(211, 0, 1, 0.08);
}

.book-card-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ember);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.book-card-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 0.5rem;
}

.book-card-desc {
  color: var(--silver);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.book-card-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--silver);
}
.book-card-meta .key { color: var(--ember); }

/* Book chapter layout — full width content */
.book-layout {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* Sidebar as off-canvas drawer */
.book-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--charcoal);
  border-right: 1px solid var(--graphite);
  z-index: 960;
  padding: 2rem 1.25rem;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--duration) var(--ease);
}
.book-sidebar.open {
  transform: translateX(0);
}

/* Backdrop when sidebar is open */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 955;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration) var(--ease);
}
.sidebar-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.sidebar-book-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--graphite);
}
.sidebar-book-title a {
  color: var(--white);
  text-decoration: none;
}
.sidebar-book-title a:hover { color: var(--ruby-red); }

.sidebar-chapters {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-chapters li {
  margin-bottom: 0.15rem;
}
.sidebar-chapter-link {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--silver);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
  border-left: 2px solid transparent;
}
.sidebar-chapter-link:hover {
  color: var(--white);
  background: rgba(211, 0, 1, 0.08);
}
.sidebar-chapter-link.active {
  color: var(--white);
  background: rgba(211, 0, 1, 0.12);
  border-left-color: var(--ruby-red);
}

.sidebar-part-link {
  padding-left: 1.75rem;
  font-size: 0.82rem;
}

.sidebar-chapter-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ember);
  margin-right: 0.35rem;
}

/* Chapter content area */
.chapter-content {
  width: 100%;
}

.chapter-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--silver);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.chapter-breadcrumb a {
  color: var(--ruby-red);
  text-decoration: none;
}
.chapter-breadcrumb a:hover { color: var(--ruby-red-glow); }
.chapter-breadcrumb .sep { color: var(--graphite); }

/* Book overview / cover page */
.book-cover {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--graphite);
  margin-bottom: 2.5rem;
}
.book-cover h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 1rem;
}
.book-cover-desc {
  font-size: 1.1rem;
  color: var(--silver);
  max-width: 60ch;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.book-toc {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}
.book-toc-item {
  border-bottom: 1px solid var(--graphite);
}
.book-toc-item a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.5rem;
  color: var(--chalk);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}
.book-toc-item a:hover {
  color: var(--white);
  padding-left: 1rem;
  background: rgba(211, 0, 1, 0.04);
}
.book-toc-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ember);
  min-width: 2.5rem;
}
.book-toc-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
}

.book-toc-parts {
  list-style: none;
  padding: 0 0 0 3.5rem;
  margin: 0;
}
.book-toc-parts li a {
  padding: 0.5rem 0.5rem;
  font-size: 0.9rem;
  color: var(--silver);
}

/* Video label */
.video-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ember);
  margin-bottom: 0.5rem;
}

/* Sidebar toggle button — always visible on book pages */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: var(--radius);
  color: var(--chalk);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: all var(--duration) var(--ease);
}
.sidebar-toggle:hover {
  border-color: var(--ruby-red);
  color: var(--white);
}

/* ============================================
   RESUME PAGE
   ============================================ */
.resume { padding-bottom: 4rem; }

.resume-header {
  padding: 2rem 0 2.5rem;
  border-bottom: 1px solid var(--graphite);
  margin-bottom: 2.5rem;
}
.resume-name {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0.25rem;
}
.resume-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ember);
  margin-bottom: 0.75rem;
}
.resume-contact {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--silver);
}
.resume-contact a { color: var(--ruby-red); }
.resume-sep { margin: 0 0.5rem; color: var(--graphite); }

.resume-section {
  margin-bottom: 2.5rem;
}
.resume-section-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ruby-red);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--graphite);
}

.resume-entry {
  margin-bottom: 2rem;
}
.resume-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.resume-entry-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  margin: 0;
}
.resume-entry-company {
  font-size: 0.9rem;
  color: var(--silver);
  margin-top: 0.15rem;
}
.resume-entry-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ember);
  white-space: nowrap;
  flex-shrink: 0;
}
.resume-entry-list {
  padding-left: 1.25rem;
  margin: 0;
}
.resume-entry-list li {
  font-size: 0.92rem;
  color: var(--chalk);
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

.resume-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.resume-skill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  background: rgba(255, 107, 53, 0.1);
  color: var(--ember);
  border: 1px solid rgba(255, 107, 53, 0.2);
}

/* ============================================
   CODE COPY BUTTON
   ============================================ */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--silver);
  background: var(--charcoal);
  border: 1px solid var(--graphite);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: all var(--duration) var(--ease);
  z-index: 2;
}
.highlighter-rouge:hover .code-copy-btn,
.highlight:hover .code-copy-btn,
pre:hover .code-copy-btn {
  opacity: 1;
}
.code-copy-btn:hover {
  color: var(--white);
  border-color: var(--ruby-red);
  background: rgba(211, 0, 1, 0.15);
}
.code-copy-btn.copied {
  color: #28CA42;
  border-color: #28CA42;
}

/* ============================================
   TAGS CLOUD
   ============================================ */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--graphite);
}
.tag-cloud-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}
.tag-cloud-item:hover {
  background: rgba(255, 107, 53, 0.2);
  border-color: var(--ember);
  transform: translateY(-1px);
}
.tag-count {
  font-size: 0.65rem;
  color: var(--silver);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 100px;
}
.tag-section { margin-bottom: 2rem; }

/* ============================================
   COMMENTS
   ============================================ */
.comments {
  padding: 2rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--graphite);
}

/* ============================================
   BOOK READ INDICATORS
   ============================================ */
.sidebar-chapter-link.read::after {
  content: '✓';
  margin-left: auto;
  font-size: 0.7rem;
  color: #28CA42;
  opacity: 0.7;
}

/* ============================================
   SOCIAL LINKS
   ============================================ */
.social-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--silver);
  transition: all var(--duration) var(--ease);
}
.social-link:hover {
  color: var(--white);
  background: rgba(211, 0, 1, 0.12);
}
.social-link svg { width: 18px; height: 18px; }

.footer-social {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 640px) {
  .posts-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .book-sidebar { width: 260px; }
}

@media (max-width: 640px) {
  h1 { font-size: 2rem; }
  .content-wrapper { padding: 1.5rem 1rem; }
  .nav-pill { bottom: 1rem; padding: 0.3rem 0.4rem; }
  .nav-item span { display: none; }
  .nav-cmd span { display: none; }
  .post-nav { grid-template-columns: 1fr; }
  .hero { padding: 3rem 0 2rem; }
}
