:root {
  --ink: #171717;
  --paper: #f5f0e6;
  --paper-strong: #fffdf7;
  --red: #e43f2f;
  --blue: #315ee8;
  --muted: #716d66;
  --line: rgba(23, 23, 23, 0.16);
  --shadow: 0 20px 55px rgba(22, 20, 17, 0.13);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 10%, rgba(228, 63, 47, 0.1), transparent 24rem),
    linear-gradient(90deg, transparent 0 49.9%, rgba(23,23,23,.025) 50%, transparent 50.1%),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.site-header {
  min-height: 76px;
  padding: 14px clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 240, 230, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--ink); border-radius: 10px 10px 10px 2px; font-family: "Literata", serif; font-size: 1.35rem; }

.cart-button, .filters button, .empty-state button, footer button {
  border: 1px solid var(--ink);
  background: transparent;
  border-radius: 999px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 600;
}

.cart-button span { display: inline-grid; place-items: center; min-width: 25px; height: 25px; margin-left: 7px; color: white; background: var(--red); border-radius: 99px; }

main { width: min(1460px, 100%); margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px) 88px; }

.intro {
  padding: clamp(48px, 8vw, 100px) 0 clamp(42px, 6vw, 76px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, .65fr);
  gap: 40px;
  align-items: end;
  border-bottom: 1px solid var(--ink);
}

.eyebrow, .section-kicker { margin: 0 0 10px; color: var(--red); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
h1, h2, h3 { font-family: "Literata", serif; }
h1 { max-width: 900px; margin: 0; font-size: clamp(3.1rem, 8vw, 8.4rem); line-height: .91; letter-spacing: -.06em; }
.intro-copy { max-width: 440px; margin: 0 0 8px; color: #403d38; font-family: "Literata", serif; font-size: clamp(1.05rem, 1.7vw, 1.35rem); line-height: 1.55; }

.catalog { padding-top: 40px; }
.catalog-toolbar { display: flex; gap: 30px; align-items: end; justify-content: space-between; }
.catalog-toolbar h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.5rem); }
.search-field { display: flex; align-items: center; gap: 10px; width: min(100%, 390px); padding: 12px 16px; border: 1px solid var(--ink); border-radius: 999px; background: var(--paper-strong); }
.search-field svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 1rem; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 26px 0 32px; }
.filters button { border-color: var(--line); padding: 8px 13px; font-size: .9rem; }
.filters button.active { color: white; background: var(--ink); border-color: var(--ink); }

.book-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(14px, 2vw, 28px); }
.book-card { min-width: 0; }
.cover-button { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.cover-frame { position: relative; aspect-ratio: .68; overflow: hidden; background: #d8d2c6; border: 1px solid rgba(23,23,23,.18); border-radius: 3px 12px 12px 3px; box-shadow: 7px 12px 24px rgba(23,23,23,.15); transition: transform .22s ease, box-shadow .22s ease; }
.cover-button:hover .cover-frame, .cover-button:focus-visible .cover-frame { transform: translateY(-7px) rotate(-.6deg); box-shadow: 12px 22px 36px rgba(23,23,23,.2); }
.cover-image { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cover-badge { position: absolute; right: 9px; top: 9px; padding: 6px 9px; color: white; background: var(--blue); border-radius: 99px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; z-index: 2; }
.book-meta { padding: 17px 2px 0; }
.book-meta h3 { margin: 0 0 6px; font-size: clamp(1.05rem, 1.5vw, 1.35rem); line-height: 1.16; }
.author { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.35; }
.price-row { margin-top: 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.price { font-size: 1.2rem; font-weight: 700; }
.reserve-card { margin-top: 13px; width: 100%; padding: 10px 12px; border: 1px solid var(--ink); background: transparent; cursor: pointer; font-weight: 700; border-radius: 3px; }
.reserve-card:hover { color: white; background: var(--ink); }

.empty-state { padding: 60px 20px; text-align: center; border: 1px dashed var(--line); }

footer { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; align-items: center; padding: 30px clamp(20px, 5vw, 72px); color: white; background: var(--ink); }
footer p { margin: 0; }

dialog { width: min(100% - 28px, 1080px); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 12px; color: var(--ink); background: var(--paper-strong); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(14, 13, 12, .72); backdrop-filter: blur(5px); }
.close-button { position: absolute; top: 14px; right: 14px; z-index: 3; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper-strong); cursor: pointer; font-size: 1.7rem; line-height: 1; }
.close-button.static { position: static; flex: 0 0 auto; }
.detail-layout { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.35fr); min-height: 620px; }
.detail-visual { display: grid; place-items: center; padding: 62px; background: #d9d1c4; overflow: hidden; }
.detail-cover { width: min(100%, 330px); }
.detail-copy { padding: clamp(48px, 7vw, 82px) clamp(28px, 5vw, 70px) 54px; overflow-y: auto; }
.detail-copy h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.8rem); line-height: 1; letter-spacing: -.035em; }
.detail-author { margin: 12px 0 28px; color: var(--muted); font-size: 1.06rem; }
.detail-price { display: flex; align-items: baseline; gap: 13px; margin: 20px 0 6px; }
.detail-price strong { font-size: 2rem; }
.discount { color: var(--red); font-weight: 700; }
.detail-copy > p { line-height: 1.62; }
.sales-detail { font-family: "Literata", serif; font-size: 1.12rem; }
.data-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; margin: 28px 0; border-top: 1px solid var(--line); }
.data-list div { padding: 13px 0; border-bottom: 1px solid var(--line); }
.data-list dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.data-list dd { margin: 4px 0 0; }
.review-box { margin: 22px 0; padding: 18px; background: #eee7db; border-left: 3px solid var(--red); }
.review-box p { margin: 5px 0; line-height: 1.5; }
.review-box a, .excerpt-link { font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.primary-action { width: 100%; padding: 15px 20px; border: 0; border-radius: 4px; color: white; background: var(--red); cursor: pointer; font-weight: 700; font-size: 1rem; }

.cart-dialog { width: min(100% - 24px, 650px); padding: 30px; }
.cart-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.cart-head h2 { margin: 0; font-size: 2rem; }
.cart-item { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--line); }
.cart-item p { margin: 2px 0; }
.cart-item small { color: var(--muted); }
.remove-item { border: 0; background: transparent; cursor: pointer; color: var(--red); text-decoration: underline; }
.cart-summary { padding-top: 24px; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.25rem; font-weight: 700; margin-bottom: 18px; }
.cart-help { color: var(--muted); line-height: 1.5; font-size: .9rem; }
.copy-request { width: 100%; padding: 14px; color: white; border: 0; background: var(--blue); border-radius: 4px; cursor: pointer; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 120px); padding: 12px 18px; color: white; background: var(--ink); border-radius: 999px; box-shadow: var(--shadow); transition: transform .25s ease; }
.toast.show { transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 44px; }
}

@media (max-width: 760px) {
  .site-header { min-height: 66px; }
  .intro { grid-template-columns: 1fr; gap: 25px; padding-top: 48px; }
  h1 { font-size: clamp(3.2rem, 17vw, 6rem); }
  .catalog-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .book-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 36px 14px; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-visual { min-height: 500px; padding: 56px; }
  .detail-copy { padding-top: 38px; }
  footer { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .brand span:last-child { font-size: .95rem; }
  .cart-button { padding: 8px 10px; font-size: .85rem; }
  .book-grid { grid-template-columns: 1fr; gap: 46px; }
  .cover-frame { width: min(80vw, 300px); margin: 0 auto; }
  .book-meta { width: min(80vw, 300px); margin: 0 auto; }
  .detail-visual { min-height: 430px; padding: 52px; }
  .data-list { grid-template-columns: 1fr; }
  .cart-item { grid-template-columns: 1fr auto; }
  .cart-item .remove-item { grid-column: 1 / -1; justify-self: start; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
