/* Лендинг и документы Сказителя. Та же «чернильная ночь», что в приложении, плюс бумага:
   страница книги под лампой. Блок историй перекрашивается палитрой выбранной истории. */
@property --s-bg { syntax: "<color>"; inherits: true; initial-value: #121110; }
@property --s-surface { syntax: "<color>"; inherits: true; initial-value: #1c1a18; }
@property --s-text { syntax: "<color>"; inherits: true; initial-value: #ece6dc; }
@property --s-muted { syntax: "<color>"; inherits: true; initial-value: #a59d91; }
@property --s-accent { syntax: "<color>"; inherits: true; initial-value: #d9a441; }

:root {
  --bg: #121110;
  --surface: #1c1a18;
  --text: #ece6dc;
  --muted: #a59d91;
  --accent: #d9a441;
  --line: rgba(236, 230, 220, 0.1);
  --paper: #e6dcc8;
  --paper-ink: #2a221b;
  --paper-muted: #75685a;
  --rust: #93421f;
  --serif: "Alegreya", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  --r-sm: 4px;
  --r-md: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow-x: clip;
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.defs { position: absolute; width: 0; height: 0; }
h1, h2 { text-wrap: balance; }

/* ---------- шапка ---------- */
.l-top {
  max-width: 1180px; margin: 0 auto; padding: 18px var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
}
.l-mark { font: 600 26px/1 var(--serif); letter-spacing: -0.012em; text-decoration: none; }
.l-mark span { color: var(--accent); }
.l-login {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px;
}

/* ---------- кнопка ---------- */
.l-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 28px;
  border-radius: var(--r-md); background: var(--accent); color: var(--bg);
  font: 700 16px/1 var(--sans); text-decoration: none; border: 0;
  transition-property: transform, background-color; transition-duration: 140ms; transition-timing-function: var(--ease-out);
}
.l-btn:active { transform: scale(0.96); }
@media (hover: hover) {
  .l-btn:hover { background: color-mix(in oklch, var(--accent) 86%, white); }
  .l-login:hover { color: var(--text); }
}

/* ---------- первый экран: слова и лист ---------- */
.hero {
  position: relative; max-width: 1180px; margin: 0 auto; padding: 32px var(--gutter) 96px;
  display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: clamp(32px, 6vw, 80px);
  align-items: start; min-height: calc(100svh - 80px);
}
/* свет лампы, под которой лежит лист */
.hero::before {
  content: ""; position: absolute; z-index: -1; right: -10%; top: 0; width: 70%; aspect-ratio: 1;
  background: radial-gradient(closest-side, rgba(217, 164, 65, 0.13), rgba(217, 164, 65, 0.04) 60%, transparent);
  pointer-events: none;
}
.hero__words { padding-top: clamp(8px, 7vh, 88px); }
.hero h1 { margin: 0 0 24px; font: 400 clamp(44px, 6.4vw, 82px)/0.98 var(--serif); letter-spacing: -0.024em; }
.hero h1 span { display: block; animation: rise 900ms var(--ease-out) both; }
.hero h1 span + span { font-style: italic; color: var(--accent); animation-delay: 140ms; }
.hero__lead { margin: 0 0 32px; max-width: 42ch; color: var(--muted); font-size: 18px; line-height: 1.6;
  animation: rise 900ms 260ms var(--ease-out) both; }
.hero .l-btn { animation: rise 900ms 360ms var(--ease-out) both; }
.hero__gift { margin: 14px 0 0; color: var(--muted); font-size: 14px; animation: rise 900ms 420ms var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }

/* лист бумаги */
.leaf {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-rows: auto 1fr auto; min-height: 560px;
  padding: clamp(22px, 3.6vw, 44px) clamp(22px, 4vw, 52px) clamp(18px, 2.4vw, 28px);
  border-radius: var(--r-sm); color: var(--paper-ink);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .15 0 0 0 .11 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(120% 90% at 30% 20%, #eee5d3, var(--paper) 55%, #d3c6ad);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9), 0 2px 0 rgba(255, 255, 255, 0.25) inset;
  animation: rise 1100ms 220ms var(--ease-out) both;
}
.leaf__head {
  display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; margin-bottom: 22px;
  border-bottom: 1px solid rgba(42, 34, 27, 0.16);
  font: 400 15px/1.3 var(--serif); font-variant: small-caps; letter-spacing: 0.04em; color: var(--paper-muted);
}
.leaf__text { font: 400 clamp(18px, 1.55vw, 20.5px)/1.62 var(--serif); }
.leaf__text p { margin: 0 0 0.8em; }
.leaf__text > p:first-child::first-letter {
  float: left; font-size: 3.5em; line-height: 0.82; padding: 0.06em 0.08em 0 0; color: var(--rust);
}
.leaf__text .you { font-style: italic; color: var(--rust); }
.leaf__text .you::before { content: "— "; }
.caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 1px; vertical-align: -0.15em;
  background: currentColor; animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.leaf__choices { display: grid; margin: 6px 0 4px; }
.leaf__choices[hidden] { display: none; }
.choice {
  display: flex; gap: 12px; align-items: baseline; width: 100%; min-height: 48px; padding: 12px 0;
  border: 0; border-top: 1px dashed rgba(42, 34, 27, 0.22); background: none; text-align: left;
  font: 400 19px/1.35 var(--serif); color: var(--paper-ink);
  opacity: 0; transform: translateY(8px);
  transition-property: opacity, transform, color; transition-duration: 420ms, 420ms, 140ms;
  transition-timing-function: var(--ease-out);
}
.choice.in { opacity: 1; transform: none; }
.choice b { font-weight: 400; font-style: italic; color: var(--rust); min-width: 1.4em; }
.choice:active { transform: scale(0.98); transition-duration: 120ms; }
.choice[disabled] { cursor: default; }
@media (hover: hover) { .choice:not([disabled]):hover { color: var(--rust); } }

/* «свободный ввод» в примере: строка, которую игрок как будто печатает сам */
.scribble {
  display: flex; align-items: flex-end; gap: 12px; margin: 4px 0 18px; padding: 10px 0 8px;
  border-bottom: 1.5px solid var(--paper-ink); font: 400 16px/1.5 var(--sans); color: var(--paper-ink);
}
.scribble span { flex: 1; min-height: 1.5em; }
.scribble i { font-style: normal; font-size: 12px; color: var(--paper-muted); white-space: nowrap; }

.after {
  margin-top: 6px; padding-top: 16px; border-top: 1px solid rgba(42, 34, 27, 0.16);
  font: 400 15px/1.55 var(--sans); color: var(--paper-muted);
  opacity: 0; transform: translateY(8px); transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.after.in { opacity: 1; transform: none; }
.after p { margin: 0 0 14px; max-width: 46ch; }
.after__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.after .l-btn { min-height: 46px; padding: 0 22px; background: var(--paper-ink); color: var(--paper); }
.after button.again {
  min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--paper-ink);
  text-decoration: underline; text-decoration-color: rgba(42, 34, 27, 0.3); text-underline-offset: 4px;
}
@media (hover: hover) { .after .l-btn:hover { background: #3d3127; } }

.leaf__folio {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 22px;
  font-size: 12px; color: var(--paper-muted);
}
.leaf__folio span:last-child { font: italic 400 15px/1 var(--serif); white-space: nowrap; }

/* клякса при выборе хода */
.blot {
  position: absolute; z-index: -1; width: 300px; height: 300px; margin: -150px 0 0 -150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(36, 26, 18, 0.55) 0 38%, rgba(36, 26, 18, 0.18) 56%, transparent 70%);
  filter: url(#ink-edge); pointer-events: none; mix-blend-mode: multiply;
  animation: blot 1100ms var(--ease-out) forwards;
}
@keyframes blot {
  from { opacity: 1; transform: scale(0.2); }
  55% { opacity: 0.8; }
  to { opacity: 0; transform: scale(1.25); }
}

/* ---------- переплёты: палитра выбранной истории ---------- */
.worlds {
  --s-font: "Alegreya";
  background: var(--s-bg); color: var(--s-text);
  transition-property: --s-bg, --s-surface, --s-text, --s-muted, --s-accent;
  transition-duration: 700ms; transition-timing-function: var(--ease-out);
}
.worlds.instant { transition-duration: 0s; }
.worlds > * { max-width: 1180px; margin-left: auto; margin-right: auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.worlds { padding: 104px 0 96px; }
.worlds__head h2 { margin: 0 0 10px; font: 400 clamp(32px, 4.4vw, 54px)/1.04 var(--s-font), var(--serif); letter-spacing: -0.02em; }
.worlds__head p { margin: 0 0 40px; color: var(--s-muted); font-size: 17px; }
.worlds__body { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.tomes { list-style: none; margin: 0; padding: 0; }
.tome {
  display: grid; grid-template-columns: 52px 1fr; column-gap: 8px; width: 100%; padding: 22px 0;
  border: 0; border-top: 1px solid color-mix(in srgb, var(--s-text) 14%, transparent); background: none;
  text-align: left; color: var(--s-text);
  transition-property: transform; transition-duration: 140ms;
}
.tomes li:last-child .tome { border-bottom: 1px solid color-mix(in srgb, var(--s-text) 14%, transparent); }
.tome:active { transform: scale(0.985); }
.tome__no { grid-row: span 2; padding-top: 6px; font: italic 400 20px/1 var(--serif); color: var(--s-muted); }
.tome__title { font: 400 clamp(22px, 2.3vw, 30px)/1.15 var(--t-font), var(--serif); transition: color 300ms var(--ease-out); }
.tome__genre { margin-top: 6px; color: var(--s-muted); font-size: 14px; }
.tome[aria-selected="true"] .tome__title, .tome[aria-selected="true"] .tome__no { color: var(--s-accent); }
@media (hover: hover) { .tome[aria-selected="false"]:hover .tome__title { color: var(--t-accent); } }

.tome-stage { display: grid; }
.tome-panel { grid-area: 1 / 1; margin: 0; }
.tome-panel[hidden] { display: none; }
.tome-panel.enter { animation: rise 600ms var(--ease-out) both; }
.tome-panel img, .cover-blank {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px;
  outline: 1px solid rgba(255, 255, 255, 0.1); outline-offset: -1px; background: var(--s-surface);
}
.cover-blank { display: grid; place-items: center; padding: 24px; text-align: center;
  font: 400 clamp(28px, 4vw, 44px)/1.1 var(--s-font), var(--serif); color: var(--s-accent); }
.tome-panel figcaption { margin-top: 20px; max-width: 54ch; font: italic 400 20px/1.5 var(--serif); }
.worlds__more p { margin: 56px 0 0; max-width: 64ch; color: var(--s-muted); font-size: 16px; }

/* ---------- оглавление ---------- */
.contents { max-width: 900px; margin: 0 auto; padding: 112px var(--gutter) 64px; }
.contents h2 { margin: 0 0 28px; font: 400 clamp(36px, 4.6vw, 56px)/1 var(--serif); letter-spacing: -0.02em; }
.toc { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.toc li {
  display: grid; grid-template-columns: auto minmax(24px, 1fr) auto; align-items: baseline; column-gap: 12px;
  padding: 22px 0; border-top: 1px solid var(--line);
  opacity: 0; transform: translateY(12px);
  transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.toc li.in { opacity: 1; transform: none; }
.toc__t { font: 400 clamp(20px, 2.3vw, 27px)/1.2 var(--serif); }
.toc__t::before { counter-increment: ch; content: counter(ch, upper-roman) ". "; color: var(--accent); font-style: italic; }
.toc__dots {
  height: 4px; align-self: end; margin-bottom: 0.45em;
  background: radial-gradient(circle, var(--muted) 1px, transparent 1.6px) 0 50% / 9px 4px repeat-x;
  opacity: 0.7; clip-path: inset(0 100% 0 0);
  transition: clip-path 1100ms var(--ease-out); transition-delay: calc(var(--d, 0ms) + 200ms);
}
.toc li.in .toc__dots { clip-path: inset(0 0 0 0); }
.toc__p { font: italic 400 20px/1 var(--serif); color: var(--muted); font-variant-numeric: tabular-nums; }
.toc p { grid-column: 1 / -1; margin: 10px 0 0; max-width: 62ch; color: var(--muted); }

/* ---------- чернила ---------- */
.ink { max-width: 1180px; margin: 0 auto; padding: 96px var(--gutter); }
.ink__head { max-width: 640px; }
.ink h2 { margin: 0 0 14px; font: 400 clamp(36px, 4.6vw, 56px)/1 var(--serif); letter-spacing: -0.02em; }
.ink__rule { margin: 0 0 10px; font: italic 400 24px/1.35 var(--serif); color: var(--accent); }
.ink__free { margin: 0 0 44px; color: var(--muted); font-size: 17px; }
.vials { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.vial {
  display: grid; grid-template-columns: 72px 1fr; grid-template-rows: auto auto 1fr; column-gap: 20px;
  padding-top: 28px; border-top: 1px solid var(--line);
}
.vial__glass {
  grid-row: 1 / 4; position: relative; width: 56px; height: 92px; margin-top: 12px; overflow: hidden;
  border: 1.5px solid rgba(236, 230, 220, 0.38); border-radius: 12px 12px 20px 20px;
}
.vial__glass::before { /* горлышко */
  content: ""; position: absolute; top: -1px; left: 50%; width: 22px; height: 10px; margin-left: -11px;
  border: 1.5px solid rgba(236, 230, 220, 0.38); border-top: 0; border-radius: 0 0 4px 4px; background: var(--bg);
}
.vial__glass span {
  position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(0);
  background: linear-gradient(to top, color-mix(in oklch, var(--accent) 70%, black), var(--accent));
  transition: transform 1400ms var(--ease-out); transition-delay: var(--d, 0ms);
}
.vial.in .vial__glass span { transform: scaleY(var(--fill)); }
.vial__ink { font: 400 28px/1.1 var(--serif); }
.vial__price { margin-top: 4px; font: 700 22px/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.vial__note { margin-top: 6px; color: var(--muted); font-size: 14px; }
.ink__facts { list-style: none; margin: 48px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 32px; }
.ink__facts li { position: relative; padding-left: 20px; }
.ink__facts li::before { /* капля */
  content: ""; position: absolute; left: 0; top: 0.62em; width: 8px; height: 8px;
  border-radius: 50% 0 50% 50%; background: var(--accent); transform: rotate(-45deg);
}
.ink__pay { margin: 28px 0 0; max-width: 70ch; color: var(--muted); font-size: 14px; }
.ink a, .worlds a, .colophon a, .doc a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
@media (hover: hover) { .ink a:hover, .colophon a:hover, .doc a:hover { color: var(--accent); } }

/* ---------- чистая страница ---------- */
.blank {
  position: relative; width: calc(100% - 2 * var(--gutter)); max-width: 620px; margin: 48px auto 120px; padding: 44px clamp(22px, 5vw, 56px) 40px;
  border-radius: var(--r-sm); color: var(--paper-ink);
  background: radial-gradient(120% 90% at 30% 20%, #eee5d3, var(--paper) 55%, #d3c6ad);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
}
.blank__chapter { margin: 0; font: 400 16px/1 var(--serif); font-variant: small-caps; letter-spacing: 0.06em; color: var(--paper-muted); }
.blank__line { margin: 26px 0 30px; height: 1.6em; border-bottom: 1px solid rgba(42, 34, 27, 0.25); font: 400 24px/1.6 var(--serif); }
.blank h2 { margin: 0 0 26px; font: 400 clamp(30px, 4vw, 42px)/1.08 var(--serif); letter-spacing: -0.02em; }
.blank .l-btn { background: var(--paper-ink); color: var(--paper); }
.blank__login { display: inline-flex; align-items: center; min-height: 44px; margin-left: 18px; color: var(--paper-muted); font-size: 15px; }
@media (hover: hover) { .blank .l-btn:hover { background: #3d3127; } }

/* ---------- выходные данные ---------- */
.colophon {
  max-width: 900px; margin: 0 auto; padding: 40px var(--gutter) calc(48px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px;
}
.colophon__title { margin: 0 0 12px; font: 400 17px/1 var(--serif); font-variant: small-caps; letter-spacing: 0.06em; color: var(--text); }
.colophon__lead { margin: 0 0 16px; max-width: 62ch; }
.colophon__lead b { color: var(--text); font-weight: 600; }
.colophon__req, .doc__req { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0 0 16px; }
.colophon__req:empty, .doc__req:empty { display: none; }
.colophon__req dt, .doc__req dt { color: var(--muted); }
.colophon__req dd, .doc__req dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.colophon__line { margin: 0 0 8px; max-width: 70ch; }
.colophon__docs { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 18px; }
.colophon__docs a { display: inline-flex; align-items: center; min-height: 40px; color: var(--text); }

/* ---------- документы ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 32px var(--gutter) 72px; }
.doc__kicker { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.doc h1 { margin: 0 0 22px; font: 400 clamp(34px, 5vw, 50px)/1.05 var(--serif); letter-spacing: -0.02em; }
.doc h2 { margin: 44px 0 12px; font: 600 22px/1.25 var(--serif); }
.doc__lead { font: italic 400 20px/1.5 var(--serif); color: var(--text); }
.doc p, .doc li { max-width: 68ch; line-height: 1.7; }
.doc ol, .doc ul { padding-left: 1.3em; }
.doc li { margin-bottom: 8px; }
.doc li::marker { color: var(--muted); }
.doc code { font-size: 0.92em; padding: 1px 5px; border-radius: 4px; background: var(--surface); }
.doc__table { width: 100%; max-width: 520px; margin: 12px 0; border-collapse: collapse; font-size: 15px; }
.doc__table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; }
.doc__table th, .doc__table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: 16px; gap: 40px; }
  .hero::before { right: -40%; top: 30%; width: 120%; }
  .leaf { min-height: 0; }
  .worlds__body { grid-template-columns: minmax(0, 1fr); }
  .vials { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .vial { padding: 22px 0; }
}
@media (max-width: 520px) {
  .leaf__folio span:first-child { max-width: 24ch; }
  .blank__login { margin: 8px 0 0; display: flex; }
  .toc li { grid-template-columns: minmax(0, 1fr) auto; }
  .toc__dots { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .caret { animation: none; }
}
