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

:root {
  --ink: #000000;
  --cream: #f5f0e8;
  --red: #9f1212;
  --red-light: #b72d2d;
  --nav-height: 95px;
  --book-expand-bg: #1e3a2f;
}

html, body {
  height: 100%;
  font-family: 'EB Garamond', Georgia, serif;
  background: var(--cream);
  color: var(--ink);
}

/* ── NAV ── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: #0e0e0e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3rem;
  z-index: 100;
  filter: drop-shadow(0 0 0.25rem black);
}

/* ── HEADER BRAND BLOCK ── */
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  transition: opacity 0.2s;
}

.header-brand:hover { opacity: 0.85; }

.header-brand.hidden { display: none; }

.header-icon {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  background-image: url('img/sitelogo_tiny.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.header-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.site-title {
  font-family: 'Merriweather', serif;
  font-size: 1.75rem;
  color: var(--cream);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.1;
}

.site-subtitle {
  font-family: 'EB Garamond', serif;
  font-size: 0.75rem;
  color: var(--cream);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1;
}

nav {
  display: flex;
  gap: 2.5rem;
}

nav a {
  font-family: 'EB Garamond', serif;
  font-size: 0.95rem;
  color: var(--cream);
  text-decoration: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  transition: color 0.2s;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0;
  width: 0; height: 1px;
  background: var(--red);
  transition: width 0.3s ease;
}

nav a:hover { color: var(--red); }
nav a:hover::after { width: 100%; }

/* ── MAIN SECTION ── */
main {
  margin-top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  background-image: url('img/background.jpg');
  background-size: cover;
  background-position: center;
  background-color: #2a1d10;
  position: relative;
  transition: background-color 0.6s ease;
  overflow: hidden;
}

main::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10,6,2,0.35) 0%, rgba(10,6,2,0.15) 50%, rgba(10,6,2,0.45) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── BOOKS SHELF ── */
.shelf {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2.5rem);
  padding: clamp(0.5rem, 1.5vh, 1rem) clamp(1.5rem, 4vw, 3rem) clamp(2rem, 4vh, 3rem);
  height: 100%;
}

.book-card {
  width: clamp(150px, calc((100vw - 8rem) / 4 - 2.5rem), 240px);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(.22,.68,0,1.2), opacity 0.4s ease;
  position: relative;
}

.book-card:hover {
  transform: translateY(-18px) scale(1.10);
}

.book-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, #3d2b1a 0%, #6b4226 50%, #3d2b1a 100%);
  border-radius: 3px 8px 8px 3px;
  box-shadow: -4px 8px 24px rgba(0,0,0,0.7), inset -3px 0 8px rgba(0,0,0,0.3);
  overflow: hidden;
  position: relative;
}

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

.book-cover::before {
  content: '';
  position: absolute;
  top: 0; left: 12px; bottom: 0;
  width: 2px;
  background: rgba(0,0,0,0.25);
  z-index: 1;
  pointer-events: none;
}

.book-title-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: 'EB Garamond', serif;
  font-size: clamp(0.75rem, 1.2vw, 1rem);
  color: var(--red-light);
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  line-height: 1.4;
}

.book-hover-label {
  margin-top: 0.75rem;
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 0.8rem;
  color: var(--cream);
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.book-card:hover .book-hover-label {
  opacity: 1;
  transform: translateY(0);
}

/* ── EXPANDED VIEW ── */
.expanded-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1.5rem clamp(2rem, 5vw, 5rem);
  opacity: 0;
  transition: opacity 0.5s ease;
  overflow: hidden;
}

.expanded-overlay.visible {
  display: flex;
  flex-direction: column;
}

.expanded-overlay.faded-in {
  opacity: 1;
}

.expanded-inner {
  display: flex;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.expanded-book-wrap {
  flex-shrink: 0;
  height: calc(100vh - var(--nav-height) - 6rem);
  width: auto;
  aspect-ratio: 2/3;
}

.expanded-book-cover {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #3d2b1a 0%, #6b4226 50%, #3d2b1a 100%);
  border-radius: 3px 10px 10px 3px;
  box-shadow: -6px 12px 50px rgba(0,0,0,0.75), inset -4px 0 12px rgba(0,0,0,0.3);
  overflow: hidden;
  position: relative;
}

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

.expanded-book-cover::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; bottom: 0;
  width: 2px;
  background: rgba(0,0,0,0.25);
  z-index: 1;
  pointer-events: none;
}

.expanded-title-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  font-family: 'EB Garamond', serif;
  font-size: 1.1rem;
  color: var(--red-light);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  line-height: 1.4;
}

.book-info {
  flex: 1;
  color: var(--cream);
  overflow-y: auto;
  min-height: 0;
  padding-right: 0.5rem;
}

.book-info h2 {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 400;
  color: var(--cream);
  margin-bottom: 1.25rem;
  line-height: 1.2;
}

.book-description {
  font-size: clamp(0.9rem, 1.1vw, 1rem);
  line-height: 1.9;
  color: var(--cream);
  margin-bottom: 2rem;
  max-width: 58ch;
}

.book-description p + p {
  margin-top: 1rem;
}

/* ── PURCHASE BUTTONS ── */
.purchase-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.purchase-group h3 {
  font-family: 'EB Garamond', serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.purchase-group h3::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(200,146,42,0.3);
  max-width: 120px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn-buy {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1px solid var(--red);
  border-radius: 2px;
  font-family: 'EB Garamond', serif;
  font-size: 0.78rem;
  color: var(--cream);
  text-decoration: none;
  background: var(--red);
  transition: background 0.2s, color 0.2s, transform 0.15s;
  letter-spacing: 0.04em;
}

.btn-buy:hover {
  background: var(--red-light);
  border-color: var(--red-light);
  color: var(--cream);
  transform: translateY(-2px);
}

.btn-close-header {
  display: none;
  background: none;
  border: none;
  color: var(--cream);
  font-family: 'Merriweather', serif;
  font-size: 1rem;
  font-style: italic;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
  white-space: nowrap;
}

.btn-close-header:hover { color: var(--red-light); }
.btn-close-header.visible { display: block; }

.book-card.hidden {
  opacity: 0;
  pointer-events: none;
}

main.expanded {
  background-color: var(--book-expand-bg);
}

/* ── BOOK SUBTITLE ── */
.book-subtitle {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.25rem, 1vw, 0.95rem);
  font-style: italic;
  color: rgba(245,240,232,0.6);
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  margin-top: -0.75rem;
}

/* ── BOOK NAV CHEVRONS ── */
.book-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: none;
}

.book-nav img {
  width: 32px;
  height: 32px;
  display: block;
  filter: invert(1);
}

.book-nav:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.2);
}

.book-nav-prev { left: 0.75rem; }
.book-nav-next { right: 0.75rem; }
.book-nav.visible { display: block; }

/* ── STAR RATINGS ── */
.book-ratings {
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  margin-top: -0.5rem;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.rating-stars {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  line-height: 1;
}

.star-icon {
  width: 16px;
  height: 16px;
  display: block;
  filter: invert(100%) sepia(0%) saturate(100%) hue-rotate(0deg) brightness(95%);
}

.rating-label {
  font-family: 'EB Garamond', serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245,240,232,0.55);
  text-decoration: none;
  transition: color 0.2s;
}

.rating-label:hover {
  color: var(--cream);
}
