:root {
  color-scheme: light dark;
  --bg: #f7f1e8;
  --bg-alt: #efe5d8;
  --text: #1d1c1a;
  --muted: #5c5145;
  --accent: #c46a3b;
  --card: #fffaf2;
  --border: rgba(29, 28, 26, 0.12);
  --shadow: 0 18px 40px rgba(29, 28, 26, 0.08);
  --radius: 18px;
  --font-heading: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --font-body: "Avenir Next", "Avenir", "Gill Sans", "Segoe UI", sans-serif;
  --toggle-bg: #12110f;
  --toggle-fg: #f2ede6;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f1e8;
  --bg-alt: #efe5d8;
  --text: #1d1c1a;
  --muted: #5c5145;
  --accent: #c46a3b;
  --card: #fffaf2;
  --border: rgba(29, 28, 26, 0.12);
  --shadow: 0 18px 40px rgba(29, 28, 26, 0.08);
  --toggle-bg: #12110f;
  --toggle-fg: #f2ede6;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12110f;
  --bg-alt: #1b1916;
  --text: #f2ede6;
  --muted: #b5a79a;
  --accent: #f1a76b;
  --card: #1a1916;
  --border: rgba(242, 237, 230, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  --toggle-bg: #f7f1e8;
  --toggle-fg: #1d1c1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --bg-alt: #1b1916;
    --text: #f2ede6;
    --muted: #b5a79a;
    --accent: #f1a76b;
    --card: #1a1916;
    --border: rgba(242, 237, 230, 0.14);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    --toggle-bg: #f7f1e8;
    --toggle-fg: #1d1c1a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, var(--bg-alt), var(--bg));
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.4;
}

body::before {
  background: radial-gradient(circle at 15% 20%, rgba(196, 106, 59, 0.18), transparent 55%);
}

body::after {
  background: radial-gradient(circle at 85% 70%, rgba(96, 105, 88, 0.18), transparent 60%);
}

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

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

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 36px clamp(20px, 4vw, 64px) 12px;
}

.brand {
  max-width: 520px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  color: inherit;
}

.brand-mark {
  width: 280px;
  height: 48px;
}

.brand-tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.site-nav {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  align-items: center;
  align-self: center;
}

.nav-link {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1;
  padding: 10px 0;
  margin-top: -38px;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--toggle-bg);
  color: var(--toggle-fg);
  margin-top: -38px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
}

.theme-toggle:hover,
.theme-toggle[aria-pressed="true"] {
  color: var(--toggle-fg);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 106, 59, 0.2), 0 12px 22px rgba(0, 0, 0, 0.18);
}

.theme-toggle-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-icon svg {
  width: 100%;
  height: 100%;
}

.icon-sun {
  display: none;
}

html[data-theme="dark"] .icon-sun {
  display: inline-flex;
}

html[data-theme="dark"] .icon-moon {
  display: none;
}

.site-main {
  padding: 0 clamp(20px, 4vw, 64px) 64px;
}

.hero {
  margin: 12px 0 24px;
}

.hero-intro {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 620px;
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tag-filter-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.tag-filter-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.tag-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag-chip.active,
.tag-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 106, 59, 0.2);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.post-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  animation: riseIn 0.6s ease both;
  animation-delay: var(--delay, 0s);
}

.post-link {
  display: block;
  flex: 1;
}

.post-media {
  position: relative;
  overflow: hidden;
}

.post-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-media.single {
  aspect-ratio: 4 / 3;
}

.post-media.collage {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
  padding: 4px;
  aspect-ratio: 4 / 3;
}

.post-media.collage img {
  border-radius: 12px;
}

.collage-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.post-text-only {
  padding: 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 180px;
}

.post-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.4rem;
}

.post-meta {
  padding: 18px 20px 22px;
  border-top: 1px solid var(--border);
}

.post-meta-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
}

.post-meta-date {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.post-meta-tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.post-tag {
  appearance: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.post-tag:hover,
.post-tag.active {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(196, 106, 59, 0.2);
}

.list-title {
  margin: 12px 0 0;
  font-family: var(--font-heading);
  font-size: 2rem;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.post-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 16px 0 4px;
}

.post-gallery {
  display: grid;
  gap: 18px;
  margin: 24px 0;
}

.post-gallery figure {
  margin: 0;
}

.post-gallery img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-gallery figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.7;
}

.post-content p {
  margin: 0 0 16px;
}

.comments {
  margin-top: 40px;
}

.site-footer {
  padding: 32px clamp(20px, 4vw, 64px) 48px;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  margin-top: 32px;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-card {
    animation: none;
  }
}

@media (max-width: 720px) {
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand nav"
      "tagline tagline";
    column-gap: 16px;
    row-gap: 8px;
    align-items: start;
  }

  .brand {
    display: contents;
  }

  .brand-link {
    grid-area: brand;
  }

  .brand-mark {
    width: 200px;
  }

  .brand-tagline {
    grid-area: tagline;
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .site-nav {
    grid-area: nav;
    margin-top: 0;
    justify-self: end;
    align-self: start;
  }

  .nav-link {
    margin-top: 6px;
  }

  .theme-toggle {
    margin-top: 0;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }
}
