/* =====================================================================
   Страница PDF-документа (template-parts/doc-pdf.php) + просмотрщик.
   Подключается только на таких страницах (inc/doc-pdf.php).
   Палитра сайта: заголовки #213a59, текст #043b7e/#3d5d84, приглушённый #9eb6d2,
   границы #ced8e5, мягкий фон #f5f7f9.
   ===================================================================== */

.main--doc-pdf .docpdf-intro { gap: 16px; }

.docpdf-intro_kicker {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: .02em;
  color: #3d5d84;
}
.docpdf-intro_lead {
  max-width: 860px;
  margin: 0;
  font-size: 18px;
  line-height: calc(28 / 18);
  color: #043b7e;
}

.docpdf { padding: 32px 0 64px; }

/* ---- Реквизиты: равные плитки на всю ширину при любом их количестве ---- */
.docpdf_props-wrap { position: relative; margin: 0 0 24px; }
.docpdf_props {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 0;
}
.docpdf_prop {
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid #ced8e5;
  border-radius: 12px;
  background: #f5f7f9;
}
.docpdf_prop-label {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.3;
  color: #6f8bad;
}
.docpdf_prop-value {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
  color: #213a59;
}

/* ---- Скачать + формат ---- */
.docpdf_download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 0 0 12px;
}
.docpdf_download-btn { gap: 8px; }
.docpdf_download-icon { flex: none; }
.docpdf_download-meta {
  font-size: 15px;
  line-height: 1.4;
  color: #3d5d84;
}
.docpdf_source {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #6f8bad;
}
.docpdf_source a { color: #3d5d84; text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 3px; }

.docpdf_title {
  margin: 40px 0 16px;
  font-size: 32px;
  line-height: calc(36 / 32);
  font-weight: 600;
  color: #213a59;
}

/* ---- Просмотрщик ---- */
.docpdf-viewer {
  border: 1px solid #ced8e5;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
/* Панель: все контролы одной высоты (40px), одна строка без переносов — ничего не прыгает */
.docpdf-viewer_bar {
  --docpdf-ctrl: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: calc(var(--docpdf-ctrl) + 24px);
  padding: 12px 16px;
  border-bottom: 1px solid #ced8e5;
  background: #f5f7f9;
  box-sizing: border-box;
}
.docpdf-viewer_goto,
.docpdf-viewer_tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;
}
.docpdf-viewer_label,
.docpdf-viewer_total {
  font-size: 15px;
  line-height: 1;
  color: #3d5d84;
  white-space: nowrap;
}

.docpdf-viewer_ctrl {
  box-sizing: border-box;
  height: var(--docpdf-ctrl);
  margin: 0;
  border: 1px solid #ced8e5;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: #213a59;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.docpdf-viewer_ctrl:disabled { opacity: .6; cursor: default; }
.docpdf-viewer_ctrl:focus-visible,
.docpdf-viewer_scroll:focus-visible { outline: 2px solid #3d5d84; outline-offset: 1px; }
@media (hover: hover) {
  .docpdf-viewer_ctrl:not(:disabled):hover { border-color: #3d5d84; }
}

.docpdf-viewer_input {
  width: 64px;
  padding: 0 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.docpdf-viewer_input::-webkit-outer-spin-button,
.docpdf-viewer_input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.docpdf-viewer_btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.docpdf-viewer_go-icon { display: none; flex: none; }
.docpdf-viewer_fs { width: var(--docpdf-ctrl); padding: 0; }
.docpdf-viewer_fs[hidden] { display: none; }

/* Кастомный селект масштаба (кнопка + listbox, логика в doc-pdf-viewer.js) */
.docpdf-zoom { position: relative; }
.docpdf-zoom_btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 148px;
  padding: 0 14px;
  text-align: left;
  cursor: pointer;
}
.docpdf-zoom_value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docpdf-zoom_arrow { flex: none; color: #3d5d84; transition: transform .2s ease; }
.docpdf-zoom.is-open .docpdf-zoom_btn { border-color: #3d5d84; }
.docpdf-zoom.is-open .docpdf-zoom_arrow { transform: rotate(180deg); }
.docpdf-zoom_list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid #ced8e5;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(4, 59, 126, .14), 0 2px 6px rgba(4, 59, 126, .06);
  box-sizing: border-box;
  outline: none;
  animation: docpdf-zoom-in .14s ease-out;
}
.docpdf-zoom_list[hidden] { display: none; }
@keyframes docpdf-zoom-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.docpdf-zoom_opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 8px;
  font-size: 15px;
  color: #213a59;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.docpdf-zoom_check { flex: none; color: #3d5d84; opacity: 0; }
.docpdf-zoom_opt[aria-selected="true"] { font-weight: 600; }
.docpdf-zoom_opt[aria-selected="true"] .docpdf-zoom_check { opacity: 1; }
.docpdf-zoom_opt.is-active { background: #eef3f9; }
@media (hover: hover) {
  .docpdf-zoom_opt:hover { background: #f5f7f9; }
  .docpdf-zoom_opt.is-active:hover { background: #eef3f9; }
}
@media (prefers-reduced-motion: reduce) {
  .docpdf-zoom_list { animation: none; }
  .docpdf-zoom_arrow { transition: none; }
}

/* Статус загрузки — поверх области просмотра, без сдвига вёрстки */
.docpdf-viewer_body { position: relative; }
.docpdf-viewer_status {
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 16px;
  border: 1px solid #ced8e5;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(4, 59, 126, .08);
  font-size: 14px;
  line-height: 1.4;
  color: #3d5d84;
  text-align: center;
  box-sizing: border-box;
}
.docpdf-viewer_status[hidden] { display: none; }
.docpdf-viewer_status.is-error { border-radius: 12px; color: #b42318; }
.docpdf-viewer_status a { color: inherit; text-decoration: underline; }

.docpdf-viewer_scroll {
  height: min(85vh, 1200px);
  overflow: auto;
  background: #e8edf3;
  overscroll-behavior: contain;
}
.docpdf-viewer_pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: max-content;
  min-width: 100%;
  padding: 16px;
  box-sizing: border-box;
}
.docpdf-page {
  position: relative;
  flex: none;
  background: #fff;
  box-shadow: 0 1px 3px rgba(4, 59, 126, .12), 0 4px 14px rgba(4, 59, 126, .06);
}
.docpdf-page canvas { display: block; }

/* Полноэкранный режим */
.docpdf-viewer.is-fullscreen {
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border: 0;
}
.docpdf-viewer.is-fullscreen .docpdf-viewer_scroll { flex: 1; height: auto; }

/* ---- Похожие документы ---- */
.docpdf-related { padding: 0 0 80px; }
.docpdf-related .docpdf_title { margin-top: 0; }
.docpdf-related_list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.docpdf-related_link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 20px 24px;
  border: 1px solid #ced8e5;
  border-radius: 16px;
  background: #fff;
  color: #213a59;
  text-decoration: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.docpdf-related_kicker { font-size: 13px; color: #6f8bad; }
.docpdf-related_name { font-size: 17px; line-height: 1.35; font-weight: 600; }
@media (hover: hover) {
  .docpdf-related_link:hover { border-color: #9eb6d2; box-shadow: 0 6px 20px rgba(4, 59, 126, .08); }
  .docpdf-related_link:hover .docpdf-related_name { text-decoration: underline; }
}
.docpdf-related_all {
  font-size: 16px;
  color: #3d5d84;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-underline-offset: 3px;
}

/* ---- Адаптив ---- */
@media (max-width: 991.98px) {
  .docpdf-related_list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docpdf_title { font-size: 24px; margin-top: 32px; }
}
@media (max-width: 767.98px) {
  .docpdf { padding: 24px 0 48px; }
  .docpdf-intro_lead { font-size: 16px; line-height: 1.55; }

  /* Реквизиты — лента с прокруткой до края экрана: следующая плитка «выглядывает»,
     справа затухание, пока есть что листать (класс is-end снимает его). */
  .docpdf_props-wrap { margin: 0 -20px 24px; }
  .docpdf_props {
    grid-auto-columns: minmax(150px, 1fr);
    gap: 8px;
    padding: 0 20px 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 20px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .docpdf_props::-webkit-scrollbar { display: none; }
  .docpdf_props-wrap.is-scrollable .docpdf_props { grid-auto-columns: 42%; }
  .docpdf_prop { padding: 12px 14px; scroll-snap-align: start; }
  .docpdf_prop-value { font-size: 16px; }
  .docpdf_props-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 20px; /* над точками */
    width: 48px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff 85%);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
  }
  .docpdf_props-wrap.is-scrollable:not(.is-end)::after { opacity: 1; }
  .docpdf_props-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
  .docpdf_props-dot { width: 6px; height: 6px; border-radius: 50%; background: #ced8e5; transition: background-color .2s ease, width .2s ease; }
  .docpdf_props-dot.is-active { width: 18px; border-radius: 3px; background: #3d5d84; }

  .docpdf-viewer { border-radius: 12px; }
  .docpdf-viewer_bar { --docpdf-ctrl: 40px; gap: 8px; padding: 10px 12px; }
  /* подписи прячем визуально (для скринридеров остаются), «Перейти» → стрелка */
  .docpdf-viewer_label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .docpdf-viewer_goto { gap: 6px; }
  .docpdf-viewer_input { width: 52px; }
  .docpdf-viewer_go { width: var(--docpdf-ctrl); padding: 0; }
  .docpdf-viewer_go-text { display: none; }
  .docpdf-viewer_go-icon { display: block; }
  .docpdf-viewer_tools { gap: 6px; }
  .docpdf-zoom { min-width: 0; }
  .docpdf-zoom_btn { width: auto; min-width: 112px; max-width: 100%; gap: 6px; padding: 0 10px 0 12px; font-size: 14px; }
  .docpdf-viewer_scroll { height: 75vh; }
  .docpdf-viewer_pages { padding: 8px; gap: 8px; }
  .docpdf-related { padding-bottom: 56px; }
  .docpdf-related_list { grid-template-columns: 1fr; }
}
@media (max-width: 575.98px) {
  .docpdf_download-btn { width: 100%; justify-content: center; }
}
@media (max-width: 359.98px) {
  .docpdf-zoom_btn { padding: 0 8px 0 10px; }
}
