/*!
 * PDF Modal v1.4.0
 */

/* 開いている間は背面のページをスクロールさせない */
html.pdfm-lock,
html.pdfm-lock body {
  overflow: hidden !important;
}

.pdfm {
  position: fixed;
  inset: 0;
  z-index: 100000; /* テーマの固定ヘッダーより前面に */
  display: none;
  align-items: center;
  justify-content: center;
}
.pdfm.is-open {
  display: flex;
}

/* 背景の暗幕 */
.pdfm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  animation: pdfm-fade 0.2s ease;
}

/* 子ウインドウ */
.pdfm__window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1000px, 92vw);
  height: 90vh;
  height: 90dvh;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: pdfm-pop 0.2s ease;
}

/* ヘッダー（タイトル・新しいタブ・閉じる） */
.pdfm__header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 8px 8px 8px 16px;
  background: #222;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
}
.pdfm__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: bold;
}
.pdfm__download,
.pdfm__download:visited {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.pdfm__download[hidden] {
  display: none !important;
}
.pdfm__download::before {
  content: "";
  width: 14px;
  height: 14px;
  background: currentColor;
  /* ダウンロードアイコン（↓ と受け皿） */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M6 10l6 6 6-6M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M6 10l6 6 6-6M4 20h16'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pdfm__download:hover,
.pdfm__download:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  outline: none;
}
.pdfm__close {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.pdfm__close:hover,
.pdfm__close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  outline: none;
}

/* 本文 */
.pdfm__body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: #525659;
}
.pdfm__iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* スマホ用（PDF.js で描画したページ） */
.pdfm__pages {
  padding: 10px;
}
.pdfm__page {
  width: 100%;
  margin: 0 auto 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.pdfm__page:last-child {
  margin-bottom: 0;
}
.pdfm__page canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pdfm__status {
  padding: 48px 16px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  line-height: 2;
}
.pdfm__fallback,
.pdfm__fallback:visited {
  color: #fff;
  text-decoration: underline;
}

/* スマホでは全画面表示 */
@media (max-width: 768px) {
  .pdfm__window {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .pdfm__header {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .pdfm__pages {
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  }
  .pdfm__page {
    margin-bottom: 6px;
  }
}

@keyframes pdfm-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pdfm-pop {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .pdfm__backdrop,
  .pdfm__window {
    animation: none;
  }
}
