/* ==========================================================================
   THE KNOWLEDGE — bookstore stylesheet
   Light, editorial, fast. No framework, no webfonts.

   Typeface note: headings use Georgia, body uses the system UI stack. Both are
   already on every device, so text paints on the first frame instead of waiting
   on a font download. For a bookshop a real serif is the right look anyway.
   ========================================================================== */

:root {
  /* Brand */
  --accent:        #e8534d;
  --accent-dark:   #d13f39;
  --accent-soft:   #fdeceb;
  --accent-line:   rgba(232, 83, 77, 0.28);

  /* Surfaces */
  --bg:            #ffffff;
  --bg-alt:        #f7f7f8;
  --bg-sunken:     #f0f0f2;
  --card:          #ffffff;

  /* Ink */
  --ink:           #1a1a1c;
  --ink-2:         #5c5c66;
  --ink-3:         #8b8b96;
  --line:          #e6e6ea;
  --line-strong:   #d4d4dc;

  --ok:            #1f8a52;
  --warn:          #b4690e;

  /* Type */
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --sans:  system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Space */
  --wrap:   1180px;
  --gutter: 20px;
  --tap:    44px;

  --radius:    4px;
  --radius-lg: 8px;

  --shadow-sm: 0 1px 3px rgba(16, 16, 24, 0.06);
  --shadow:    0 6px 22px rgba(16, 16, 24, 0.09);
  --shadow-lg: 0 18px 48px rgba(16, 16, 24, 0.14);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------- reset -- */

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

html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

::selection { background: var(--accent); color: #fff; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -80px; z-index: 300;
  background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: var(--radius); font-weight: 600;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* -------------------------------------------------------------- header -- */

.announce {
  background: var(--ink);
  color: #fff;
  text-align: center;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  padding: 8px var(--gutter);
}
.announce a { color: #fff; text-decoration: underline; }

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: #fff; } }

.header-bar {
  max-width: var(--wrap); margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 74px;
  display: flex; align-items: center; gap: 24px;
}

.brand {
  font-family: var(--serif);
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.brand img { width: 34px; height: 34px; border-radius: var(--radius); }

.main-nav { margin-left: auto; }
.main-nav ul { display: flex; align-items: center; gap: 30px; }

.main-nav a {
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 6px 0;
  position: relative;
  transition: color 0.18s var(--ease);
}
.main-nav a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.22s var(--ease);
}
.main-nav a:hover { color: var(--ink); }
.main-nav a:hover::after { transform: scaleX(1); }
.main-nav a.current { color: var(--accent); }
.main-nav a.current::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  width: var(--tap); height: var(--tap);
  margin-left: auto;
  align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.nav-toggle span {
  display: block; width: 18px; height: 2px; background: var(--ink);
  position: relative; border-radius: 2px;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: ''; position: absolute; left: 0; width: 18px; height: 2px;
  background: var(--ink); border-radius: 2px;
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after  { top: 6px; }

/* ---------------------------------------------------------------- hero -- */

.hero {
  background:
    linear-gradient(105deg, #e7ece4 0%, #eceaf1 46%, #efe7ea 100%);
  overflow: hidden;
}

.hero-inner {
  max-width: var(--wrap); margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-items: center;
  gap: 40px;
  min-height: 460px;
}

.hero-eyebrow {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  line-height: 1.16;
  margin-bottom: 18px;
  white-space: pre-line;
}

.hero p {
  color: var(--ink-2);
  font-size: 1.02rem;
  max-width: 44ch;
  margin-bottom: 28px;
}

.hero-media { position: relative; }
.hero-media img {
  width: 100%; height: 100%;
  max-height: 460px;
  object-fit: cover;
  object-position: center;
}

/* Placeholder when no hero image is set */
.hero-media .hero-fallback {
  display: grid; place-items: center;
  min-height: 300px;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-3);
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 12px 26px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
              border-color 0.18s var(--ease), transform 0.12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.btn-outline {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-outline:hover { border-color: var(--ink); }

.btn-ghost { background: var(--bg-alt); color: var(--ink); }
.btn-ghost:hover { background: var(--bg-sunken); }

.btn-block { width: 100%; }

.btn-wa { background: #25d366; color: #fff; }
.btn-wa:hover { background: #1db954; color: #fff; }

/* ------------------------------------------------------------ features -- */

.features { border-bottom: 1px solid var(--line); background: #fff; }

.features-grid {
  max-width: var(--wrap); margin: 0 auto;
  padding: 42px var(--gutter);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px;
}

.feature { display: flex; gap: 16px; align-items: flex-start; }
.feature svg { flex-shrink: 0; width: 38px; height: 38px; stroke: var(--ink); stroke-width: 1.2; fill: none; }
.feature h3 { font-size: 1.02rem; margin-bottom: 4px; }
.feature p { color: var(--ink-2); font-size: 0.88rem; line-height: 1.55; }

/* -------------------------------------------------------------- filter -- */

.filter-bar { background: #fff; border-bottom: 1px solid var(--line); }

.filter-inner {
  max-width: var(--wrap); margin: 0 auto;
  padding: 24px var(--gutter);
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
}

.field {
  position: relative;
  display: flex; align-items: center;
}
.field select,
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 38px 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  appearance: none;
  -webkit-appearance: none;
}
.field input { padding-right: 16px; }
.field select:focus, .field input:focus { border-color: var(--accent); outline: none; }

.field::after {
  content: '';
  position: absolute; right: 16px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.field.no-caret::after { display: none; }

/* -------------------------------------------------------------- layout -- */

.section { padding: 64px 0; }
.section-alt { background: var(--bg-alt); }

.section-head { text-align: center; margin-bottom: 40px; }

.section-head h2 {
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  margin-bottom: 12px;
}
.section-head h2::after {
  content: ''; display: block;
  width: 56px; height: 2px; margin: 12px auto 0;
  background: var(--accent);
}
.section-head p { color: var(--ink-2); max-width: 56ch; margin: 0 auto; }

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

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

.book-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow 0.22s var(--ease), transform 0.22s var(--ease),
              border-color 0.22s var(--ease);
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.cover-link { display: block; position: relative; background: var(--bg-sunken); }

/* Fixed aspect box: the image slot holds its size before the picture arrives,
   so the grid never jumps as covers load. */
.cover {
  display: block;            /* a <span> is inline, and inline boxes ignore aspect-ratio */
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--bg-sunken);
}
.cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}
.book-card:hover .cover img { transform: scale(1.035); }

/* Cover placeholder — a typeset spine, so a missing image still looks intentional */
.cover-ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 18px 16px;
  background: linear-gradient(150deg, #2d3142 0%, #454a63 100%);
  color: #fff;
  text-align: left;
}
.cover-ph b {
  font-family: var(--serif);
  font-size: 0.98rem; line-height: 1.25;
  display: block; margin-bottom: 8px;
}
.cover-ph span {
  font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase;
  opacity: 0.72;
}
.cover-ph::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: var(--accent);
}

.badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: var(--ink); color: #fff;
  font-size: 0.64rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 2px;
}
.badge-sale { background: var(--accent); }

.book-body {
  padding: 16px 16px 18px;
  text-align: center;
  display: flex; flex-direction: column; flex: 1; gap: 6px;
}

.book-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.3;
}
.book-title a:hover { color: var(--accent); }

.book-author {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-3);
}

.book-meta {
  font-size: 0.74rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.price { margin-top: 4px; font-size: 1.02rem; font-weight: 700; color: var(--accent); }
.price del { color: var(--ink-3); font-weight: 400; font-size: 0.88rem; margin-right: 7px; }
.price .off {
  display: inline-block; margin-left: 7px;
  font-size: 0.7rem; font-weight: 700; color: var(--ok);
}

.book-body .btn { margin-top: auto; }

/* --------------------------------------------------------- book detail -- */

.book-detail {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 48px;
  align-items: start;
}

.detail-cover {
  position: sticky; top: 100px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 2 / 3;
  background: var(--bg-sunken);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }

.detail-cat {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}

.book-detail h1 { font-size: clamp(1.6rem, 3.6vw, 2.35rem); margin-bottom: 8px; }
.detail-sub { font-size: 1.05rem; color: var(--ink-2); margin-bottom: 18px; }

.detail-price {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 18px 0; margin: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.detail-price .now { font-size: 1.85rem; font-weight: 700; color: var(--accent); font-family: var(--serif); }
.detail-price del { color: var(--ink-3); font-size: 1.05rem; }
.detail-price .off {
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 0.76rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}

.buy-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.buy-row .btn { flex: 1 1 200px; }

.spec-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px 22px;
  padding: 20px; margin-bottom: 26px;
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
}
.spec-list div { font-size: 0.86rem; }
.spec-list dt { color: var(--ink-3); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }
.spec-list dd { font-weight: 600; margin-top: 2px; }

.prose { color: var(--ink-2); }
.prose p { margin-bottom: 15px; }
.prose p:last-child { margin-bottom: 0; }
.prose h2, .prose h3 { color: var(--ink); margin: 26px 0 10px; font-size: 1.12rem; }
.prose strong { color: var(--ink); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.checks { margin: 22px 0; display: grid; gap: 10px; }
.checks li {
  position: relative; padding-left: 28px;
  font-size: 0.93rem; color: var(--ink-2);
}
.checks li::before {
  content: ''; position: absolute; left: 4px; top: 8px;
  width: 11px; height: 6px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.crumbs {
  font-size: 0.8rem; color: var(--ink-3);
  padding: 20px 0 0;
}
.crumbs a:hover { color: var(--accent); }
.crumbs span { margin: 0 7px; }

/* ------------------------------------------------------- simple pages -- */

.page-head { padding: 52px 0 10px; text-align: center; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin-bottom: 10px; }
.page-head p { color: var(--ink-2); max-width: 60ch; margin: 0 auto; }

.link-list { display: grid; gap: 12px; margin-top: 26px; }
.link-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.link-list a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.link-list strong { font-weight: 600; }
.link-list small { color: var(--ink-3); display: block; font-weight: 400; }
.link-list .arrow { color: var(--accent); font-size: 1.1rem; flex-shrink: 0; }

.contact-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px; margin-top: 30px;
}
.contact-card {
  padding: 24px; text-align: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.contact-card h3 { font-size: 1rem; margin-bottom: 6px; }
.contact-card p { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 14px; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--ink-3);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
}

/* -------------------------------------------------------------- footer -- */

.site-footer {
  background: var(--ink);
  color: #c9c9d2;
  padding: 54px 0 0;
  margin-top: 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 40px;
}

.site-footer h4 {
  color: #fff; font-family: var(--sans);
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 16px;
}
.site-footer .brand { color: #fff; margin-bottom: 14px; }
.site-footer p { font-size: 0.88rem; line-height: 1.7; max-width: 42ch; }
.site-footer li { margin-bottom: 9px; font-size: 0.88rem; }
.site-footer a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 20px 0 calc(20px + var(--safe-b));
  font-size: 0.8rem;
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; min-height: 0; padding-top: 44px; gap: 30px; }
  .hero-media { order: -1; margin: 0 calc(var(--gutter) * -1); }
  .hero-media img { max-height: 260px; }
  /* Keep the empty-state box short so the headline stays above the fold
     before a banner image has been uploaded. */
  .hero-media .hero-fallback { min-height: 140px; font-size: .88rem; }
  .hero p { max-width: none; }

  .features-grid { grid-template-columns: 1fr; gap: 22px; padding: 30px var(--gutter); }
  .filter-inner { grid-template-columns: 1fr; }
  .book-detail { grid-template-columns: 1fr; gap: 30px; }
  /* `relative`, not `static` — the placeholder inside is absolutely positioned,
     and a static parent would let it escape to the viewport. */
  .detail-cover { position: relative; top: auto; max-width: 260px; margin: 0 auto; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 760px) {
  .header-bar { min-height: 62px; }
  .brand { font-size: 1.08rem; letter-spacing: 0.12em; }

  .nav-toggle { display: flex; }

  .main-nav {
    position: fixed; inset: 62px 0 auto 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    margin: 0;
    max-height: 0; overflow: hidden;
    transition: max-height 0.28s var(--ease);
  }
  .main-nav.open { max-height: 70vh; overflow-y: auto; }
  .main-nav ul { flex-direction: column; align-items: stretch; gap: 0; padding: 6px 0; }
  .main-nav a {
    display: block; padding: 14px var(--gutter);
    font-size: 0.9rem; border-bottom: 1px solid var(--line);
  }
  .main-nav a::after { display: none; }
  .main-nav li:last-child a { border-bottom: none; }

  .section { padding: 44px 0; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .book-body { padding: 13px 11px 15px; }
  .book-title { font-size: 0.92rem; }
  .book-body .btn { padding: 10px 14px; font-size: 0.8rem; }
  .buy-row .btn { flex: 1 1 100%; }
  .footer-bottom { justify-content: center; text-align: center; }
}

@media (max-width: 400px) {
  :root { --gutter: 14px; }
  .book-grid { gap: 11px; }
  .book-title { font-size: 0.86rem; }
}

/* ------------------------------------------------------- preferences -- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .book-card:hover { transform: none; }
}

@media print {
  .site-header, .site-footer, .filter-bar, .buy-row, .skip-link, .announce { display: none !important; }
  body { color: #000; }
  .book-detail { grid-template-columns: 1fr; }
}
