/* melehov.com — сайт как альбом акварелей: бумага, тушь, охра лиственниц,
   хвоя и ржавчина. Иллюстрации — SVG из tools/gen_art.py. */

:root {
  --paper: #f8f5ee;
  --paper-2: #f1ebdf;
  --ink: #2f2a24;
  --ink-soft: #4a4238;
  --muted: #7a705f;
  --line: #ded5c3;
  --rust: #a2502c;
  --ochre: #c68a31;
  --forest: #3f5244;
  --serif: "Lora", "PT Serif", Georgia, serif;
  --hand: "Caveat", "Segoe Print", "Comic Sans MS", cursive;
  --mono: ui-monospace, Consolas, "Liberation Mono", monospace;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .22 0 0 0 .075 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 18px/1.65 var(--serif);
  background-color: var(--paper);
  /* Бумага: зерно и едва заметные акварельные разводы по краям листа */
  background-image:
    var(--grain),
    radial-gradient(40vw 30vw at 0% 18%, rgba(214, 170, 96, .10), transparent 70%),
    radial-gradient(38vw 34vw at 100% 55%, rgba(150, 175, 180, .10), transparent 70%),
    radial-gradient(30vw 26vw at 8% 92%, rgba(160, 80, 45, .06), transparent 70%);
  background-attachment: scroll, fixed, fixed, fixed;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
::selection { background: rgba(214, 160, 67, .3); }

.wrap { max-width: 740px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.hand { font-family: var(--hand); }

/* ---------- Шапка: название и меню поверх акварельного пейзажа ---------- */
.masthead { position: relative; }
.masthead-inner { position: relative; }
.masthead:not(.masthead--home) .masthead-inner {
  min-height: 290px;
  background: url("/assets/img/scene-header.webp") center bottom / cover no-repeat;
}
.masthead-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding: 34px 38px 0; }
.masthead--home .masthead-bar { padding: 26px 0 10px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand-text { display: flex; flex-direction: column; }
/* Логотип — как круглая наклейка на акварельном листе */
.badge { width: 68px; height: 68px; flex: none; border-radius: 50%; transform: rotate(-6deg); transition: transform .3s ease;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .25), 0 6px 14px -6px rgba(60, 40, 20, .45); }
.brand:hover .badge { transform: rotate(4deg) scale(1.04); }
.intro-badge { width: 150px; height: 150px; margin: 0 auto 14px; border-radius: 50%; transform: rotate(-4deg);
  box-shadow: 0 2px 3px rgba(60, 40, 20, .2), 0 12px 26px -12px rgba(60, 40, 20, .5); }
.foot-brand { display: inline-flex; align-items: center; gap: 10px; }
.foot-brand img { width: 40px; height: 40px; border-radius: 50%; transform: rotate(-6deg); box-shadow: 0 3px 8px -4px rgba(60, 40, 20, .5); }
.logo { font: 700 32px/1 var(--serif); text-decoration: none; letter-spacing: -.015em; color: var(--ink); }
.tagline { font: 500 23px/1.1 var(--hand); color: var(--rust); margin-top: 4px; }
.nav { display: flex; gap: 6px 22px; flex-wrap: wrap; padding-top: 4px; }
.nav a { font: 600 24px/1.2 var(--hand); color: var(--ink-soft); text-decoration: none; padding-bottom: 4px; }
.nav a:hover, .nav a.on { color: var(--rust); background: url("/assets/img/squiggle-rust.webp") left bottom / 100% 7px no-repeat; }

/* ---------- Главная ---------- */
.hero { margin: 4px auto 0; max-width: 1200px; padding: 0 20px; }
.hero img {
  width: 100%;
  -webkit-mask: url("/assets/img/mask-deckle.webp") center / 100% 100% no-repeat;
  mask: url("/assets/img/mask-deckle.webp") center / 100% 100% no-repeat;
}
.intro { text-align: center; padding: 26px 0 8px; }
.intro h1 { font: 700 clamp(38px, 6.5vw, 58px)/1.05 var(--serif); margin: 0; letter-spacing: -.02em; }
.intro p { font: 500 clamp(24px, 3.2vw, 30px)/1.25 var(--hand); color: var(--rust); margin: 8px 0 0; }
.section-label { text-align: center; margin: 34px 0 6px; font: 700 30px/1 var(--hand); color: var(--forest); }
.section-label span { display: inline-block; padding: 6px 30px 10px; background: url("/assets/img/blob-sage.webp") center / 100% 100% no-repeat; }
.page-title { text-align: center; font: 700 clamp(34px, 5.5vw, 48px)/1.1 var(--serif); margin: 34px 0 0; }
.page-title small { display: block; font: 500 26px var(--hand); color: var(--rust); }
.empty { text-align: center; font: 500 28px var(--hand); color: var(--muted); padding: 30px 0 10px; }
.empty::before { content: ""; display: block; height: 70px; margin: 0 auto 10px; max-width: 280px; background: url("/assets/img/sprig.webp") center / contain no-repeat; }

/* Лента */
.feed { display: grid; }
.divider { width: 100%; height: 64px; margin: 8px auto; max-width: 240px; background: url("/assets/img/sprig-plain.webp") center / contain no-repeat; opacity: .85; }
.card { padding: 26px 0; display: grid; grid-template-columns: 1fr; gap: 24px; }
.card:has(.card-cover) { grid-template-columns: 1fr 250px; align-items: center; }
.card:has(.card-cover) .card-cover { order: 2; }
/* Обложка с рваным акварельным краем */
.card-cover, .post-cover img, .prose figure img, .prose > p > img {
  -webkit-mask: url("/assets/img/mask-deckle.webp") center / 100% 100% no-repeat;
  mask: url("/assets/img/mask-deckle.webp") center / 100% 100% no-repeat;
}
.card-cover { display: block; transition: transform .35s ease; }
.card-cover:hover { transform: rotate(-.8deg) scale(1.01); }
.card-cover img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.card h2 { font: 700 28px/1.22 var(--serif); margin: 2px 0 10px; letter-spacing: -.01em; }
.card h2 a { text-decoration: none; background: url("/assets/img/brush-ochre.webp") left 92% / 0 .55em no-repeat; transition: background-size .35s ease; }
.card h2 a:hover { background-size: 100% .55em; }
.card p { margin: 0; color: var(--ink-soft); font-size: 17px; }
.card--lead:has(.card-cover) { grid-template-columns: 1fr; text-align: center; }
.card--lead .card-cover { order: 0 !important; }
.card--lead .card-cover img { aspect-ratio: 16 / 9; }
.card--lead h2 { font-size: clamp(30px, 4.5vw, 40px); }
.card--lead .meta, .card--lead .tags { justify-content: center; }

.meta { font: 500 22px/1.2 var(--hand); color: var(--rust); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta .dot { color: var(--ochre); }
.tags { display: flex; gap: 6px 10px; flex-wrap: wrap; margin-top: 12px; }
.tags a { font: 600 21px/1 var(--hand); color: var(--forest); text-decoration: none; padding: 7px 14px 9px; background: url("/assets/img/blob-sage.webp") center / 100% 100% no-repeat; }
.tags a:nth-child(3n+2) { background-image: url("/assets/img/blob-ochre.webp"); color: #7a5418; }
.tags a:nth-child(3n) { background-image: url("/assets/img/blob-sky.webp"); color: #3d5560; }
.tags a:hover { color: var(--rust); }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 30px 0 0; font: 500 24px var(--hand); color: var(--muted); }
.pager a { color: var(--rust); text-decoration: none; padding: 4px 16px 8px; background: url("/assets/img/blob-ochre.webp") center / 100% 100% no-repeat; }

/* ---------- Статья ---------- */
.post-head { text-align: center; padding: 30px 0 4px; }
.post-head h1 { font: 700 clamp(32px, 5.5vw, 48px)/1.14 var(--serif); margin: 8px 0 16px; letter-spacing: -.02em; }
.post-head .meta { justify-content: center; }
.lead { font: italic 21px/1.55 var(--serif); color: var(--ink-soft); margin: 0 auto; max-width: 620px; }
.post-cover { margin: 30px -30px 6px; }
.post-cover img { width: 100%; }
figcaption { font: 500 21px/1.3 var(--hand); color: var(--muted); text-align: center; margin-top: 8px; }

.prose { font: 19.5px/1.78 var(--serif); margin-top: 28px; overflow-wrap: break-word; color: var(--ink); }
.prose > * { margin: 0 0 1.1em; }
.prose > p:first-child::first-letter {
  float: left; font: 700 3.4em/.8 var(--serif); color: var(--rust);
  margin: .1em .14em 0 0; padding: .12em .12em .06em;
  background: url("/assets/img/blob-ochre.webp") center / 100% 100% no-repeat;
}
.prose h2 { display: table; font: 700 30px/1.25 var(--serif); margin: 1.7em 0 .6em; letter-spacing: -.01em;
  background: url("/assets/img/brush-ochre.webp") left 88% / 100% .5em no-repeat; padding: 0 4px; }
.prose h3 { font: italic 700 24px/1.3 var(--serif); margin: 1.5em 0 .5em; color: var(--forest); }
.prose h4 { font: 700 30px/1.2 var(--hand); color: var(--rust); margin: 1.2em 0 .3em; }
.prose a { color: var(--rust); text-decoration: underline; text-decoration-color: rgba(198, 138, 49, .6); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.prose a:hover { text-decoration-color: var(--rust); }
.prose strong { font-weight: 700; background: linear-gradient(transparent 62%, rgba(226, 184, 98, .38) 62%); }

.prose blockquote {
  position: relative; margin: 1.6em -20px; padding: 34px 54px 30px 64px; font-style: italic; color: var(--ink-soft);
  background: url("/assets/img/panel-sky.webp") center / 100% 100% no-repeat;
}
.prose blockquote::before { content: "“"; position: absolute; left: 22px; top: 6px; font: 700 76px/1 var(--serif); color: var(--rust); opacity: .75; }
.prose blockquote > :last-child { margin-bottom: 0; }

.prose ul { list-style: none; padding-left: 1.6em; }
.prose ul > li { position: relative; }
.prose ul > li::before { content: ""; position: absolute; left: -1.45em; top: .42em; width: .95em; height: .95em; background: url("/assets/img/leaf.webp") center / contain no-repeat; transform: rotate(-35deg); }
.prose ol { padding-left: 1.6em; }
.prose ol > li::marker { font: 700 1.25em var(--hand); color: var(--rust); }
.prose li { margin: .35em 0; }

.prose figure { margin: 1.9em -30px; }
.prose figure img { width: 100%; }
.prose hr { border: 0; height: 70px; margin: 1.6em auto; max-width: 280px; background: url("/assets/img/sprig.webp") center / contain no-repeat; }
.prose code { font: .84em var(--mono); background: rgba(226, 184, 98, .25); padding: .1em .35em; border-radius: 4px; }
.prose pre { font: 15px/1.55 var(--mono); background: var(--paper-2); padding: 18px 20px; border-radius: 3px 10px 4px 12px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { border-collapse: collapse; width: 100%; font-size: 16px; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px dashed var(--line); padding: 8px 10px; text-align: left; }
.prose th { font: 700 21px var(--hand); color: var(--forest); }
.prose iframe, .prose video { max-width: 100%; }

.post .tags { justify-content: center; margin-top: 30px; }
.subscribe {
  margin: 40px -20px 0; padding: 34px 40px; text-align: center;
  background: url("/assets/img/panel-ochre.webp") center / 100% 100% no-repeat;
  font: 500 26px/1.3 var(--hand); color: var(--ink-soft);
}
.subscribe a { color: var(--rust); font-weight: 700; margin: 0 8px; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 30px; }
.post-nav::before { content: ""; grid-column: 1 / -1; height: 64px; background: url("/assets/img/sprig-plain.webp") center / auto 100% no-repeat; opacity: .85; }
.post-nav a { text-decoration: none; font: 700 19px/1.35 var(--serif); }
.post-nav a:hover { color: var(--rust); }
.post-nav small { display: block; font: 500 22px var(--hand); color: var(--rust); margin-bottom: 2px; }
.post-nav .right { text-align: right; }

.preview-bar { margin-top: 20px; padding: 14px 20px; text-align: center; font: 500 22px/1.3 var(--hand); color: #5a4200; background: url("/assets/img/panel-ochre.webp") center / 100% 100% no-repeat; }
.preview-bar a { color: var(--rust); font-weight: 700; }

.page-404 { text-align: center; padding: 40px 0 0; }
.page-404 h1 { font: 700 44px/1.1 var(--serif); margin: 0 0 8px; }
.page-404 p { font: 500 26px var(--hand); color: var(--muted); }
.page-404 a { color: var(--rust); }

/* ---------- Подвал: лесная опушка ---------- */
.site-footer { margin-top: 70px; }
.footer-scene { max-width: 1200px; margin: 0 auto; height: 190px; background: url("/assets/img/scene-footer.webp") center bottom / cover no-repeat; }
.foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 36px; font: 500 23px var(--hand); color: var(--muted); }
.foot a { color: var(--rust); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .masthead:not(.masthead--home) .masthead-inner { min-height: 220px; }
  .masthead-bar { padding: 22px 20px 0; }
  .card:has(.card-cover) { grid-template-columns: 1fr; }
  .card:has(.card-cover) .card-cover { order: 0; }
  .card-cover img { aspect-ratio: 16 / 9; }
  .post-cover, .prose figure { margin-left: 0; margin-right: 0; }
  .prose blockquote { margin-left: -6px; margin-right: -6px; padding: 34px 30px 30px 50px; }
  .prose blockquote::before { left: 12px; }
  .subscribe { margin-left: 0; margin-right: 0; padding: 30px 24px; }
}
@media (max-width: 600px) {
  body { font-size: 17px; }
  .wrap, .wrap-wide, .hero { padding: 0 16px; }
  .masthead-bar { padding: 18px 16px 0; }
  .masthead--home .masthead-bar { padding: 18px 0 6px; }
  .logo { font-size: 25px; }
  .badge { width: 52px; height: 52px; }
  .brand { gap: 10px; }
  .intro-badge { width: 120px; height: 120px; }
  .nav a { font-size: 22px; }
  .masthead:not(.masthead--home) .masthead-inner { min-height: 175px; padding: 0; }
  .card h2 { font-size: 24px; }
  .prose { font-size: 18px; }
  .prose h2 { font-size: 25px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .right { text-align: left; }
  .footer-scene { height: 130px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
