:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-strong: #ede4d5;
  --text: #1f2623;
  --muted: #6f766f;
  --line: #ded4c5;
  --accent: #9f6b3f;
  --accent-dark: #5d3924;
  --ink: #17201e;
  --shadow: 0 24px 60px rgba(51, 39, 26, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  align-items: center;
  background: rgba(247, 243, 234, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

.brand,
.nav-links {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand {
  align-items: center;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  height: 52px;
  object-fit: contain;
  width: 52px;
}

.brand-wordmark {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1;
}

.brand-wordmark span:first-child {
  font-family: Georgia, serif;
  font-size: 1.28rem;
}

.brand-wordmark span:last-child {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  padding-top: 4px;
}

.beta-badge {
  align-items: center;
  background: rgba(159, 107, 63, 0.11);
  border: 1px solid rgba(159, 107, 63, 0.35);
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 0.68rem;
  font-weight: 900;
  min-height: 24px;
  padding: 3px 8px;
  text-transform: uppercase;
}

.nav-links a {
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  padding: 8px 2px;
}

.nav-links a.active,
.nav-links a:hover {
  border-color: var(--accent);
  color: var(--text);
}

main {
  margin: 0 auto;
  max-width: 1220px;
  padding: 0 clamp(18px, 4vw, 56px) 64px;
}

.hero {
  align-items: start;
  display: grid;
  gap: 56px;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  min-height: 560px;
  padding: clamp(56px, 9vw, 104px) 0 36px;
}

.catalog-hero {
  max-width: 760px;
  padding: clamp(42px, 8vw, 82px) 0 28px;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Libre Baskerville", Georgia, serif;
  line-height: 1.08;
}

h1 {
  font-size: 5rem;
  max-width: 900px;
  margin-bottom: 22px;
}

h2 {
  font-size: 2.7rem;
  margin-bottom: 0;
}

h3 {
  font-size: 1rem;
}

.hero-copy p:not(.eyebrow),
.catalog-hero p {
  color: var(--muted);
  font-size: 1.16rem;
  max-width: 680px;
}

.hero-intro {
  max-width: 760px;
}

.hero-manifesto {
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-weight: 800;
  margin: 22px 0 14px;
  max-width: 680px;
  padding-left: 18px;
}

.hero-context {
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 680px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  align-items: center;
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

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

.button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.button.secondary {
  background: transparent;
  color: var(--ink);
}

.hero-panel {
  align-self: start;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.08), transparent 42%),
    var(--ink);
  border: 1px solid rgba(255, 250, 240, 0.12);
  color: var(--surface);
  margin-top: 38px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.matrix-score {
  align-items: end;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr auto;
  margin-bottom: 16px;
  padding-bottom: 20px;
}

.score-number {
  color: #fffaf0;
  display: block;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 4.4rem;
  grid-column: 2;
  grid-row: 1 / span 2;
  line-height: 1;
}

.score-label {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.score-label:first-child {
  color: #fffaf0;
  font-size: 1.05rem;
}

.matrix-breakdown {
  display: grid;
  gap: 10px;
}

.matrix-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.matrix-row strong {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  white-space: nowrap;
}

.matrix-row small {
  align-items: center;
  background: rgba(255, 250, 240, 0.12);
  color: #fffaf0;
  display: inline-flex;
  font-size: 0.92rem;
  height: 28px;
  justify-content: center;
  min-width: 28px;
  padding: 0 8px;
}

.matrix-row strong span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.section-block,
.rating-system,
.catalog-layout {
  padding-top: 48px;
}

.section-heading {
  margin-bottom: 24px;
}

.section-block .section-heading {
  text-align: right;
}

.compact-section {
  padding-top: 58px;
}

.section-note {
  color: var(--muted);
  margin: 10px 0 0 auto;
  max-width: 620px;
}

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

.book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.book-card:hover,
.book-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.book-cover {
  aspect-ratio: 3 / 4.35;
  background:
    linear-gradient(145deg, var(--cover-start, #2f3632), var(--cover-end, #111614));
  color: #fffaf0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.book-cover::before {
  border: 1px solid rgba(255, 255, 255, 0.3);
  content: "";
  inset: 12px;
  position: absolute;
  z-index: 1;
}

.book-cover::after {
  background: var(--cover-accent, rgba(255, 255, 255, 0.35));
  content: "";
  position: absolute;
  z-index: 0;
}

.book-cover img {
  height: 100%;
  inset: 0;
  object-fit: cover;
  position: absolute;
  width: 100%;
  z-index: 2;
}

.pattern-0::after {
  height: 56%;
  opacity: 0.22;
  right: -18%;
  top: -8%;
  transform: rotate(18deg);
  width: 44%;
}

.pattern-1::after {
  border-radius: 999px;
  height: 150px;
  opacity: 0.2;
  right: -58px;
  top: 46px;
  width: 150px;
}

.pattern-2::after {
  bottom: 0;
  height: 8px;
  left: 0;
  opacity: 0.72;
  width: 100%;
}

.pattern-3::after {
  bottom: -36px;
  height: 120px;
  left: -28px;
  opacity: 0.18;
  transform: rotate(-22deg);
  width: 78%;
}

.cover-author,
.cover-title,
.cover-ornament {
  position: relative;
  z-index: 2;
}

.cover-author {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.cover-title {
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.15;
}

.cover-ornament {
  align-self: center;
  border-bottom: 1px solid rgba(255, 250, 240, 0.54);
  border-top: 1px solid rgba(255, 250, 240, 0.54);
  height: 38px;
  opacity: 0.72;
  width: 42%;
}

.tone-gold {
  background: linear-gradient(145deg, #bf8d3c, #3a2915);
}

.tone-blue {
  background: linear-gradient(145deg, #405a7f, #111827);
}

.tone-ink {
  background: linear-gradient(145deg, #39423f, #101514);
}

.tone-stone {
  background: linear-gradient(145deg, #8b8174, #2f2a24);
}

.tone-green {
  background: linear-gradient(145deg, #62705a, #1d2a1f);
}

.tone-copper {
  background: linear-gradient(145deg, #ad6741, #341d16);
}

.tone-silver {
  background: linear-gradient(145deg, #b9bab1, #343837);
}

.tone-white {
  background: linear-gradient(145deg, #ece7db, #746b60);
  color: #181916;
}

.tone-red {
  background: linear-gradient(145deg, #9e3f36, #2b1210);
}

.tone-teal {
  background: linear-gradient(145deg, #2f7b78, #132c2c);
}

.tone-navy {
  background: linear-gradient(145deg, #2c3d59, #101826);
}

.tone-yellow {
  background: linear-gradient(145deg, #d5aa3d, #3a2a0f);
}

.book-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px;
}

.book-card-body h3 {
  margin-bottom: 6px;
}

.book-card-body p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.total-score {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.stars {
  color: var(--accent);
  font-size: 0.92rem;
  white-space: nowrap;
}

.rating-columns {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, 1fr);
}

.rating-columns article {
  border-top: 2px solid var(--ink);
  background: rgba(255, 253, 248, 0.68);
  padding: 22px 0 0;
  text-align: center;
}

.rating-max {
  color: var(--accent);
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 3.4rem;
  line-height: 1;
}

.rating-columns p {
  color: var(--muted);
}

.scale-list {
  color: var(--muted);
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.scale-list strong {
  color: var(--text);
}

.subjective-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin: 26px 0 0;
  max-width: 780px;
  padding-top: 18px;
}

.subjective-note a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.catalog-layout {
  align-items: start;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(240px, 300px) 1fr;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 88px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  background: #fbf8f1;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(159, 107, 63, 0.18);
}

.full-width {
  width: 100%;
}

.results-bar {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.results-bar span {
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 24px;
}

.modal {
  display: none;
}

.modal.is-open {
  display: block;
  inset: 0;
  position: fixed;
  z-index: 50;
}

.modal-backdrop {
  background: rgba(20, 18, 14, 0.62);
  inset: 0;
  position: absolute;
}

.modal-dialog {
  background: var(--surface);
  box-shadow: var(--shadow);
  left: 50%;
  max-height: min(86vh, 860px);
  max-width: 940px;
  overflow: auto;
  padding: clamp(18px, 3vw, 32px);
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(100vw - 28px), 940px);
}

.modal-close {
  background: var(--ink);
  border: 0;
  color: var(--surface);
  cursor: pointer;
  font-size: 1.6rem;
  height: 38px;
  line-height: 1;
  position: absolute;
  right: 18px;
  top: 18px;
  width: 38px;
  z-index: 2;
}

.modal-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(210px, 300px) 1fr;
}

.modal-cover-column {
  align-self: start;
  display: grid;
  gap: 10px;
}

.cover-order-button {
  width: 100%;
}

.purchase-actions {
  display: grid;
  gap: 10px;
  position: relative;
}

.purchase-actions::before {
  background: rgba(255, 253, 248, 0.74);
  border: 1px solid rgba(159, 107, 63, 0.26);
  content: "";
  inset: -8px;
  position: absolute;
  z-index: 1;
}

.coming-soon-badge {
  background: var(--accent-dark);
  color: var(--surface);
  font-size: 0.72rem;
  font-weight: 900;
  left: 50%;
  padding: 6px 12px;
  position: absolute;
  text-transform: uppercase;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  z-index: 2;
}

.purchase-actions .button {
  pointer-events: none;
  position: relative;
  z-index: 0;
}

.purchase-actions .button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.modal-cover-column .book-cover {
  margin-bottom: 6px;
}

.modal-content h2 {
  padding-right: 44px;
}

.modal-author {
  color: var(--muted);
  font-weight: 800;
  margin: 4px 0 0;
}

.modal-score {
  margin: 14px 0 22px;
}

.detail-ratings {
  display: grid;
  gap: 10px;
}

.detail-ratings div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(118px, 1fr) minmax(116px, auto) minmax(70px, auto) 52px;
  padding: 10px 0;
}

.detail-ratings span {
  color: var(--muted);
  font-weight: 800;
}

.detail-ratings .rating-value {
  color: var(--accent-dark);
}

.language-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.language-list span {
  background: var(--surface-strong);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 7px 10px;
}

.modal-text h3 {
  margin: 18px 0 6px;
}

.modal-text p {
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 12px;
  justify-content: space-between;
  margin: 0 clamp(18px, 4vw, 56px);
  padding: 28px 0;
}

@media (max-width: 860px) {
  h1 {
    font-size: 3.5rem;
  }

  h2 {
    font-size: 2.25rem;
  }

  .hero,
  .catalog-layout,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .section-block .section-heading {
    text-align: left;
  }

  .hero {
    min-height: auto;
  }

  .hero-panel {
    margin-top: 0;
  }

  .filters {
    position: static;
  }

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

@media (min-width: 980px) {
  .top-grid,
  .fiction-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .perfect-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  h1 {
    font-size: 2.55rem;
  }

  h2 {
    font-size: 1.9rem;
  }

  .hero-copy p:not(.eyebrow),
  .catalog-hero p {
    font-size: 1rem;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .section-heading,
  .results-bar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .book-card {
    min-height: 330px;
  }

  .detail-ratings div {
    align-items: start;
    grid-template-columns: 1fr;
  }
}
