/* ═══════════════════════════════════════════
   Медіатека — стилі публічних сторінок і переглядача
   Палітра й шрифти узгоджені з app.css сайту
   ═══════════════════════════════════════════ */
.mt, .mr-body {
  --mt-ink: #1a1a1a;
  --mt-muted: #6b6b6b;
  --mt-line: rgba(0, 0, 0, .09);
  --mt-paper: #ffffff;
  --mt-shelf: #f6f3ec;
  --mt-gold: #c9a84c;
  --mt-gold-soft: #f4ecd6;
  --mt-blue: #1d4ed8;
}
.mt { padding-bottom: 64px; }
.mt a:focus-visible, .mt summary:focus-visible, .mr-body a:focus-visible,
.mr-body button:focus-visible, .mr-body input:focus-visible {
  outline: 3px solid var(--mt-blue);
  outline-offset: 2px;
}

/* ── Підменю розділу ── */
.mt-subnav {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 2px solid var(--mt-line);
  margin: 0 0 32px;
}
.mt-subnav a {
  padding: 10px 18px; margin-bottom: -2px;
  font-size: 14px; font-weight: 600; color: var(--mt-muted);
  text-decoration: none; border-bottom: 2px solid transparent;
}
.mt-subnav a:hover { color: var(--mt-ink); }
.mt-subnav a.is-active { color: var(--mt-ink); border-bottom-color: var(--mt-gold); }

.mt-h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px; font-weight: 700; line-height: 1.2;
  margin: 0 0 20px; color: var(--mt-ink);
}
.mt-h3 span { font-family: 'Montserrat', sans-serif; font-size: 13px; font-weight: 500; color: var(--mt-muted); margin-left: 10px; }
.mt-empty { color: var(--mt-muted); padding: 8px 0 24px; }
.mt-back { margin: 0 0 20px; font-size: 13px; }
.mt-back a { color: var(--mt-muted); text-decoration: none; }
.mt-back a:hover { color: var(--mt-ink); }
.mt-back-bottom { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--mt-line); }
.mt-meta { font-size: 13px; color: var(--mt-muted); margin-top: 8px; }
.mt-block { margin-top: 48px; }
.mt-rich { font-size: 15px; line-height: 1.65; color: #333; }
.mt-rich p { margin: 0 0 .6em; }
.mt-rich p:last-child { margin-bottom: 0; }
.mt-rich a { color: var(--mt-blue); }
.mt-rich ul, .mt-rich ol { padding-left: 1.3em; margin: 0 0 .6em; }

/* ── Фільтри (класи, роки, місяці) ── */
.mt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 28px; }
.mt-chips a, .mt-chips span {
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--mt-line); color: #444;
}
.mt-chips a:hover { border-color: var(--mt-ink); }
.mt-chips a.is-active { background: var(--mt-ink); border-color: var(--mt-ink); color: #fff; }
.mt-chips a span { border: 0; padding: 0 0 0 4px; color: inherit; opacity: .6; font-weight: 500; }
.mt-chips .is-disabled { color: #bbb; border-style: dashed; cursor: default; }

/* ── Головна: графік і контакти ── */
.mt-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 20px; }
.mt-info-block { background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 12px; padding: 22px 24px; }
.mt-info-block h3 { font-size: 13px; font-weight: 700; color: var(--mt-muted); margin: 0 0 12px; }

/* Пам'ятка — закладка з золотим корінцем */
.mt-memo {
  background: var(--mt-shelf); border-left: 5px solid var(--mt-gold);
  border-radius: 0 12px 12px 0; margin: 0 0 32px;
}
.mt-memo summary {
  cursor: pointer; list-style: none; padding: 18px 24px;
  font-family: 'Playfair Display', Georgia, serif; font-size: 19px; font-weight: 700;
}
.mt-memo summary::-webkit-details-marker { display: none; }
.mt-memo summary::after { content: '+'; float: right; font-family: 'Montserrat', sans-serif; color: var(--mt-gold); font-weight: 700; }
.mt-memo[open] summary::after { content: '−'; }
.mt-memo .mt-rich { padding: 0 24px 22px; }

/* ── Найближчі дати ── */
.mt-dates { background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 12px; padding: 22px 24px; margin: 0 0 40px; }
.mt-dates h3 { font-size: 13px; font-weight: 700; color: var(--mt-muted); margin: 0 0 14px; }
.mt-dates ul { list-style: none; margin: 0; padding: 0; }
.mt-dates li {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; align-items: baseline;
  padding: 10px 0; border-top: 1px solid var(--mt-line);
}
.mt-dates li:first-child { border-top: 0; }
.mt-dates-day { font-weight: 700; }
.mt-dates-when { font-size: 12px; color: var(--mt-muted); white-space: nowrap; }
.mt-ann { display: inline-block; font-size: 12px; color: var(--mt-muted); margin-left: 4px; }
.mt-ann.is-jubilee { background: var(--mt-gold-soft); color: #7a5b12; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.mt-more { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--mt-blue); text-decoration: none; }

/* ── Новини ── */
.mt-news-item {
  display: grid; grid-template-columns: 180px 1fr; gap: 0;
  background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 12px;
  overflow: hidden; margin-bottom: 14px;
}
.mt-news-item.no-cover { grid-template-columns: 1fr; }
.mt-news-cover img { width: 100%; height: 100%; min-height: 120px; object-fit: cover; display: block; }
.mt-news-body { padding: 16px 22px; }
.mt-news-body time { font-size: 12px; color: var(--mt-muted); }
.mt-news-body h4 { font-size: 17px; font-weight: 700; line-height: 1.35; margin: 6px 0 8px; }
.mt-news-body h4 a { color: var(--mt-ink); text-decoration: none; }
.mt-news-body h4 a:hover { color: var(--mt-blue); }
.mt-news-body p { font-size: 14px; color: #555; line-height: 1.55; margin: 0; }
.mt-pager { display: flex; gap: 6px; justify-content: center; margin: 28px 0 0; }
.mt-pager a { min-width: 38px; text-align: center; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--mt-line); font-weight: 600; color: #555; text-decoration: none; }
.mt-pager a.is-active { background: var(--mt-ink); border-color: var(--mt-ink); color: #fff; }
.mt-archive-link { text-align: center; margin-top: 28px; }
.mt-archive-link a { font-weight: 700; color: var(--mt-blue); text-decoration: none; }
.mt-article-cover { width: 100%; max-height: 420px; object-fit: cover; border-radius: 12px; display: block; margin-bottom: 32px; }

/* Архів */
.mt-archive { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.mt-archive li { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--mt-line); }
.mt-archive time { color: var(--mt-muted); font-size: 13px; }
.mt-archive a { color: var(--mt-ink); font-weight: 600; text-decoration: none; }
.mt-archive a:hover { color: var(--mt-blue); }

/* ── Підручники: полиці ── */
.mt-shelf { margin-bottom: 48px; }
.mt-books {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 28px 22px;
  padding-bottom: 24px; border-bottom: 6px solid var(--mt-shelf);
}
.mt-book { display: flex; flex-direction: column; }
.mt-book-cover {
  display: block; aspect-ratio: 3 / 4; border-radius: 3px 8px 8px 3px; overflow: hidden;
  background: var(--mt-shelf); border: 1px solid var(--mt-line);
  box-shadow: inset 6px 0 0 rgba(0, 0, 0, .06);
}
.mt-book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mt-book-placeholder {
  display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px;
  text-align: center; font-family: 'Playfair Display', Georgia, serif; font-size: 18px; color: var(--mt-muted);
}
.mt-book-info { padding: 12px 2px 0; flex: 1; }
.mt-book-subject { font-size: 12px; font-weight: 700; color: #8a6d1f; margin: 0 0 4px; }
.mt-book h4 { font-size: 15px; font-weight: 700; line-height: 1.3; margin: 0 0 6px; }
.mt-book-authors, .mt-book-meta, .mt-book-note { font-size: 13px; color: var(--mt-muted); margin: 0 0 3px; line-height: 1.4; }
.mt-book-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.mt-btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--mt-line); color: var(--mt-ink); background: var(--mt-paper);
}
.mt-btn:hover { border-color: var(--mt-ink); }
.mt-btn-primary { background: var(--mt-ink); border-color: var(--mt-ink); color: #fff; }
.mt-btn-primary:hover { background: #333; color: #fff; }

/* ── Матеріали ── */
.mt-group { margin-bottom: 32px; scroll-margin-top: 20px; }
.mt-group-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--mt-gold); display: inline-block; }
.mt-item { background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 10px; padding: 18px 22px; margin-bottom: 12px; max-width: 900px; }
.mt-item h4 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.mt-item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.mt-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.mt-link-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px;
  background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 10px;
  text-decoration: none; color: var(--mt-ink);
}
.mt-link-card:hover { border-color: var(--mt-ink); }
.mt-link-title { font-weight: 700; font-size: 16px; }
.mt-link-desc { font-size: 13px; color: #555; line-height: 1.5; }
.mt-link-host { font-size: 12px; color: var(--mt-blue); margin-top: auto; }

/* ── Календар ── */
.mt-cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.mt-cal-month { background: var(--mt-paper); border: 1px solid var(--mt-line); border-radius: 12px; padding: 18px 22px; scroll-margin-top: 20px; }
.mt-cal-month.is-current { border-color: var(--mt-gold); box-shadow: inset 0 3px 0 var(--mt-gold); }
.mt-cal-month h4 { font-family: 'Playfair Display', Georgia, serif; font-size: 20px; margin: 0 0 12px; }
.mt-cal-month dl { display: grid; grid-template-columns: 34px 1fr; gap: 10px 12px; margin: 0; }
.mt-cal-month dt { font-weight: 700; font-size: 18px; color: var(--mt-gold); line-height: 1.3; }
.mt-cal-month dd { margin: 0; line-height: 1.4; }
.mt-cal-title { font-weight: 600; }
.mt-cal-year { font-size: 12px; color: var(--mt-muted); margin-left: 6px; }
.mt-cal-desc { display: block; font-size: 13px; color: #555; margin-top: 3px; }

@media (max-width: 640px) {
  .mt-subnav a { padding: 9px 12px; font-size: 13px; }
  .mt-news-item { grid-template-columns: 1fr; }
  .mt-news-cover img { max-height: 200px; }
  .mt-dates li { grid-template-columns: 1fr; gap: 2px; }
  .mt-books { grid-template-columns: repeat(2, 1fr); gap: 22px 14px; }
  .mt-archive li { grid-template-columns: 1fr; gap: 2px; }
}

/* ═══════════ Переглядач (reader.php) ═══════════ */
.mr-body {
  margin: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: #2b2a28; color: #f3f1ec;
  font-family: 'Montserrat', sans-serif;
}
.mr-bar {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: #1f1e1c; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.mr-back, .mr-download { color: #f3f1ec; text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.mr-download { padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 6px; }
.mr-download:hover, .mr-back:hover { color: #fff; border-color: #fff; }
.mr-title { flex: 1; min-width: 0; text-align: center; line-height: 1.3; }
.mr-title strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-title span { font-size: 12px; color: rgba(243, 241, 236, .6); }

.mr-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 12px; }
.mr-book { margin: 0 auto; }
.mr-page { background: #fff; overflow: hidden; }
.mr-page::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, #f4f2ee 25%, #ebe8e2 50%, #f4f2ee 75%);
}
.mr-page.is-ready::before { display: none; }
.mr-page-num {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: #888; pointer-events: none;
}
.mr-page.is-ready .mr-page-num { display: none; }

.mr-status { text-align: center; font-size: 14px; }
.mr-status-bar { display: block; width: 220px; height: 4px; margin: 14px auto 0; background: rgba(255, 255, 255, .15); border-radius: 2px; overflow: hidden; }
.mr-status-bar span { display: block; height: 100%; width: 0; background: var(--mt-gold); transition: width .2s; }
.mr-status.is-error .mr-status-bar { display: none; }
.mr-status a { color: var(--mt-gold); }

.mr-controls {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px 18px 14px; background: #1f1e1c; border-top: 1px solid rgba(255, 255, 255, .08);
}
.mr-nav {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25);
  background: transparent; color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.mr-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.mr-nav:disabled { opacity: .3; cursor: default; }
.mr-counter { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.mr-counter input {
  width: 64px; padding: 6px 8px; text-align: center; font: inherit;
  background: #2b2a28; color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 6px;
}
.mr-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mr-noscript { text-align: center; padding: 20px; }
.mr-noscript a { color: var(--mt-gold); }

@media (max-width: 640px) {
  .mr-bar { flex-wrap: wrap; gap: 8px; }
  .mr-title { order: 3; flex-basis: 100%; }
}
