:root {
  --text: #2c2c2c;
  --text-light: #666;
  --bg: #faf9f7;
  --accent: #4a6274;
  --border: #e5e3df;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Navigation */
.site-nav {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

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

.site-title {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-light);
}

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

/* Main content */
main {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 2rem;
  width: 100%;
}

/* Poem styles */
.poem, .book-poem {
  margin-bottom: 3rem;
}

.poem-header {
  margin-bottom: 1.5rem;
}

.poem-title {
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

h2.poem-title {
  font-size: 1.2rem;
}

.poem-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
}

.poem-meta time::after {
  content: " · ";
}

.poem-meta .authors a {
  color: var(--text-light);
}

.poem-meta .authors a:hover {
  color: var(--accent);
}

.poem-meta .collab {
  font-style: italic;
}

.poem-meta .collab a {
  color: var(--text-light);
}

.poem-meta .collab a:hover {
  color: var(--accent);
}

.poem-body {
  font-size: 1.05rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.poem-commentary {
  margin-top: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  white-space: pre-wrap;
}

.poem-footer {
  margin-top: 0.5rem;
  padding: 0;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
  text-align: left;
}

/* Book page header */
.book-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

/* Cover with text overlay at top */
.book-header.has-cover {
  background-size: contain;
  background-position: center top;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  border-bottom: none;
  margin-bottom: 3rem;
  border-radius: 4px;
  /* Maintain 2:3 aspect ratio (height = width * 1.5) */
  padding-top: 150%;
}

/* Subtle gradient overlay for text readability at top */
.book-header.has-cover::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.3) 40%,
    rgba(0, 0, 0, 0) 100%
  );
  z-index: 0;
}

/* Container for text overlaid on cover */
.book-header.has-cover .book-info {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 2rem;
  z-index: 1;
}

.book-header.has-cover h1,
.book-header.has-cover .book-author,
.book-header.has-cover .book-date,
.book-header.has-cover .book-description,
.book-header.has-cover .download-button {
  position: relative;
  z-index: 1;
}

.book-header.has-cover h1 {
  color: white;
  font-size: 1.8rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.6);
  margin-bottom: 0.5rem;
}

.book-header.has-cover .book-author {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 0, 0, 0.6);
  margin-bottom: 0.3rem;
}

.book-header.has-cover .book-date {
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 0, 0, 0.6);
  margin-bottom: 1rem;
}

.book-header.has-cover .book-author a {
  color: rgba(255, 255, 255, 0.95);
}

.book-header.has-cover .book-description {
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 0, 0, 0.6);
  margin-bottom: 1rem;
}

.book-header.has-cover .download-button {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 0, 0, 0.6);
  display: inline-block;
}

.book-header.has-cover .download-button:hover {
  color: white;
}

.book-header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.book-author {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.book-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.book-author a {
  color: var(--text-light);
}

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

.book-description {
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 1rem;
}

.download-button {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--accent);
}

/* Poems page header */
.poems-page-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.year-nav {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.8;
}

.year-nav a {
  color: var(--text);
}

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

/* Book poems list */
.book-poems {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.book-poem {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.book-poem:last-child {
  border-bottom: none;
}

/* Books section on homepage */
.books-section {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.books-section h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.books-list {
  border-collapse: collapse;
}

.books-list td {
  padding: 0.4rem 0;
  white-space: nowrap;
}

.books-list .book-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-light);
  white-space: nowrap;
  padding-right: 0.5rem;
}

.books-list .download-cell {
  padding-right: 0.5rem;
}

.books-list .download-link {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-light);
}

.books-list .download-link:hover {
  color: var(--accent);
}

/* Footer */
footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Error page */
.error-page {
  text-align: center;
  padding: 3rem 0;
}

.error-page h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.error-page p {
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, color 0.2s, border-color 0.2s;
  z-index: 100;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Responsive */
@media (max-width: 600px) {
  main {
    padding: 2rem 1.25rem;
  }

  .poem-meta {
    display: block;
  }

  .poem-meta time::after {
    content: "";
    display: block;
  }

  .scroll-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
  }
}
