:root {
  --bg: #121212;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --line: #333333;
  --accent: #ff3e6c;

  --paper: #f3ead7;
  --paper-edge: #e4d9bf;
  --paper-shade: #b8ab8c;
  --ink: #2b2520;
  --ink-muted: #7a6e5d;
  --accent-ink: #b0243f;

  --serif-title: 'Libre Baskerville', Georgia, serif;
  --serif-body: 'Merriweather', Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0 16px 80px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif-body);
  line-height: 1.6;
}

/* Header */

.intro {
  padding-top: 56px;
  text-align: center;
}

.avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--accent);
}

.intro h1 {
  margin: 24px 0 0;
  font-family: var(--serif-title);
  font-size: 2.2em;
  font-weight: 700;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-style: italic;
}

/* Section menu */

.sections {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 32px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
}

.sections:not(:has(a + a)) {
  display: none;
}

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

.sections a + a::before {
  content: '·';
  margin-right: 12px;
  color: var(--muted);
}

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

/* Sections */

main section {
  max-width: 680px;
  margin: 64px auto 0;
}

main h2 {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 32px;
  font-family: var(--serif-title);
  font-size: 1.1em;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.15em;
  color: var(--text);
}

main h2::before,
main h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.cover {
  display: block;
  width: 100%;
  object-fit: cover;
  object-position: top;
}

/* Shelf: grid of covers that open the book dialog. */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 32px 24px;
}

.cover-button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cover-button .cover {
  aspect-ratio: 2 / 3;
}

/* Spine highlight on the left edge of each cover. */
.cover-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.2) 0, rgba(0, 0, 0, 0.3) 3px, transparent 10px);
}

.cover-button:hover,
.cover-button:focus-visible {
  transform: translateY(-6px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.75);
}

.cover-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Dialog */

.book-dialog {
  width: calc(100% - 32px);
  max-width: 680px;
  max-height: calc(100% - 32px);
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  overflow: auto;
}

.book-dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

body:has(.book-dialog[open]) {
  overflow: hidden;
}

.close {
  position: absolute;
  top: 8px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: 1.5em;
  line-height: 1;
  cursor: pointer;
}

.close:hover {
  background: var(--accent-ink);
}

/* Book: cover as the left page, paper text as the right page. */

.book {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    2px 0 0 -1px var(--paper-edge),
    4px 0 0 -2px var(--paper-shade),
    6px 0 0 -3px var(--paper-edge),
    8px 0 0 -4px var(--paper-shade);
}

.book .cover {
  height: 100%;
}

.page {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 28px 0 24px -20px rgba(0, 0, 0, 0.45);
}

.date {
  margin: 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85em;
  font-variant: small-caps;
  letter-spacing: 0.08em;
}

.description {
  margin: 16px 0 24px;
  text-align: justify;
  font-size: 0.85em;
}

.description::first-letter {
  float: left;
  padding: 2px 8px 0 0;
  font-family: var(--serif-title);
  font-size: 3.4em;
  line-height: 0.8;
  color: var(--accent-ink);
}

.read {
  margin-top: auto;
  align-self: center;
  padding: 8px 32px;
  border: 1px solid var(--accent-ink);
  border-radius: 4px;
  color: var(--accent-ink);
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  transition: background 0.2s ease, color 0.2s ease;
}

.read:hover {
  background: var(--accent-ink);
  color: var(--paper);
}

@media (max-width: 640px) {
  .book {
    grid-template-columns: 1fr;
  }

  .book .cover {
    height: auto;
  }

  .page {
    padding: 20px 16px;
    box-shadow: inset 0 28px 24px -20px rgba(0, 0, 0, 0.45);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .cover-button,
  .read {
    transition: none;
  }

  .cover-button:hover,
  .cover-button:focus-visible {
    transform: none;
  }
}
