/* ============================================================
   Прототип 1 — «Книжный разворот»
   ============================================================ */

/* Палитра из обложки */
:root {
  --ink:        #2b1410;
  --wine-deep:  #462627;
  --wine:       #822625;
  --brick:      #b94722;
  --amber:      #c47731;
  --ochre:      #cca063;
  --honey:      #f1c06f;
  --gold:       #f3db91;
  --paper:      #f5ebd5;
  --paper-soft: #f8f1de;
  --moss:       #6b9c8e;
  --coral:      #d04b3b;

  --shadow-soft: 0 12px 32px -16px rgba(70, 38, 39, .35), 0 4px 12px -6px rgba(70, 38, 39, .2);
  --shadow-deep: 0 30px 60px -24px rgba(43, 20, 16, .55), 0 8px 20px -8px rgba(43, 20, 16, .3);
  --radius: 14px;

  --font-display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-body:    'Lora', 'Georgia', serif;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, rgba(241, 192, 111, .25), transparent 55%),
    radial-gradient(ellipse at bottom, rgba(130, 38, 37, .12), transparent 60%),
    var(--paper-soft);
  /* мягкая бумажная текстура — тонкий шум через layered radial */
  background-attachment: fixed;
  line-height: 1.7;
  font-size: 17px;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 30% 20%, rgba(70, 38, 39, .04) 0 2px, transparent 2px 6px),
    repeating-radial-gradient(circle at 70% 80%, rgba(70, 38, 39, .035) 0 2px, transparent 2px 5px);
  mix-blend-mode: multiply;
  opacity: .6;
  z-index: 0;
}

img { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- Прогресс ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(70, 38, 39, .08);
  z-index: 100;
}
.progress__bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--wine), var(--brick), var(--honey));
  transition: width 80ms linear;
  box-shadow: 0 0 8px rgba(241, 192, 111, .6);
}

/* ---------- Топбар ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(248, 241, 222, .78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(130, 38, 37, .12);
  z-index: 50;
  margin-top: 3px; /* под прогресс-полосой */
  transition: transform .35s ease;
}
.topbar.is-hidden { transform: translateY(-110%); }

.topbar__brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--wine);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: .02em;
}
.topbar__brand:hover { color: var(--brick); }
.topbar__icon { width: 22px; height: 22px; }

/* Языковой переключатель */
.lang {
  display: inline-flex; align-items: center;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(130, 38, 37, .18);
  border-radius: 999px;
  padding: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}
.lang__btn {
  appearance: none; background: transparent; border: 0;
  color: var(--wine-deep);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  padding: 7px 13px;
  border-radius: 999px;
  transition: all .25s ease;
  position: relative;
}
.lang__btn:hover { color: var(--brick); }
.lang__btn.is-active {
  background: linear-gradient(135deg, var(--wine), var(--brick));
  color: var(--paper-soft);
  box-shadow: 0 2px 8px -2px rgba(130, 38, 37, .5);
}
.lang__flag { margin-right: 4px; }

/* ---------- Cover ---------- */
.cover {
  position: relative;
  min-height: 100vh;
  padding: 100px 24px 64px;
  display: flex; align-items: center;
  z-index: 1;
  overflow: hidden;
}
.cover__bg {
  position: absolute; inset: -40px;
  background:
    radial-gradient(circle at 20% 30%, rgba(241, 192, 111, .35), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(208, 75, 59, .18), transparent 55%);
  filter: blur(20px);
  z-index: -1;
}
.cover__inner {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 56px;
  align-items: center;
}
.cover__text { max-width: 540px; }
.cover__eyebrow {
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: 12px;
  color: var(--amber);
  margin: 0 0 6px;
  font-weight: 600;
}
.cover__authors {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--wine-deep);
  margin: 0 0 28px;
  font-size: 15px;
}
.cover__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 6.2vw, 78px);
  line-height: 1.02;
  margin: 0 0 14px;
  color: var(--wine);
  letter-spacing: -.01em;
  text-shadow: 0 2px 0 rgba(255,255,255,.4);
}
.cover__title::after {
  content: "";
  display: block;
  width: 88px; height: 4px;
  margin-top: 18px;
  background: linear-gradient(90deg, var(--honey), var(--brick));
  border-radius: 2px;
}
.cover__subtitle {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(22px, 2.4vw, 32px);
  color: var(--brick);
  margin: 8px 0 36px;
  line-height: 1.2;
}
.cover__cta {
  display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--wine), var(--brick) 70%, var(--amber));
  color: var(--paper-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .04em;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .25s ease, box-shadow .25s ease;
}
.cover__cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-deep); }
.cover__cta svg { transition: transform .3s ease; }
.cover__cta:hover svg { transform: translateY(3px); }

.cover__hint {
  margin: 26px 0 0;
  font-size: 13px;
  color: var(--wine-deep);
  opacity: .55;
  font-style: italic;
  letter-spacing: .06em;
}

.cover__image-wrap {
  position: relative;
  justify-self: center;
  max-width: 480px;
  width: 100%;
  transform: rotate(-1.5deg);
  transition: transform .4s ease;
}
.cover__image-wrap:hover { transform: rotate(0deg) scale(1.01); }
.cover__shadow {
  position: absolute; inset: 14px -10px -18px 14px;
  background: rgba(43, 20, 16, .35);
  filter: blur(28px);
  border-radius: 18px;
  z-index: 0;
}
.cover__image {
  position: relative;
  width: 100%; height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
  z-index: 1;
  border: 6px solid rgba(255, 251, 235, .9);
}
.cover__bookmark {
  position: absolute;
  top: -8px; right: 36px;
  width: 28px; height: 86px;
  background: linear-gradient(180deg, var(--coral), var(--wine) 80%);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 4px 8px -2px rgba(43, 20, 16, .35);
  z-index: 2;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

/* ---------- Story ---------- */
.story {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 24px 64px;
  z-index: 1;
}

.page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
  margin: 0 0 120px;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity .8s ease, transform .8s ease;
}
.page.is-visible { opacity: 1; transform: none; }
.page--right .page__media { order: 2; }
.page--right .page__body  { order: 1; }

/* Media (картинка-полоса = нижняя половина обложки) */
.page__media {
  position: relative;
  margin: 0;
  aspect-ratio: 922 / 640;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-deep);
  background-color: var(--wine-deep);
  isolation: isolate;
  transform: rotate(-.6deg);
  transition: transform .4s ease;
}
.page--right .page__media { transform: rotate(.6deg); }
.page__media:hover { transform: rotate(0deg) scale(1.01); }

.page__image {
  position: absolute; inset: 0;
  background-image: var(--section-image-url);
  background-size: cover;
  background-position: center bottom;  /* видим нижнюю половину обложки */
  background-repeat: no-repeat;
  transition: transform .6s ease, filter .4s ease;
  transform: scale(1.02);
}
.page.is-visible .page__image { transform: scale(1.06); }

/* Лёгкий тёплый оверлей для каждой секции (разный) */
.page__media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(70, 38, 39, .05), rgba(241, 192, 111, .1));
  mix-blend-mode: multiply;
  pointer-events: none;
}
.page[data-tint="warm"]   .page__media::after { background: linear-gradient(180deg, rgba(241, 192, 111, .15), rgba(196, 119, 49, .12)); }
.page[data-tint="dusk"]   .page__media::after { background: linear-gradient(180deg, rgba(70, 38, 39, .15), rgba(130, 38, 37, .15)); }
.page[data-tint="mist"]   .page__media::after { background: linear-gradient(180deg, rgba(107, 156, 142, .1), rgba(243, 219, 145, .1)); }
.page[data-tint="ember"]  .page__media::after { background: linear-gradient(180deg, rgba(185, 71, 34, .15), rgba(208, 75, 59, .12)); }

/* Уголок-страничка */
.page__corner {
  position: absolute; top: 0; right: 0;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, transparent 50%, rgba(248, 241, 222, .92) 50%);
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(-2px 2px 2px rgba(43, 20, 16, .2));
}

/* Текстовая колонка */
.page__chapter {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 10px;
}
.page__chapter::before {
  content: "";
  display: inline-block;
  width: 28px; height: 1.5px;
  background: var(--amber);
}
.page__chapter-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: .01em;
  text-transform: none;
  color: var(--wine);
  display: block;
  margin: 4px 0 18px;
  font-style: italic;
}

.page__text {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  margin: 0;
  hyphens: auto;
  text-align: justify;
}
.page__text .dropcap {
  float: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 78px;
  line-height: .85;
  margin: 6px 10px 0 0;
  color: var(--wine);
  text-shadow: 2px 2px 0 var(--honey);
}

/* Маленькие меточки */
.page__index {
  position: absolute;
  bottom: -8px; left: 12px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .25em;
  color: var(--amber);
  background: var(--paper-soft);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(196, 119, 49, .3);
}

/* ============================================================
   Беседа после сказки — «Журнальный разговор»
   ============================================================ */

.chat {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 40px auto 60px;
  padding: 64px 28px 56px;
}

/* Декоративная страничка с подложкой */
.chat__paper {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 251, 235, 0.92), rgba(248, 241, 222, 0.96)),
    radial-gradient(ellipse at top left, rgba(241, 192, 111, .25), transparent 50%);
  border-radius: 6px;
  padding: clamp(28px, 4vw, 56px);
  box-shadow:
    0 30px 60px -28px rgba(43, 20, 16, .35),
    0 6px 18px -8px rgba(43, 20, 16, .18),
    inset 0 0 0 1px rgba(196, 119, 49, .18);
}

/* Левая «полоса полей» с лёгкой линией */
.chat__paper::before {
  content: "";
  position: absolute;
  left: clamp(36px, 5vw, 64px);
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(208, 75, 59, .35), rgba(208, 75, 59, .35), transparent);
  opacity: .55;
}

/* Заголовок беседы */
.chat__header {
  text-align: center;
  margin: 0 0 36px;
  position: relative;
  z-index: 1;
}
.chat__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 12px;
  font-weight: 600;
}
.chat__eyebrow::before,
.chat__eyebrow::after {
  content: "";
  display: inline-block;
  width: 24px; height: 1.5px;
  background: currentColor;
  opacity: .6;
}
.chat__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 38px);
  color: var(--wine);
  margin: 0 0 8px;
  font-style: italic;
  line-height: 1.15;
}
.chat__subtitle {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--wine-deep);
  opacity: 0.7;
  margin: 0;
  font-style: italic;
}

/* Лента сообщений */
.chat__stream {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-msg {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .55s ease;
}
.chat-msg.is-visible {
  opacity: 1;
  transform: none;
}
.chat-msg--boy {
  grid-template-columns: 1fr 38px;
}

/* Аватар */
.chat-msg__avatar {
  grid-row: 1 / span 2;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -4px rgba(43, 20, 16, .35);
  border: 2px solid rgba(255, 251, 235, .8);
}
.chat-msg--ai .chat-msg__avatar {
  grid-column: 1;
  background: linear-gradient(135deg, var(--wine), var(--brick));
  color: var(--paper-soft);
}
.chat-msg--boy .chat-msg__avatar {
  grid-column: 2;
  background: linear-gradient(135deg, var(--honey), var(--amber));
  color: var(--wine-deep);
}

/* Метка имени */
.chat-msg__name {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 600;
  margin: 0 0 4px;
  display: block;
}
.chat-msg--ai .chat-msg__name { color: var(--wine); }
.chat-msg--boy .chat-msg__name {
  color: var(--amber);
  text-align: right;
  grid-column: 1;
}

/* Пузырь */
.chat-msg__bubble {
  position: relative;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.62;
  padding: 14px 18px;
  border-radius: 16px;
  max-width: 100%;
  word-wrap: break-word;
  hyphens: auto;
}
.chat-msg--ai .chat-msg__bubble {
  background: rgba(255, 251, 235, .85);
  border: 1px solid rgba(70, 38, 39, .14);
  color: var(--ink);
  border-top-left-radius: 4px;
  box-shadow: 0 6px 14px -10px rgba(43, 20, 16, .3);
}
.chat-msg--boy .chat-msg__bubble {
  grid-column: 1;
  background: linear-gradient(180deg, rgba(243, 219, 145, .55), rgba(241, 192, 111, .35));
  border: 1px solid rgba(196, 119, 49, .35);
  color: var(--ink);
  border-top-right-radius: 4px;
  box-shadow: 0 6px 14px -10px rgba(196, 119, 49, .45);
  text-align: left;
}

/* «Хвостик» у пузыря */
.chat-msg--ai .chat-msg__bubble::before {
  content: "";
  position: absolute;
  top: 10px; left: -7px;
  width: 14px; height: 14px;
  background: inherit;
  border-left: 1px solid rgba(70, 38, 39, .14);
  border-bottom: 1px solid rgba(70, 38, 39, .14);
  transform: rotate(45deg);
  border-radius: 2px;
}
.chat-msg--boy .chat-msg__bubble::before {
  content: "";
  position: absolute;
  top: 10px; right: -7px;
  width: 14px; height: 14px;
  background: linear-gradient(180deg, rgba(243, 219, 145, .55), rgba(241, 192, 111, .55));
  border-right: 1px solid rgba(196, 119, 49, .35);
  border-top: 1px solid rgba(196, 119, 49, .35);
  transform: rotate(45deg);
  border-radius: 2px;
}

/* Орнамент-разделитель внизу */
.chat__ornament {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 36px 0 22px;
  color: var(--amber);
  opacity: .7;
}
.chat__ornament span {
  height: 1px; width: 60px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
}
.chat__ornament svg { width: 16px; height: 16px; }

/* Декоративный «инпут» — неактивный, чтобы намекнуть на контекст */
.chat__input {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 251, 235, .7);
  border: 1px dashed rgba(196, 119, 49, .45);
  border-radius: 999px;
  margin-top: 10px;
  cursor: not-allowed;
}
.chat__input-text {
  flex: 1;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--wine-deep);
  opacity: .55;
}
.chat__input-hint {
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
  background: rgba(241, 192, 111, .35);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(196, 119, 49, .35);
}
.chat__input-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(196, 119, 49, .25);
  display: flex; align-items: center; justify-content: center;
  color: var(--wine);
  font-size: 13px;
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 24px 80px;
  max-width: 700px;
  margin: 0 auto;
}
.footer__ornament {
  display: flex; align-items: center; gap: 16px;
  justify-content: center;
  color: var(--amber);
  margin-bottom: 22px;
}
.footer__line {
  height: 1px; width: 80px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
}
.footer__end {
  font-family: var(--font-display);
  font-size: 32px;
  font-style: italic;
  color: var(--wine);
  margin: 0 0 24px;
}
.footer__top {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  color: var(--wine);
  background: rgba(241, 192, 111, .25);
  border: 1px solid rgba(196, 119, 49, .4);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: all .25s ease;
}
.footer__top:hover {
  background: var(--honey);
  border-color: var(--amber);
}
.footer__top::before { content: "↑"; }

/* ---------- Loading state ---------- */
.is-loading .story::before {
  content: "";
  display: block;
  width: 32px; height: 32px;
  border: 3px solid rgba(130, 38, 37, .2);
  border-top-color: var(--wine);
  border-radius: 50%;
  margin: 40px auto;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cover { padding: 90px 20px 40px; min-height: auto; }
  .cover__inner {
    grid-template-columns: 1fr;
    gap: 36px;
    text-align: center;
  }
  .cover__text { max-width: none; margin: 0 auto; }
  .cover__title::after { margin-left: auto; margin-right: auto; }
  .cover__image-wrap { max-width: 320px; order: -1; }

  .story { padding: 32px 18px 32px; }
  .page {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 80px;
  }
  .page--right .page__media,
  .page--right .page__body { order: initial; }

  .page__media { transform: rotate(0) !important; }
  .page__text { font-size: 16.5px; text-align: left; }
  .page__text .dropcap { font-size: 60px; }

  .chat { padding: 32px 16px 40px; }
  .chat__paper { padding: 28px 18px; }
  .chat__paper::before { display: none; }
  .chat-msg { grid-template-columns: 32px 1fr; gap: 10px; }
  .chat-msg--boy { grid-template-columns: 1fr 32px; }
  .chat-msg__avatar { width: 32px; height: 32px; font-size: 14px; }
  .chat-msg__bubble { font-size: 15px; padding: 12px 14px; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  .topbar__brand-text { display: none; }
  .lang__btn { padding: 6px 10px; font-size: 12px; }

  .cover__cta { padding: 12px 20px; font-size: 14px; }
  .footer__end { font-size: 26px; }

  .chat__input-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .page { opacity: 1; transform: none; }
  .chat-msg { opacity: 1; transform: none; }
}
