:root {
  color-scheme: light;
  --background: #FAF6F1;
  --text: #2C2420;
  --muted: #6B5E54;
  --accent: #C0593A;
  --accent-dark: #9E4430;
  --border: #D9CFC2;
  --surface: #F0E9DF;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #111;
  --text: #fff;
  --muted: #bbb;
  --accent: #fff;
  --accent-dark: #bbb;
  --border: #333;
  --surface: #1a1a1a;
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 72px 24px 56px;
}

section {
  padding: 38px 0;
  border-top: 1px solid var(--border);
}

section:first-child {
  border-top: 0;
}

h1, h2 {
  margin: 0;
  color: var(--text);
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  margin-bottom: 26px;
  font-size: clamp(2.75rem, 10vw, 5.75rem);
  font-weight: 700;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
}

p {
  margin: 0 0 18px;
}

section > p {
  max-width: 38em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent), transparent 48%);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

a:hover {
  color: var(--accent-dark);
  text-decoration-color: currentColor;
}

.thesis-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.05em;
  font-style: italic;
  font-weight: 600;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.link-row a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.link-row a:hover {
  border-color: var(--accent);
}

footer {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 24px 48px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  main {
    padding-top: 42px;
  }

  .theme-toggle {
    top: 12px;
    right: 12px;
  }

  section {
    padding: 32px 0;
  }
}

.page-title {
  margin-bottom: 12px;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
}

.back {
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 42px 28px;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
  perspective: 1400px;
}

.book {
  margin: 0;
}

/* the cover: layered shadow ramp, printed spine, a little gloss */
.book-cover {
  position: relative;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  transform-origin: 50% 85%;
  box-shadow:
    0 1px 1px rgba(44, 36, 32, 0.09),
    0 2px 3px rgba(44, 36, 32, 0.08),
    0 5px 9px -2px rgba(44, 36, 32, 0.09),
    0 12px 20px -8px rgba(44, 36, 32, 0.14),
    0 26px 38px -16px rgba(44, 36, 32, 0.20);
  transition:
    transform 460ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 460ms cubic-bezier(0.16, 1, 0.3, 1);
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.34) 0,
      rgba(0, 0, 0, 0.14) 3px,
      rgba(0, 0, 0, 0.04) 7px,
      rgba(255, 255, 255, 0.14) 9px,
      rgba(255, 255, 255, 0.04) 16px,
      rgba(255, 255, 255, 0) 26px),
    linear-gradient(103deg,
      rgba(255, 255, 255, 0.16) 0%,
      rgba(255, 255, 255, 0.04) 26%,
      rgba(255, 255, 255, 0) 42%),
    linear-gradient(0deg,
      rgba(0, 0, 0, 0.10) 0%,
      rgba(0, 0, 0, 0) 14%);
  transition: opacity 460ms ease;
}

.book-cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--surface);
}

.book:hover .book-cover {
  transform: translateY(-10px) rotateX(5deg) scale(1.025);
  box-shadow:
    0 2px 2px rgba(44, 36, 32, 0.10),
    0 5px 7px rgba(44, 36, 32, 0.09),
    0 12px 18px -4px rgba(44, 36, 32, 0.12),
    0 26px 38px -12px rgba(44, 36, 32, 0.20),
    0 48px 62px -22px rgba(44, 36, 32, 0.28);
}

.book:hover .book-cover::after {
  opacity: 0.72;
}

:root[data-theme="dark"] .book-cover {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 4px 8px rgba(0, 0, 0, 0.45),
    0 12px 22px -8px rgba(0, 0, 0, 0.65),
    0 28px 44px -18px rgba(0, 0, 0, 0.85);
}

:root[data-theme="dark"] .book:hover .book-cover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.6),
    0 8px 16px rgba(0, 0, 0, 0.5),
    0 20px 34px -10px rgba(0, 0, 0, 0.7),
    0 46px 66px -24px rgba(0, 0, 0, 0.95);
}

.book-title {
  margin: 12px 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  transition: color 300ms ease;
}

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

.book-author {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* scroll reveal — books settle into place */
html.js .book {
  opacity: 0;
  transform: translateY(34px) scale(0.93) rotate(-1.4deg);
  filter: blur(5px);
}

html.js .book.is-visible {
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    opacity 700ms cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms),
    transform 820ms cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms),
    filter 700ms cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  html.js .book,
  html.js .book.is-visible {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  .book-cover,
  .book:hover .book-cover {
    transition: none;
    transform: none;
  }
}

.books-count {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}
