/*
 * Чӧлскон Куа — визуальный язык каталога.
 *
 * Палитра взята с удмуртского флага: чёрное, небелёный холст, марена.
 * Охра и мох — служебные, для акцентов второго ряда. Шрифты — семейство PT
 * (ParaType): оно сделано по программе шрифтов для языков народов России и
 * штатно держит ӝ ӟ ӥ ӧ ӵ, тогда как системный стек подставляет их из
 * запасного шрифта и ломает начертание посреди слова.
 */

:root {
  --ground:      #F2EEEA;
  --surface:     #FFFFFF;
  --surface-alt: #E8E2DC;
  --ink:         #1A1310;
  --muted:       #6F625B;
  --line:        #D6CCC4;
  --accent:      #B8332A;
  --accent-ink:  #FFFFFF;
  --accent-soft: #F0DCD8;
  --ochre:       #9A6D18;
  --moss:        #4C6B4E;
  --shadow:      0 1px 2px rgba(26, 19, 16, .06), 0 8px 24px rgba(26, 19, 16, .06);
  --shadow-lift: 0 2px 4px rgba(26, 19, 16, .08), 0 16px 32px rgba(26, 19, 16, .10);

  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans:  "PT Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:  "PT Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Средняя полоса флага — белая в обеих темах: это цвет флага,
     а не поверхность интерфейса, и он не должен ездить за темой */
  --flag-white: #FFFFFF;

  /* Логотип нарисован тёмным по прозрачному фону: в тёмной теме он
     пропадает, поэтому там ложится на светлую подложку */
  --logo-plate: transparent;
  --logo-pad:   0px;

  --radius:    10px;
  --radius-sm: 7px;
  --page:      1180px;
}

/* Тёмная тема: по системной настройке, если пользователь не выбрал светлую */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #13100E;
    --surface:     #1C1815;
    --surface-alt: #262019;
    --ink:         #EFE7E0;
    --muted:       #A2938A;
    --line:        #372F29;
    --accent:      #E06A5B;
    --accent-ink:  #1A1310;
    --accent-soft: #3A211D;
    --ochre:       #D6A03F;
    --moss:        #86AA88;
    --shadow:      0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .55), 0 16px 32px rgba(0, 0, 0, .45);
    --logo-plate:  #F2EEEA;
    --logo-pad:    5px;
  }
}

/* …и по явному выбору — он должен побеждать системную настройку в обе стороны */
:root[data-theme="dark"] {
  --ground:      #13100E;
  --surface:     #1C1815;
  --surface-alt: #262019;
  --ink:         #EFE7E0;
  --muted:       #A2938A;
  --line:        #372F29;
  --accent:      #E06A5B;
  --accent-ink:  #1A1310;
  --accent-soft: #3A211D;
  --ochre:       #D6A03F;
  --moss:        #86AA88;
  --shadow:      0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .55), 0 16px 32px rgba(0, 0, 0, .45);
  --logo-plate:  #F2EEEA;
  --logo-pad:    5px;
}

/* ─────────── база ─────────── */

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  margin: 0;
  line-height: 1.2;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-underline-offset: 3px; }

img { max-width: 100%; }

button, input, select { font: inherit; color: inherit; }

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

[x-cloak] { display: none !important; }

/* Подвал живёт внутри #app (ему нужны переводы), поэтому колонку с
   растягивающейся серединой строим здесь, а не на body */
.app {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* width: 100% обязателен: .wrap.stack — флекс-элемент внутри .app, а
   margin-inline: auto по поперечной оси отменяет растягивание, и без явной
   ширины блок сжимается по содержимому. Из-за этого поле поиска на пустом
   экране поиска было 208px, а с результатами разъезжалось до 1140px. */
.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: 20px;
}

.stack { flex: 1 0 auto; padding-block: 36px 56px; }

/* ─────────── шапка ─────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.brand__logo {
  box-sizing: content-box;
  height: 40px;
  width: auto;
  padding: var(--logo-pad);
  border-radius: 7px;
  background: var(--logo-plate);
}

.brand__name {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Три полосы флага — разделитель под шапкой */
.flagrule {
  display: grid;
  grid-template-rows: repeat(3, 3px);
}
.flagrule i { display: block; }
.flagrule i:nth-child(1) { background: var(--ink); }
.flagrule i:nth-child(2) { background: var(--flag-white); }
.flagrule i:nth-child(3) { background: var(--accent); }

.nav { display: flex; align-items: center; gap: 6px; }

.nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.nav__btn:hover { background: var(--surface-alt); }
.nav__btn.is-active { background: var(--accent-soft); color: var(--accent); }

.nav__group {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.nav__chip {
  padding: 5px 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.nav__chip:hover { color: var(--ink); }
.nav__chip.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  transition: background-color .15s ease;
}
.icon-btn:hover { background: var(--surface-alt); }

.nav-toggle { display: none; }

/* мобильное меню */

.mobile-nav {
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.mobile-nav__inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-block: 12px 16px;
}
.mobile-nav .nav__btn { width: 100%; justify-content: flex-start; padding: 12px 14px; }
.mobile-nav .nav__group { margin: 8px 0 0; }
.mobile-nav .nav__chip { flex: 1; text-align: center; padding-block: 9px; }

@media (max-width: 880px) {
  .nav--desktop { display: none; }
  .nav-toggle { display: inline-flex; }
}
@media (min-width: 881px) {
  .mobile-nav { display: none !important; }
}

/* ─────────── поиск ─────────── */

.search { position: relative; margin-bottom: 28px; }

.search__field {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search__field::placeholder { color: var(--muted); }
.search__field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__drop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 380px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}

.search__hit {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-weight: 700;
  transition: background-color .12s ease;
}
.search__hit:last-child { border-bottom: 0; }
.search__hit:hover { background: var(--surface-alt); }

.search__empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

/* ─────────── хлебные крошки ─────────── */

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.crumbs__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.crumbs__back:hover { color: var(--accent); border-color: var(--accent); }

.crumbs__trail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
}

.crumbs__link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
}
.crumbs__link:hover { text-decoration: underline; }
.crumbs__link.is-current {
  color: var(--ink);
  font-weight: 700;
  pointer-events: none;
}

.crumbs__step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumbs__sep { color: var(--muted); }

/* ─────────── карточки каталога ─────────── */

.section-head {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.section-head__title { font-size: clamp(24px, 3.4vw, 32px); margin-bottom: 10px; }

/* Ровно одна, две или три колонки — auto-fill на широком экране давал
   четыре, и карточки мельчали */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
}

.card__title { font-size: 18px; margin-bottom: 8px; }

.card__text {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Карточка «предложить» — намеренно другая: это не элемент каталога */
.card--ghost {
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-style: dashed;
  background: transparent;
  color: var(--muted);
  text-align: center;
  min-height: 128px;
}
.card--ghost:hover { color: var(--accent); box-shadow: none; }

.ghost-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
}

.empty {
  grid-column: 1 / -1;
  padding: 44px 0;
  text-align: center;
  color: var(--muted);
}

/* ─────────── страница элемента ─────────── */

.detail {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail__title {
  font-size: clamp(28px, 4.4vw, 40px);
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.detail__section { margin-bottom: 32px; }
.detail__section:last-child { margin-bottom: 0; }

.detail__heading { font-size: 22px; margin-bottom: 16px; }

.factbox {
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-alt);
  margin-bottom: 32px;
}
.factbox__label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.factbox__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 24px;
  font-size: 14.5px;
}
.factbox a { word-break: break-all; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 32px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s ease, background-color .15s ease;
}
.btn:hover { filter: brightness(1.08); }

.btn--quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn--quiet:hover { background: var(--surface-alt); filter: none; }

/* ─────────── карточки записей ─────────── */

.entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.entry {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.entry__poster {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  overflow: hidden;
}
.entry__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease, opacity .2s ease;
}
.entry__poster:hover img { transform: scale(1.03); opacity: .85; }

.entry__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.entry__play span {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFF;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  transition: transform .2s ease;
}
.entry__poster:hover .entry__play span { transform: scale(1.1); }

.entry__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px;
}

.entry__title { font-size: 18px; margin-bottom: 8px; }

/* цвет и кегль приходят из .prose--tight, здесь только раскладка */
.entry__text {
  flex: 1;
  margin-bottom: 16px;
}

.entry__links { display: flex; flex-wrap: wrap; gap: 8px; }

.linkbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.linkbtn:hover { background: var(--surface-alt); border-color: var(--muted); }

/* ─────────── текст из markdown ─────────── */

.prose { max-width: 68ch; color: var(--ink); }
.prose--full { max-width: none; }
.prose--tight { font-size: 14.5px; color: var(--muted); }

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.6em 0 .5em; }
.prose h2 { font-size: 24px; }
.prose h3 { font-size: 20px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose a { text-decoration: underline; }
.prose code {
  font-family: var(--mono);
  font-size: .85em;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-alt);
}
.prose pre {
  overflow-x: auto;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.prose pre code { border: 0; padding: 0; background: none; }
.prose blockquote {
  margin: 1em 0;
  padding-left: 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.prose img { border-radius: var(--radius-sm); }

/* ─────────── о проекте ─────────── */

.page { max-width: 720px; }
.page__title { font-size: clamp(26px, 3.6vw, 34px); margin-bottom: 20px; }
.page__subtitle { font-size: 19px; margin: 32px 0 12px; color: var(--accent); }

.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
.checklist li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.checklist i { color: var(--moss); font-size: 13px; }

/* ─────────── модальное окно ─────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(26, 19, 16, .6);
}

.modal__box {
  width: 100%;
  max-width: 440px;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
}

.modal__title { font-size: 23px; margin-bottom: 18px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.field input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ground);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

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

.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-block: 26px;
  font-size: 14.5px;
  color: var(--muted);
}

.site-footer__brand { display: flex; align-items: center; gap: 12px; }

.site-footer__logo {
  box-sizing: content-box;
  height: 32px;
  width: auto;
  padding: var(--logo-pad);
  border-radius: 6px;
  background: var(--logo-plate);
}
.site-footer a { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .entry__poster:hover img { transform: none; }
}

@media (max-width: 640px) {
  .detail { padding: 22px 18px; }
  .stack { padding-block: 24px 40px; }
  .brand__name { font-size: 18px; }
  .brand__logo { height: 32px; }
}
