/* 📚 Тепла «книжкова» тема: кремовий папір, темно-зелений і золотистий акценти */
:root {
  --bg: #f7f1e6;
  --paper: #fffdf8;
  --text: #2b2420;
  --muted: #7a6e63;
  --line: #e7dccb;
  --accent: #2f5d50;
  --accent-soft: #e3eee9;
  --gold: #c58b2b;
  --danger: #c0392b;
  --shadow: rgba(60, 40, 20, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1814;
    --paper: #26221d;
    --text: #f1e9dd;
    --muted: #b3a797;
    --line: #3a342c;
    --accent: #7fc0aa;
    --accent-soft: #24332d;
    --gold: #e0a84a;
    --danger: #ff7b6b;
    --shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* приховане — завжди приховане, навіть з display: flex */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, .brand { font-family: Georgia, "Times New Roman", serif; }
button { font: inherit; cursor: pointer; }

/* Шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 21px;
  font-weight: 700;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}
.lang button.active { background: var(--accent); color: var(--paper); }
.cart-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  padding: 8px 14px;
  font-weight: 600;
}
.cart-btn b {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 13px;
  text-align: center;
}

/* Перший екран */
.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 20px 28px;
  text-align: center;
}
.hero h1 { margin: 0 0 10px; font-size: clamp(30px, 6vw, 46px); line-height: 1.15; }
.hero p { margin: 0 auto 24px; max-width: 560px; color: var(--muted); font-size: 18px; }
.search {
  width: 100%;
  max-width: 520px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--text);
  font: inherit;
  box-shadow: 0 4px 16px var(--shadow);
}

/* Каталог */
main { max-width: 1160px; margin: 0 auto; padding: 12px 20px 48px; }
.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 26px 22px;
}
.book {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 20px var(--shadow);
  transition: transform 0.15s;
}
.book:hover { transform: translateY(-3px); }
.book.out { opacity: 0.6; }
.book h3 { margin: 8px 0 0; font-size: 18px; line-height: 1.25; }
.author { margin: 0; color: var(--muted); font-size: 14px; }
.cover-btn { padding: 0; border: 0; background: none; border-radius: 10px; }
.cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 8px 18px var(--shadow);
}
.cover-fake {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 14px;
  color: #fff;
  text-align: left;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 6px, transparent 6px),
    linear-gradient(160deg, hsl(var(--hue) 45% 42%), hsl(calc(var(--hue) + 40) 50% 26%));
}
.cover-fake strong { font-family: Georgia, serif; font-size: 20px; line-height: 1.2; }
.cover-fake span { font-size: 13px; opacity: 0.85; }
.cover-fake.big strong { font-size: 26px; }
.link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  text-decoration: underline;
}
.book-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}
.price { font-size: 19px; font-weight: 800; color: var(--gold); }
.add-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
}
.add-btn.in-cart { background: var(--accent-soft); color: var(--accent); }
.add-btn:disabled { background: var(--line); color: var(--muted); cursor: default; }
.empty, .muted { color: var(--muted); text-align: center; }
.foot { padding: 24px 20px 40px; text-align: center; color: var(--muted); font-size: 14px; }

/* Детальніше про книжку */
.dialog {
  width: min(760px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  color: var(--text);
  box-shadow: 0 30px 80px var(--shadow);
}
.dialog::backdrop { background: rgba(20, 14, 8, 0.55); }
.details { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.details h2 { margin: 0 0 4px; font-size: 28px; }
.summary { white-space: pre-line; line-height: 1.6; }
.close {
  float: right;
  border: 0;
  background: var(--bg);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

/* Кошик */
.cart {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(20, 14, 8, 0.45);
}
.cart[hidden] { display: none; }
.cart-panel {
  width: min(440px, 100vw);
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: var(--paper);
  box-shadow: -10px 0 40px var(--shadow);
}
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head h2 { margin: 0; }
.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cart-title { display: flex; flex-direction: column; min-width: 0; }
.cart-title small { color: var(--muted); }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
}
.cart-total { display: flex; justify-content: space-between; padding: 14px 0; font-size: 18px; }
.order-form { display: flex; flex-direction: column; gap: 10px; }
.order-form h3 { margin: 10px 0 0; }
.order-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.order-form input, .order-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.note { margin: 0; color: var(--muted); font-size: 13px; }
.error { margin: 0; min-height: 1em; color: var(--danger); font-size: 14px; }
.primary {
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: var(--accent);
  color: var(--paper);
  font-weight: 700;
  font-size: 16px;
}
.primary:disabled { opacity: 0.6; }
.done { padding: 30px 0; text-align: center; }
.done h3 { font-size: 22px; }

@media (max-width: 600px) {
  .top { padding: 10px 14px; }
  .brand span { display: none; }
  .hero { padding-top: 36px; }
  .books { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .book { padding: 10px; }
  .book h3 { font-size: 15px; }
  .book-row { flex-direction: column; align-items: stretch; }
  .price { text-align: center; }
  .details { grid-template-columns: 1fr; }
  .details .cover { max-width: 200px; margin: 0 auto; }
}

/* ---------- ✨ Оформлення: полиця, значки, 3D-книжки, анімації ---------- */
body {
  background:
    radial-gradient(circle at 15% 10%, rgba(197, 139, 43, 0.12), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(47, 93, 80, 0.12), transparent 45%),
    var(--bg);
  background-attachment: fixed;
}
.hero {
  position: relative;
  max-width: none;
  padding: 60px 20px 150px;
  overflow: hidden;
  background: linear-gradient(180deg, #f3e3c3 0%, #ead2a6 100%);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .hero { background: linear-gradient(180deg, #2a2219 0%, #1f1912 100%); }
}
.hero > *:not(.shelf) { position: relative; z-index: 1; }
.hero h1 { max-width: 760px; margin-inline: auto; }
.hero h1 em {
  font-style: italic;
  color: var(--accent);
  background: linear-gradient(transparent 62%, rgba(197, 139, 43, 0.35) 62%);
}
.hero p { max-width: 620px; }
.shelf {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 230px;
  background: url("/shelf.svg") center bottom / auto 230px repeat-x;
  opacity: 0.9;
  mask-image: linear-gradient(180deg, transparent, #000 45%);
}
.perks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}
.perks li {
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  border: 1px solid var(--line);
  font-size: 14px;
}
.search-row { display: flex; justify-content: center; gap: 10px; max-width: 640px; margin: 0 auto; }
.search-row .search { flex: 1; max-width: none; }
.surprise {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform 0.15s;
}
.surprise:hover { transform: rotate(-3deg) scale(1.04); }
.section-title { margin: 28px 0 18px; font-size: 26px; }

/* 3D-книжка: при наведенні трохи повертається, видно корінець */
.cover-btn { perspective: 900px; }
.cover-btn .cover {
  transform-origin: left center;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  box-shadow: 4px 6px 14px var(--shadow), inset 4px 0 0 rgba(0, 0, 0, 0.18);
}
.book:hover .cover-btn .cover {
  transform: rotateY(-18deg);
  box-shadow: 14px 12px 24px var(--shadow), inset 4px 0 0 rgba(0, 0, 0, 0.18);
}
.book:hover { transform: none; }

/* Кошик підстрибує */
@keyframes bump {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.18) rotate(-4deg); }
  60% { transform: scale(0.95) rotate(2deg); }
}
.cart-btn.bump { animation: bump 0.5s ease; }

/* «Порадь книжку» — вікно з'являється з ефектом */
@keyframes pop {
  0% { transform: scale(0.7) rotate(-4deg); opacity: 0; }
  70% { transform: scale(1.03) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.dialog.pop { animation: pop 0.45s ease; }

/* Картки каталогу з'являються по черзі */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.book { animation: rise 0.4s ease both; }
.book:nth-child(2) { animation-delay: 0.05s; }
.book:nth-child(3) { animation-delay: 0.1s; }
.book:nth-child(4) { animation-delay: 0.15s; }
.book:nth-child(5) { animation-delay: 0.2s; }
.book:nth-child(n + 6) { animation-delay: 0.25s; }
@media (prefers-reduced-motion: reduce) {
  .book, .dialog.pop, .cart-btn.bump { animation: none; }
}
@media (max-width: 600px) {
  .hero { padding: 36px 16px 230px; }
  .search-row { flex-direction: column; }
  .surprise { padding: 12px; }
}

/* 👑 Вхід в адмінку з цього ж сайту */
.admin-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  text-decoration: none;
  font-size: 18px;
}
.owner-link { margin-inline-start: 8px; opacity: 0.35; text-decoration: none; }
.owner-link:hover { opacity: 1; }

/* 🏷️ Жанри, мітки, знижки */
.genres { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 18px; }
.chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}
.chip:hover { transform: translateY(-2px); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.cover-btn { position: relative; display: block; }
.badges {
  position: absolute;
  inset-block-start: -8px;
  inset-inline-end: -8px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  transform: rotate(6deg);
  z-index: 1;
  gap: 4px;
  pointer-events: none;
}
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.badge-sale { background: #d9363e; }
.badge-new { background: #2f7de1; }
.badge-hit { background: #e07b00; }
.old-price { font-size: 14px; font-weight: 500; color: var(--muted); }
