/* Вики: каталог, разделы, статьи и поиск. */

:root { --wrap: 1480px; }

a:hover { color: var(--accent); }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--ink-3);
  color: var(--soft);
  font: 12px/1.5 var(--mono);
}

/* полоса прогресса чтения под шапкой */
.read-progress {
  border-radius: 0 2px 2px 0;
  position: fixed;
  top: var(--bar);
  left: 0;
  right: 0;
  z-index: 41;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

/* ---------- каркас ---------- */

.wiki-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 48px;
  width: min(var(--wrap), 100% - 48px);
  min-height: calc(100vh - var(--bar));
  margin-inline: auto;
  padding: 32px 0 80px;
}
.wiki-shell:has(.article-toc) { grid-template-columns: 280px minmax(0, 1fr) 210px; gap: 44px; }
main { min-width: 0; }

/* ---------- боковое меню ---------- */

.sidebar {
  position: sticky;
  top: calc(var(--bar) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--bar) - 48px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  view-transition-name: sidebar;
}

.search-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 26px;
  padding: 11px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--ink-2);
  box-shadow: 0 -24px 0 var(--ink), 0 10px 12px var(--ink);
  color: var(--muted);
  font-size: 16px;
  text-align: left;
  transition: border-color .2s, color .2s;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text); }
.search-trigger:hover kbd { border-color: var(--accent-lo); }

.nav-group { margin-bottom: 26px; }
.group-title {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font: 600 13px/1.4 var(--display);
}
.nav-article {
  position: relative;
  display: block;
  padding: 7px 12px 7px 14px;
  border-left: 2px solid var(--line);
  color: var(--soft);
  font-size: 15.5px;
  line-height: 1.45;
  transition: color .15s, border-color .15s, padding-left .25s var(--out);
}
.nav-article:hover { color: var(--text); border-left-color: var(--muted); padding-left: 18px; }
.nav-article.active { color: var(--accent); border-left-color: var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: linear-gradient(90deg, var(--accent-wash), transparent); }
.nav-icon { display: none; }
.sidebar-shade { display: none; }

/* ---------- заголовок страницы ---------- */

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; color: var(--muted); font-size: 15px; }
.breadcrumbs a { color: var(--soft); }
.breadcrumbs a:hover { color: var(--accent); }

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 210px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.heading-copy { flex: 1; min-width: 0; padding-bottom: 24px; animation: rise .6s var(--out) both; }
.heading-copy h1 { font-size: clamp(30px, 3.6vw, 46px); line-height: 1.12; letter-spacing: -.035em; overflow-wrap: anywhere; }
.article-heading h1 { font-size: clamp(28px, 3.1vw, 40px); }
.heading-copy p { margin-top: 12px; font-size: 19px; }
.heading-copy > span { display: block; margin-top: 14px; color: var(--muted); font-size: 14px; }

.page-character {
  flex: none;
  width: 200px;
  height: 200px;
  object-fit: contain;
  transform-origin: 50% 100%;
  animation: char-in .7s var(--out) .15s both, char-idle 4.5s ease-in-out 1s infinite;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes char-in { from { opacity: 0; transform: translateY(24px) scale(.9); } }
@keyframes char-idle { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }

/* ---------- каталог ---------- */

.category-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.category-card {
  display: flex;
  flex-direction: column;
  padding: 24px 24px 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--ink-2);
  overflow: hidden;
  transition: border-color .25s, transform .35s var(--out);
  animation: rise .6s var(--out) both;
}
.category-card:nth-child(2) { animation-delay: 60ms; }
.category-card:nth-child(3) { animation-delay: 120ms; }
.category-card:nth-child(4) { animation-delay: 180ms; }
.category-card:nth-child(5) { animation-delay: 240ms; }
.category-card:hover { border-color: var(--line-2); transform: translateY(-3px); }

.card-title { display: flex; align-items: flex-start; gap: 18px; }
.category-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; background: var(--ink-3); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--accent); font-size: 22px; }
.category-icon img { width: 32px; height: 32px; image-rendering: pixelated; }
.feature-thumb { width: 64px; height: 64px; overflow: hidden; }
.feature-thumb img { width: 100%; height: 100%; object-fit: cover; }
.article-list > a:hover .feature-thumb img { animation: none; transform: scale(1.08); transition: transform .4s var(--out); }
.category-card:hover .category-icon img, .article-list > a:hover .category-icon img { animation: item-bob .9s ease-in-out infinite; }
@keyframes item-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.card-title h2 { font-size: 20px; line-height: 1.3; letter-spacing: -.02em; }
.card-title p { margin-top: 6px; font-size: 16px; line-height: 1.55; }

.category-card ul { list-style: none; margin: 20px 0 0; padding: 0; }
.category-card li a { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); font-size: 16.5px; transition: color .15s, padding-left .25s var(--out); }
.category-card li a:hover { color: var(--accent); padding-left: 6px; }
.category-card li a > span { display: none; }

.card-bottom { display: flex; justify-content: space-between; gap: 12px; margin: auto -24px 0; padding: 14px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; transition: background-color .2s; }
.card-bottom:hover { background: var(--accent-wash); }
.card-bottom b { color: var(--accent); font-weight: 600; }
.card-bottom i { display: inline-block; padding-left: 6px; font-style: normal; transition: transform .25s var(--out); }
.card-bottom:hover i { transform: translateX(4px); }

/* ---------- список статей раздела ---------- */

.article-list { display: grid; border-top: 1px solid var(--line); }
.article-list > a { display: flex; align-items: center; gap: 20px; padding: 20px 8px; border-bottom: 1px solid var(--line); border-radius: var(--r-sm); transition: background-color .2s, padding-left .3s var(--out); animation: rise .5s var(--out) both; }
.article-list > a:nth-child(2) { animation-delay: 50ms; }
.article-list > a:nth-child(3) { animation-delay: 100ms; }
.article-list > a:nth-child(4) { animation-delay: 150ms; }
.article-list > a:nth-child(5) { animation-delay: 200ms; }
.article-list > a:nth-child(6) { animation-delay: 250ms; }
.article-list > a:hover { background: var(--ink-2); padding-left: 16px; color: inherit; }
.article-list h2 { font-size: 19px; letter-spacing: -.02em; transition: color .15s; }
.article-list > a:hover h2 { color: var(--accent); }
.article-list p { margin-top: 3px; color: var(--muted); font-size: 16px; }
.article-list > a > span:last-child { margin-left: auto; color: var(--accent); font-size: 20px; transition: transform .25s var(--out); }
.article-list > a:hover > span:last-child { transform: translateX(5px); }

/* ---------- статья ---------- */

.article-body { max-width: 46em; font-size: 18px; line-height: 1.8; overflow-wrap: anywhere; animation: rise .6s var(--out) .1s both; }
.article-body section { margin-bottom: 44px; scroll-margin-top: calc(var(--bar) + 20px); }
.article-body h2 { margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 24px; line-height: 1.3; letter-spacing: -.025em; }
.article-body p { margin-bottom: 18px; scroll-margin-top: calc(var(--bar) + 28px); }
.article-body strong { color: var(--text); font-weight: 650; }
.article-body ul { margin: 0 0 18px; padding-left: 22px; }
.article-body li { margin-bottom: 6px; }
.article-body li::marker { color: var(--accent); }

/* ---------- пункты Общих правил: номер слева, текст справа, подпункты с отступом ---------- */
.article-body div.rule { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 12px; margin: 0; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); scroll-margin-top: calc(var(--bar) + 28px); }
.article-body div.rule strong { color: var(--accent); font: 600 14px/1.75 var(--mono); }
.article-body div.rule.rule-sub { padding-left: 3.4em; grid-template-columns: 3.9em minmax(0, 1fr); }
.article-body div.rule.rule-sub strong { color: var(--muted); }
.article-body div.rule ul { margin: 6px 0; }
.article-body div.rule:target { animation: target-flash 2.4s ease-out both; }
.article-body .chapter + .chapter { margin-top: 34px; }
.rules-intro p { margin: 0 0 6px; }
.rules-intro p:last-child { margin: 0; }
@media (max-width: 560px) { .article-body div.rule.rule-sub { padding-left: 1.2em; } }

/* ---------- фишки сервера: картинки, таблицы, команды, рецепты ---------- */
.article-body h3 { margin: 26px 0 12px; font-size: 18px; letter-spacing: -.015em; }
.article-body code { padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--ink-2); color: var(--text); font: .92em var(--mono); white-space: nowrap; }
.wiki-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; margin: 6px 0 22px; }
.wiki-figs.one { grid-template-columns: 1fr; }
.wiki-fig { display: grid; grid-template-rows: 1fr auto; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--ink-2); }
.wiki-fig > div { display: grid; place-items: center; min-height: 120px; padding: 14px; background: #0b0f22; }
.wiki-fig.photo > div { padding: 0; }
.wiki-fig img { display: block; max-width: 100%; height: auto; }
.wiki-fig.photo img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.wiki-fig.pixel img { image-rendering: pixelated; }
.wiki-fig figcaption { padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.callout { margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--accent-lo); border-left-width: 3px; border-radius: var(--r-sm); background: var(--accent-wash); color: var(--soft); }
.callout b { color: var(--text); }
.wiki-table { width: 100%; margin: 0 0 22px; border-collapse: collapse; font-size: 15px; }
.wiki-table th, .wiki-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.wiki-table th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.wiki-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }
.cmd-list { display: grid; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.cmd-list li { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 14px; align-items: baseline; margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--ink-2); }
.cmd-list li code { justify-self: start; }
@media (max-width: 560px) { .cmd-list li { grid-template-columns: 1fr; gap: 6px; } .wiki-table td:first-child { white-space: normal; } }

/* рецепты Brewery */
.brew-tools { position: sticky; top: calc(var(--bar) + 10px); z-index: 3; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 22px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--ink) 88%, transparent); backdrop-filter: blur(10px); }
.brew-tools input { flex: 1 1 220px; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--ink-2); color: var(--text); font: inherit; }
.brew-tools input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.brew-tools span { color: var(--muted); font-size: 14px; }
.brew-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px; margin: 0 0 26px; }
.brew { display: grid; align-content: start; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--ink-2); }
.brew h4 { display: flex; justify-content: space-between; gap: 10px; margin: 0; font-size: 16px; line-height: 1.35; }
.brew h4 b { flex: none; align-self: start; padding: 2px 8px; border-radius: 999px; background: var(--ink-3); color: var(--soft); font: 600 12px/1.6 var(--mono); }
.brew h4 b.hot { background: #e2604f26; color: #ff9d8f; }
.brew h4 b.soft { background: #5ed3a21f; color: var(--live); }
.brew dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 0; font-size: 14px; }
.brew dt { color: var(--muted); }
.brew dd { margin: 0; color: var(--soft); }
.brew[hidden], .brew-group[hidden] { display: none; }
.brew-empty { color: var(--muted); }
.article-body a, .notice a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-lo); text-underline-offset: 4px; transition: text-decoration-color .2s; }
.article-body a:hover, .notice a:hover { text-decoration-color: var(--accent); }
.article-body p:target { animation: target-flash 2.4s ease-out both; }
@keyframes target-flash {
  0%, 35% { background: #8f9bff33; box-shadow: 0 0 0 8px #8f9bff33; }
  100% { background: var(--accent-wash); box-shadow: 0 0 0 8px var(--accent-wash); }
}
.notice { margin-bottom: 32px; padding: 16px 20px; border-left: 3px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--accent-wash); color: var(--text); font-size: 16px; }

.mobile-toc { display: none; margin-bottom: 26px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 16px; }
.mobile-toc summary { color: var(--accent); cursor: pointer; }
.mobile-toc a { display: block; margin-top: 10px; color: var(--soft); }

.article-pagination { display: flex; justify-content: space-between; gap: 16px; max-width: 46em; margin-top: 56px; padding-top: 26px; border-top: 1px solid var(--line); }
.article-pagination a { flex: 1; max-width: 50%; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--ink-2); color: var(--text); font-size: 16px; font-weight: 600; transition: border-color .2s, transform .3s var(--out); }
.article-pagination a:hover { border-color: var(--accent); color: var(--text); }
.article-pagination a:first-child:hover { transform: translateX(-4px); }
.article-pagination a:last-child { text-align: right; }
.article-pagination a:last-child:hover { transform: translateX(4px); }
.article-pagination small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 400; }

/* оглавление справа */
.article-toc {
  position: sticky;
  top: calc(var(--bar) + 28px);
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--bar) - 56px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.article-toc > span { margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.article-toc a { padding: 5px 0 5px 14px; border-left: 2px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.45; transition: color .2s, border-color .2s; }
.article-toc a:hover { color: var(--text); }
.article-toc a.is-here { color: var(--accent); border-left-color: var(--accent); }

/* ---------- подвал ---------- */

.site-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; width: min(var(--wrap), 100% - 48px); margin-inline: auto; padding: 26px 0 34px; border-top: 1px solid var(--line); }
.site-foot .logo { font-size: 14px; }
.site-foot .logo svg { width: 22px; height: 22px; }
.site-foot p, .site-foot small { color: var(--muted); font-size: 14px; }
.site-foot small { margin-left: auto; }

/* ---------- поиск ---------- */

dialog {
  width: min(760px, 100vw - 28px);
  max-height: calc(100svh - 60px);
  margin: 76px auto 20px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--ink-2);
  color: var(--text);
  box-shadow: 0 30px 90px #00000099;
  opacity: 0;
  transform: translateY(-14px) scale(.98);
  transition: opacity .2s, transform .3s var(--out), overlay .3s allow-discrete, display .3s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
dialog::backdrop { background: #04060f00; transition: background-color .3s, overlay .3s allow-discrete, display .3s allow-discrete; }
dialog[open]::backdrop { background: #04060fcc; }
@starting-style {
  dialog[open] { opacity: 0; transform: translateY(-14px) scale(.98); }
  dialog[open]::backdrop { background: #04060f00; }
}
body.modal-open { overflow: hidden; }

.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head > span { color: var(--accent); font-size: 24px; line-height: 1; }
.modal-head input { flex: 1; min-width: 0; height: 34px; border: 0; outline: 0; background: none; font-size: 18px; }
.modal-head input::placeholder { color: var(--muted); }
.modal-head input::-webkit-search-cancel-button { display: none; }

.search-scroll { min-height: 120px; max-height: calc(100svh - 250px); overflow-y: auto; padding: 18px 14px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.search-label { margin-bottom: 10px; padding: 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.search-category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; }
.search-category { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-sm); }
.search-category .category-icon { width: 38px; height: 38px; }
.search-category .category-icon img { width: 24px; height: 24px; }
.search-category b { display: block; font-size: 16px; font-weight: 600; line-height: 1.3; }
.search-category small { color: var(--muted); font-size: 13px; }
.search-item { display: block; padding: 12px 10px; border-left: 2px solid transparent; border-radius: var(--r-sm); line-height: 1.5; }
.search-item-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.search-item-head b { font-size: 16.5px; font-weight: 600; }
.search-item-head small { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.search-item p { margin-top: 4px; color: var(--soft); font-size: 15px; }
.search-item:hover, .search-category:hover, .search-item.selected, .search-category.selected { background: var(--ink-3); color: var(--text); }
.search-item.selected { border-left-color: var(--accent); }
.search-empty { padding: 24px 10px; color: var(--muted); font-size: 16px; }
#search-results > * { animation: rise .25s var(--out) both; }
mark { padding: 0 2px; border-radius: 3px; background: #8f9bff38; color: var(--accent-hi); }

.modal-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 11px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.modal-footer kbd { margin-right: 4px; }
#search-count { margin-left: auto; }

/* ---------- узкие экраны ---------- */

@media (max-width: 1200px) {
  .wiki-shell, .wiki-shell:has(.article-toc) { grid-template-columns: 260px minmax(0, 1fr); gap: 36px; }
  .article-toc { display: none; }
  .mobile-toc { display: block; }
  .category-grid { grid-template-columns: 1fr; }
  .topbar { gap: 20px; }
}

@media (max-width: 860px) {
  .topbar nav { display: none; }
  .topbar { gap: 12px; }
  .mobile-menu { display: grid; }
  .wiki-shell, .wiki-shell:has(.article-toc) { display: block; width: calc(100% - 36px); padding: 24px 0 56px; }
  .site-foot { width: calc(100% - 36px); }
  .site-foot small { margin-left: 0; }

  .sidebar {
    position: fixed;
    top: var(--bar);
    bottom: 0;
    left: 0;
    z-index: 35;
    width: min(330px, 88vw);
    height: calc(100dvh - var(--bar));
    max-height: none;
    align-self: auto;
    padding: 20px 18px;
    background: var(--ink);
    border-right: 1px solid var(--line-2);
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform .35s var(--out), visibility 0s .35s;
    view-transition-name: none;
  }
  .sidebar.open { visibility: visible; transform: none; transition-delay: 0s; }
  .sidebar-shade { display: block; position: fixed; inset: var(--bar) 0 0; z-index: 34; background: #04060fcc; opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }
  .sidebar.open + .sidebar-shade { opacity: 1; visibility: visible; transition-delay: 0s; }

  .page-heading { min-height: 0; gap: 12px; }
  .page-character { width: 120px; height: 150px; }
  .heading-copy p { font-size: 17px; }
  .article-body { font-size: 17px; }
  .article-body h2 { font-size: 22px; }
  .article-pagination { flex-direction: column; }
  .article-pagination a { max-width: 100%; }
  .search-category-grid { grid-template-columns: 1fr; }
  .search-item-head { display: block; }
  .search-item-head small { display: block; margin-top: 2px; text-align: left; }
  dialog { margin-top: 30px; }
  .modal-head input { font-size: 16px; }
}

@media (max-width: 420px) {
  .page-character { width: 88px; height: 130px; }
  .category-card { padding: 20px 18px 0; }
  .card-bottom { margin-inline: -18px; padding-inline: 18px; }
}
