:root {
  /* Light mode colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-tertiary: #f5f5f5;
  --bg-highlight: #f0f0f0;
  --bg-highlight-hover: #e0e0e0;
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-tertiary: #333333;
  --link-color: #0066cc;
  --border-light: #eeeeee;
  --border-medium: #dddddd;
  --border-dark: #cccccc;
}

[data-theme="dark"] {
  /* Dark mode colors */
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2a2a2a;
  --bg-highlight: #2a2a2a;
  --bg-highlight-hover: #333333;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --text-tertiary: #cccccc;
  --link-color: #5aa3ff;
  --border-light: #333333;
  --border-medium: #3a3a3a;
  --border-dark: #444444;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  line-height: 1.6;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}
header {
  margin-bottom: 2rem;
}
header h1 {
  margin-bottom: 0.5rem;
}
header h1 a {
  text-decoration: none;
  color: inherit;
}
nav a {
  color: var(--link-color);
}
nav a[aria-current="page"] {
  font-weight: bold;
}
main {
  margin-bottom: 2rem;
}
footer {
  border-top: 1px solid var(--border-dark);
  padding-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
a {
  color: var(--link-color);
}

/* Blog listing styles */
.blog-list {
  list-style: none;
  padding: 0;
}
.blog-list li {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.blog-list li:last-child {
  border-bottom: none;
}
.thumbnail {
  width: 150px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.post-info {
  flex: 1;
}
.post-info h3 {
  margin: 0 0 0.5rem 0;
}
.post-info h3 a {
  text-decoration: none;
}
.post-info h3 a:hover {
  text-decoration: underline;
}
.post-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.post-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tag {
  background: var(--bg-highlight);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text-secondary);
}
.tag:hover {
  background: var(--bg-highlight-hover);
  color: var(--text-tertiary);
}

/* Blog post styles */
.blog-post {
  max-width: 100%;
}
.post-header {
  margin-bottom: 1rem;
}
.post-header h2 {
  margin-bottom: 0.5rem;
}
.post-header time {
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.5rem;
}
.featured-image {
  margin: 0 0 2rem 0;
  max-height: 350px;
  overflow: hidden;
  border-radius: 4px;
}
.featured-image img {
  width: 100%;
  height: 350px;
  object-fit: cover;
  object-position: center;
}
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem 0;
}
.post-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* Blog image grid styles */
.blog-image-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.blog-image-group[data-group-size="2"] {
  grid-template-columns: repeat(2, 1fr);
}

.blog-image-item {
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  aspect-ratio: 4 / 3;
}

.blog-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.blog-image-item picture,
.blog-image-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* YouTube embed styles */
.youtube-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  margin: 2rem 0;
  border-radius: 4px;
  background: #000;
}

.youtube-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Page styles */
.page-header h2 {
  margin-bottom: 0;
}
.page-header {
  margin-bottom: 1rem;
}
.page-description {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* Recent posts on home page */
.recent-posts li {
  margin-bottom: 0.5rem;
}
.recent-posts time {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Photo mosaic on home page */
.photo-mosaic {
  margin-top: 2rem;
}
.mosaic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-width: 100%;
}
.mosaic-item {
  aspect-ratio: 1;
  overflow: hidden;
}
.mosaic-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.2s;
}
.mosaic-item:hover img {
  transform: scale(1.05);
}

/* Gallery styles */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}
.gallery-item {
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-secondary);
  transition: transform 0.2s, box-shadow 0.2s;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.gallery-thumbnail {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
.gallery-caption {
  padding: 0.75rem;
}
.gallery-caption strong {
  display: block;
  margin-bottom: 0.25rem;
}
.gallery-caption p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Lightbox styles */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.lightbox.active {
  display: flex;
}
.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  text-align: center;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}
.lightbox-caption {
  color: #fff;
  padding: 1rem;
  text-align: center;
}
.lightbox-caption p {
  margin: 0.5rem 0 0 0;
  color: #ccc;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 1rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
}
.lightbox-close {
  top: 0;
  right: 0;
  font-size: 2.5rem;
}
.lightbox-prev {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* Table styles */
.table-wrapper {
  overflow-x: auto;
  margin: 1rem 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  border: 1px solid var(--border-medium);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--bg-tertiary);
  font-weight: 600;
  white-space: nowrap;
}
tr:hover {
  background: var(--bg-secondary);
}

@media (max-width: 600px) {
  .blog-image-group {
    grid-template-columns: 1fr;
  }
  .blog-image-item {
    aspect-ratio: auto; /* Natural aspect on mobile */
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
  .gallery-thumbnail {
    height: 150px;
  }
  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
    padding: 0.5rem;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .blog-image-group {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Theme toggle button */
#theme-toggle {
  background: var(--bg-highlight);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
#theme-toggle:hover {
  background: var(--bg-highlight-hover);
}
.theme-toggle-sun,
.theme-toggle-moon {
  font-size: 1.1rem;
  line-height: 1;
}
[data-theme="light"] .theme-toggle-moon {
  display: none;
}
[data-theme="dark"] .theme-toggle-sun {
  display: none;
}

/* Tag list page (/tags/) */
.tag-list-page {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.tag-card {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s, transform 0.2s;
  min-width: 140px;
}

.tag-card:hover {
  background: var(--bg-highlight-hover);
  transform: translateY(-2px);
}

.tag-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-tertiary);
}

.tag-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}
