/* Imperfect Congruence — static book edition.
   A plain, print-like design: serif text, quiet sidebar contents,
   one deep-teal accent. No frameworks, no webfonts. */

:root {
  --paper: #ffffff;
  --panel: #f4f3ee;
  --ink: #232420;
  --muted: #62655c;
  --line: #e0ded4;
  --accent: #0e5f58;
  --accent-dark: #093f3b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.33rem;
  line-height: 1.62;
}

/* ---------- header ---------- */

.site-header {
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
}

.site-header .inner {
  max-width: 1350px;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1.1rem;
}

.site-title {
  font-size: 2.125rem;
  line-height: 1.2;
  margin: 0;
  font-weight: 700;
}

.site-title a {
  color: var(--ink);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* original Marinelli theme banner (1020x320), recovered from the live server,
   with its original caption overlaid as the theme did */
.site-banner {
  position: relative;
  display: block;
  margin-top: 1rem;
  text-decoration: none;
}

.site-banner img {
  display: block;
  width: 100%;
  height: auto;
}

.site-banner .banner-caption {
  position: absolute;
  left: 0;
  bottom: 0;
  max-width: 100%;
  background: rgba(8, 18, 16, 0.72);
  color: #f2f3ec;
  font-family: var(--sans);
  font-size: 1.06rem;
  padding: 0.45rem 0.8rem;
}

/* ---------- shell ---------- */

.shell {
  max-width: 1350px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 3.75rem;
  align-items: start;
}

main {
  min-width: 0;
  max-width: 57.5rem;
  padding-top: 1.75rem;
}

/* ---------- sidebar contents ---------- */

.book-nav {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem 1rem 1.1rem;
  margin-top: 1.75rem;
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.45;
}

.book-nav h2 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.book-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.book-nav ul ul {
  padding-left: 0.85rem;
  border-left: 1px solid var(--line);
  margin: 0.15rem 0 0.35rem 0.1rem;
}

.book-nav li {
  margin: 0.12rem 0;
}

.book-nav a {
  color: var(--ink);
  text-decoration: none;
  display: block;
  padding: 0.1rem 0.3rem;
  border-left: 2px solid transparent;
  margin-left: -0.3rem;
}

.book-nav a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.book-nav li.depth-2 > a {
  font-weight: 600;
}

.book-nav li.active > a {
  color: var(--accent-dark);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* mobile contents drawer (desktop uses the sidebar) */
.toc-mobile {
  display: none;
  font-family: var(--sans);
  font-size: 1.06rem;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.55rem 0.8rem;
  margin: 1.25rem 0 0;
}

.toc-mobile summary {
  cursor: pointer;
  font-weight: 600;
}

.toc-mobile ul {
  list-style: none;
  padding-left: 1rem;
}

.toc-mobile > ul,
.toc-mobile nav > ul {
  padding-left: 0;
}

.toc-mobile a {
  color: var(--ink);
}

/* ---------- prose ---------- */

.kicker {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 0.3rem;
}

.kicker a {
  color: var(--accent-dark);
}

h1, h2, h3, h4 {
  line-height: 1.25;
  text-wrap: balance;
}

.prose h1, h1.page-title {
  font-size: 2.5rem;
  margin: 0 0 0.4rem;
}

.prose h2 {
  font-size: 1.81rem;
  margin: 2rem 0 0.6rem;
}

.prose h3 {
  font-size: 1.48rem;
  margin: 1.6rem 0 0.5rem;
}

.prose a {
  color: var(--accent-dark);
  text-underline-offset: 0.12em;
}

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

.prose img {
  max-width: 100%;
  height: auto;
}

.prose p img:only-child {
  display: block;
  margin: 1rem auto;
}

/* gallery visual index */
.prose img.image_gallery {
  display: inline-block;
  height: 160px;
  width: auto;
  margin: 0 10px 12px 0;
  border: 1px solid var(--line);
  vertical-align: top;
}

.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 1.19rem;
  margin: 1.2rem 0;
}

.prose p, .prose li, .prose td {
  overflow-wrap: break-word;
}

/* legacy floated image boxes carried over from the Drupal theme */
.prose .imgbox_right {
  float: right;
  margin: 0 0 1rem 1.25rem;
}

.prose .imgbox_left {
  float: left;
  margin: 0 1.25rem 1rem 0;
}

.prose .imgbox_right img, .prose .imgbox_left img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* cap legacy fixed pixel widths so nothing overflows narrow screens */
.prose div[style] {
  max-width: 100%;
  box-sizing: border-box;
}

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

.prose th {
  background: var(--panel);
  font-family: var(--sans);
  font-size: 1.02rem;
}

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

.prose pre {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 1.02rem;
  line-height: 1.5;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

/* ---------- book pager ---------- */

.book-pager {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin: 2.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 1.02rem;
}

.book-pager a {
  color: var(--accent-dark);
  text-decoration: none;
}

.book-pager a:hover {
  text-decoration: underline;
}

.book-pager .up {
  text-align: center;
  color: var(--muted);
}

.book-pager .next {
  text-align: right;
}

.book-pager .label {
  display: block;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---------- home contents ---------- */

.home-toc ul {
  list-style: none;
  padding-left: 1.25rem;
}

.home-toc > ul {
  padding-left: 0;
}

.home-toc li {
  margin: 0.3rem 0;
}

.home-toc li.depth-2 {
  margin-top: 0.9rem;
  font-size: 1.4rem;
}

.home-toc a {
  color: var(--accent-dark);
}

.home-toc li.depth-3, .home-toc li.depth-4 {
  font-size: 1.22rem;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
}

.site-footer .inner {
  max-width: 1350px;
  margin: 0 auto;
  padding: 1.2rem 1.25rem 2rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--accent-dark);
}

/* ---------- narrow screens ---------- */

@media (max-width: 920px) {
  body {
    font-size: 1.25rem;
  }

  .site-title {
    font-size: 1.75rem;
  }

  .site-banner .banner-caption {
    font-size: 0.9rem;
    padding: 0.35rem 0.6rem;
  }

  .prose h1, h1.page-title {
    font-size: 2rem;
  }

  .shell {
    grid-template-columns: 1fr;
    gap: 0;
  }

  main {
    padding-top: 1.25rem;
  }

  .book-nav {
    display: none;
  }

  .toc-mobile {
    display: block;
  }

  .toc-mobile a {
    display: block;
    padding: 0.3rem 0;
  }

  /* floats become centered blocks; override legacy fixed widths */
  .prose .imgbox_right, .prose .imgbox_left {
    float: none;
    width: auto !important;
    margin: 1rem auto;
    text-align: center;
  }

  .prose img.image_gallery {
    height: 120px;
  }

  .book-pager {
    grid-template-columns: 1fr;
  }

  .book-pager .next, .book-pager .up {
    text-align: left;
  }

  .book-pager a {
    display: block;
    padding: 0.4rem 0;
  }
}
