:root {
  --bg: #0a0a0b;
  --bg-elevated: #121214;
  --bg-card: #18181b;
  --text: #f4f4f5;
  --text-muted: #8b949e;
  --teal: #14b8a6;
  --teal-light: #2dd4bf;
  --teal-dim: #0d9488;
  --teal-glow: rgba(20, 184, 166, 0.22);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --nav-h: 72px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

.glow--hero {
  width: 420px;
  height: 420px;
  top: -80px;
  right: -60px;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.14) 0%, transparent 70%);
}

/* Nav */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav__logo {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: var(--teal-light);
}

.nav__logo-mark {
  font-size: 1.25rem;
  line-height: 1;
}

.nav__links {
  display: flex;
  gap: 2rem;
}

.nav__links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}

.nav__links a:hover { color: var(--teal-light); }

.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.nav__toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: transform 0.25s, opacity 0.25s;
}

.nav__toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 1rem) clamp(1rem, 3vw, 2rem) 2rem;
}

.hero__intro {
  text-align: center;
  margin-bottom: 1.25rem;
}

.hero__stats {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.hero__stat--label {
  color: var(--teal-light);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.hero__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 12vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.hero__title-main { color: var(--text); }
.hero__title-accent { color: var(--teal-light); }

.hero__tagline {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--text-muted);
  font-size: 1rem;
}

.section__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

/* Grid header */
.grid-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.grid-header__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.04em;
}

.grid-header__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.filter-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.filter-toggle__btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.filter-toggle__btn.is-active,
.filter-toggle__btn:hover {
  color: var(--text);
  background: rgba(20, 184, 166, 0.18);
}

.filter-toggle__btn.is-active {
  color: var(--teal-light);
}

.sort-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.sort-toggle__btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.sort-toggle__btn.is-active,
.sort-toggle__btn:hover {
  color: var(--text);
  background: rgba(20, 184, 166, 0.18);
}

.sort-toggle__btn.is-active {
  color: var(--teal-light);
}

/* Book grid — 2 / 4 / 6 / 8 columns */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.75rem, 1.5vw, 1.125rem);
}

@media (min-width: 640px) {
  .book-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .book-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 1280px) {
  .book-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.28s ease;
  will-change: transform;
}

.book-card:hover {
  transform: translateY(-5px) scale(1.015);
  border-color: rgba(20, 184, 166, 0.38);
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.42),
    0 0 28px var(--teal-glow),
    0 0 0 1px rgba(20, 184, 166, 0.22);
}

.book-card--wip {
  border-color: rgba(20, 184, 166, 0.28);
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.06) 0%, var(--bg-card) 40%);
}

.book-card--wip:hover {
  border-color: rgba(45, 212, 191, 0.55);
}

.book-card__ribbon {
  position: absolute;
  top: 10px;
  left: -28px;
  z-index: 2;
  width: 110px;
  padding: 0.28rem 0;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: #042f2e;
  background: linear-gradient(90deg, var(--teal-light), var(--teal));
  transform: rotate(-42deg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.book-card__cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--bg-elevated);
  overflow: hidden;
}

.book-card__cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    180deg,
    rgba(20, 184, 166, 0.08) 0%,
    transparent 45%,
    rgba(0, 0, 0, 0.12) 100%
  );
  transition: opacity 0.28s ease;
}

.book-card:hover .book-card__cover-wrap::after {
  opacity: 1;
}

.book-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), filter 0.28s ease;
}

.book-card:hover .book-card__cover {
  transform: scale(1.045);
  filter: brightness(1.07) saturate(1.04);
}

.book-card__cover--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--teal-light);
  background: linear-gradient(145deg, var(--bg-elevated), #1a2e2c);
}

.book-card__body {
  padding: 0.85rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.book-card__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card__author {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-light);
  border: 1px solid rgba(20, 184, 166, 0.25);
}

.badge--muted {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border-color: var(--border);
}

.badge--series {
  background: rgba(20, 184, 166, 0.08);
  color: var(--teal);
  border-color: rgba(20, 184, 166, 0.18);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Star rating */
.stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-top: auto;
  padding-top: 0.35rem;
}

.stars__btn {
  padding: 2px;
  line-height: 0;
  color: var(--text-muted);
  transition: color 0.15s, transform 0.15s;
}

.stars__btn:hover,
.stars__btn:focus-visible {
  color: var(--teal-light);
  transform: scale(1.1);
  outline: none;
}

.stars__btn.is-filled {
  color: var(--teal-light);
}

.stars__btn.is-half {
  color: var(--teal-light);
  opacity: 0.55;
}

.stars__value {
  margin-left: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.grid-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

/* About */
.section {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: 3rem clamp(1rem, 3vw, 2rem) 4rem;
}

.section--about {
  border-top: 1px solid var(--border);
}

.about__grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 3rem;
  align-items: start;
}

.about__copy h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3rem);
  letter-spacing: 0.03em;
  line-height: 1.05;
}

.about__copy p {
  margin: 0 0 1rem;
  color: var(--text-muted);
  max-width: 52ch;
}

.about__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.stat__num {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.04em;
  color: var(--teal-light);
}

.stat__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.about__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.btn--primary {
  background: var(--teal);
  color: #042f2e;
}

.btn--primary:hover {
  background: var(--teal-light);
}

.btn--ghost {
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn--ghost:hover {
  border-color: rgba(20, 184, 166, 0.4);
  color: var(--teal-light);
}

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

.footer a {
  color: var(--teal-light);
}

.footer a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .nav__links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.25rem;
    background: rgba(10, 10, 11, 0.96);
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s, opacity 0.3s;
  }

  .nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav__toggle { display: flex; }

  .about__grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about__stats {
    grid-template-columns: 1fr;
  }
}

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