:root {
  --color-text: #1a1a1a;
  --color-bg: #fdfcf9;
  --color-muted: #6b6b6b;
  --color-accent: #7a4b3a;
  --color-border: #e2ddd3;
  --color-card: #ffffff;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.25;
  font-weight: normal;
}

p { margin: 0 0 1rem; }

a { color: var(--color-accent); }

img { max-width: 100%; display: block; }

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem;
}

/* ---------- Header / Footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 2rem 0;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-header .brand {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--color-text);
  letter-spacing: 0.01em;
}

.site-header nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: var(--color-accent);
}

.site-footer {
  max-width: 820px;
  margin: 3rem auto 0;
  padding: 2rem;
  color: var(--color-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
}

/* ---------- Hero ---------- */
/* Looks complete on its own (gradient) and is enhanced automatically
   if public/assets/img/hero.jpg is ever placed on disk. */

.hero {
  margin: 1.5rem auto 0;
  max-width: 100%;
  min-height: 420px;
  padding: 3rem 2.5rem;
  display: flex;
  align-items: center;
  border-radius: 10px;
  text-align: left;
  color: #33261d;
  /* A soft light scrim on the LEFT (where the heading sits) first, then a
     calm LIGHT gradient fallback, then the real photo underneath. The photo
     keeps its negative space on the left, so dark text reads cleanly over it;
     if hero.jpg is missing, the light fallback gradient shows through and the
     dark text still reads. */
  background-color: #e7dcc9;
  background-image:
    linear-gradient(90deg, rgba(247, 242, 233, 0.94) 0%, rgba(247, 242, 233, 0.78) 32%, rgba(247, 242, 233, 0.28) 58%, rgba(247, 242, 233, 0) 78%),
    url(../img/hero.jpg);
  background-size: cover, cover;
  background-position: center, center right;
  background-repeat: no-repeat, no-repeat;
}

.hero-inner {
  max-width: 30rem;
  margin: 0;
}

.hero h1 {
  font-size: 3.1rem;
  line-height: 1.05;
  margin: 0 0 0.6rem;
  color: #2a1f17;
}

.hero .tagline {
  font-size: 1.2rem;
  margin: 0;
  color: #6a5844;
}

.home-block {
  margin-top: 3rem;
}

.home-block h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

/* ---------- Post list / cards ---------- */

.post-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.post-card img {
  border-radius: 6px;
  margin-bottom: 0.75rem;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  width: 100%;
}

.post-card h2,
.post-card h3 {
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

.post-card h2 a,
.post-card h3 a {
  text-decoration: none;
  color: var(--color-text);
}

.post-card h2 a:hover,
.post-card h3 a:hover {
  color: var(--color-accent);
}

.post-card time {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  display: block;
}

.post-card p { margin: 0; color: var(--color-text); }

.cat-filter {
  margin-bottom: 1.5rem;
}

.cat-filter a {
  display: inline-block;
  margin: 0 0.5rem 0.5rem 0;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--color-text);
}

.cat-filter a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ---------- Single post ---------- */

.post-full h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.post-full > time {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.post-cats {
  margin: 0.5rem 0 1rem;
}

.post-cats a {
  margin-right: 0.75rem;
  font-size: 0.85rem;
  text-decoration: none;
}

.post-hero {
  width: 100%;
  border-radius: 8px;
  margin: 1rem 0 1.5rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.post-body {
  font-size: 1.05rem;
}

.post-body h2, .post-body h3 { margin-top: 2rem; }
/* Single body images: centered, capped — never stretched full-column. */
.post-body > img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  margin: 1.25rem auto;
  border-radius: 6px;
}
/* Runs of consecutive images tile into a responsive grid instead of stacking. */
.post-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin: 1.5rem 0;
}
.post-gallery img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  margin: 0;
}
/* A 2-image run reads better as two halves than four cramped columns. */
.post-gallery[data-n="2"] { grid-template-columns: repeat(2, 1fr); }
.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1.25rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-muted);
  font-style: italic;
}

/* ---------- Books ---------- */

.lede {
  color: var(--color-muted);
  font-size: 1.05rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.book-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-card img {
  border-radius: 6px;
  margin-bottom: 0.75rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  width: 100%;
  max-width: 160px;
}

.book-card h2,
.book-card h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

.book-card .author {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.book-card .blurb {
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
}

.btn:hover { opacity: 0.9; }

.btn.amazon {
  margin-top: auto;
}

/* ---------- About ---------- */

.about h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.about-body {
  font-size: 1.05rem;
}

.about-body img {
  border-radius: 8px;
  margin: 1rem 0;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  gap: 0.5rem;
  margin: 2rem 0;
}

.pagination a {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.9rem;
}

.pagination a.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.pagination a:hover:not(.active) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ---------- Admin ---------- */

body.admin {
  background: #f3f1ec;
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 2rem;
  background: var(--color-text);
}

.admin-bar a {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
}

.admin-bar a:hover {
  text-decoration: underline;
}

.admin-bar form.inline {
  margin-left: auto;
}

.admin-bar button {
  background: none;
  border: 1px solid #fff;
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

.admin-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92rem;
}

.admin-table th {
  background: #f3f1ec;
  font-weight: 600;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table td.actions a,
.admin-table td.actions button {
  margin-right: 0.5rem;
}

/* Dashboard: stat tiles */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat {
  flex: 1 1 200px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  font-size: 0.95rem;
  color: var(--color-muted);
}

.stat .num {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--color-text);
  line-height: 1.2;
}

/* Dashboard: two-column layout */

.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.dash-cols section {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.dash-cols h2 {
  font-size: 1.1rem;
  margin-top: 0;
}

.dash-cols ol {
  margin: 0;
  padding-left: 1.25rem;
}

.dash-cols li {
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
}

/* Dashboard: views-per-day bar strip */

.sparkbars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding: 0.75rem 1rem 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.sparkbars .bar {
  flex: 1 1 auto;
  min-width: 3px;
  background: var(--color-accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}

.sparkbars .bar:hover {
  opacity: 1;
}

/* Admin forms */

.admin-main form label,
.login label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: 1rem;
}

.admin-main input[type="text"],
.admin-main input[type="email"],
.admin-main input[type="password"],
.admin-main input[type="number"],
.admin-main input[type="url"],
.admin-main select,
.admin-main textarea,
.login input {
  padding: 0.5rem 0.6rem;
  border: 1px solid #cfc9bd;
  border-radius: 4px;
  font: inherit;
  width: 100%;
}

.admin-main textarea {
  min-height: 8rem;
  font-family: var(--font-sans);
}

.login {
  max-width: 360px;
  margin: 3rem auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login button,
.admin-main button,
.admin-main .btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.flash-error {
  background: #fbe4e1;
  color: #8a2c1f;
}

.flash-ok {
  background: #e3f0e3;
  color: #2c5a2c;
}

/* ---------- Mobile breakpoints ---------- */

@media (max-width: 800px) {
  .dash-cols {
    grid-template-columns: 1fr;
  }

  .book-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .container {
    padding: 1.25rem;
  }

  .site-header {
    padding: 1.25rem 1.25rem 0;
  }

  .hero {
    min-height: 340px;
    padding: 2.5rem 1.5rem;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .post-list {
    grid-template-columns: 1fr;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .book-card img {
    max-width: 200px;
  }

  .stat-row {
    flex-direction: column;
  }

  .admin-main {
    padding: 1.25rem;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }
}
