/* ========== Токены ========== */
:root {
  --paper: #f4eee3;
  --paper-2: #ece4d5;
  --card: #fffcf6;
  --ink: #1f1b17;
  --ink-soft: #3f3831;
  --muted: #7b7165;
  --line: rgba(31, 27, 23, .14);
  --accent: #e5533d;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);

  --f-sans: "Manrope", system-ui, sans-serif;
  --f-serif: "Lora", Georgia, serif;
  --f-display: "Unbounded", "Manrope", sans-serif;
  --f-hand: "Caveat", "Comic Sans MS", cursive;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 4vw, 32px);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--f-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* зерно ризографа поверх всего */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .12  0 0 0 0 .1  0 0 0 0 .08  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
::selection { background: var(--accent); color: #fff; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px;
}
.skip:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ========== Сетка ========== */
.wrap { width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
.wrap-narrow { max-width: calc(700px + var(--gutter) * 2); }
.wrap-normal { max-width: calc(940px + var(--gutter) * 2); }
.wrap-wide { max-width: calc(1240px + var(--gutter) * 2); }
.wrap-full { max-width: none; padding: 0; }

/* ========== Шрифты блоков ========== */
.font-sans { font-family: var(--f-sans); }
.font-serif { font-family: var(--f-serif); }
.font-display { font-family: var(--f-display); letter-spacing: -.01em; }
.font-hand { font-family: var(--f-hand); font-size: 1.4em; line-height: 1.3; }
.font-mono { font-family: var(--f-mono); font-size: .9em; }

.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }

/* ========== Шапка ========== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px dashed var(--line);
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 72px; max-width: calc(1240px + var(--gutter) * 2); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-logo { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font: 700 1.15rem/1.1 var(--f-display); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tagline { font: 400 .68rem/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.site-nav { display: flex; gap: 6px; }
.site-nav a {
  position: relative; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: .95rem;
  transition: background .2s, color .2s;
}
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }

.nav-toggle { display: none; }

@media (max-width: 760px) {
  .header-row { min-height: 64px; }
  .nav-toggle {
    display: grid; place-content: center; gap: 6px;
    width: 44px; height: 44px; border: 1.5px solid var(--ink); border-radius: 12px;
    background: transparent; cursor: pointer; flex-shrink: 0;
  }
  .nav-toggle span { display: block; width: 18px; height: 2px; background: var(--ink); transition: transform .25s; }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; gap: 4px; padding: 12px var(--gutter) 20px;
    background: var(--paper); border-bottom: 1px dashed var(--line);
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 16px; font-size: 1.05rem; }
}

/* ========== Заголовок страницы ========== */
.page-hero { padding: clamp(48px, 8vw, 96px) 0 8px; }
.page-title {
  margin: 0;
  font: 700 clamp(2.1rem, 6vw, 4rem)/1.02 var(--f-display);
  letter-spacing: -.03em;
  text-shadow: .06em .05em 0 color-mix(in srgb, var(--accent) 55%, transparent);
  overflow-wrap: anywhere;
}

/* ========== Блоки ========== */
.block { padding-top: var(--space-top, 32px); padding-bottom: var(--space-bottom, 32px); }
.blocks > .block:first-child { padding-top: max(var(--space-top), 24px); }

.heading .kicker, .kicker {
  margin: 0 0 14px;
  font: 600 .74rem/1.4 var(--f-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
}
.heading .kicker::before, .not-found .kicker::before { content: "✦ "; }
.h { margin: 0; line-height: 1.05; letter-spacing: -.02em; overflow-wrap: anywhere; text-wrap: balance; }
.h1 { font-size: clamp(2.4rem, 7.5vw, 5.4rem); font-weight: 900; }
.h2 { font-size: clamp(1.75rem, 4.2vw, 3rem); font-weight: 700; }
.h3 { font-size: clamp(1.3rem, 2.6vw, 1.75rem); font-weight: 700; line-height: 1.2; }
.heading.font-display .h1 { text-shadow: .05em .045em 0 color-mix(in srgb, var(--accent) 60%, transparent); }
.heading.font-serif .h { font-weight: 600; letter-spacing: -.01em; }
.heading.font-hand .h { font-size: 1.35em; font-weight: 700; letter-spacing: 0; line-height: 1; }
.heading.font-hand .h1 { font-size: clamp(3.2rem, 10vw, 7rem); }
.heading.font-mono .h { letter-spacing: -.04em; }

/* текст */
.prose { color: var(--ink-soft); line-height: 1.7; overflow-wrap: break-word; }
.prose.size-s { font-size: .95rem; }
.prose.size-m { font-size: 1.07rem; }
.prose.size-l { font-size: clamp(1.18rem, 2.2vw, 1.38rem); line-height: 1.6; color: var(--ink); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1em; }
.prose h3, .prose h4 { font-family: var(--f-display); color: var(--ink); line-height: 1.25; margin: 1.8em 0 .6em; letter-spacing: -.01em; }
.prose h3 { font-size: 1.14em; }
.block-text .prose > h3:first-child { margin-top: .9em; }
.prose h4 { font-size: 1em; }
.prose strong, .prose b { color: var(--ink); font-weight: 700; }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; transition: background .2s; }
.prose a:hover { background: var(--accent-soft); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .35em 0; padding-left: .2em; }
.prose ul li::marker { content: "✦  "; color: var(--accent); font-size: .8em; }
.prose ol li::marker { color: var(--accent); font-weight: 700; font-family: var(--f-mono); }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); font-style: italic; }
.prose mark { background: var(--accent-soft); color: var(--ink); padding: 0 .15em; border-radius: 3px; }
.prose.font-hand { color: var(--ink); }
.prose.font-hand ul li::marker { font-size: .6em; }

.token-missing { outline: 1.5px dashed var(--accent); outline-offset: 1px; background: var(--accent-soft); border-radius: 3px; padding: 0 3px; font-size: .9em; }

/* ========== Картинки и рамки ========== */
.single-image { margin: 0; }
.single-image a { display: block; }
.frame { display: block; position: relative; }
.frame img { width: 100%; }
.frame-round img { border-radius: calc(var(--radius) + 8px); }
.frame-offset { border: 2px solid var(--ink); box-shadow: 10px 10px 0 var(--accent); }
.frame-paper {
  background: var(--card);
  padding: 12px 12px 44px;
  box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 12px 30px -12px rgba(60, 40, 20, .35);
  transform: rotate(-1.2deg);
}
.frame-paper::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 110px; height: 26px;
  transform: translateX(-50%) rotate(2deg);
  background: color-mix(in srgb, var(--accent) 35%, rgba(255, 255, 255, .55));
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.wrap-full .frame-offset, .wrap-full .frame-paper { margin: 0 var(--gutter); }

/* ========== Фото с подписью ========== */
.figure { margin: 0; display: grid; gap: clamp(20px, 4vw, 56px); }
.figure-bottom { gap: 18px; }
.figure-bottom .figure-text { max-width: 720px; }
.figure-bottom .figure-media + .figure-text { font-size: .98rem; }
.figure-left, .figure-right { grid-template-columns: 1fr 1fr; }
.figure-left .figure-text { order: -1; }
.valign-top { align-items: start; }
.valign-center { align-items: center; }
.valign-bottom { align-items: end; }
.wrap-full .figure-text { padding: 0 var(--gutter); }
@media (max-width: 760px) {
  .figure-left, .figure-right { grid-template-columns: 1fr; gap: 20px; }
  .figure-left .figure-text { order: 0; }
}

/* ========== Карусель ========== */
.carousel { --gap: 16px; position: relative; }
.carousel-track {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: calc((100% - var(--gap) * (var(--per-view) - 1)) / var(--per-view));
  gap: var(--gap);
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  align-items: start;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide { margin: 0; scroll-snap-align: start; }
.carousel-media { aspect-ratio: var(--ratio); overflow: hidden; border-radius: var(--radius); background: var(--paper-2); }
.carousel-media img { width: 100%; height: 100%; object-fit: cover; }
.ratio-auto .carousel-media { aspect-ratio: auto; }
.ratio-auto .carousel-media img { height: auto; }
.carousel-slide figcaption { margin-top: 10px; font-size: .92rem; color: var(--muted); line-height: 1.5; }
.carousel-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.wrap-full .carousel-controls { padding: 0 var(--gutter); }
.wrap-full .carousel-media { border-radius: 0; }
.carousel-btn {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  display: grid; place-items: center; cursor: pointer; transition: background .2s, color .2s, transform .15s;
}
.carousel-btn:hover { background: var(--ink); color: var(--paper); }
.carousel-btn:active { transform: scale(.94); }
.carousel-btn:disabled { opacity: .3; pointer-events: none; }
.carousel-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.carousel-dots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.carousel-dots button { width: 8px; height: 8px; padding: 0; border-radius: 99px; border: 0; background: var(--line); cursor: pointer; transition: width .25s, background .25s; }
.carousel-dots button.active { width: 26px; background: var(--accent); }
@media (max-width: 760px) {
  .carousel-track { grid-auto-columns: calc((100% - var(--gap) * (min(var(--per-view), 2) - 1)) / min(var(--per-view), 2)); }
  .carousel[style*="--per-view: 1"] .carousel-track { grid-auto-columns: 100%; }
}

/* ========== Цитата ========== */
.quote { margin: 0; position: relative; padding: 36px 0 0 clamp(0px, 5vw, 56px); }
.quote::before {
  content: "“"; position: absolute; left: 0; top: -.15em;
  font: 900 6rem/1 var(--f-display); color: var(--accent);
}
.quote-body { font-size: clamp(1.25rem, 2.6vw, 1.7rem); line-height: 1.45; color: var(--ink); }
.quote.font-hand .quote-body { font-size: clamp(1.8rem, 3.6vw, 2.4rem); line-height: 1.2; }
.quote-body p { margin: 0 0 .6em; }
.quote-body p:last-child { margin: 0; }
.quote-author { margin-top: 18px; font: 600 .78rem/1.4 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.quote-author::before { content: "✦ "; color: var(--accent); }

/* ========== Кнопка ========== */
.button-row { display: flex; }
.button-row.align-left { justify-content: flex-start; }
.button-row.align-center { justify-content: center; }
.button-row.align-right { justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 14px 30px;
  font: 700 .95rem/1.2 var(--f-display); letter-spacing: -.005em; text-decoration: none; text-align: center;
  border: 2px solid var(--ink); border-radius: 14px;
  transition: transform .15s ease, box-shadow .15s ease, background .2s, color .2s;
}
.btn-filled { background: var(--ink); color: var(--paper); box-shadow: 5px 5px 0 var(--accent); }
.btn-filled:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--accent); }
.btn-filled:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--accent); }
.btn-outline { background: transparent; color: var(--ink); }
.btn-outline:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ========== Разделитель ========== */
.divider { display: flex; align-items: center; justify-content: center; min-height: 20px; }
.divider-line { border-top: 1.5px solid var(--ink); opacity: .85; }
.divider-dots { height: 6px; background: radial-gradient(circle, var(--ink) 1.6px, transparent 2px) 0 50% / 14px 6px repeat-x; opacity: .6; min-height: 6px; }
.divider-stars { gap: 28px; color: var(--accent); font-size: 1.1rem; }
.divider-wave svg { width: 100%; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* ========== Пустые состояния ========== */
.empty-page { padding: 80px var(--gutter); color: var(--muted); text-align: center; }
.not-found { padding: clamp(64px, 12vw, 140px) 0; }
.not-found .h1 { margin-bottom: 24px; }
.not-found .prose { margin-bottom: 36px; }

/* ========== Подвал ========== */
.site-footer {
  margin-top: 72px;
  background: var(--ink); color: #e9e1d3;
  padding: 64px 0 28px;
  position: relative;
}
.site-footer::before {
  content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 15px;
  background: radial-gradient(circle at 10px -3px, transparent 12px, var(--ink) 12.5px) 0 0 / 20px 15px repeat-x;
}
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 40px 32px; max-width: calc(1240px + var(--gutter) * 2); }
.footer-brand { font: 700 1.5rem/1.1 var(--f-display); letter-spacing: -.02em; color: #fff; margin-bottom: 14px; }
.footer-about p { margin: 0; font-size: .92rem; line-height: 1.65; color: #b9b0a3; max-width: 40ch; }
.footer-title { margin: 6px 0 16px; font: 600 .72rem/1.4 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) 55%, #fff); }
.footer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .93rem; }
.footer-list a { text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .2s, color .2s; }
.footer-list a:hover { color: #fff; border-color: var(--accent); }
.socials { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.social {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 12px; border-radius: 999px;
  border: 1px solid rgba(233, 225, 211, .25); text-decoration: none; font-weight: 600; font-size: .92rem;
  transition: background .2s, border-color .2s, color .2s;
}
.social svg { width: 20px; height: 20px; fill: currentColor; }
.social:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  margin-top: 48px; padding-top: 22px; border-top: 1px dashed rgba(233, 225, 211, .2);
  font: 400 .78rem/1.5 var(--f-mono); color: #8f867a; max-width: calc(1240px + var(--gutter) * 2);
}
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; }
}

.admin-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  padding: 11px 18px; border-radius: 999px;
  background: var(--ink); color: var(--paper); text-decoration: none;
  font: 600 .85rem/1 var(--f-sans); box-shadow: 0 8px 24px -8px rgba(0,0,0,.5), 3px 3px 0 var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  html, .carousel-track { scroll-behavior: auto; }
  * { transition: none !important; }
}
