/* /books/: the library of books to learn, with covers.
   Paper colors follow the homepage; the hero is the shared dark band. */
.books-page {
  --books-ink: #10271f;
  --books-muted: #4a5a50;
  --books-paper: #fffdf7;
  --books-cream: #f6f1e8;
  --books-line: rgba(16, 39, 31, 0.14);
  --books-butter: #f5ebc8;
  --books-sage: #e1eee0;
  --books-blush: #f6e0d6;
  background: var(--books-cream);
}

/* Hero ------------------------------------------------------------------ */
.books-page .books-hero h1 { max-width: 12ch; }
.books-page .books-hero-accent { display: block; color: #8be3a2; font-size: 0.62em; line-height: 1.05; margin-top: 0.18em; letter-spacing: -0.02em; }
.books-page .books-hero-actions { gap: 18px 22px; }
.books-page .books-hero-actions .course-store-buttons { margin: 0; }
.books-page .books-hero-actions .button-primary { min-height: 56px; padding: 0 26px; display: inline-flex; align-items: center; font-size: 17px; }

.books-hero-fan {
  position: relative;
  margin: 0;
  min-height: 470px;
  display: grid;
  place-items: center;
}
.books-fan-cover {
  position: absolute;
  top: 18px;
  left: 50%;
  width: 196px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px 10px 10px 6px;
  box-shadow: inset 6px 0 10px -6px rgba(0, 0, 0, 0.35), var(--site-shadow-float);
  transform-origin: 50% 110%;
  animation: books-fan-in 900ms var(--site-ease-out) both;
}
.books-fan-1 { transform: translateX(calc(-50% - 150px)) translateY(46px) rotate(-14deg); animation-delay: 60ms; }
.books-fan-2 { transform: translateX(calc(-50% - 78px)) translateY(16px) rotate(-7deg); animation-delay: 120ms; }
.books-fan-3 { transform: translateX(calc(-50% + 78px)) translateY(16px) rotate(7deg); animation-delay: 180ms; }
.books-fan-4 { transform: translateX(calc(-50% + 150px)) translateY(46px) rotate(14deg); animation-delay: 240ms; }
.books-fan-5 { transform: translateX(-50%); width: 216px; top: 0; z-index: 2; animation-delay: 300ms; }
.books-fan-2, .books-fan-3 { z-index: 1; }
@keyframes books-fan-in {
  from { opacity: 0; translate: 0 26px; }
  to { opacity: 1; translate: 0 0; }
}
.books-fan-request {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, 100%);
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(3, 25, 17, 0.84);
  backdrop-filter: blur(16px);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: var(--site-shadow-float);
}
.books-fan-request img { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 12px; }

/* Steps ------------------------------------------------------------------ */
.books-page .books-steps { padding: clamp(56px, 7vw, 96px) 0 0; }
.books-step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.books-step {
  padding: 26px 26px 28px;
  border-radius: 22px;
  color: var(--books-ink);
}
.books-step-1 { background: var(--books-butter); }
.books-step-2 { background: var(--books-sage); }
.books-step-3 { background: var(--books-blush); }
.books-step-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--books-ink);
  color: #fffdf7;
  font-weight: 800;
  font-size: 15px;
}
.books-step h3 { margin: 18px 0 8px; font-size: 22px; letter-spacing: -0.02em; }
.books-step p { margin: 0; color: #33443a; font-size: 16px; line-height: 1.6; }

/* Library ------------------------------------------------------------------ */
.books-page .books-library { padding: clamp(64px, 8vw, 112px) 0 clamp(56px, 7vw, 96px); scroll-margin-top: calc(var(--header-height, 72px) + 8px); }
.books-library-head h2 { margin: 0; color: var(--books-ink); font-size: clamp(34px, 4vw, 52px); }
.books-library-head p { margin: 12px 0 0; color: var(--books-muted); font-size: 18px; line-height: 1.6; }

.books-controls {
  position: sticky;
  top: var(--header-height, 72px);
  z-index: 5;
  margin: 28px calc(-1 * clamp(16px, 2vw, 24px)) 0;
  padding: 14px clamp(16px, 2vw, 24px) 12px;
  background: color-mix(in srgb, var(--books-cream) 94%, transparent);
  backdrop-filter: blur(12px);
}
.books-search {
  position: relative;
  display: block;
  max-width: 560px;
}
.books-search svg {
  position: absolute;
  top: 50%;
  left: 18px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--books-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.books-search input {
  width: 100%;
  min-height: 54px;
  padding: 0 20px 0 50px;
  border: 1px solid var(--books-line);
  border-radius: 999px;
  background: var(--books-paper);
  color: var(--books-ink);
  font: inherit;
  font-size: 17px;
  box-shadow: 0 1px 2px rgba(16, 39, 31, 0.05);
}
.books-search input::placeholder { color: #6b7a70; }
.books-search input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.books-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.books-filter {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--books-line);
  border-radius: 999px;
  background: var(--books-paper);
  color: var(--books-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.books-filter:hover { border-color: rgba(16, 39, 31, 0.4); }
.books-filter[aria-pressed="true"] { background: var(--books-ink); border-color: var(--books-ink); color: #fffdf7; }
.books-filter[aria-pressed="true"]::before { content: "\2713\00a0"; }
.books-filter:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.books-count { min-height: 1.5em; margin: 6px 0 0; color: var(--books-muted); font-size: 15px; font-weight: 700; }

.books-grid {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 34px 24px;
}
.books-card[hidden] { display: none; }
.books-card-button {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--books-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.books-card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 4px 8px 8px 4px;
  background: linear-gradient(160deg, #e7dfcf, #d9d0bd);
  box-shadow: inset 5px 0 8px -5px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(16, 39, 31, 0.08), 0 14px 26px -16px rgba(16, 39, 31, 0.45);
  transition: transform 420ms var(--site-ease-out), box-shadow 420ms var(--site-ease-out);
}
.books-card-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.books-card-title {
  display: -webkit-box;
  margin-top: 12px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--site-heading);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.books-card-author {
  margin-top: 3px;
  overflow: hidden;
  color: var(--books-muted);
  font-size: 14px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}
@media (hover: hover) and (pointer: fine) {
  .books-card-button:hover .books-card-cover {
    transform: translateY(-6px) rotate(-1deg);
    box-shadow: inset 5px 0 8px -5px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(16, 39, 31, 0.08), 0 26px 40px -18px rgba(16, 39, 31, 0.55);
  }
}
.books-card-button:focus-visible { outline: none; }
.books-card-button:focus-visible .books-card-cover { outline: 3px solid var(--focus-ring); outline-offset: 4px; }

.books-empty {
  max-width: 640px;
  margin: 24px 0 0;
  padding: 28px;
  border-radius: 22px;
  background: var(--books-paper);
  border: 1px solid var(--books-line);
}
.books-empty > p { margin: 0 0 16px; color: var(--books-ink); font-size: 18px; }
.books-attribution { margin: 40px 0 0; color: var(--books-muted); font-size: 14px; }
.books-attribution a { color: inherit; text-underline-offset: 3px; }

/* Any book ---------------------------------------------------------------- */
.books-page .books-any {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(28px, 6vw, 80px);
  padding: clamp(48px, 6vw, 80px) clamp(24px, 4vw, 56px);
  border-radius: 28px;
  background: var(--books-paper);
  box-shadow: var(--site-shadow-raised);
}
.books-any h2 { margin: 0; color: var(--books-ink); font-size: clamp(30px, 3.2vw, 42px); }
.books-any p { margin: 14px 0 0; color: var(--books-muted); font-size: 18px; line-height: 1.65; }

.books-page .books-faq { padding-top: clamp(64px, 8vw, 112px); }
.books-faq h2 { margin: 0 0 28px; color: var(--books-ink); font-size: clamp(30px, 3.2vw, 42px); }

/* Book sheet ---------------------------------------------------------------- */
.books-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100svh - 48px);
  padding: 28px;
  border: 0;
  border-radius: 26px;
  background: var(--books-paper);
  color: var(--books-ink);
  box-shadow: var(--site-shadow-float);
}
.books-dialog::backdrop { background: rgba(8, 26, 19, 0.55); backdrop-filter: blur(3px); }
.books-dialog[open] { animation: books-sheet-in 360ms var(--site-ease-out) both; }
@keyframes books-sheet-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.books-dialog-close-form { position: absolute; top: 14px; right: 14px; margin: 0; }
.books-dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 39, 31, 0.07);
  color: var(--books-ink);
  cursor: pointer;
}
.books-dialog-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.books-dialog-close:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.books-dialog-book {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  padding-right: 44px;
}
.books-dialog-cover {
  width: 112px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px 8px 8px 4px;
  box-shadow: inset 5px 0 8px -5px rgba(0, 0, 0, 0.3), 0 16px 28px -16px rgba(16, 39, 31, 0.6);
}
.books-dialog h2 { margin: 4px 0 0; font-size: 26px; line-height: 1.15; letter-spacing: -0.025em; }
.books-dialog-author { margin: 6px 0 0; color: var(--books-muted); font-size: 16px; font-weight: 700; }
.books-dialog-promise { margin: 14px 0 0; color: #33443a; font-size: 15px; line-height: 1.55; }
.books-dialog .course-request { margin-top: 22px; }
.books-dialog-next { margin: 14px 0 0; color: var(--books-muted); font-size: 15px; line-height: 1.55; }
.books-dialog .course-store-buttons { margin-top: 18px; }

/* Phone ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .books-page .books-hero .public-hero-shell { grid-template-columns: minmax(0, 1fr); }
  .books-hero-fan { min-height: 380px; }
  .books-fan-cover { width: 150px; }
  .books-fan-5 { width: 166px; }
  .books-fan-1 { transform: translateX(calc(-50% - 116px)) translateY(40px) rotate(-14deg); }
  .books-fan-2 { transform: translateX(calc(-50% - 60px)) translateY(14px) rotate(-7deg); }
  .books-fan-3 { transform: translateX(calc(-50% + 60px)) translateY(14px) rotate(7deg); }
  .books-fan-4 { transform: translateX(calc(-50% + 116px)) translateY(40px) rotate(14deg); }
  .books-step-list { grid-template-columns: minmax(0, 1fr); }
  .books-page .books-any { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .books-hero-fan { min-height: 330px; }
  .books-fan-cover { width: 112px; }
  .books-fan-5 { width: 132px; }
  .books-fan-1 { transform: translateX(calc(-50% - 84px)) translateY(34px) rotate(-14deg); }
  .books-fan-2 { transform: translateX(calc(-50% - 44px)) translateY(12px) rotate(-7deg); }
  .books-fan-3 { transform: translateX(calc(-50% + 44px)) translateY(12px) rotate(7deg); }
  .books-fan-4 { transform: translateX(calc(-50% + 84px)) translateY(34px) rotate(14deg); }
  .books-filters { flex-wrap: nowrap; overflow-x: auto; margin-right: calc(-1 * clamp(16px, 2vw, 24px)); padding-right: 16px; scrollbar-width: none; }
  .books-filters::-webkit-scrollbar { display: none; }
  .books-filter { flex: 0 0 auto; }
  .books-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 12px; }
  .books-card-title { font-size: 13px; }
  .books-card-author { font-size: 12px; }
  .books-dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
  }
  .books-dialog-book { grid-template-columns: 88px minmax(0, 1fr); gap: 16px; }
  .books-dialog-cover { width: 88px; }
  .books-dialog h2 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .books-fan-cover, .books-dialog[open] { animation: none; }
  .books-card-cover { transition: none; }
}
