/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* CSS Variables for Theme Support */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e1e1e1;
  --accent-color: #007acc;
  --accent-hover: #005a9e;
  --card-bg: #ffffff;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  
  /* Theme transition */
  --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Dark Theme Colors */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #888888;
  --border-color: #404040;
  --accent-color: #4da6ff;
  --accent-hover: #66b3ff;
  --card-bg: #252525;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.4);
}

/* System preference support */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #404040;
    --accent-color: #4da6ff;
    --accent-hover: #66b3ff;
    --card-bg: #252525;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: var(--theme-transition);
}

/* CSS View Transitions */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.3s;
  }
  
  ::view-transition-old(main) {
    animation: slide-out-left 0.3s ease-out;
  }
  
  ::view-transition-new(main) {
    animation: slide-in-right 0.3s ease-out;
  }
}

@keyframes slide-out-left {
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Header */
.site-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--theme-transition);
}

.main-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--theme-transition);
}

.site-title:hover {
  color: var(--accent-color);
}

.nav-wrapper {
  display: flex;
  align-items: center;
  gap: 2rem;
}

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

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--theme-transition);
}

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

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--theme-transition);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: 50%;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.9);
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 140px);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 1rem;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent-color);
  text-decoration: underline;
  transition: var(--theme-transition);
}

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

/* Code */
code {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Consolas', monospace;
  border: 1px solid var(--border-color);
}

pre {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

pre code {
  background: none;
  padding: 0;
  border: none;
}

/* Lists */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Cards and Sections */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px var(--shadow-light);
  transition: transform 0.3s ease, box-shadow 0.3s ease, var(--theme-transition);
  border: 1px solid var(--border-color);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow-medium);
}

/* Footer */
.site-footer {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
  border-top: 1px solid var(--border-color);
  transition: var(--theme-transition);
}

/* Mobile Hamburger Menu */
.mobile-menu-toggle {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: var(--theme-transition);
  width: 40px;
  height: 40px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.mobile-menu-toggle:hover {
  background: var(--border-color);
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  transition: all 0.3s ease;
  border-radius: 1px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Overlay */
.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.nav-overlay.active {
  display: block;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100%;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  z-index: 1000;
  padding: 2rem;
  transition: right 0.3s ease;
  box-shadow: -4px 0 8px var(--shadow-light);
}

.mobile-nav.active {
  right: 0;
}

.mobile-nav .nav-links {
  flex-direction: column;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.mobile-nav .nav-links a {
  font-size: 1.1rem;
  padding: 0.5rem 0;
}

.mobile-nav .theme-toggle {
  margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-wrapper {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .mobile-nav {
    display: block;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  
  .main-nav {
    padding: 0 1rem;
  }
  
  .theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

/* Blog Index Styles */
.blog-posts {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 2rem;
}

.blog-post-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, var(--theme-transition);
  display: block;
  text-decoration: none;
  color: inherit;
}

.blog-post-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px var(--shadow-light);
  border-color: var(--accent-color);
}

.post-content {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.post-thumbnail {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  flex-grow: 0;
  flex-basis: 120px;
}

.post-text {
  flex: 1;
  min-width: 0;
}

.blog-post-card h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.blog-post-card:hover h2 {
  color: var(--accent-color);
}

.post-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.post-excerpt {
  line-height: 1.5;
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Blog Hero Images */
.page-blog img:first-child,
.page-portfolio img:first-child,
.page-about img:first-child,
.page-contact img:first-child {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 2rem;
}

/* Mobile responsive blog cards */
@media (max-width: 768px) {
  .blog-post-card {
    padding: 1rem;
  }
  
  .post-content {
    gap: 1rem;
  }
  
  .post-thumbnail {
    width: 80px;
    height: 60px;
  }
  
  .blog-post-card h2 {
    font-size: 1.2rem;
  }
  
  .post-excerpt {
    font-size: 0.9rem;
  }
}

/* Page-specific view transitions */
.page-home {
  view-transition-name: page-home;
}

.page-about {
  view-transition-name: page-about;
}

.page-blog {
  view-transition-name: page-blog;
}

.page-contact {
  view-transition-name: page-contact;
}