/* ==========================================================================
   Блог: список статей, страница статьи, блок на главной и админка
   Использует переменные и компоненты из style.css
   ========================================================================== */

/* ---------- Шапка блога ---------- */
.blog-nav { display: flex; align-items: center; gap: 26px; }
.blog-nav__link { font-size: 14px; font-weight: 500; color: var(--muted); transition: color .2s; }
.blog-nav__link:hover { color: var(--text); }
.blog-page .brand__mark, .admin .brand__mark { width: 30px; height: 30px; object-fit: contain; }

/* ---------- Список статей ---------- */
.blog { padding: calc(var(--header-h) + clamp(50px, 8vw, 90px)) 0 clamp(80px, 10vw, 130px); min-height: 70vh; }
.blog__empty { color: var(--muted); font-size: 18px; margin: 0 0 30px; }
.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.post-card { border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; overflow: hidden; transition: box-shadow .3s, transform .4s var(--ease); }
.post-card:hover { box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9), 0 0 0 1px var(--line-2) inset; transform: translateY(-4px); }
.post-card__link { display: flex; flex-direction: column; height: 100%; }
.post-card__img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--bg-3); }
.post-card__img--empty { display: grid; place-items: center; background: radial-gradient(circle at 50% 60%, rgba(255, 110, 20, .18), transparent 70%), var(--bg-3); }
.post-card__img--empty img { width: 64px; height: auto; opacity: .55; }
.post-card__body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 22px 24px 26px; }
.post-card__date { font: 600 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.post-card__title { font: 500 26px/1.15 var(--serif); color: var(--text); }
.post-card__text { color: var(--muted); font-size: 15px; line-height: 1.55; flex: 1; }
.post-card__more { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--gold); }
.post-card__more::after { content: " →"; transition: margin .3s var(--ease); }
.post-card:hover .post-card__more::after { margin-left: 4px; }

/* ---------- Статья ---------- */
.article__back { display: inline-block; margin-bottom: 30px; font-size: 14px; color: var(--muted); }
.article__back:hover { color: var(--gold); }
.article__head .eyebrow { margin-bottom: 16px; }
.article__title { margin: 0 0 34px; font: 500 clamp(38px, 5.4vw, 64px)/1.05 var(--serif); letter-spacing: -.01em; }
.article__cover { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--radius); margin-bottom: 40px; box-shadow: var(--shadow); }
.article__draft { margin: 0 0 24px; padding: 12px 18px; border-radius: var(--radius-sm); background: rgba(255, 154, 46, .1); box-shadow: 0 0 0 1px var(--line-2) inset; font-size: 14px; color: var(--gold); }
.article__draft--ok { background: var(--surface); color: var(--muted); }
.article__note { margin-top: 40px; }
.article__cta { margin-top: 50px; padding: 34px; border-radius: var(--radius); background: var(--grad-soft); box-shadow: 0 0 0 1px var(--line-2) inset; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.article__cta p { margin: 0; font: 500 clamp(24px, 3vw, 32px)/1.2 var(--serif); }

/* Текст статьи (и в редакторе) */
.prose { font-size: 18px; line-height: 1.75; color: rgba(245, 237, 226, .88); overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { margin: 1.8em 0 .6em; font: 500 clamp(30px, 3.6vw, 40px)/1.15 var(--serif); color: var(--text); }
.prose h3 { margin: 1.5em 0 .5em; font: 600 21px/1.3 var(--sans); color: var(--gold); }
.prose strong { color: var(--text); font-weight: 700; }
.prose a { color: var(--gold); border-bottom: 1px solid var(--line-2); }
.prose a:hover { color: var(--amber); border-color: var(--amber); }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { color: var(--amber); }
.prose blockquote { margin: 1.6em 0; padding: 4px 0 4px 26px; border-left: 2px solid var(--amber); font: italic 500 clamp(22px, 2.6vw, 28px)/1.4 var(--serif); color: var(--text); }
.prose img { width: auto; max-width: 100%; height: auto; margin: 1.4em auto; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.prose p:has(> img:only-child) { margin: 0; }

/* ---------- Блок «Блог» на главной ---------- */
.blog-home[hidden] { display: none; }
.blog-home .posts { margin-bottom: 36px; }
.blog-home__more { display: flex; justify-content: center; }

@media (max-width: 1000px) { .posts { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .posts { grid-template-columns: 1fr; }
  .blog-nav { gap: 16px; }
  .blog-nav__link:first-child { display: none; }
  .blog-page .brand__text small { display: none; }
  .prose { font-size: 17px; }
  .article__cta { padding: 26px 22px; }
}

/* ==========================================================================
   Админка
   ========================================================================== */
.admin { background: var(--bg); }
.admin-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; padding: 10px max(16px, calc((100% - 960px) / 2)); background: rgba(11, 9, 7, .9); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.admin-bar__nav { display: flex; align-items: center; gap: 22px; font-size: 14px; color: var(--muted); }
.admin-bar__nav a:hover, .admin-bar__nav button:hover { color: var(--gold); }
.admin-bar__nav form { margin: 0; }
.admin-main { width: min(960px, 100% - 32px); margin: 0 auto; padding: 40px 0 120px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.admin-head h1 { margin: 0; font: 500 44px/1.1 var(--serif); }
.admin-back { color: var(--muted); font-size: 15px; }
.admin-back:hover { color: var(--gold); }

.notice { margin: 0 0 24px; padding: 14px 18px; border-radius: var(--radius-sm); font-size: 15px; }
.notice--ok { background: rgba(120, 200, 120, .1); box-shadow: 0 0 0 1px rgba(120, 200, 120, .35) inset; color: #b9e6b0; }
.notice--err { background: rgba(255, 90, 90, .1); box-shadow: 0 0 0 1px rgba(255, 110, 110, .4) inset; color: #ffb3b3; }
.notice--warn { background: rgba(255, 154, 46, .1); box-shadow: 0 0 0 1px var(--line-2) inset; color: var(--gold); }
.notice--warn .link { margin-left: 12px; font-size: 15px; cursor: pointer; }
.notice[hidden] { display: none; }

.badge { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px; font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.badge--pub { background: rgba(120, 200, 120, .14); color: #b9e6b0; }
.badge--draft { background: var(--surface-2); color: var(--muted); }

.empty-state { padding: 60px 24px; text-align: center; border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; }
.empty-state p { margin: 0 0 20px; color: var(--muted); font-size: 18px; }

.post-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.post-row { display: flex; align-items: center; gap: 12px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; transition: box-shadow .2s, background .2s; }
.post-row:hover { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-2) inset; }
.post-row__main { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 18px 20px; }
.post-row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row__date { font-size: 13px; white-space: nowrap; }
.post-row__view { padding: 18px 20px 18px 0; font-size: 13px; color: var(--muted); white-space: nowrap; }
.post-row__view:hover { color: var(--gold); }

/* Формы */
.auth { width: min(420px, 100%); margin: 6vh auto 0; padding: 36px 32px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.auth h1 { margin: 0 0 14px; font: 500 38px/1.1 var(--serif); }
.auth > p { margin: 0 0 22px; font-size: 15px; }
.auth__back { display: block; margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }
.field { display: block; margin-bottom: 26px; }
.field > span { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 600; color: var(--text); }
.field small { font-weight: 400; }
.field input, .field textarea { width: 100%; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: rgba(0, 0, 0, .25); color: var(--text); font: 400 16px/1.5 var(--sans); transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 200, 115, .15); }
.field textarea { resize: vertical; }
.field--title input { font: 500 clamp(24px, 3vw, 30px)/1.25 var(--serif); padding: 14px 18px; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.cover { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cover__img { width: 180px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--line-2); }
.cover__img[hidden] { display: none; }
.cover__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cover__actions [hidden] { display: none; }

/* Редактор */
.toolbar { position: sticky; top: 68px; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--line-2); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--bg-3); }
.toolbar button { min-width: 40px; height: 38px; padding: 0 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.toolbar button:hover { background: var(--surface-2); color: var(--text); }
.toolbar button.on { background: rgba(255, 154, 46, .18); color: var(--gold); }
.toolbar i { width: 1px; height: 22px; margin: 0 4px; background: var(--line-2); }
.editor { min-height: 420px; padding: 26px 28px; border: 1px solid var(--line-2); border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: rgba(0, 0, 0, .25); outline: none; transition: border-color .2s, box-shadow .2s; }
.editor:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247, 200, 115, .12); }
.editor > p:only-child:has(> br:only-child)::before { content: "Начните писать здесь…"; position: absolute; color: rgba(184, 168, 149, .5); pointer-events: none; }
.editor img { cursor: default; }

.editor-actions { position: sticky; bottom: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.btn--danger { margin-left: auto; border: 1px solid rgba(255, 110, 110, .4); color: #ffb3b3; }
.btn--danger:hover { background: rgba(255, 90, 90, .12); border-color: #ff8a8a; }

.upload-status { position: fixed; left: 50%; bottom: 24px; z-index: 100; padding: 12px 20px; border-radius: 999px; background: var(--bg-3); box-shadow: var(--shadow); font-size: 14px; transform: translate(-50%, 140%); opacity: 0; transition: transform .35s var(--ease), opacity .35s; pointer-events: none; }
.upload-status.show { transform: translate(-50%, 0); opacity: 1; }
.upload-status.err { color: #ffb3b3; }

@media (max-width: 640px) {
  .admin-bar .brand__text small { display: none; }
  .admin-bar__nav { gap: 14px; font-size: 13px; }
  .admin-bar__nav a[target] { display: none; }
  .admin-head h1 { font-size: 36px; }
  .post-row { flex-direction: column; align-items: stretch; gap: 0; }
  .post-row__main { grid-template-columns: 1fr; gap: 8px; padding: 16px 18px 6px; }
  .post-row__title { white-space: normal; }
  .post-row__view { padding: 4px 18px 16px; }
  .editor { padding: 20px 18px; min-height: 340px; }
  .toolbar { top: 68px; }
  .editor-actions .btn { flex: 1 1 auto; }
  .btn--danger { margin-left: 0; }
  .auth { padding: 28px 22px; }
}
