*, *::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: #1e2422;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  height: 100vh;
  overflow: hidden;
  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: clamp(0.85rem, 3.5vw, 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: clamp(0.5rem, 1.5vw, 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;
  position: relative;
  overflow: hidden;
}

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

/* Per-book color tint overlay — fades in on expand over background.jpg */
main::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--book-expand-bg);
  opacity: 0.7;
  transition: opacity 0.6s ease, background-color 0.6s ease;
  pointer-events: none;
  z-index: 0;
}

main.expanded::after {
  opacity: 0.75;
}

/* ── BOOKS SHELF ── */
.shelf {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(10.5rem, 8.5vh, 14.5rem) clamp(5.5rem, 4vw, 3rem) clamp(1rem, 2vh, 2rem);
  height: 100%;
  gap: 0;
}

/* Row of book cards */
.shelf-books {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(1rem, 2.5vw, 2.5rem);
  flex-shrink: 0;
}

/* Blurb below the books */
.shelf-blurb {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.5rem, 1vw, 0.95rem);
  line-height: 1.4;
  letter-spacing: .74px;
  color: rgba(245, 240, 232, 0.65);
  text-align: center;
  max-width: 0; /* will be set dynamically to match book row width */
  margin-top: clamp(1rem, 1.5vh, 2rem);
  flex-shrink: 0;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

/* ── SERIES TITLE IMAGE ── */
/* To customize: set --series-title-color and --series-title-blend in :root */
:root {
  --series-title-color: var(--cream);
  --series-title-blend: multiply;
}

.series-title-img {
  position: absolute;
  top: clamp(1rem, 3vh, 2rem);
  left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  width: auto;
  max-width: 60%;
  max-height: 18%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  opacity: 0.4;
  /* Color tint via background-color + mix-blend-mode on a wrapper isn't
     possible on <img>, so we use a CSS filter approach for SVGs:
     set the SVG fill via a ::after overlay or use the color/blend below */
  mix-blend-mode: var(--series-title-blend);
  filter: invert(0%) sepia(45%) saturate(100%) hue-rotate(0deg) brightness(100%);
  /* For SVG color: open seriestitle.svg and set fill="currentColor",
     then control color here — or use filter for a quick tint: */
  color: var(--series-title-color);
}

/* Hide shelf decorations when a book is expanded */
.expanded .series-title-img,
main.expanded .series-title-img,
main.expanded .shelf-blurb {
  display: none;
}


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

.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.1);
  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: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  flex: 1;
  min-height: 0;
  position: relative;
  padding-top: 1.5rem;
}

/* ── LEFT DECORATIVE COLUMN (slogan + seal) ── */
/* In-flow left cell but deco elements are absolute within it,
   so they can bleed right and overlap behind the book */
.expanded-deco {
  position: relative;
  grid-column: 1;
  align-self: start;
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  width: clamp(100px, 18vw, 220px);
  /* overflow visible so slogan/seal can spill behind the book */
  overflow: visible;
}

.expanded-slogan {
  width: 200%;
  height: auto;
  object-fit: contain;
  opacity: 0.1;
  filter: invert(1);
  mix-blend-mode: screen;
}

.expanded-seal {
  width: 130%;
  height: auto;
  object-fit: contain;
  opacity: 0.1;
  filter: invert(1);
  mix-blend-mode: screen;
  align-self: flex-end;
  margin-right: -2rem;
  /* transform set per-book via data-seal-transform in JS */
}

/* Center column: book cover */
.expanded-book-wrap {
  grid-column: 2;
  flex-shrink: 0;
  height: calc(100vh - var(--nav-height) - 6rem);
  width: auto;
  aspect-ratio: 2/3;
  position: relative;
  z-index: 1;
  transition: transform 2s cubic-bezier(.22,.68,0,1.2);
  cursor: pointer;
}

.expanded-book-wrap:hover {
  transform: translateY(-14px);
}

/* Right column: info */
.book-info {
  grid-column: 3;
  align-self: start;
  justify-self: start;
  position: relative;
  z-index: 1;
  width: clamp(320px, 38vw, 560px);
  padding-left: clamp(2rem, 3vw, 4rem);
}

.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;
}

.btn-excerpt {
  position: absolute;
  bottom: 4rem;
  right: -1px;
  font-family: 'EB Garamond', serif;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(245,240,232,0.25);
  border-right: none;
  border-radius: 3px 0 0 3px;
  padding: 0.6rem 1rem;
  text-decoration: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s;
  z-index: 5;
  pointer-events: none;
  white-space: nowrap;
}

.btn-excerpt:hover {
  background: rgba(0,0,0,0.85);
  color: var(--cream);
}

.expanded-book-wrap:hover .btn-excerpt {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.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 {
  color: var(--cream);
  overflow-y: auto;
  max-height: calc(100vh - var(--nav-height) - 6rem);
  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;
}

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

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

.purchase-group h3 {
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream);
  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: 1rem;
  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 color tint handled by main::after opacity */

/* ── 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);
}


.copyright-inline {
  display: none;
  font-family: 'EB Garamond', serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(245,240,232,0.35);
  margin-top: 2rem;
  text-align: center;
  user-select: none;
}

/* ══════════════════════════════════════════════════════════
   MID-SIZED SCREENS  (769px–1300px)
   ══════════════════════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1300px) {

  .expanded-book-wrap {
    height: calc((100vh - var(--nav-height) - 6rem) * 0.8);
  }

  .book-info {
    max-height: calc((100vh - var(--nav-height) - 6rem) * 0.8);
    width: auto;
    max-width: 100%;
    justify-self: stretch;
  }

}

@media (min-width: 669px) and (max-width: 1300px) {

  .expanded-deco {
    display: none;
  }

  .expanded-inner {
    grid-template-columns: 0 auto 1fr;
    padding-left: clamp(1.5rem, 4vw, 3rem);
  }

}
/* ══════════════════════════════════════════════════════════
   MOBILE  (max-width: 768px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  .copyright {
    display: none;
  }

  .copyright-inline {
    display: block;
  }


  /* ── Header ── */
  header {
    padding: 0 1.25rem;
  }

  .header-icon {
    display: none;
  }

  nav {
    gap: 1.25rem;
  }

  nav a {
    font-size: 0.8rem;
  }

  nav a[href*="free-stuff"] {
    display: none;
  }

  /* ── Shelf: 2-col book grid, blurb below ── */
  .shelf {
    justify-content: flex-start;
    padding: 4rem 5rem 6rem;
    gap: 0;
    overflow-y: auto;
  }

  .shelf-books {
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    margin-top: 4.5rem; /* clear the series title */
  }

  .book-card {
    width: calc(75vw - 2rem);
  }

  .shelf-blurb {
    max-width: 100% !important;
    font-size: 1.25rem;
    margin-top: 2.5rem;
    padding: 0 0.25rem;
  }

  .series-title-img {
    max-width: 80%;
    max-height: 18%;
    top: 0.75rem;
  }

  /* ── Expanded: vertical stack ── */
  .expanded-overlay {
    padding: 1rem 1.25rem 4rem;
    overflow-y: auto;
  }

  .expanded-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    overflow-y: visible;
  }

  /* Hide decorative elements and excerpt button on mobile */
  .expanded-deco,
  .btn-excerpt {
    display: none;
  }

  /* Book cover: fixed reasonable height, centered */
  .expanded-book-wrap {
    grid-column: unset;
    height: clamp(220px, 80vw, 320px);
    width: auto;
    aspect-ratio: 2/3;
    flex-shrink: 0;
  }

  /* Info panel: full width below the book */
  .book-info {
    grid-column: unset;
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    overflow-y: visible;
    max-height: none;
  }

  .book-info h2 {
    font-size: clamp(1.4rem, 6vw, 2rem);
  }

  .book-description {
    max-width: 100%;
    font-size: 1.25rem;
  }

  .book-ratings {
    flex-wrap: wrap;
    gap: 1rem;
  }

  /* Chevrons: smaller, closer to edges */
  .book-nav img {
    width: 24px;
    height: 24px;
  }

  .book-nav-prev { left: 0.25rem; }
  .book-nav-next { right: 0.25rem; }
  .book-nav {
    top: calc(1rem + clamp(220px, 80vw, 320px) / 2);
  }

  /* Purchase buttons: full width rows */
  .btn-row {
    gap: 0.5rem;
  }

  .btn-buy {
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
  }
}

/* ── COPYRIGHT ── */
.copyright {
  position: fixed;
  bottom: 0.6rem;
  left: 1rem;
  font-family: 'EB Garamond', serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(245,240,232,0.35);
  pointer-events: none;
  user-select: none;
  z-index: 50;
}
