:root {
  --paper: #f2ebdf;
  --paper-deep: #e7dccb;
  --paper-light: #f8f3ea;
  --card: #faf6ef;
  --ink: #2a211b;
  --ink-soft: #6b5d50;
  --rule: #dccfbc;
  --accent: #7b2d22;
  --accent-dark: #5f2219;
  --accent-ink: #fff8f2;
  --star: #b7791f;
  --green: #4f7a43;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --wrap: 1160px;
  --wide: 1440px;
  /* A faint paper grain, drawn by the browser rather than loaded as an image. */
  --grain: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.15 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper) var(--grain);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
}

.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }

img { max-width: 100%; display: block; }

a { color: inherit; }
a:hover { color: var(--accent); }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--ink-soft); }
.small { font-size: 15px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ header & footer */

header.site {
  border-bottom: 1px solid var(--rule);
  background: rgba(242, 235, 223, 0.94);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(6px);
}

.header-row {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 76px;
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; flex: none; }
.brand:hover { color: inherit; }
.brand-mark { width: auto; height: 50px; flex: none; }
.brand-name { display: block; font: 600 27px/1 var(--serif); letter-spacing: -0.02em; }
.brand-tag { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; letter-spacing: 0.02em; }
.brand-rule { width: 1px; height: 40px; background: var(--rule); flex: none; }

header nav.main-nav { display: flex; gap: 34px; font-size: 16.5px; font-weight: 600; }
header nav.main-nav a { text-decoration: none; display: inline-flex; align-items: center; gap: 7px; }
header nav.main-nav .icon { width: 20px; height: 20px; color: var(--accent); }

.search { position: relative; margin-left: auto; width: 240px; }
.search input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--rule);
  border-radius: 21px;
  background: var(--paper-light);
  font: 15px var(--sans);
  color: var(--ink);
}
.search input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.search > .icon { position: absolute; left: 15px; top: 12px; width: 18px; height: 18px; color: var(--ink-soft); }
.search-results {
  position: absolute;
  top: 48px;
  right: 0;
  width: 340px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 16px 40px -18px rgba(40, 25, 15, 0.45);
  padding: 6px;
  z-index: 50;
}
.search-results a { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 7px 8px; border-radius: 5px; text-decoration: none; font-size: 14.5px; line-height: 1.3; }
.search-results a:hover, .search-results a.active { background: var(--paper-deep); color: inherit; }
.search-results img { width: 34px; }
.search-results small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.search-results .none { padding: 10px; font-size: 14.5px; color: var(--ink-soft); }

.icon-link { position: relative; display: inline-flex; padding: 6px; text-decoration: none; }
.icon-link .icon { width: 26px; height: 26px; }
.icon-link .count { position: absolute; top: -4px; right: -6px; }
.signed-in-dot { position: absolute; right: 3px; bottom: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2px solid var(--paper); }
.signed-in-dot.pending { background: #c98a1b; }

.count {
  display: inline-block;
  min-width: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 21px;
  text-align: center;
}

.wordmark {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.02em;
}

footer.site { border-top: 1px solid var(--rule); margin-top: 72px; padding: 28px 0 32px; font-size: 14.5px; background: rgba(231, 220, 203, 0.35); }
footer.site p { margin: 0; }
.footer-row {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.footer-row .brand-name { font-size: 24px; }
.footer-sep { width: 1px; align-self: stretch; background: var(--rule); }
.trust-item { display: flex; align-items: center; gap: 12px; line-height: 1.35; }
.trust-item .icon { width: 28px; height: 28px; color: var(--ink); }
.trust-item strong { display: block; font-size: 14.5px; }
.trust-item span { color: var(--ink-soft); font-size: 13.5px; }
.pay-methods { margin-left: auto; }
.pay-methods p { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.pay-logos { display: flex; gap: 8px; align-items: center; }
.pay-logos span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-light);
  font: 700 13px var(--sans);
}
.pay-logos .visa { color: #1a1f71; font-style: italic; letter-spacing: 0.04em; }
.pay-logos .upi { color: #3a3a3a; font-style: italic; }
.pay-logos .mc { gap: 0; }
.pay-logos .mc i { width: 15px; height: 15px; border-radius: 50%; background: #eb001b; display: block; }
.pay-logos .mc i + i { background: #f79e1b; margin-left: -6px; opacity: 0.9; }
.footer-meta { flex-basis: 100%; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13.5px; border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 6px; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: 600 16px var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #6f281c; border-color: #6f281c; color: var(--accent-ink); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-soft); font: inherit; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--accent); }

/* ------------------------------------------------------------ book cards */

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 40px 28px;
}

.card { text-decoration: none; display: block; }
.card .cover { position: relative; aspect-ratio: 0.707; background: var(--paper-deep); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; box-shadow: 0 10px 20px -12px rgba(40, 30, 20, 0.5); transition: transform 0.2s; }
.card .cover.wide { background: transparent; }
.card .cover.wide img { object-fit: contain; box-shadow: none; }
.card .cover.mock { background: transparent; }
.card .cover.mock img { object-fit: contain; object-position: center bottom; box-shadow: none; filter: drop-shadow(0 10px 10px rgba(40, 25, 15, 0.3)) drop-shadow(0 2px 3px rgba(40, 25, 15, 0.2)); }
img.mock-img { box-shadow: none !important; filter: drop-shadow(0 5px 6px rgba(40, 25, 15, 0.3)); }
.card:hover .cover img { transform: translateY(-4px); }
.card .card-title { font: 500 18px/1.15 var(--serif); letter-spacing: -0.01em; margin: 14px 0 2px; }
.card .sub {
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.card .price { margin-top: 6px; font-weight: 600; font-size: 15.5px; display: flex; gap: 10px; align-items: center; }
.card .price .stars { font-size: 13px; }

/* ------------------------------------------------------------ book page */

.crumbs { font-size: 14.5px; color: var(--ink-soft); padding: 22px 0 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.book {
  display: grid;
  grid-template-columns: minmax(260px, 400px) 1fr;
  gap: 64px;
  padding: 28px 0 56px;
  align-items: start;
}
.book .cover-lg img { box-shadow: 0 24px 40px -20px rgba(40, 30, 20, 0.6); width: 100%; }
/* 3D hardcover mockups are cut out, so their shadow follows the book instead of a box. */
.book .cover-lg.mock img { box-shadow: none; filter: drop-shadow(0 18px 18px rgba(40, 25, 15, 0.32)) drop-shadow(0 3px 4px rgba(40, 25, 15, 0.22)); }
.book .series-label { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.book h1 { font-size: clamp(32px, 3.6vw, 46px); }
.book .subtitle { font: italic 400 21px/1.4 var(--serif); color: var(--ink-soft); margin-bottom: 20px; }
.book .rating-line { font-size: 15px; color: var(--ink-soft); margin-bottom: 18px; }
.book .rating-line a { color: var(--ink-soft); }
.book .price-lg { font: 500 34px var(--serif); margin: 6px 0 18px; }
.book .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.book .actions .btn { min-width: 170px; }
.book .delivery { font-size: 15px; color: var(--ink-soft); margin-bottom: 28px; }

.facts-table { width: 100%; border-collapse: collapse; font-size: 15.5px; margin-bottom: 32px; }
.facts-table th, .facts-table td { text-align: left; padding: 9px 0; border-top: 1px solid var(--rule); vertical-align: top; }
.facts-table th { font-weight: 600; width: 34%; color: var(--ink-soft); }
.facts-table tr:last-child th, .facts-table tr:last-child td { border-bottom: 1px solid var(--rule); }

.prose { max-width: 62ch; }
.prose .lead { font: 400 22px/1.45 var(--serif); }
.prose h2 { font-size: 22px; margin-top: 28px; }
.prose ul { padding-left: 0; list-style: none; margin: 0; }
.prose li { padding: 7px 0 7px 26px; position: relative; border-bottom: 1px dashed var(--rule); }
.prose li::before { content: "—"; position: absolute; left: 0; color: var(--accent); }

.section { border-top: 1px solid var(--rule); padding: 48px 0 8px; }
.section > h2 { font-size: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 30px; }

.pages {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 18px;
  scroll-snap-type: x proximity;
}
.pages button {
  flex: 0 0 auto;
  height: 250px;
  padding: 0;
  border: 1px solid var(--rule);
  background: #fff;
  cursor: zoom-in;
  scroll-snap-align: start;
}
.pages button img { height: 100%; width: auto; }
.pages button:hover { border-color: var(--ink); }

.reader {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(24, 21, 18, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 64px 16px;
}
.reader img { max-height: calc(100vh - 96px); max-width: 100%; width: auto; background: #fff; }
.reader .bar { color: #e9e3d8; font-size: 15px; margin-top: 12px; display: flex; gap: 20px; align-items: center; }
.reader .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 1px solid #7a7167;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.reader .nav:hover { background: rgba(255, 255, 255, 0.1); }
.reader .prev { left: 12px; }
.reader .next { right: 12px; }
.reader .close { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: #fff; font-size: 30px; cursor: pointer; line-height: 1; }

.reviews { display: grid; grid-template-columns: 280px 1fr; gap: 56px; }
.review-summary .big { font: 500 54px/1 var(--serif); }
.review-summary .stars { font-size: 20px; }
.review-list { list-style: none; padding: 0; margin: 0; }
.review-list li { border-top: 1px solid var(--rule); padding: 20px 0; }
.review-list li:first-child { border-top: 0; padding-top: 0; }
.review-meta { font-size: 14.5px; color: var(--ink-soft); margin-bottom: 6px; }
.review-meta strong { color: var(--ink); font-weight: 600; }
.review-list p { margin: 0; white-space: pre-line; }
.verified { font-size: 13px; color: #3d6b45; margin-left: 6px; }

.stars { color: var(--star); letter-spacing: 1px; }
.stars-off { color: var(--rule); }

.review-form { background: var(--card); border: 1px solid var(--rule); padding: 24px; margin-top: 28px; }
.review-form h3 { font-size: 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
.field textarea { min-height: 120px; resize: vertical; }
.star-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { font-size: 30px; line-height: 1; color: var(--rule); cursor: pointer; margin: 0; font-weight: 400; }
.star-input label:hover, .star-input label:hover ~ label,
.star-input input:checked ~ label { color: var(--star); }
.star-input input:focus-visible + label { outline: 2px solid var(--ink); }
.form-error { color: var(--accent); font-size: 15px; }

.more { padding-bottom: 8px; }

/* Phones: keep the price and Buy button in reach while reading the page. */
.buy-bar { display: none; }
@media (max-width: 700px) {
  .buy-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(250, 246, 239, 0.97);
    border-top: 1px solid var(--rule);
    box-shadow: 0 -8px 20px -14px rgba(40, 25, 15, 0.4);
  }
  .buy-bar div { flex: 1; min-width: 0; line-height: 1.25; }
  .buy-bar strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .buy-bar span { font-size: 14px; color: var(--ink-soft); }
  .buy-bar .btn { height: 44px; padding: 0 22px; flex: none; }
  body:has(.buy-bar) footer.site { padding-bottom: 96px; }
}

/* ------------------------------------------------------------ cart & success */

.page-title { padding: 48px 0 24px; border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.page-title h1 { font-size: 42px; margin: 0; }

.cart { display: grid; grid-template-columns: 1fr 340px; gap: 56px; align-items: start; }
.line { display: grid; grid-template-columns: 72px 1fr auto; gap: 20px; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.line img { width: 72px; box-shadow: 0 6px 12px -8px rgba(40, 30, 20, 0.6); }
.line h3 { font-size: 19px; margin: 0 0 2px; }
.line h3 a { text-decoration: none; }
.line .meta { font-size: 14.5px; color: var(--ink-soft); }
.line .right { text-align: right; }
.line .right .amount { font-weight: 600; display: block; margin-bottom: 4px; }

.summary { background: var(--card); border: 1px solid var(--rule); padding: 26px; position: sticky; top: 24px; margin-top: 20px; }
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary .total { border-top: 1px solid var(--rule); margin-top: 8px; padding-top: 14px; font: 500 24px var(--serif); }
.summary .btn { width: 100%; margin: 20px 0 12px; }
.summary .note { font-size: 14px; color: var(--ink-soft); margin: 0; }

.empty { padding: 56px 0; }

.downloads { max-width: 720px; }
.download-book { border-bottom: 1px solid var(--rule); padding: 24px 0; display: grid; grid-template-columns: 64px 1fr; gap: 20px; }
.download-book img { width: 64px; }
.download-book h3 { font-size: 20px; margin-bottom: 8px; }
.download-book ul { list-style: none; padding: 0; margin: 0 0 10px; }
.download-book li { margin-bottom: 6px; }
.download-book .file { font-weight: 600; }
.downloads .back { margin-top: 28px; }
.notice .btn { margin-top: 12px; height: 42px; }
.notice { background: var(--card); border-left: 3px solid var(--accent); padding: 16px 20px; margin: 24px 0; font-size: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 3px;
  font-size: 15.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: var(--paper); font-weight: 600; margin-left: 10px; }

.loading { padding: 80px 0; color: var(--ink-soft); }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1180px) {
  header nav.main-nav { gap: 22px; }
  .brand-rule { display: none; }
}

@media (max-width: 980px) {
  header nav.main-nav { display: none; }
  .search { width: auto; flex: 1; max-width: 360px; }
  .pay-methods { margin-left: 0; }
  .footer-sep { display: none; }
}

@media (max-width: 600px) {
  .header-row { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px 14px; }
  .brand-tag { display: none; }
  .brand-name { font-size: 23px; }
  .brand-mark { height: 38px; }
  .header-icons { margin-left: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search input { font-size: 16px; } /* 16px stops phones zooming in on focus */
  .search-results { width: 100%; }
  .footer-row { padding: 0 16px; gap: 18px; }
}

@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .book { gap: 40px; }
}

@media (max-width: 800px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 32px 20px; }
  .book { grid-template-columns: 1fr; }
  .book .cover-lg { max-width: 300px; }
  .reviews { grid-template-columns: 1fr; gap: 24px; }
  .cart { grid-template-columns: 1fr; gap: 0; }
  .reader { padding: 16px 8px 12px; }
  .reader .nav { top: auto; bottom: 10px; transform: none; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 28px 16px; }
  header nav { gap: 18px; }
  .pages button { height: 200px; }
  .book .actions .btn { flex: 1; min-width: 0; }
  .line { grid-template-columns: 56px 1fr; }
  .line img { width: 56px; }
  .line .right { grid-column: 2; text-align: left; }
}

/* ------------------------------------------------------------ sign in, library, privacy */

.wrap.narrow { max-width: 720px; }

.auth-card { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 26px; margin: 24px 0; max-width: 520px; }
.auth-card.wide { max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.auth-card.wide p { margin: 0; max-width: 60ch; }
.auth-card .field input { font-size: 16px; }
.auth-card .btn { margin-top: 4px; }
.auth-card .form-error { margin: 0 0 12px; }

.library { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; align-items: start; }
.library .download-book h3 a { text-decoration: none; }
.download-book .file { display: inline-flex; align-items: center; gap: 6px; }
.download-book .file .icon { width: 17px; height: 17px; }
.sub-title { font-size: 24px; margin-top: 36px; }

.account-box { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 22px; margin-top: 24px; position: sticky; top: 100px; }
.account-box h2 { font-size: 22px; }
.account-box h3 { font: 600 14px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 18px 0 6px; }
.order-list { list-style: none; padding: 0; margin: 0; font-size: 14.5px; }
.order-list li { padding: 8px 0; border-top: 1px solid var(--rule); }
.order-list li span { display: block; font-size: 13px; color: var(--ink-soft); }
.account-actions { display: grid; gap: 12px; justify-items: start; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }
.link-btn.danger { color: var(--accent); }

.prose-page h2 { font-size: 24px; margin-top: 32px; }
.prose-page ul { padding-left: 20px; }
.prose-page li { margin-bottom: 8px; }

@media (max-width: 800px) {
  .library { grid-template-columns: 1fr; gap: 8px; }
  .account-box { position: static; }
}
