:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #ec4899;
  --accent-hover: #db2777;
  --border-subtle: #e5e7eb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.25rem 3vw;
}

.site-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  white-space: nowrap;
}

.nav-link {
  font-size: 0.95rem;
  color: var(--muted);
}

.nav-link--active {
  color: var(--text);
  font-weight: 500;
}

.site-title a {
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
}

.nav-text-link {
  font-size: 0.95rem;
  color: var(--muted);
}

.nav-button {
  font-size: 0.95rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

.nav-button:hover {
  background: var(--accent-hover);
}

.site-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.5rem 3vw 3.5rem;
}

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero__title {
  font-size: 2rem;
  margin: 0;
}

.hero__subtitle {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .site-header__inner {
    flex-wrap: wrap;
    justify-content: center;
  }

  .image-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.image-card {
  background: #fff;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.image-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

.image-card__image-wrapper {
  position: relative;
  padding-bottom: 120%;
  overflow: hidden;
}

.image-card__image-wrapper img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card__meta {
  padding: 0.75rem 0.95rem 0.85rem;
}

.image-card__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 500;
}

.image-card__date {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.image-card__image-wrapper--placeholder {
  background: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-card__placeholder {
  font-size: 0.85rem;
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}
.empty-state code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  background: var(--border-subtle);
  border-radius: 0.25rem;
}

.post {
  max-width: 760px;
  margin: 0 auto;
}

.post__hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1rem;
  margin-bottom: 1.75rem;
}

.post__title {
  font-size: 2.1rem;
  margin: 0 0 0.4rem;
}

.post__date {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.post__content {
  line-height: 1.8;
  font-size: 1rem;
}

.post__content img {
  max-width: 100%;
  border-radius: 0.75rem;
  margin: 1.5rem 0;
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 3vw 1.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer__inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer__social {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.social-link {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f3f4f6;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
}

.social-link svg {
  width: 14px;
  height: 14px;
  fill: #4b5563;
}

.social-link:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .site-footer__inner {
    flex-direction: column-reverse;
    justify-content: center;
  }
}

/* Archive & taxonomy */
.archive-header {
  margin-bottom: 2rem;
}
.archive-header__title {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}
.archive-header__subtitle,
.archive-header__body {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}
.terms-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.terms-list__link {
  color: var(--accent);
  font-weight: 500;
}
.terms-list__count {
  color: var(--muted);
  font-size: 0.9rem;
}
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.archive-list__item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.archive-list__link {
  font-weight: 500;
  flex: 1;
}
.archive-list__date {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Post rows (Posts list page) */
.post-rows {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.post-row {
  border-bottom: 1px solid var(--border-subtle);
}
.post-row:last-child {
  border-bottom: none;
}
.post-row__link {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  padding: 1.25rem 0;
  transition: background 120ms ease;
}
.post-row__link:hover {
  background: var(--bg-toc, #f9fafb);
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  border-radius: 0.5rem;
}
.post-row__media {
  flex-shrink: 0;
  width: 180px;
  aspect-ratio: 4/3;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--border-subtle);
}
.post-row__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-row__media--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-row__placeholder {
  font-size: 0.8rem;
  color: var(--muted);
}
.post-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}
.post-row__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}
.post-row__date {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}
.post-row__summary {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  line-height: 1.5;
}
@media (max-width: 640px) {
  .post-row__link {
    flex-direction: column;
    gap: 0.75rem;
  }
  .post-row__media {
    width: 100%;
    aspect-ratio: 16/9;
  }
}

/* Post meta, tags, reading time, TOC */
.post__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}
.post__date {
  margin: 0;
}
.post__reading-time {
  font-size: 0.9rem;
  color: var(--muted);
}
.post__taxonomy {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}
.post__taxonomy-label {
  color: var(--muted);
  margin-right: 0.35rem;
}
.post__tag,
.post__category {
  color: var(--accent);
  margin-right: 0.5rem;
}
.post__tag:hover,
.post__category:hover {
  text-decoration: underline;
}
.toc {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-toc, #f9fafb);
  border-radius: 0.5rem;
  font-size: 0.9rem;
}
.toc__title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.toc li { margin: 0.25rem 0; }
.toc a { color: inherit; }

/* Figure shortcode */
.figure { margin: 1.5rem 0; }
.figure__img {
  max-width: 100%;
  border-radius: 0.75rem;
  display: block;
}
.figure__caption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

/* Gallery shortcode — CSS Grid + wider than article text */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.photo-gallery--cols-1 { grid-template-columns: 1fr; }
.photo-gallery--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.photo-gallery--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.photo-gallery--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.photo-gallery__item {
  margin: 0;
}

.photo-gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0.5rem;
}

/* Break out of narrow .post column (760px) up to site width (~1120px), centered */
.post__content .photo-gallery {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(1120px, calc(100vw - 6vw));
  max-width: none;
}

/* Don’t inherit big vertical margins from .post__content img */
.post__content .photo-gallery img {
  margin: 0;
}

@media (max-width: 900px) {
  .post__content .photo-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .post__content .photo-gallery {
    width: 100%;
    left: auto;
    transform: none;
    grid-template-columns: 1fr !important;
  }
}

/* Share bar */
.post-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}
.post-share__label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-right: 0.25rem;
}
.post-share__btn {
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  background: var(--border-subtle);
  color: var(--text);
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.post-share__btn--copy { }
.post-share__btn--twitter,
.post-share__btn--linkedin {
  text-decoration: none;
  display: inline-block;
}
.post-share__btn:hover {
  background: var(--muted);
  color: var(--bg);
}

/* Related posts */
.related-posts {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}
.related-posts__title {
  font-size: 1.1rem;
  margin: 0 0 1rem;
}
.related-posts__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 700px) {
  .related-posts__grid { grid-template-columns: 1fr; }
}
.related-posts__card a {
  display: block;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.related-posts__card a:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
.related-posts__img-wrap {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--border-subtle);
}
.related-posts__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.related-posts__card-title {
  font-size: 0.95rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-weight: 500;
}
.related-posts__card-date {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  padding: 0 0.75rem 0.75rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.lightbox[hidden] { display: none; }
.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}
.lightbox__inner {
  max-width: 90vw;
  max-height: 90vh;
}
.lightbox__img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
}
.content-lightbox img {
  cursor: pointer;
}

/* Footer extra links */
.site-footer__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-footer__links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.footer-link {
  font-size: 0.9rem;
  color: var(--muted);
}
.footer-link:hover { color: var(--text); }
@media (max-width: 640px) {
  .site-footer__inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }
  .site-footer__right {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Theme toggle */
.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  cursor: pointer;
  position: relative;
}
.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 0.35rem;
  border-radius: 50%;
  background: var(--text);
  opacity: 0.8;
}
.theme-dark .theme-toggle::after {
  background: #fbbf24;
  opacity: 1;
}

/* Search page */
.search-page { max-width: 560px; margin: 0 auto; }
.search-page__title { margin-bottom: 1rem; }
.search-form__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  font-family: inherit;
}
.search-results { margin-top: 1.5rem; min-height: 2rem; }
.search-results__msg { color: var(--muted); font-size: 0.95rem; }
.search-results__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.search-results__list li { margin: 0.5rem 0; }
.search-results__list a { font-weight: 500; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Dark mode */
.theme-dark {
  --bg: #111827;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #f472b6;
  --accent-hover: #fb7185;
  --border-subtle: #374151;
  --bg-toc: #1f2937;
}
.theme-dark .image-card { background: #1f2937; }
.theme-dark .social-link { background: #374151; }
.theme-dark .social-link svg { fill: #d1d5db; }
.theme-dark .social-link:hover { background: #4b5563; }
.theme-dark .post-share__btn { background: #374151; color: #f3f4f6; }
.theme-dark .post-share__btn:hover { background: #4b5563; }
.theme-dark .lightbox__close { color: #f3f4f6; }
.theme-auto {
  color-scheme: light;
}
.theme-dark,
.theme-dark body {
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  .theme-auto {
    --bg: #111827;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #f472b6;
    --accent-hover: #fb7185;
    --border-subtle: #374151;
    --bg-toc: #1f2937;
    color-scheme: dark;
  }
  .theme-auto .image-card { background: #1f2937; }
  .theme-auto .social-link { background: #374151; }
  .theme-auto .social-link svg { fill: #d1d5db; }
  .theme-auto .post-share__btn { background: #374151; color: #f3f4f6; }
  .theme-auto .lightbox__close { color: #f3f4f6; }
}

