:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e4e2dd;
  --text: #1c1917;
  --muted: #57534e;
  --accent: #b45309;
  --accent-hover: #92400e;
  --code-bg: #f5f5f4;
  --radius: 8px;
  --max-width: 42rem;
  --wide: 72rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 1.0625rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem 1.25rem 1.25rem;
}

.site-hero {
  position: relative;
  max-width: var(--wide);
  margin: 0 auto;
  line-height: 0;
  background: var(--surface);
}

.site-hero-image {
  display: block;
  width: 100%;
  height: clamp(180px, 28vw, 320px);
  object-fit: cover;
}

.site-hero-categories {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 0.35rem 0.5rem;
  padding: 1.25rem min(11rem, 28%) 1rem 1.25rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  white-space: nowrap;
  overflow-x: auto;
}

.site-hero-categories a {
  flex-shrink: 0;
}

.site-hero-categories .category-sep {
  flex-shrink: 0;
}

.site-hero-search {
  position: absolute;
  right: 1.25rem;
  bottom: 1rem;
  z-index: 2;
  width: min(10rem, calc((100% - 2.5rem) / 2));
  line-height: normal;
}

.site-hero-search-input {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

.site-hero-search-input::placeholder {
  color: var(--muted);
}

.site-hero-search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-view .search-status {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
}

.site-header-inner {
  max-width: var(--wide);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

/* Layout only; typography from shared/site-nav.css when integrated. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  align-items: center;
}

.site-brand {
  color: inherit;
  text-decoration: none;
}

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

.site-title {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-tagline {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 400;
}

.site-author {
  max-width: var(--wide);
  margin: 0.75rem auto 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.post-grid .post-card {
  margin: 0;
}

.post-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.post-list:not(.post-grid) .post-card {
  padding-bottom: 2rem;
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.post-list:not(.post-grid) .post-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.post-date {
  display: block;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.post-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  line-height: 1.3;
}

.post-card-title a {
  color: inherit;
  text-decoration: none;
}

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

.post-card-excerpt {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.post-card-excerpt p:last-child {
  margin-bottom: 0;
}

.post-card-excerpt iframe {
  width: 100%;
  min-height: 160px;
  aspect-ratio: 16 / 9;
}

.post-card-more {
  margin: 0 0 0.75rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

.post-card-more a {
  font-weight: 500;
  text-decoration: none;
}

.post-card-more a:hover {
  text-decoration: underline;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

.pagination a {
  text-decoration: none;
}

.pagination-current {
  font-weight: 600;
  color: var(--text);
}

.post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
}

.category {
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.category:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-full {
  margin: 0 auto;
  max-width: var(--max-width);
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.post-full .post-header {
  margin-bottom: 2rem;
  max-width: none;
}

.post-header {
  margin-bottom: 2rem;
  max-width: var(--max-width);
}

.post-title,
.page-title {
  margin: 0.25rem 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.category-page-num {
  font-size: 0.65em;
  font-weight: 400;
  color: var(--muted);
}

.post-body {
  max-width: var(--max-width);
}

.post-full .post-body {
  max-width: none;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.25rem;
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--code-bg);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.45;
}

.prose code {
  font-family: ui-monospace, "Cascadia Code", Menlo, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose pre code {
  padding: 0;
  background: none;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.prose iframe {
  display: block;
  max-width: 100%;
  margin: 1.25rem 0;
  border: 0;
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  width: min(100%, 560px);
  height: auto;
  min-height: 200px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.post-back {
  margin-top: 2.5rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
  margin: 2rem auto 0;
  max-width: var(--max-width);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
}

.post-nav-link:hover .post-nav-title {
  color: var(--accent);
}

.post-nav-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post-nav-title {
  font-weight: 500;
  line-height: 1.35;
}

.post-nav-prev {
  text-align: left;
}

.post-nav-next {
  text-align: right;
}

.post-nav-index {
  align-self: center;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.post-nav-index:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.post-nav-empty {
  visibility: hidden;
}

@media (max-width: 640px) {
  .post-nav {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .post-nav-prev,
  .post-nav-next {
    text-align: center;
  }

  .post-nav-index {
    order: -1;
    justify-self: center;
  }
}

.site-footer {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  border-top: 1px solid var(--border);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.empty {
  color: var(--muted);
}

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

@media (max-width: 640px) {
  .post-grid {
    grid-template-columns: 1fr;
  }

  .site-hero-categories {
    padding: 1rem 1rem 3.75rem;
  }

  .site-hero-search {
    right: 0.75rem;
    left: auto;
    bottom: 0.75rem;
    max-width: calc(100% - 1.5rem);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #292524;
    --border: #44403c;
    --text: #fafaf9;
    --muted: #a8a29e;
    --accent: #fbbf24;
    --accent-hover: #fcd34d;
    --code-bg: #292524;
  }
}
