:root {
  --color-bg-light: #f9f7f1;
  --color-bg-deep: #d1c5a4;
  --coffee-dark: #3e2f1c;
  --coffee-mid: #a8803d;
  --accent: #b77d2a;
  --coffee-light: #f8efd3;
  --font-head: 'Montserrat', serif;
  --font-body: 'Open Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg-deep) 75%);
  font-family: var(--font-body);
  color: var(--coffee-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Верхняя панель */
header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, rgba(183, 135, 30, 0.95), rgba(183, 135, 30, 0.8));
  box-shadow: 0 4px 12px rgba(170, 120, 20, 0.6);
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 2rem;
  user-select: none;
  font-family: var(--font-head);
  color: #fff;
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: default;
  text-shadow: 0 0 8px #ffd042aa;
}

nav {
  display: flex;
  gap: 2rem;
}

nav a {
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 12px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

nav a:hover,
nav a:focus-visible {
  background: #ffd042dd;
  color: #4a2e00;
  outline-offset: 4px;
  outline: 3px solid #b97700;
  text-shadow: none;
  cursor: pointer;
}

.section-title {
  max-width: 1520px;
  margin: 2.2rem auto 1.2rem;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 2.4rem;
  color: var(--accent);
  text-shadow: 1px 1px 4px #faf0a1b3;
  user-select: none;
}

.bookshelf {
  max-width: 1520px;
  margin: 0 auto 3rem;
  padding: 40px 24px 48px 24px;
  background: linear-gradient(135deg, var(--coffee-light) 60%, #f3d87f 120%);
  border-radius: 40px;
  box-shadow: 0 16px 80px rgba(183, 135, 30, 0.35), 0 8px 40px rgba(166, 123, 21, 0.25);
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  user-select: none;
  position: relative;
  gap: 0 0;
  overflow-x: visible;
}

.bookshelf.second-row {
  margin-top: 30px;
}

.book-card {
  width: 178px;
  height: 600px;
  background: linear-gradient(120deg, #fcf4c8 40%, #d5bb78 120%);
  border-radius: 36px 36px 28px 28px / 60px 45px 40px 45px;
  box-shadow: 0 10px 45px rgba(170, 130, 40, 0.2), 0 24px 70px #d8ca8a66;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
  border-bottom: 14px solid var(--accent);
  margin-left: -48px;
  user-select: none;
  will-change: transform, box-shadow;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.35s ease,
    background 0.35s ease;
  z-index: 1;
  outline-offset: 6px;
}

.book-card.first-in-row {
  margin-left: 0 !important;
}

.book-card:hover,
.book-card:focus-visible {
  background: linear-gradient(125deg, #fff3b8 50%, #c9a94d 120%);
  box-shadow: 0 50px 100px rgba(255, 231, 98, 0.85), 0 28px 88px rgba(230, 210, 145, 0.9);
  transform: translateY(-50px) scale(1.4) rotate(-2deg);
  outline: 4px solid var(--accent);
  z-index: 10000 !important;
  transition:
    transform 0.4s cubic-bezier(0.42, 0, 0.58, 1),
    box-shadow 0.4s ease,
    background 0.4s ease;
}

.mini-cover-frame {
  width: 111px;
  height: 164px;
  margin-top: 52px;
  background: linear-gradient(135deg, #fffdfa 90%, #f2e1a9 130%);
  border-radius: 18px 18px 12px 12px;
  box-shadow: 0 6px 28px #ffe68cba;
  border: 3.5px solid #fbe08a;
  overflow: hidden;
  flex-shrink: 0;
  transition: box-shadow 0.3s ease;
}

.book-card:hover .mini-cover-frame,
.book-card:focus-visible .mini-cover-frame {
  box-shadow: 0 12px 46px #fbe470cc;
}

.mini-cover {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 14px 14px 12px 12px;
  background: #fcf8e4;
  box-shadow: inset 0 0 12px #dbba659c;
  transition: transform 0.3s ease;
}

.book-card:hover .mini-cover,
.book-card:focus-visible .mini-cover {
  transform: scale(1.07);
  box-shadow: 0 6px 20px #f9db6bba;
}

.spine-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.16em;
  color: var(--coffee-mid);
  margin: 44px 14px 28px;
  max-height: 240px;
  text-align: center;
  white-space: pre-line;
  overflow: hidden;
  text-shadow: 0 4px 26px #fff8d1bb;
  line-height: 1.1;
  user-select: none;
  background: rgba(255 255 255 / 0.07);
  padding: 12px 0 8px;
  border-radius: 14px;
  box-sizing: border-box;
}

#floating-books {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.float-book {
  position: absolute;
  user-select: none;
  opacity: 0.15;
  will-change: transform,left,top;
}

.particle {
  pointer-events: none;
  user-select: none;
  mix-blend-mode: screen;
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 238, 155, 0.3);
  filter: drop-shadow(0 0 5px rgba(255, 238, 155, 0.6));
}

#light-rays-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.light-ray {
  position: absolute;
  width: 2px;
  height: 40px;
  background: linear-gradient(180deg, rgba(255,238,155,0.6), transparent);
  border-radius: 1px;
  filter: drop-shadow(0 0 8px rgba(255,238,155,0.8));
  opacity: 0.8;
  transform-origin: center bottom;
  will-change: transform,opacity;
}

.modal-content {
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(180, 140, 30, 0.35);
  transition: transform 0.4s ease;
}

.modal-image {
  max-width: 700px;
  box-shadow: 0 6px 30px #d7c26bcc inset;
  border-radius: 20px;
  max-height: 420px;
  object-fit: contain;
}

.modal-header {
  border-bottom: none;
}

.modal-title {
  font-family: var(--font-head);
  font-weight: 800;
  color: var(--accent);
}

#modalAuthor {
  font-style: italic;
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

#modalDesc {
  font-size: 1rem;
  color: var(--coffee-dark);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.btn-close {
  filter: drop-shadow(0 0 1px var(--accent));
  transition: filter 0.3s ease;
}

.btn-close:hover {
  filter: drop-shadow(0 0 6px var(--accent));
}
