/* ========================================
   Manga Viewer
======================================== */

.manga-viewer-data {
  display: none;
}

.wp-block-image.manga-viewer {
  position: relative;
}

/* ========================================
   表紙画像
======================================== */

.wp-block-image.manga-viewer .manga-viewer__cover {
  display: block;
  width: 700px !important;
  max-width: 100% !important;
  height: auto !important;

  cursor: pointer;
}

/* ========================================
   「タップして読む」
======================================== */

.manga-viewer__label {
  position: absolute;
  left: var(--manga-label-x, 50%);
  top: var(--manga-label-y, 50%);
  transform: translate(-50%, -50%);
  z-index: 2;

  display: flex;
  align-items: center;
  justify-content: center;

  min-height: 50px;
  min-width: 190px;
  padding: 10px 24px;

  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;

  background: rgba(0, 0, 0, 0.82);
  color: #fff;

  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.03em;
  white-space: nowrap;

  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.4);

  /*
   * ラベル自体はクリックを奪わない。
   * 下にある表紙画像へクリックを通す。
   */
  pointer-events: none;
}

.manga-viewer__label::before {
  content: "▶";
  margin-right: 8px;
  font-size: 13px;
}

/* ========================================
   全画面ビューア
======================================== */

.manga-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;

  display: none;

  background: rgba(0, 0, 0, 0.96);
}

.manga-lightbox.is-open {
  display: block;
}

/* ========================================
   画像表示領域
======================================== */

.manga-lightbox__image-area {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
}

.manga-lightbox__image,
.manga-lightbox__preview-image {
  display: block;

  max-width: 100%;
  max-height: 100%;

  width: auto;
  height: auto;

  object-fit: contain;

  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;

  pointer-events: none;
}

.manga-lightbox__image {
  position: relative;
  z-index: 2;

  transform:
    translate3d(
      var(--manga-image-x, 0px),
      0,
      0
    );
}

.manga-lightbox__preview-image {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;

  opacity: 0;

  transform:
    translate3d(
      calc(-50% + var(--manga-preview-image-x, 0px)),
      -50%,
      0
    );
}

.manga-lightbox__preview-image.is-visible {
  opacity: 1;
}

.manga-lightbox.is-dragging-image .manga-lightbox__image,
.manga-lightbox.is-dragging-image .manga-lightbox__preview-image,
.manga-lightbox.is-dragging-image .manga-lightbox__purchase {
  transition: none;
}

.manga-lightbox.is-sliding-image .manga-lightbox__image,
.manga-lightbox.is-sliding-image .manga-lightbox__preview-image,
.manga-lightbox.is-sliding-image .manga-lightbox__purchase {
  transition:
    transform 0.22s ease;
}

/* ========================================
   左右タップ領域
======================================== */

.manga-lightbox .manga-lightbox__next,
.manga-lightbox .manga-lightbox__prev {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 6;

  width: 50%;

  margin: 0;
  padding: 0;

  border: 0 !important;
  border-radius: 0 !important;

  outline: 0 !important;
  box-shadow: none !important;

  background: transparent !important;
  background-image: none !important;

  appearance: none;
  -webkit-appearance: none;

  cursor: pointer;
  pointer-events: auto;

  -webkit-tap-highlight-color: transparent;
}

.manga-lightbox .manga-lightbox__next {
  left: 0;
  right: auto;
}

.manga-lightbox .manga-lightbox__prev {
  right: 0;
  left: auto;
}

.manga-lightbox .manga-lightbox__next:focus,
.manga-lightbox .manga-lightbox__prev:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* ========================================
   読み方向の案内
======================================== */

.manga-lightbox__reading-hint {
  position: absolute;
  left: var(--manga-reading-hint-x, 50%);
  top: var(--manga-reading-hint-y, 50%);
  z-index: 12;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;

  min-width: 190px;
  padding: 18px 24px;

  transform: translate(-50%, -50%);

  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 12px;

  background: rgba(0, 0, 0, 0.78);
  color: #fff;

  opacity: 0;
  visibility: hidden;

  pointer-events: none;

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.42);

  transition:
    opacity 0.18s ease,
    visibility 0.18s ease;
}

.manga-lightbox__reading-hint.is-visible {
  opacity: 1;
  visibility: visible;
}

.manga-lightbox__reading-hint-arrow {
  width: 48px;
  height: 48px;

  background:
    url("./arrow.png")
    center / contain
    no-repeat;

  filter:
    drop-shadow(0 2px 8px rgba(255, 255, 255, 0.28));
}

.manga-lightbox__reading-hint-text {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

/* ========================================
   右上の閉じるボタン
======================================== */

.manga-lightbox__close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 20;

  width: 44px;
  height: 44px;

  border: 0 !important;
  border-radius: 50%;

  outline: 0;
  box-shadow: none !important;

  background: rgba(0, 0, 0, 0.65) !important;
  color: #fff;

  font-size: 28px;
  line-height: 44px;

  cursor: pointer;
}

/* ========================================
   ページ番号
======================================== */

.manga-lightbox__counter {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  z-index: 20;

  color: rgba(255, 255, 255, 0.8);

  font-size: 13px;

  pointer-events: none;
}

/* ========================================
   購入案内ページ
======================================== */

.manga-lightbox__purchase {
  position: absolute;
  inset: 0;
  z-index: 7;

  display: none;

  align-items: center;
  justify-content: center;

  padding:
    60px
    56px
    40px;

  background: #fff;

  transform:
    translate3d(
      var(--manga-purchase-x, 0px),
      0,
      0
    );
}

.manga-lightbox__purchase.is-visible {
  display: flex;
}

.manga-lightbox__purchase-inner {
  position: relative;
  z-index: 10;

  width: 100%;
  max-width: 420px;

  text-align: center;

  color: #333;
}

.manga-lightbox__purchase-title {
  margin: 0 0 26px;

  color: #ff6a2b;

  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}

/* ========================================
   購入リンク一覧
======================================== */

.manga-lightbox__purchase-links {
  width: 100%;
}

/* ========================================
   購入ボタン
======================================== */

.manga-lightbox__purchase-link {
  display: flex;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;

  width: 100%;
  min-height: 58px;

  margin: 14px 0;
  padding: 12px 20px;

  border-radius: 12px;

  background:
    linear-gradient(
      135deg,
      #ff6845,
      #ed472b
    );

  color: #fff;

  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;

  box-shadow:
    0 4px 12px rgba(190, 70, 35, 0.24);

  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}

.manga-lightbox__purchase-link:hover,
.manga-lightbox__purchase-link:focus {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ========================================
   購入画面の「閉じる」
======================================== */

.manga-lightbox__purchase-close {
  min-width: 120px;
  min-height: 44px;

  margin-top: 22px;
  padding: 10px 22px;

  border: 1px solid rgba(0, 0, 0, 0.18) !important;
  border-radius: 999px;

  box-shadow: none !important;

  background: #fff !important;
  color: #555;

  font-size: 15px;
  font-weight: 600;

  cursor: pointer;
}

.manga-lightbox__purchase-close:hover,
.manga-lightbox__purchase-close:focus {
  background: #f5f5f5 !important;
}

/* ========================================
   ビューア表示中
======================================== */

body.manga-viewer-open {
  overflow: hidden;
}
