/* =============================================
   MONTE BOOKS — main stylesheet
   ============================================= */

/* ---------- Reset & base ---------- */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ---------- Design tokens ---------- */

:root {
  --bg:           #F8F5F0;
  --bg-tinted:    #F2EDE6;
  --text:         #1A1A1A;
  --text-muted:   #6B6460;
  --border:       #DDD8D0;
  --font-serif:   Georgia, 'Times New Roman', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --max-width:    1200px;
  --gap:          clamp(24px, 4vw, 48px);
  --section-py:   clamp(56px, 8vw, 96px);
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 64px);
}

.section {
  padding-block: var(--section-py);
  border-top: 1px solid var(--border);
}

.section--tinted {
  background-color: var(--bg-tinted);
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: normal;
  letter-spacing: -0.01em;
  margin-bottom: clamp(32px, 5vw, 56px);
}

/* ---------- Header ---------- */

.site-header {
  padding-block: clamp(20px, 3vw, 32px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(20px, 3vw, 28px);
}

/* Logo */

.logo {
  display: flex;
  align-items: center;
  gap: 0;
}

.logo-word {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: normal;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-image {
  height: clamp(104px, 14vw, 160px);
  width: auto;
  mix-blend-mode: multiply;
  margin-inline: -40px;
}

/* Language switcher */

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 2px 0;
  transition: color 0.15s;
}

.lang-btn:hover,
.lang-btn.active {
  color: var(--text);
}

.lang-btn.active {
  font-weight: 600;
}

.lang-sep {
  color: var(--border);
  font-size: 0.75rem;
  user-select: none;
}

/* Nav */

.header-nav {
  display: flex;
  gap: clamp(20px, 4vw, 40px);
  flex-wrap: wrap;
}

.header-nav a {
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}

.header-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ---------- Books grid ---------- */

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Placeholder covers — пока нет реальных обложек */
.book-cover {
  aspect-ratio: 2 / 3;
  background-color: var(--bg-tinted);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Цветовые акценты для placeholder-обложек */
.book-cover--1 { background-color: #E8E2D8; }
.book-cover--2 { background-color: #DDD7CC; }
.book-cover--3 { background-color: #E4DDD4; }
.book-cover--4 { background-color: #D9D2C8; }

.book-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.book-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: normal;
  line-height: 1.3;
}

.book-author {
  font-size: 0.8125rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.book-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.55;
}

/* ---------- Book 3D promo ---------- */

.book3d-track {
  position: relative;
  border-top: 1px solid var(--border);
  overflow: clip; /* обрезает 3D-overflow не ломая sticky */
}

.book3d-scroll-space {
  height: 250vh;
}

.book3d-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding-block: 48px;
  overflow: hidden;
}

.book3d-scene {
  perspective: 2400px;
  position: relative;
  overflow: hidden;
  /* Ширина + aspect-ratio — работает на всех браузерах включая iOS Safari */
  width: min(720px, 94vw);
  aspect-ratio: 1515 / 1038;
  max-height: 62vh;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

/* --- Два столбца --- */
.book3d-col {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  overflow: hidden;
}

.book3d-col--left  { left: 0; border-right: 1px solid rgba(0,0,0,0.08); }
.book3d-col--right { right: 0; }

/* Левый столбец изначально скрыт */
.book3d-col--left {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.book3d-col--left.is-visible { opacity: 1; }

/* Слои внутри левого столбца */
.book3d-left-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.book3d-left-layer.is-active { opacity: 1; }
.book3d-left-inside { background: #ede8e0; }
.book3d-left-layer img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* Слои правого столбца */
.book3d-right-layer {
  position: absolute;
  inset: 0;
}
.book3d-right-layer img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* --- Обложка (в правом столбце) --- */
.book3d-cover {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(0deg);
  z-index: 3;
  will-change: transform;
}

.book3d-cover-front,
.book3d-cover-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.book3d-cover-front img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

.book3d-cover-back {
  transform: rotateY(180deg);
  background: #ede8e0;
}

/* --- Страница разворота (в правом столбце) --- */
.book3d-page {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(0deg);
  z-index: 2;
  will-change: transform;
}

.book3d-page-front,
.book3d-page-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.book3d-page-front img,
.book3d-page-back img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

.book3d-page-back { transform: rotateY(180deg); }

/* --- Подпись --- */
.book3d-caption {
  text-align: center;
  max-width: min(560px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book3d-caption .promo-title {
  font-size: clamp(1rem, 2vw, 1.375rem);
}

.book3d-caption .promo-desc {
  font-size: 0.8125rem;
}

/* ---------- Promo banner (old, kept for reference) ---------- */

.promo-banner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

.promo-image img {
  width: 100%;
  height: auto;
  display: block;
}

.promo-text {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.promo-label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.promo-title {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 2.5vw, 1.875rem);
  font-weight: normal;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.promo-desc {
  font-size: clamp(0.875rem, 1.2vw, 1rem);
  color: var(--text-muted);
  line-height: 1.7;
}

@media (max-width: 680px) {
  .promo-banner {
    grid-template-columns: 1fr;
  }
}

/* ---------- About ---------- */

.about-content {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}

.about-content p {
  font-size: clamp(0.9375rem, 1.5vw, 1.0625rem);
  line-height: 1.7;
}

/* ---------- Contacts ---------- */

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.contact-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
}

.contact-icon svg {
  width: 100%;
  height: 100%;
}

.contact-link {
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: border-color 0.15s, color 0.15s;
}

.contact-link:hover {
  border-bottom-color: var(--text);
}

/* ---------- Lightbox ---------- */

.zoomable {
  cursor: zoom-in;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 28px;
}

.footer-copy {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ---------- Legal (скрыт) ---------- */

.section--legal {
  padding-block: 32px;
}

.legal-content {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 720px;
  line-height: 1.6;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .lang-switcher {
    align-self: flex-end;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
