:root {
  --bg: #fbfaf7;
  --text: #22201c;
  --muted: #6b6459;
  --line: #e4e0d6;
  --accent: #7a5b3a;
  --max-width: 760px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
a:hover { border-bottom-color: currentColor; }

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

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.25;
  font-weight: 600;
  margin: 1.6em 0 0.5em;
}
h1 { font-size: 2.1rem; margin-top: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p, ul, ol, blockquote { margin: 0 0 1.1em; }

blockquote {
  margin-left: 0;
  padding-left: 1em;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5em 0;
}

code {
  background: #f0ede3;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Layout */
.site-header {
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.site-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  border-bottom: none;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-bottom: none;
  line-height: 0;
}
.social-icon:hover { color: var(--accent); }
.social-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text);
  font-size: 0.95rem;
}
.site-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.lang-switch {
  display: flex;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.lang-switch a { color: var(--muted); }
.lang-switch a.active { color: var(--accent); font-weight: 600; }

main.plain {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

main.wide {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Section layout: left tree/sidebar + content, used on blog/projects */
.section-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.section-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
}

.section-sidebar .sidebar-root {
  display: block;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 0.75rem;
  border-bottom: none;
}
.section-sidebar .sidebar-root.active { color: var(--accent); }

.section-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--line);
}
.section-sidebar li { margin: 0; }
.section-sidebar a {
  display: block;
  padding: 0.4rem 0 0.4rem 0.9rem;
  margin-left: -2px;
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: none;
  border-left: 2px solid transparent;
}
.section-sidebar a:hover { color: var(--text); }
.section-sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.section-content {
  flex: 1;
  min-width: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem;
  text-align: center;
}

/* Landing / about */
.hero {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.hero img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.hero .tagline {
  color: var(--muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  margin-top: 0.3rem;
}

/* Card grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.75rem;
  margin: 1.5rem 0 2rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}
.card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.card-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.card-summary {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 0.75rem;
  flex: 1;
}
.card-link {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Books table — spine images stacked directly on top of each other with
   zero gap (like the reference photo of the physical stack). Each row's
   height is driven ONLY by its spine image: .book-cover-cell is a plain
   50%-width block so the image's own aspect ratio sets the row height,
   and .book-info-cell is taken out of flow (position: absolute) so a
   long description can never stretch the row and reopen a gap between
   spines. The description overlays the right half, vertically centered,
   clamped to 2 lines (1 line for books whose spine is very thin — see
   the "thin" class added by layouts/books/list.html). */
.books-table {
  margin: 1.5rem 0 2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.book-row {
  position: relative;
  min-height: 2.8rem;
}
.book-row.thin {
  min-height: 1.6rem;
}
.book-cover-cell {
  display: block;
  width: 50%;
}
.book-cover-cell img {
  width: 100%;
  height: auto;
  display: block;
}
.book-info-cell {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  box-sizing: border-box;
  overflow: hidden;
}
.book-info-cell .card-summary {
  margin: 0;
  width: 100%;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
/* Thin divider between each book's description, so it's clear which
   summary belongs to which spine even though the rows themselves touch. */
.book-row + .book-row .book-info-cell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  width: 80%;
  height: 1px;
  background: var(--line);
}
.book-row.thin .book-info-cell .card-summary {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

/* Projects table — square thumbnail (25% width) on the left, bold
   project name + short description on the right. */
.projects-table {
  margin: 1.5rem 0 2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.project-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}
.project-row:last-child { border-bottom: none; }
.project-cover-cell {
  display: block;
  flex: 0 0 25%;
  max-width: 25%;
}
.project-cover-cell img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.project-info-cell {
  flex: 1;
  min-width: 0;
  padding: 0 0 0 1.5rem;
}
.project-title {
  display: block;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
  border-bottom: none;
  margin-bottom: 0.4rem;
}
.project-title:hover { color: var(--accent); }
.project-info-cell .card-summary {
  margin: 0;
  color: var(--muted);
}

/* Project detail page — a stacked gallery of 3-5 images on the left,
   name/subtitle/link on the right, full description below. */
.project-detail-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.project-gallery {
  flex: 0 0 260px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.project-gallery img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.project-detail-layout .info-col { flex: 1; min-width: 260px; }

/* Blog list */
.post-item {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--line);
}
.post-item h3 { margin: 0 0 0.3rem; }
.post-date {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.detail-header {
  margin-bottom: 2rem;
}
.detail-cover {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.book-detail-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.book-detail-layout .cover-col img {
  width: 280px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.book-detail-layout .info-col { flex: 1; min-width: 260px; }

/* Live Google Books rating — filled in by js/google-rating.js. Starts as
   plain muted "Loading…" text and is replaced (or removed, if the book
   has no rating on Google Books) once the fetch resolves. */
.google-rating {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.3rem 0 0;
}
.google-rating-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  color: var(--text);
  border-bottom: none;
}
.google-rating-link:hover { color: var(--accent); }
.google-rating-stars {
  color: #c9972f;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
}
.google-rating-num { font-weight: 600; }
.google-rating-source {
  font-size: 0.78rem;
  color: var(--muted);
}

.praise-block { margin-top: 1.2rem; }
.praise-block h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.praise-block blockquote { margin: 0; }
.praise-block blockquote p { margin-bottom: 0.3em; }
.praise-block blockquote cite {
  display: block;
  font-style: normal;
  font-size: 0.85rem;
}

.related-books {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.related-books h2 { margin-top: 0; }
.related-books-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.related-book {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 140px;
  color: var(--text);
  border-bottom: none;
}
.related-book img {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.related-book span {
  font-size: 0.88rem;
  font-weight: 600;
}
.related-book:hover span { color: var(--accent); }

.tag-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tag {
  font-size: 0.75rem;
  background: #f0ede3;
  color: var(--muted);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.contact-hero,
.section-hero {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}
.contact-lead {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--text);
  text-align: center;
}
.contact-email {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  text-align: center;
}
.contact-email a { color: var(--accent); }

.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
}
.btn:hover { background: var(--text); color: var(--bg); border-bottom: none; }

/* Mobile */
@media (max-width: 700px) {
  .header-inner { padding: 0.9rem 1rem; }
  .site-nav { gap: 0.75rem; }
  .site-nav a { font-size: 0.88rem; }
  .lang-switch { font-size: 0.8rem; gap: 0.5rem; }

  main.plain, main.wide { padding: 1.75rem 1.1rem 3rem; }

  .book-row { min-height: 42px; }
  .book-row.thin { min-height: 24px; }
  .book-info-cell { padding: 0 0.9rem; }
  .book-info-cell .card-summary { font-size: 0.85rem; }

  .hero { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .hero img { width: 100px; height: 100px; }

  .section-layout {
    flex-direction: column;
    gap: 0;
    padding: 1.25rem 1.1rem 3rem;
  }
  .section-sidebar {
    width: 100%;
    position: static;
    margin-bottom: 1.5rem;
  }
  .section-sidebar .sidebar-root { margin-bottom: 0.5rem; }
  .section-sidebar ul {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-left: none;
    border-bottom: 1px solid var(--line);
    gap: 0.25rem;
    padding-bottom: 0.6rem;
  }
  .section-sidebar li { flex-shrink: 0; }
  .section-sidebar a {
    padding: 0.35rem 0.8rem;
    margin-left: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .section-sidebar a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.1rem; }

  .book-detail-layout { flex-direction: column; }
  .book-detail-layout .cover-col img { width: 160px; }

  .project-row { flex-direction: column; align-items: stretch; }
  .project-cover-cell { flex: 0 0 auto; max-width: 100%; }
  .project-info-cell { padding: 0.75rem 0 0; }
  .project-detail-layout { flex-direction: column; }
  .project-gallery { width: 100%; flex-direction: row; overflow-x: auto; flex: 0 0 auto; }
  .project-gallery img { width: 140px; flex-shrink: 0; }
}

/* "More about the project" text shown before the detail page is published: looks like a link, but is not clickable. */
.project-more-soon { color: var(--accent); cursor: default; }
