/* --- Premium CSS Design System --- */

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

:root {
  /* HSL Color Palette - Option 4: Deep Oceanic Drift */
  --bg-primary: 210 40% 98%;       /* Soft sky blue-white */
  --bg-secondary: 0 0% 100%;       /* Pure white panels */
  --bg-tertiary: 210 25% 94%;       /* Ocean foam grey */
  --text-primary: 222 47% 11%;     /* Dark oceanic navy */
  --text-secondary: 215 16% 47%;   /* Muted slate blue */
  --accent-primary: 221 83% 53%;   /* Cobalt Blue */
  --accent-secondary: 14 85% 57%;  /* Living Coral */
  --accent-glow: 221 83% 53% / 0.1;
  --border-color: 214 32% 90%;
  --glass-bg: 0 0% 100% / 0.75;
  --glass-border: 214 32% 90% / 0.5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Georgia', 'Merriweather', 'Lora', serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 0px;
}

/* Dark Mode Theme Overrides */
[data-theme="dark"] {
  --bg-primary: 222 47% 4%;        /* Deep Abyssal Blue */
  --bg-secondary: 222 35% 10%;     /* Dark ocean panels */
  --bg-tertiary: 222 35% 7%;       /* Midnight reef background */
  --text-primary: 210 33% 92%;     /* Pale cloud blue */
  --text-secondary: 215 20% 68%;   /* Soft sea slate */
  --accent-primary: 217 91% 60%;   /* Radiant Cobalt Blue */
  --accent-secondary: 14 90% 62%;  /* Glowing Living Coral */
  --accent-glow: 217 91% 60% / 0.25;
  --border-color: 222 35% 16%;
  --glass-bg: 222 47% 4% / 0.75;
  --glass-border: 222 35% 16% / 0.5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

html {
  font-family: var(--font-sans);
  background-color: hsl(var(--bg-primary));
  color: hsl(var(--text-primary));
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: hsl(var(--text-primary));
  margin-bottom: 0.5rem;
}

a {
  color: hsl(var(--accent-primary));
  text-decoration: none;
  transition: var(--transition-smooth);
}

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

/* --- Two-Column Oceanic Hyde Sidebar Layout --- */
.sidebar {
  background-color: hsl(222 47% 12%); /* Deep midnight oceanic navy */
  color: hsl(210 33% 92%);
  padding: 3.5rem 2rem 2.5rem;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 20rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid hsl(222 35% 18% / 0.4);
  transition: var(--transition-smooth);
  z-index: 100;
}

[data-theme="dark"] .sidebar {
  background-color: hsl(222 47% 5%); /* Deeper abyssal midnight black */
  border-right: 1px solid hsl(222 35% 12%);
}

.sidebar-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  gap: 3rem;
}

.sidebar-about {
  margin-bottom: 1rem;
}

.sidebar-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1px;
  margin-bottom: 1rem;
}

.sidebar-title a {
  color: #ffffff;
  background: linear-gradient(135deg, hsl(var(--accent-primary)), hsl(var(--accent-secondary)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: var(--transition-smooth);
}

.sidebar-title a:hover {
  background: linear-gradient(135deg, hsl(var(--accent-secondary)), hsl(var(--accent-primary)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-lead {
  color: hsl(215 20% 75%);
  font-size: 0.95rem;
  line-height: 1.6;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: auto;
}

.sidebar-nav a {
  color: hsl(215 20% 75%);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius);
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  position: relative;
}

.sidebar-nav a:hover {
  color: #ffffff;
  background-color: hsl(222 35% 18% / 0.5);
  padding-left: 1.5rem; /* Micro-animation: gentle nudge right */
}

.sidebar-nav a.active {
  color: #ffffff;
  background: linear-gradient(to right, hsl(var(--accent-primary) / 0.2), transparent);
  border-left: 4px solid hsl(var(--accent-primary));
  font-weight: 600;
  padding-left: 1rem;
}

.sidebar-footer {
  font-size: 0.8rem;
  color: hsl(215 20% 65%);
  line-height: 1.5;
  border-top: 1px solid hsl(222 35% 18% / 0.5);
  padding-top: 1.5rem;
}

.sidebar-footer .theme-toggle-btn {
  border-color: hsl(222 35% 20%);
  background-color: hsl(222 35% 8%);
  color: hsl(215 20% 75%);
  margin-bottom: 1.5rem;
}

.sidebar-footer .theme-toggle-btn:hover {
  background-color: hsl(222 35% 18%);
  color: #ffffff;
  border-color: hsl(var(--accent-primary));
  transform: scale(1.05);
}

.sidebar-footer .copyright {
  margin-top: 0.5rem;
}

/* Reading Progress Indicator */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: linear-gradient(to right, hsl(var(--accent-primary)), hsl(var(--accent-secondary)));
  z-index: 1000;
  transition: width 0.1s ease;
}

/* Content Area Offset Layout */
.content {
  margin-left: 20rem; /* Offsets content to clear fixed desktop sidebar */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
  background-color: hsl(var(--bg-primary));
}

/* Main Layout Wrapper */
.main-wrapper {
  flex: 1;
  max-width: 100%; /* Full page width flow */
  width: 100%;
  margin: 0 auto;
  padding: 4rem 3rem;
}

/* Biography Banner */
.bio-banner {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  padding: 3rem;
  border-radius: 0px; /* Flat corners */
  box-shadow: var(--shadow-md);
  margin-bottom: 3rem;
  display: flex;
  gap: 2.5rem;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.bio-banner::before {
  content: '';
  position: absolute;
  top: -10%;
  right: -5%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, hsl(var(--accent-glow)) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.bio-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 4px solid hsl(var(--border-color));
  background-color: hsl(var(--bg-tertiary));
  flex-shrink: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.bio-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bio-content {
  z-index: 1;
}

.bio-title {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.75px;
}

.bio-text {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Post Cards Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

/* Single Grid Card */
.post-card {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: var(--transition-smooth);
  position: relative;
}

.post-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: hsl(var(--accent-primary) / 0.5);
}

.post-card-meta {
  font-size: 0.85rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 0.75rem;
  display: flex;
  gap: 1rem;
}

.post-card-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 1rem;
}

.post-card-title a {
  color: hsl(var(--text-primary));
}

.post-card-title a:hover {
  color: hsl(var(--accent-primary));
}

.post-card-excerpt {
  color: hsl(var(--text-secondary));
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
}

.tag-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background-color: hsl(var(--bg-tertiary));
  color: hsl(var(--text-secondary));
  transition: var(--transition-smooth);
}

.tag-badge:hover {
  background-color: hsl(var(--accent-primary) / 0.15);
  color: hsl(var(--accent-primary));
}

/* Pagination Styling */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 3.5rem;
}

.page-btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid hsl(var(--border-color));
  background-color: hsl(var(--bg-secondary));
  color: hsl(var(--text-primary));
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.page-btn:hover:not(.disabled) {
  background-color: hsl(var(--accent-primary));
  border-color: hsl(var(--accent-primary));
  color: #fff;
}

.page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.95rem;
  color: hsl(var(--text-secondary));
}

/* Reading View / Article Styling */
article.post-content {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0px; /* Flat corners */
  padding: 3.5rem;
  box-shadow: var(--shadow-md);
  max-width: 100%; /* Full page width flow */
  margin: 0 auto;
}

.post-header {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid hsl(var(--border-color));
  padding-bottom: 1.5rem;
}

.post-title {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.75px;
}

.post-meta {
  color: hsl(var(--text-secondary));
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.post-body {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.8;
  color: hsl(var(--text-primary));
}

.post-body p {
  margin-bottom: 1.5rem;
}

.post-body h2, .post-body h3, .post-body h4 {
  font-family: var(--font-sans);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.post-body h2 { font-size: 1.75rem; }
.post-body h3 { font-size: 1.45rem; }

.post-body blockquote {
  border-left: 4px solid hsl(var(--accent-primary));
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: hsl(var(--text-secondary));
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  margin: 2rem auto;
  display: block;
}

.post-body pre, .post-body code {
  font-family: monospace;
  background-color: hsl(var(--bg-tertiary));
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font-size: 0.95rem;
}

.post-body pre {
  padding: 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
}

.post-body pre code {
  padding: 0;
  background: none;
}

.post-body ul, .post-body ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

.post-body li {
  margin-bottom: 0.5rem;
}

/* Comment Section Tree */
.comments-section {
  max-width: 820px;
  margin: 3.5rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid hsl(var(--border-color));
}

.comments-title {
  font-size: 1.75rem;
  margin-bottom: 2rem;
}

.comments-tree {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.comment-node {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.comment-node:hover {
  border-color: hsl(var(--accent-primary) / 0.3);
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.comment-author {
  font-weight: 700;
  color: hsl(var(--text-primary));
}

.comment-date {
  color: hsl(var(--text-secondary));
}

.comment-content {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Recursive comment children nesting */
.comment-children {
  list-style: none;
  margin-left: 2rem;
  margin-top: 1rem;
  padding-left: 1.5rem;
  border-left: 2px dashed hsl(var(--border-color));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Dynamic Interactive Search & Filtering */
.search-container {
  margin-bottom: 2.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1.25rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border-color));
  background-color: hsl(var(--bg-secondary));
  color: hsl(var(--text-primary));
  font-size: 1rem;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  outline: none;
  border-color: hsl(var(--accent-primary));
  box-shadow: 0 0 0 4px hsl(var(--accent-glow));
}

.tag-cloud-wrapper {
  background-color: hsl(var(--bg-secondary));
  border: 1px solid hsl(var(--border-color));
  border-radius: 0px; /* Flat corners */
  padding: 1.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
}

.tag-cloud-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-filter-btn {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border-color));
  background-color: hsl(var(--bg-tertiary));
  color: hsl(var(--text-secondary));
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tag-filter-btn:hover, .tag-filter-btn.active {
  background-color: hsl(var(--accent-primary));
  border-color: hsl(var(--accent-primary));
  color: #fff;
  box-shadow: 0 4px 6px -1px hsl(var(--accent-glow));
}

/* Archive Two-Column Layout */
.archive-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 992px) {
  .archive-layout {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

/* Media Queries for Responsiveness */
@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 2.5rem 1.5rem 1.5rem;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border-color));
  }
  
  [data-theme="dark"] .sidebar {
    border-bottom: 1px solid hsl(222 35% 12%);
  }

  .sidebar-container {
    gap: 1.5rem;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .sidebar-nav a {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }

  .sidebar-nav a:hover {
    padding-left: 0.8rem; /* Reset sidebar hover slide on mobile */
  }

  .sidebar-nav a.active {
    border-left: none;
    border-bottom: 3px solid hsl(var(--accent-primary));
    padding-left: 0.8rem;
    border-radius: 4px;
  }

  .sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid hsl(222 35% 18% / 0.5);
    padding-top: 1.25rem;
  }

  .sidebar-footer .theme-toggle-btn {
    margin-bottom: 0;
  }

  .sidebar-footer .copyright {
    margin-top: 0;
    text-align: right;
  }

  .content {
    margin-left: 0;
  }

  .main-wrapper {
    padding: 2.5rem 1.25rem;
  }

  .bio-banner {
    flex-direction: column;
    text-align: center;
    padding: 2rem;
  }
  
  .bio-avatar {
    width: 100px;
    height: 100px;
  }

  article.post-content {
    padding: 2.25rem 1.5rem;
  }
  
  .post-title {
    font-size: 2rem;
  }
  
  .comment-children {
    margin-left: 1rem;
    padding-left: 0.75rem;
  }
}
