/* ============================================================
   BASE.CSS — structural CSS + default design tokens
   Themes override tokens only; no structural rules in theme files.
   ============================================================ */

:root {
  /* --- Colors --- */
  --color-bg:     #ffffff;
  --color-text:   #111111;
  --color-accent: #0057cc;
  --color-muted:  #666666;
  --color-border: rgba(17, 17, 17, 0.16);

  /* --- Font stacks --- */
  --font-mono:    "fira mono", monospace;
  --font-sans:    system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-serif:   Georgia, 'Times New Roman', Times, serif;
  --font-body:    var(--font-sans);
  --font-heading: var(--font-body);

  /* --- Book content layout --- */
  --content-font-size:   1.125rem;
  --content-line-height: 1.85;
  --content-text-align:  left;
  --content-hyphens:     none;
  --content-max-width:   680px;

  /* --- Paragraph behavior --- */
  --paragraph-spacing: 1.5em;
  --paragraph-indent:  0;

  /* --- Chapter headings (h1/h2) --- */
  --heading-font-size:       1.375rem;
  --heading-font-weight:     300;
  --heading-letter-spacing:  -0.01em;
  --heading-text-align:      left;
  --heading-font-variant:    normal;
  --heading-text-transform:  none;
  --heading-margin-top:      4.5rem;
  --heading-border-top:      2px solid var(--color-text);
  --heading-padding-top:     2rem;

  /* --- h3 --- */
  --h3-font-size:       0.8125rem;
  --h3-font-weight:     700;
  --h3-letter-spacing:  0.1em;
  --h3-text-transform:  uppercase;
  --h3-font-style:      normal;

  /* --- Drop cap (default: off) --- */
  --dropcap-float:         none;
  --dropcap-size:          inherit;
  --dropcap-line-height:   inherit;
  --dropcap-padding-right: 0;
  --dropcap-padding-top:   0;

  /* --- Blockquote --- */
  --blockquote-margin:       2rem 0;
  --blockquote-padding-left: 1.5rem;
  --blockquote-border-left:  3px solid var(--color-text);
  --blockquote-font-style:   normal;

  /* --- Section break (hr) --- */
  --hr-content:        '—\00a0\00a0\00a0—\00a0\00a0\00a0—';
  --hr-font-size:      0.8125rem;
  --hr-letter-spacing: 0.5em;
  --hr-margin:         3.5rem 0;

  /* --- H2 decorative underline (default: off) --- */
  --h2-after-display: none;
  --h2-after-width:   2.5rem;
  --h2-after-bg:      var(--color-border);

  /* --- Lists --- */
  --list-padding-left: 1.5em;
  --list-item-spacing: 0.35em;

  /* --- Author / book page --- */
  --author-name-weight: 700;
  --author-name-style:  normal;
  --author-bio-size:    1rem;
  --book-title-weight:  800;
  --book-title-style:   normal;
  --card-hover-bg:      rgba(0, 0, 0, 0.025);
}

/* ---- Reset ---- */

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

/* ---- Base ---- */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
}

/* ---- Site chrome ---- */

.site-header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.site-logo {
  font-size: 0.8125rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
  font-weight: 600;
}

main {
  flex: 1;
  padding: 3.5rem 2rem 5rem;
}

.site-footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

.site-footer a {
  color: inherit;
}

/* ---- Author page ---- */

.author-page {
  max-width: 780px;
  margin: 0 auto;
}

.author-header {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 4rem;
}

.author-photo {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

.author-name {
  margin: 0 0 0.3rem;
  font-size: 2rem;
  line-height: 1.1;
  font-weight: var(--author-name-weight);
  font-style: var(--author-name-style);
}

.author-tag {
  margin: 0 0 1rem;
}

.author-bio {
  font-size: var(--author-bio-size);
  line-height: 1.7;
  max-width: 54ch;
}

.author-bio p { margin: 0 0 0.75em; }
.author-bio p:last-child { margin-bottom: 0; }

.books-heading {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 0 0 1.5rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  opacity: 0.45;
  color: var(--color-muted);
}

.book-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 2rem;
}

.book-card {
  display: flex;
  gap: 1.5rem;
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
  padding: 1.25rem;
  border-radius: 4px;
  transition: background 0.12s;
}

.book-card:hover {
  background: var(--card-hover-bg);
}

.book-card-cover {
  width: 80px;
  height: auto;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.book-card-author {
  margin-top: 0;
}

.book-card-cover--placeholder {
  width: 80px;
  height: 116px;
  background: rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

.book-card-info {
  padding-top: 0.25rem;
}

.book-card-title {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
  line-height: 1.25;
}

.book-card-subtitle {
  margin: 0 0 0.5rem;
  opacity: 0.55;
  font-size: 0.9375rem;
}

.book-card-desc {
  font-size: 0.9375rem;
  line-height: 1.55;
  opacity: 0.7;
  color: var(--color-muted);
}

.book-card-desc p { margin: 0; }

/* ---- Author grid (related authors) ---- */

.author-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.author-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
  flex: 1;
  min-width: 180px;
}

.author-card:hover {
  background: var(--card-hover-bg);
}

.author-card-photo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

.author-card-photo--placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

.author-card-name {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

/* ---- Authors index page ---- */

.authors-page {
  max-width: 780px;
  margin: 0 auto;
}

.authors-page-heading {
  font-size: 2rem;
  font-weight: var(--author-name-weight);
  margin: 0 0 2rem;
  line-height: 1.1;
}

.authors-letter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.authors-letter-nav-link,
.authors-letter-nav-empty {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 3px;
  text-decoration: none;
}

.authors-letter-nav-link {
  color: var(--color-text);
  transition: background 0.12s;
}

.authors-letter-nav-link:hover {
  background: var(--card-hover-bg);
}

.authors-letter-nav-empty {
  color: var(--color-muted);
  opacity: 0.3;
  cursor: default;
}

.authors-letter-section {
  margin-bottom: 2.5rem;
}

.authors-letter-heading {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 0 0 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  opacity: 0.45;
  color: var(--color-muted);
}

.authors-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.authors-breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.authors-breadcrumb a:hover {
  text-decoration: underline;
}

.authors-breadcrumb-sep {
  opacity: 0.5;
}

.browse-all-authors-link {
  display: block;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: var(--color-muted);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.12s;
}

.browse-all-authors-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ---- Book page ---- */

.book-page {
  max-width: 780px;
  margin: 0 auto;
}

.book-header {
  display: flex;
  gap: 2.75rem;
  align-items: flex-start;
  margin-bottom: 2.75rem;
}

.book-cover-wrap {
  flex-shrink: 0;
}

.book-cover {
  width: 150px;
  height: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
}

.book-meta {
  flex: 1;
  padding-top: 0.25rem;
}

.book-author-link {
  margin: 0 0 0.625rem;
  font-size: 0.8125rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.book-author-link a {
  color: inherit;
  text-decoration: none;
}

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

.book-title {
  margin: 0 0 0.4rem;
  font-size: 2.25rem;
  line-height: 1.1;
  font-weight: var(--book-title-weight);
  font-style: var(--book-title-style);
}

.book-subtitle {
  margin: 0 0 1rem;
  font-size: 1.1875rem;
  opacity: 0.55;
  font-style: italic;
  color: var(--color-muted);
}

.book-description {
  font-size: 0.9375rem;
  line-height: 1.65;
  opacity: 0.75;
}

.book-description p { margin: 0 0 0.5em; }
.book-description p:last-child { margin-bottom: 0; }

.book-header--compact {
  display: block;
  margin-bottom: 1.5rem;
}

.book-header--compact .book-title {
  font-size: 1.25rem;
  margin: 0.2rem 0 0;
}

.book-header--compact .book-title a {
  color: inherit;
  text-decoration: none;
}

.book-header--compact .book-title a:hover {
  text-decoration: underline;
}

/* ---- Pagination ---- */

.book-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.page-link {
  color: var(--color-link, var(--color-text));
  text-decoration: none;
  padding: 0.4em 0.8em;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  min-width: 7em;
  text-align: center;
}

.page-link:hover {
  background: var(--color-border);
}

.page-link.page-disabled {
  visibility: hidden;
}

.page-indicator {
  opacity: 0.6;
}

.book-divider {
  height: 1px;
  background: var(--color-border);
  opacity: 1;
  margin: 3rem 0;
}

/* ---- Book content ---- */

.book-content {
  font-family: var(--font-body);
  font-size: var(--content-font-size);
  line-height: var(--content-line-height);
  color: var(--color-text);
  text-align: var(--content-text-align);
  hyphens: var(--content-hyphens);
  -webkit-hyphens: var(--content-hyphens);
  max-width: var(--content-max-width);
}

.book-content p {
  margin: 0 0 var(--paragraph-spacing);
  text-indent: var(--paragraph-indent);
}

/* Reset indent after headings/blocks */
.book-content p:first-of-type,
.book-content h1 + p,
.book-content h2 + p,
.book-content h3 + p,
.book-content blockquote + p,
.book-content hr + p {
  text-indent: 0;
}

/* Drop cap */
.book-content > p:first-of-type::first-letter,
.book-content h2 + p::first-letter {
  float: var(--dropcap-float);
  font-size: var(--dropcap-size);
  line-height: var(--dropcap-line-height);
  padding-right: var(--dropcap-padding-right);
  padding-top: var(--dropcap-padding-top);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-text);
}

/* Chapter headings */
.book-content h1,
.book-content h2 {
  font-family: var(--font-heading);
  font-size: var(--heading-font-size);
  font-weight: var(--heading-font-weight);
  font-variant: var(--heading-font-variant);
  letter-spacing: var(--heading-letter-spacing);
  text-align: var(--heading-text-align);
  text-transform: var(--heading-text-transform);
  margin: var(--heading-margin-top) 0 1.5rem;
  padding-top: var(--heading-padding-top);
  border-top: var(--heading-border-top);
  line-height: 1.2;
  color: var(--color-text);
  clear: both;
}

.book-content h2::after {
  content: '';
  display: var(--h2-after-display);
  width: var(--h2-after-width);
  height: 1px;
  background: var(--h2-after-bg);
  margin: 0.875rem auto 0;
}

.book-content h3 {
  font-family: var(--font-heading);
  font-size: var(--h3-font-size);
  font-weight: var(--h3-font-weight);
  font-style: var(--h3-font-style);
  letter-spacing: var(--h3-letter-spacing);
  text-transform: var(--h3-text-transform);
  margin: 3rem 0 1rem;
  color: var(--color-muted);
  text-indent: 0;
}

/* Blockquote */
.book-content blockquote {
  margin: var(--blockquote-margin);
  padding: 0 0 0 var(--blockquote-padding-left);
  border-left: var(--blockquote-border-left);
  font-style: var(--blockquote-font-style);
  color: var(--color-muted);
}

.book-content blockquote p {
  margin: 0 0 0.4em;
  text-indent: 0;
}

/* Section break */
.book-content hr {
  border: none;
  text-align: center;
  margin: var(--hr-margin);
  clear: both;
}

.book-content hr::after {
  content: var(--hr-content);
  font-size: var(--hr-font-size);
  letter-spacing: var(--hr-letter-spacing);
  color: var(--color-muted);
}

/* Inline */
.book-content em     { font-style: italic; }
.book-content strong { font-weight: 700; }

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

.book-content sup {
  font-size: 0.68em;
  vertical-align: super;
  line-height: 0;
}

/* Lists */
.book-content ul,
.book-content ol {
  padding-left: var(--list-padding-left);
  margin: 0 0 var(--paragraph-spacing);
}

.book-content li {
  margin-bottom: var(--list-item-spacing);
}

/* ---- Tables ---- */

.book-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0 0 var(--paragraph-spacing);
}

.book-content th,
.book-content td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.book-content th {
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

@media (max-width: 600px) {
  .book-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- TOC sidebar ---- */

.book-toc {
  display: none;
}

@media (min-width: 1280px) and (hover: hover) {
  .book-layout {
    display: grid;
    grid-template-columns: minmax(0, 780px) 200px;
    gap: 4rem;
    max-width: 1040px;
    margin: 0 auto;
    align-items: start;
  }

  .book-layout .book-page {
    max-width: none;
    margin: 0;
  }

  .book-toc {
    display: block;
  }

  .book-toc-inner {
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
  }
}

.book-toc-heading {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.4;
  color: var(--color-muted);
}

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

.book-toc-item {
  margin: 0;
}

.book-toc-item a {
  display: block;
  padding: 0.3em 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-muted);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.1s;
}

.book-toc-item a:hover {
  opacity: 1;
  color: var(--color-text);
}

.book-toc-item--h3 a {
  padding-left: 0.875rem;
  font-size: 0.75rem;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  main {
    padding: 2.5rem 1.5rem 4rem;
  }

  .author-header,
  .book-header {
    flex-direction: column;
    gap: 1.5rem;
  }

  .author-photo {
    width: 96px;
    height: 96px;
  }

  .book-cover {
    width: 110px;
  }

  .book-title,
  .author-name {
    font-size: 1.625rem;
  }
}

/* ---- Print ---- */

@media print {
  .site-header,
  .site-footer {
    display: none;
  }

  main {
    padding: 0;
  }

  .book-header {
    page-break-after: avoid;
  }

  .book-content {
    font-size: 11pt;
    line-height: 1.7;
    color: #000;
    max-width: none;
    text-align: left;
    hyphens: none;
  }

  .book-content > p:first-of-type::first-letter {
    float: none;
    font-size: inherit;
    line-height: inherit;
    padding: 0;
  }
}
