/* Скетчбук: бумага, графит, цветные карандаши. Всё «рисуется» при прокрутке (js/sketch.js). */
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-04FF; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-024F, U+2000-206F, U+2190-21FF; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-cyrillic-600-normal.woff2) format("woff2"); font-weight: 600; unicode-range: U+0400-04FF; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-latin-600-normal.woff2) format("woff2"); font-weight: 600; unicode-range: U+0000-024F, U+2000-206F, U+2190-21FF; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-cyrillic-500-italic.woff2) format("woff2"); font-style: italic; unicode-range: U+0400-04FF; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(../fonts/cg-latin-500-italic.woff2) format("woff2"); font-style: italic; unicode-range: U+0000-024F, U+2000-206F, U+2190-21FF; font-display: swap; }
@font-face { font-family: "Neucha"; src: url(../fonts/nc-cyrillic.woff2) format("woff2"); unicode-range: U+0400-04FF; font-display: swap; }
@font-face { font-family: "Neucha"; src: url(../fonts/nc-latin.woff2) format("woff2"); unicode-range: U+0000-024F, U+2000-206F; font-display: swap; }

:root {
  --paper: #efe9dc;
  --graphite: #36363a;
  --graphite-2: #6d6c70;
  --red: #b0412f;
  --blue: #2f4a7a;
  --violet: #5d3f9e;
  --hand: "Neucha", "Segoe Print", cursive;   /* печатный почерк: Marck читался тяжело */
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--graphite); font-family: "Cormorant", Georgia, serif; font-size: 20px; line-height: 1.5;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' seed='3'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .32  0 0 0 0 .28  0 0 0 .14 0'/></filter><rect width='260' height='260' filter='url(%23f)'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='900'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='3' seed='9'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .48  0 0 0 0 .38  0 0 0 .12 0'/></filter><rect width='900' height='900' filter='url(%23g)'/></svg>");
  font-variant-numeric: lining-nums;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: rgba(93, 63, 158, .2); }
:focus-visible { outline: 2px dashed var(--violet); outline-offset: 4px; }

/* ---------------------------------------------------------------- панель */
.sk-bar { position: fixed; inset: 0 0 auto; z-index: 20; display: flex; gap: 10px; align-items: center; padding: max(12px, env(safe-area-inset-top)) 18px 12px; pointer-events: none;
  background: linear-gradient(var(--paper) 55%, rgba(239, 233, 220, 0)); }
.sk-bar .gap { flex: 1; }
.sk-btn { position: relative; pointer-events: auto; border: 0; background: none; cursor: pointer; font: 22px var(--hand); color: var(--graphite); padding: 4px 14px; }
.sk-btn .btn-ink { position: absolute; left: -6px; top: -6px; pointer-events: none; overflow: visible; }
.sk-btn .btn-ink .pen { stroke: var(--graphite-2); stroke-width: 1.4; }
.sk-btn:hover .btn-ink .pen { stroke: var(--red); }
.sk-btn[aria-pressed="true"] { color: var(--violet); }

/* ---------------------------------------------------------------- страница */
.sk { max-width: 1120px; margin: 0 auto; padding: 90px 28px 120px; }
.hero { position: relative; min-height: 92vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.hero .title { width: min(900px, 100%); height: auto; overflow: visible; }
.hero .title text { font: 600 118px "Cormorant", serif; letter-spacing: .14em; fill: transparent; stroke: var(--graphite); stroke-width: 1.4; stroke-dasharray: 2600; stroke-dashoffset: 2600; }
.hero.titling .title text { animation: write 2.4s cubic-bezier(.5, 0, .4, 1) forwards; }
.hero.titled .title text { stroke-dashoffset: 0; fill: var(--graphite); transition: fill 1s; }
@keyframes write { to { stroke-dashoffset: 0; } }
.hero .sub { font: 34px var(--hand); color: var(--red); margin: 0 0 10px; }
.hero-art { width: min(520px, 90%); margin: 10px auto 0; }
.scroll-hint { font: 24px var(--hand); color: var(--graphite-2); margin-top: 18px; }

.sk-sec { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 64px; padding: 80px 30px 90px; }
.sk-sec .col { min-width: 0; }
.sk-sec .col > :first-child { margin-top: 0; }
svg.ink { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 0; }
.sk-sec .col, .hero > * { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- линии */
.pen { fill: none; stroke: var(--graphite); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.ink .pen:not(.ready) { opacity: 0; }
.pen.done { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
.pen.red { stroke: var(--red); stroke-width: 2; }
.pen.blue { stroke: var(--blue); stroke-width: 1.5; }
.pen.thick { stroke-width: 2.6; }
.pen.faint { opacity: .45; }
.pen.doodle { stroke: var(--graphite-2); stroke-width: 1.3; opacity: .6; }

/* ---------------------------------------------------------------- текст пишется */
.w { opacity: 0; filter: blur(2px); transition: opacity .35s, filter .35s; transition-delay: calc(min(var(--i, 0), 600) * 9ms); }
.writing .w { opacity: 1; filter: none; }
.k { font: 20px var(--hand); color: var(--red); letter-spacing: .06em; margin: 0 0 6px; display: inline-block; }
.h { font: 46px/1.1 var(--hand); color: var(--graphite); margin: 0 0 22px; }
.p { margin: 0 0 14px; }
.h + .p::first-letter { font: 56px/.8 var(--hand); float: left; color: var(--red); padding: 6px 8px 0 0; }
.p em, .list em { font-style: italic; font-weight: 600; }
.note { font: 26px/1.3 var(--hand); color: var(--blue); margin: 24px 6px 26px; transform: rotate(-1.2deg); }
.sign { font: 24px var(--hand); text-align: right; color: var(--graphite-2); }
.todo { display: none; }
.list { list-style: none; padding: 0; margin: 0 0 14px; }
.list li { position: relative; padding-left: 28px; margin-bottom: 10px; }
.list li::before { content: "✗"; position: absolute; left: 0; top: -2px; font: 22px var(--hand); color: var(--red); }
.fine { font-size: 15px; color: var(--graphite-2); font-style: italic; border-top: 1px dashed rgba(54, 54, 58, .3); padding-top: 10px; margin-top: 18px; }

.toc { list-style: none; padding: 0 0 0 4px; margin: 0; }
.toc li { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; font: 26px var(--hand); }
.toc a { color: var(--graphite); text-decoration: none; }
.toc a:hover { color: var(--red); }
.toc .dots { flex: 1; border-bottom: 2px dotted rgba(54, 54, 58, .35); }
.toc .n { color: var(--graphite-2); }
body .toc .n { display: none; }

.tiers { list-style: none; padding: 0; margin: 6px 0 0; }
.tiers li { display: grid; grid-template-columns: 46px 1fr; padding: 5px 0; border-bottom: 1px dashed rgba(54, 54, 58, .2); }
.tiers li b { grid-row: span 2; font: 26px var(--hand); color: var(--red); font-weight: 400; }
.tiers li span:first-of-type { font-weight: 600; }
.tiers li span + span { color: var(--graphite-2); font-size: 17px; }
.tiers li.on b { color: var(--violet); }
.stages, .steps { list-style: none; padding: 0; margin: 8px 0 18px; counter-reset: c; }
.stages li, .steps li { counter-increment: c; position: relative; padding-left: 42px; margin-bottom: 12px; }
.stages li::before, .steps li::before { content: counter(c); position: absolute; left: 0; top: -4px; font: 30px var(--hand); color: var(--red); }
.stages b, .steps b { display: block; }
.stages span, .steps span { color: var(--graphite-2); font-size: 18px; }
.perks { list-style: none; padding: 0; }
.perks li { padding-left: 26px; position: relative; margin-bottom: 6px; }
.perks li::before { content: "☆"; position: absolute; left: 0; color: var(--violet); }
.mods { list-style: none; padding: 0; margin: 0; }
.mods li { margin-bottom: 10px; }
.mods li b { font: 26px var(--hand); color: var(--red); font-weight: 400; }
.mods span { color: var(--graphite-2); font-style: italic; }

.links { display: flex; flex-wrap: wrap; gap: 18px; margin: 26px 0 10px; }
.links a { position: relative; display: inline-block; padding: 8px 18px; font: 26px var(--hand); color: var(--graphite); text-decoration: none; transition: transform .2s, color .2s; }
.links a.main { color: var(--red); font-size: 30px; }
.links a:hover { transform: rotate(-2deg) scale(1.05); color: var(--violet); }
.links-hint { display: none; }

/* ---------------------------------------------------------------- рисунки */
.art { margin: 18px 0 8px; position: relative; }
.art-sk { position: relative; }
.art-svg { display: block; width: 100%; height: auto; max-height: 460px; overflow: visible; }
.art-img { filter: grayscale(1) contrast(1.25) brightness(1.05); mix-blend-mode: multiply; }
.mask-pen { fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; }
.art-svg .frame { stroke: var(--graphite-2); opacity: .7; }
.art .cap, .art figcaption { font: 22px var(--hand); color: var(--graphite-2); text-align: center; margin-top: 6px; transform: rotate(-.8deg); }
.tape { position: absolute; width: 90px; height: 26px; background: rgba(230, 214, 160, .55); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); z-index: 2; }
.tape.t1 { left: -18px; top: -8px; transform: rotate(-32deg); }
.tape.t2 { right: -18px; top: -8px; transform: rotate(30deg); }
.art.missing { display: none; }

/* древо и руны — карандашом */
.tree, .runes { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; overflow: visible; }
.ink-path { fill: none; stroke: var(--graphite); stroke-linecap: round; stroke-linejoin: round; }
.ink-art:not(.draw) .ink-path, .ink-art:not(.draw) .tree-node { opacity: 0; }
.draw .ink-path { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: write var(--dur, 1.6s) var(--delay, 0s) cubic-bezier(.5, 0, .3, 1) forwards; }
.tree-node circle { fill: var(--paper); stroke: var(--red); stroke-width: 1.6; }
.tree-node text { font: 15px var(--hand); fill: var(--red); text-anchor: middle; dominant-baseline: central; }
.tree-node .lbl { fill: var(--graphite-2); text-anchor: start; }
.tree-node.on circle { fill: var(--red); } .tree-node.on text:not(.lbl) { fill: var(--paper); }
.draw .tree-node { opacity: 0; animation: pop .5s var(--delay) forwards; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
.runes .ink-path { stroke: var(--violet); }
.runes .spin { transform-origin: 150px 150px; animation: spin 90s linear infinite; }
.runes .spin.rev { animation-direction: reverse; animation-duration: 140s; }
@keyframes spin { to { transform: rotate(360deg); } }
.decor { display: none; }

/* ---------------------------------------------------------------- карандаш */
.pencil { position: fixed; left: 0; top: 0; z-index: 50; width: 26px; pointer-events: none; opacity: 0;
  transform: translate(calc(var(--x, -100px) - 2px), calc(var(--y, -100px) - 4px)) rotate(28deg); transform-origin: 50% 0; transition: opacity .3s; }
.pencil.on { opacity: 1; }
.pencil svg { display: block; width: 100%; filter: drop-shadow(6px 8px 5px rgba(0, 0, 0, .25)); }
.pc-wood { fill: #e8c99a; } .pc-lead { fill: #2b2b2e; } .pc-body { fill: #e6b422; } .pc-line { fill: #c99512; }
.pc-band { fill: #b8b8b8; } .pc-eraser { fill: #e48a8a; }

.fail { text-align: center; padding: 40px; font: 26px var(--hand); }

@media (max-width: 820px) {
  body { font-size: 18px; }
  .sk { padding: 76px 16px 80px; }
  .sk-sec { grid-template-columns: 1fr; gap: 20px; padding: 50px 6px 60px; }
  .hero .title text { font-size: 150px; letter-spacing: .06em; }
  .h { font-size: 38px; }
  .sk-btn { font-size: 19px; padding: 4px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .w { opacity: 1; filter: none; transition: none; }
  .hero .title text { stroke-dashoffset: 0; fill: var(--graphite); animation: none; }
  .draw .ink-path { animation: none; stroke-dashoffset: 0; }
  .draw .tree-node, .ink-art:not(.draw) .ink-path, .ink-art:not(.draw) .tree-node { opacity: 1; animation: none; }
  .runes .spin { animation: none; }
}
