/* Полка — лендинг. Палитра «Северный стол» (как в Mini App).
   Всё, что изображает предметы (стена, дерево, книги, бумага), — фотографии из site/assets.
   Стили отвечают только за раскладку, текст и движение. */
:root {
  --bg: #f3f1ec;
  --paper: #fbf9f4;
  --surface: #ffffff;
  --text: #24282e;
  --muted: #6b7079;
  --faint: #9a9ea6;
  --line: #e3dfd6;
  --slate: #3d5a80;
  --coral: #e07a5f;
  --butter: #f2cc8f;
  --butter-line: #e0a84f;
  --callout: #fbf1dd;
  --walnut: #5b4636;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Neucha", "Caveat", cursive;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --H: min(46vh, 31vw);           /* высота книги, от неё считается вся полка */
  color-scheme: light;
}
@media (max-width: 767px) { :root { --H: min(60vw, 40svh); } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 17px/1.6 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--slate); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px; border-radius: 12px; background: var(--slate); color: #fff; font: 500 16px/1 var(--font); text-decoration: none; transition: background .2s var(--ease), transform .2s var(--ease); }
.btn:hover { background: #33506f; transform: translateY(-1px); }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: 14px; border-radius: 10px; }
.link { font-weight: 500; color: var(--slate); text-decoration: none; border-bottom: 1.5px solid rgba(61, 90, 128, .3); padding-bottom: 2px; }
.link:hover { border-color: var(--slate); }

/* ── Шапка ─────────────────────────── */
.top { position: fixed; inset: 0 0 auto; z-index: 30; display: flex; justify-content: space-between; align-items: center; padding: 16px clamp(16px, 4vw, 40px); pointer-events: none; }
.top > * { pointer-events: auto; }
.top-logo { font: 400 30px/1 var(--hand); text-decoration: none; color: var(--text); opacity: 0; transform: translateY(-8px); transition: opacity .3s, transform .3s var(--ease); }
body.scrolled .top-logo { opacity: 1; transform: none; }
.top-nav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
.top-nav > a:not(.btn) { text-decoration: none; color: var(--text); }
body.scrolled .top { background: rgba(243, 241, 236, .86); backdrop-filter: saturate(1.2) blur(10px); }

/* ── 1. Логотип и полка на стене ─────────── */
.hero { position: relative; height: 100svh; min-height: 560px; overflow: hidden; background: #ece8e1; }
/* Сцена — ровно та часть фото, что видна; надпись стоит на полке в долях картинки. */
.hero-scene { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 50% 70%; will-change: transform; container-type: size; }
.hero-photo, .hero-photo img { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-photo img { object-fit: fill; }
.hero-photo.missing img { display: none; }
.logo { position: absolute; left: 0; right: 0; bottom: calc((1 - var(--surf, .528)) * 100%); margin: 0; text-align: center;
  font: 400 14cqw/1 var(--hand); color: #2f2a25; letter-spacing: .01em; transform: translateY(var(--base, .2em));
  filter: drop-shadow(.05em .03em .04em rgba(40, 28, 16, .22)); white-space: nowrap; transform-origin: 50% calc(100% - var(--base, .2em)); transition: scale .45s ease; }
@media (prefers-reduced-motion: reduce) { .logo { transition: none; } }
@media (max-width: 767px) {
  .hero { height: min(100svh, calc(100vw * 1440 / 804)); min-height: 0; }
  .logo { --surf: .53; font-size: 24cqw; }
}
/* Буква и стикер на её месте: стикер стоит на полке (низ — по базовой линии букв). */
.logo .ch { position: relative; display: inline-block; cursor: default; text-align: center; white-space: nowrap; transition: width .5s cubic-bezier(.3,1.25,.45,1); }
@media (prefers-reduced-motion: reduce) { .logo .ch { transition: none; } }
.logo .glyph { display: inline-block; transform-origin: 50% 80%; }
.logo .ch-sticker { position: absolute; left: 50%; bottom: var(--base, .2em); height: .82em; width: auto; max-width: none;
  transform-origin: 50% 100%; opacity: 0; pointer-events: none; }

/* ── 2. Что это ─────────────────────── */
.about { padding: clamp(80px, 12vw, 140px) 16px; text-align: center; }
.about h2 { font: 500 clamp(30px, 4.4vw, 48px)/1.15 var(--font); letter-spacing: -.02em; max-width: 18ch; margin: 0 auto; }
.about p { color: var(--muted); max-width: 54ch; margin: 22px auto 0; font-size: 19px; }
.about-cta { display: flex; justify-content: center; align-items: center; gap: 28px; flex-wrap: wrap; margin-top: 34px; }

/* ── 3. Книжная полка ───────────────── */
.library { position: relative; padding: 96px 0 72px; background: var(--bg) url("/site/assets/wall.webp") center / 1024px repeat; overflow: hidden; }
.lib-h { text-align: center; font: 500 clamp(28px, 3.6vw, 40px)/1.2 var(--font); letter-spacing: -.02em; }
.lib-sub { text-align: center; color: var(--muted); margin-top: 10px; padding: 0 16px; }

.shelf { position: relative; height: calc(var(--H) * 1.36 + 90px); margin-top: 24px; touch-action: pan-y; cursor: grab; outline: none; }
.shelf.dragging { cursor: grabbing; }
.shelf, .shelf * { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; }
.stage { position: absolute; left: 50%; top: calc(70px + var(--H) / 2); width: 0; height: 0; z-index: 2; }
/* Тень доски на стене и кронштейны — из фото первого экрана, стена в них прозрачная (без наложения: оно мерцало рядом с 3D) */
.board-shadow { position: absolute; left: 0; right: 0; top: calc(70px + var(--H) * 1.09 - 2px); height: calc(var(--H) * .5);
  background: url("/site/assets/shelf-shadow.webp?v=2") 0 0 / 100% 100% no-repeat; pointer-events: none; }
.bracket { position: absolute; top: calc(70px + var(--H) * 1.09 - 2px); height: calc(var(--H) * .25); width: auto; pointer-events: none; }
.bracket-l { left: 14%; } .bracket-r { right: 14%; }
.board { position: absolute; z-index: 3; left: 0; right: 0; top: calc(70px + var(--H) - var(--H) * .07); height: calc(var(--H) * .16);
  background: url("/site/assets/shelf-board.webp") 0 0 / auto 100% repeat-x; pointer-events: none; }
.board.missing { background: var(--walnut); }  /* временно, пока нет фото доски */

.book { position: absolute; left: 0; top: 0; transform-style: preserve-3d; cursor: pointer; }
.face { position: absolute; height: var(--H); top: calc(var(--H) / -2); backface-visibility: hidden; -webkit-backface-visibility: hidden; background-size: 100% 100%; background-repeat: no-repeat; }
.face::after { content: ""; position: absolute; inset: 0; background: #000; opacity: var(--shade, 0); pointer-events: none; }
.sp { width: var(--ws); left: calc(var(--ws) / -2); transform: translateZ(calc(var(--d) / 2)); }
.cv { width: var(--d); left: calc(var(--d) / -2); transform: rotateY(90deg) translateZ(calc(var(--ws) / 2)); }
.face.noimg { background-color: var(--book); }  /* временно, пока нет фото книг */

/* Названия — настоящим текстом с тиснением поверх ткани */
.sp-title { position: absolute; inset: 14% 0 12%; display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; font: 600 calc(var(--ws) * .3)/1 var(--font); letter-spacing: .04em; white-space: nowrap; }
.cv-title { position: absolute; left: 12%; right: 12%; top: 16%; text-align: center; font-family: var(--hand); font-weight: 400; line-height: 1.05; font-size: calc(var(--d) * .13); }
.emboss { color: rgba(255, 252, 245, .9); text-shadow: 0 1px 0 rgba(0, 0, 0, .28), 0 -1px 0 rgba(255, 255, 255, .12); mix-blend-mode: normal; }
.emboss.dark { color: rgba(36, 40, 46, .82); text-shadow: 0 1px 0 rgba(255, 255, 255, .35), 0 -1px 0 rgba(0, 0, 0, .12); }

/* Подпись под полкой: строки выезжают через маску */
.caption { position: relative; margin-top: 8px; padding: 0 72px; }
.cap-lines { display: grid; justify-items: center; gap: 6px; pointer-events: none; }
.mask { position: relative; overflow: hidden; width: 100%; max-width: 720px; text-align: center; }
.mask > span { display: block; will-change: transform; }
.mask > span + span { position: absolute; inset: 0; }
.cap-folder { font-size: 14px; color: var(--slate); font-weight: 500; }
.cap-title { font: 500 clamp(20px, 2.4vw, 26px)/1.25 var(--font); letter-spacing: -.01em; min-height: 1.25em; }
.cap-why { font: 400 22px/1.3 var(--hand); color: var(--coral); }

.arrow { position: absolute; top: 50%; margin-top: -24px; width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; color: var(--text); cursor: pointer; }
.arrow.prev { left: clamp(8px, 3vw, 40px); }
.arrow.next { right: clamp(8px, 3vw, 40px); }
.arrow svg { width: 22px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; }

.open-ring { position: absolute; z-index: 5; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 50%; border: 0; background: var(--slate); color: #fff; font: 500 13px/1 var(--font); cursor: pointer; transform: scale(0); transition: background .2s; box-shadow: 0 10px 30px -10px rgba(36, 40, 46, .5); }
.open-ring:hover { background: #33506f; }

/* ── 4. Финал ───────────────────────── */
.final { text-align: center; padding: clamp(90px, 12vw, 150px) 16px; }
.final h2 { font: 500 clamp(28px, 4vw, 44px)/1.2 var(--font); letter-spacing: -.02em; max-width: 20ch; margin: 0 auto; }
.foot { display: flex; justify-content: space-between; gap: 16px; padding: 24px clamp(16px, 4vw, 40px) 32px; border-top: 1px solid var(--line); color: var(--faint); font-size: 14px; }
.foot a { text-decoration: none; }

/* ── Раскрытая книга ─────────────────── */
.reader { position: fixed; inset: 0; z-index: 50; }
.reader[hidden] { display: none; }
/* «Закрыть» — только когда книга уже раскрыта, иначе ложится поверх шапки */
.reader.ready .reader-close { opacity: 1; visibility: visible; transition: opacity .25s; }
.reader-bg { position: absolute; inset: 0; background: var(--bg); }
.reader-close { opacity: 0; visibility: hidden; position: absolute; top: 18px; right: clamp(16px, 3vw, 32px); z-index: 3; height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 500 15px/1 var(--font); cursor: pointer; }
.rfly { position: absolute; left: 50%; top: 50%; width: calc(var(--PW) * 2); height: var(--PH); margin: calc(var(--PH) / -2) 0 0 calc(var(--PW) * -1); perspective: 2600px; z-index: 2; }
.rbook { position: absolute; inset: 0; transform-style: preserve-3d; }
.rpage { position: absolute; top: 0; width: var(--PW); height: var(--PH); container-type: inline-size; overflow: hidden;
  background: var(--paper) url("/site/assets/book-open.webp") 0 0 / 200% 100% no-repeat; }
.rpage-right { left: var(--PW); transform: translateZ(-1px); background-position: 100% 0; box-shadow: 0 40px 80px -40px rgba(30, 22, 14, .45); }
.rpage-left { background-position: 0 0; }
.flap { position: absolute; left: var(--PW); top: 0; width: var(--PW); height: var(--PH); transform-origin: 0 50%; transform-style: preserve-3d; }
.flap-front, .flap-back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 2px; }
.flap-front { background-size: 100% 100%; box-shadow: 0 40px 80px -40px rgba(30, 22, 14, .55); }
.flap-front.noimg { background-color: var(--book); }
.flap-front .cv-title { font-size: calc(var(--PW) * .13); }
.flap-back { transform: rotateY(180deg); left: 0; }
.reader-pager { display: none; }

/* Содержимое страниц: настоящий интерфейс Полки, «напечатанный» на бумаге */
/* Содержимое страниц: настоящий интерфейс Полки, напечатанный на бумаге книжным шрифтом.
   Краска чуть просвечивает и слегка «расплывается» по волокнам, картинки — как оттиск. */
.pg { --ink: #2b251f; --ink-2: #5b5148; --ink-3: #8b8074; --ink-blue: #34496a; --ink-red: #8c3a28;
  position: absolute; inset: 0; padding: 9cqw 10cqw 8cqw; display: flex; flex-direction: column; gap: 3.2cqw;
  font: 400 clamp(11px, 3.4cqw, 16px)/1.55 "Literata", Georgia, serif; font-optical-sizing: auto; color: var(--ink);
  mix-blend-mode: multiply; opacity: .93; text-shadow: 0 0 .6px rgba(43, 37, 31, .45);
  hyphens: auto; -webkit-hyphens: auto; font-kerning: normal; font-variant-ligatures: common-ligatures; }
.rpage-left .pg { padding-left: 14cqw; padding-right: 8cqw; }
.rpage-right .pg { padding-left: 8cqw; padding-right: 17cqw; }
.rv { will-change: clip-path, transform; }
.pg-crumb { display: flex; align-items: center; gap: 6px; font-size: .84em; font-style: italic; color: var(--ink-blue); }
.pg-crumb svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.pg-media { display: flex; gap: 4cqw; align-items: flex-start; }
.pg-img { width: auto; height: auto; max-width: 34cqw; max-height: 58cqw; border-radius: 0; flex: none; filter: saturate(.78) contrast(.92) sepia(.12); }
.pg-doc { width: 34cqw; aspect-ratio: 4 / 5; flex: none; border: 1px solid rgba(43, 37, 31, .35); display: grid; place-items: center; color: var(--ink-3); font-weight: 600; font-size: .9em; letter-spacing: .08em; }
.pg-t { font-size: 1.16em; line-height: 1.28; font-weight: 600; hyphens: manual; }
.pg-src { font-size: .82em; font-style: italic; color: var(--ink-3); margin-top: 6px; }
.pg-why { padding: .1em 0 .1em 1em; border-left: 1px solid rgba(140, 58, 40, .5); }
.pg-why small { display: block; font-size: .8em; font-style: italic; color: var(--ink-red); }
.pg-why span { font: 400 1.3em/1.25 var(--hand); color: var(--ink); }
.pg-s { color: var(--ink-2); text-align: justify; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.pg-h { font-size: 1.2em; font-weight: 600; display: flex; align-items: baseline; gap: .5em; }
.pg-h i { font-size: .62em; font-weight: 400; font-style: italic; color: var(--ink-3); }
.pg-intro { color: var(--ink-2); text-align: justify; }
.pg-facts { display: grid; grid-template-columns: auto 1fr; gap: 1.4cqw 4cqw; margin: 0; font-size: .94em; }
.pg-facts dt { font-style: italic; color: var(--ink-3); }
.pg-facts dd { margin: 0; }
.pg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.6cqw; font-size: .94em; }
.pg-list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted rgba(43, 37, 31, .35); padding-bottom: 1.2cqw; }
.pg-list li b { font-weight: 400; }
.pg-list li span { color: var(--ink-2); white-space: nowrap; font-variant-numeric: oldstyle-nums; }
.pg-hl { margin: 0; padding-left: 1.1em; display: grid; gap: 1.2cqw; font-size: .94em; }
.pg-hl li::marker { color: var(--ink-3); }
.pg-tip { font-size: .9em; color: var(--ink-2); border-top: 1px solid rgba(43, 37, 31, .25); padding-top: 2.2cqw; }
.pg-tip b { color: var(--ink-red); font-weight: 600; font-style: italic; }

@media (max-width: 767px) {
  .shelf { height: calc(var(--H) * 1.32 + 80px); }
  .caption { padding: 0 48px; }
  .open-ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; font-size: 12px; }
  .reader-pager { display: flex; position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 3; gap: 6px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
  .reader-pager button { height: 36px; padding: 0 14px; border-radius: 9px; border: 0; background: none; font: 500 14px/1 var(--font); color: var(--muted); cursor: pointer; }
  .reader-pager button[aria-pressed="true"] { background: var(--slate); color: #fff; }
  .top-nav > a:not(.btn) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .top-logo { transition: none; }
}

/* Девиз над финальным призывом — рукописным, как подписи на книгах */
.motto { margin: 0 0 14px; font: 400 clamp(26px, 3.4vw, 40px)/1.15 var(--hand); color: var(--coral); }

/* «ai» в логотипе — приписка от руки над последней буквой */
.logo .logo-ai { position: absolute; left: 96%; top: -.02em; font: 400 .3em/1 var(--hand); color: var(--coral); transform: rotate(-7deg); transform-origin: 0 100%; pointer-events: none; white-space: nowrap; }
.top-logo sup { font-size: .5em; color: var(--coral); margin-left: 1px; vertical-align: .9em; line-height: 0; }
