:root {
  --ink: #0f1218;
  --raised: #151a22;
  --panel: #1b2130;
  --paper: #e8e4dc;
  --paper-dim: #c9c3b6;
  --muted: #9aa3b2;
  --brass: #c49a4a;
  --brass-bright: #e0b86a;
  --mint: #6fd3a0;
  --mint-dim: #3f8f6a;
  --rule: #2a3140;
  --danger: #c45c45;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
  --font-display: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  font-family: var(--font-body);
  background: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 55% 45% at 8% 0%, rgba(196, 154, 74, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 96% 8%, rgba(111, 211, 160, 0.1), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(27, 33, 48, 0.9), transparent 60%),
    linear-gradient(165deg, #0c0f14 0%, #0f1218 45%, #121820 100%);
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(232, 228, 220, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 228, 220, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 10%, transparent 70%);
  animation: grid-drift 36s linear infinite;
  pointer-events: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem clamp(1.25rem, 4vw, 3.5rem);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(15, 18, 24, 0.82);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--paper);
}

.brand-mark {
  width: 0.7rem;
  height: 1.15rem;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass) 55%, #8a6a32);
  box-shadow: 0 0 0 3px rgba(196, 154, 74, 0.18);
  animation: pulse-mark 3.6s ease-in-out infinite;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.header-note {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vh, 3.5rem) clamp(1.25rem, 4vw, 3.5rem) 3rem;
}

.intro {
  max-width: 40rem;
  margin-bottom: clamp(2.25rem, 5vh, 3.5rem);
  animation: rise 0.8s ease both;
}

.intro-kicker,
.series-kicker {
  margin: 0 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
}

.intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--paper);
}

.intro-lede {
  margin: 1rem 0 0;
  color: var(--paper-dim);
  font-size: 1.05rem;
  max-width: 34rem;
}

.series {
  margin-bottom: clamp(2.75rem, 6vh, 4rem);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(27, 33, 48, 0.72), rgba(15, 18, 24, 0.55));
  animation: rise 0.75s ease both;
}

.series.tone-lithos {
  border-color: rgba(196, 154, 74, 0.28);
  box-shadow: inset 0 1px 0 rgba(224, 184, 106, 0.08);
}

.series.tone-ouroboros {
  border-color: rgba(111, 211, 160, 0.22);
  box-shadow: inset 0 1px 0 rgba(111, 211, 160, 0.06);
}

.series.tone-ouroboros .series-kicker {
  color: var(--mint);
}

.series-head {
  margin-bottom: 1.35rem;
}

.series-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.loading {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.book-card {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.95rem;
  text-align: left;
  animation: rise 0.7s ease both;
}

.book-cover-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  border-radius: 12px;
}

.book-cover-btn:focus-visible {
  outline: 3px solid rgba(196, 154, 74, 0.55);
  outline-offset: 3px;
}

.book-cover {
  display: block;
  aspect-ratio: 4 / 5.4;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--panel);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.book-card:hover .book-cover,
.book-card:focus-within .book-cover {
  transform: translateY(-7px) rotate(-0.4deg);
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.55);
}

.tone-ouroboros .book-card:hover .book-cover,
.tone-ouroboros .book-card:focus-within .book-cover {
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(111, 211, 160, 0.2);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-meta h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.book-meta .subtitle {
  margin: 0.4rem 0 0;
  color: var(--brass-bright);
  font-size: 0.95rem;
  font-style: italic;
  font-family: var(--font-display);
}

.tone-ouroboros .book-meta .subtitle {
  color: var(--mint);
  font-style: normal;
  font-family: var(--font-body);
  font-size: 0.92rem;
}

.book-meta .description {
  margin: 0.7rem 0 0;
  color: var(--paper-dim);
  font-size: 0.94rem;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 1rem;
}

.book-tags span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-dim);
  background: rgba(232, 228, 220, 0.06);
  border: 1px solid var(--rule);
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 3px solid rgba(196, 154, 74, 0.5);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brass);
  color: #1a1408;
}

.btn-primary:hover {
  background: var(--brass-bright);
}

.tone-ouroboros .btn-primary {
  background: var(--mint);
  color: #0c1511;
}

.tone-ouroboros .btn-primary:hover {
  background: #8de0b4;
}

.tone-ouroboros .btn:focus-visible {
  outline-color: rgba(111, 211, 160, 0.55);
}

.site-footer {
  padding: 1.5rem clamp(1.25rem, 4vw, 3.5rem) 2.5rem;
  border-top: 1px solid var(--rule);
  background: #0a0c10;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a {
  color: var(--brass-bright);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
  color: var(--mint);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-mark {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(196, 154, 74, 0.18);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(196, 154, 74, 0.06);
  }
}

@keyframes grid-drift {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 56px 56px, 56px 56px;
  }
}

@media (max-width: 640px) {
  .header-note {
    width: 100%;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
