/* --- 基本レイアウト --- */
body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #f0f7fa !important;
  /* 透け防止に背景を強制 */
  /* iOS Safari ダブルタップズーム無効化 */
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.container {
  height: 100vh;
  padding: 0 !important;
  margin: 0 !important;
  background: #f0f7fa !important;
}

#storywrapper {
  width: 100vw;
  height: 100dvh;
  /* ✅ Safari対応の100%表示 */
  max-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f0f7fa !important;
  /* Debug or transparent */
}

.storyarea {
  position: relative !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100dvh !important;
  margin: 0;
  padding: 0;
  background: #f0f7fa !important;
}

.storyarea,
#storywrapper {
  height: calc(var(--vh, 1vh) * 100);
  /* fallbackあり */
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #e1eff6;
}

/* --- ローディング --- */
#loadingOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 9999;
}

#loadingOverlay.hidden {
  display: none;
}


/* --- CTAクリック --- */
.cta-slide-overlay {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  z-index: 30000;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 3rem 1rem;
  transition: right 0.4s ease-in-out;
}

/* ✅ 開いているとき（チェックON時） */
#ctaToggle:checked~.cta-slide-overlay {
  right: 0;
}

/* --- CTAボタン --- */
.cta-button-rect {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border-radius: 12px 0 0 12px;
  padding: 1.2em 0.7em;
  background: rgba(229, 57, 53, 0.8);
  color: #fff;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.05em;
  margin: 0;
  min-width: 2.5em;
  min-height: 5em;
  opacity: 0.9;
  max-width: 3em;
  position: fixed;
  top: 30px;
  right: 0;
  z-index: 1000;
}

.cta-button-rect:hover,
.cta-button-rect:focus {
  background: rgba(183, 28, 28, 0.9);
  color: #fff;
  text-decoration: none;
}

/* --- CTAコンテンツ --- */
.cta-slide-content {
  max-width: 600px;
  margin-top: 6vh;
  text-align: center;
}

.cta-title {
  font-size: 1.6rem;
  font-weight: bold;
}

.cta-description {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.95rem;
  color: #333;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.cta-slide-content.submitted .cta-form {
  display: none !important;
}

.cta-slide-content.submitted #ctaThanks {
  display: block !important;
}

/* --- 共通ボタン（CTA＋DL） --- */
.cta-button {
  position: fixed;
  top: 20px;
  right: 20px;
  width: auto;
  height: auto;
  padding: 15px 8px;
  background-color: rgba(220, 38, 38, 0.95);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20000;
  color: white;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-appearance: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 16px;
  letter-spacing: 2px;
  line-height: 1.5;
}

/* --- スマホ時調整 --- */
@media (max-width: 600px) {
  .cta-button {
    padding: 12px 6px;
    font-size: 14px;
  }
}

@media (orientation: portrait) {
  .cta-button {
    padding: 12px 6px;
    font-size: 14px;
  }
}

.cta-button:hover {
  background-color: rgba(220, 38, 38, 1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.cta-badge {
  position: absolute;
  left: 0;
  top: 50%;
  background: red;
  color: white;
  font-size: 0.8vw;
  font-weight: bold;
  border-radius: 50%;
  width: 2vw;
  height: 2vw;
  min-width: 18px;
  min-height: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translate(-60%, -50%);
  display: none;
  /* ← 初期非表示 */
  writing-mode: horizontal-tb;
  font-family: inherit;
  letter-spacing: normal;
  text-orientation: mixed;
}

/* ぶるぶるアニメーション */
@keyframes shake {
  0% {
    transform: rotate(0deg);
  }

  20% {
    transform: rotate(-10deg);
  }

  40% {
    transform: rotate(10deg);
  }

  60% {
    transform: rotate(-6deg);
  }

  80% {
    transform: rotate(6deg);
  }

  100% {
    transform: rotate(0deg);
  }
}

.cta-shake {
  animation: shake 0.5s ease-in-out;
}

.cta-button:hover {
  background: #fff;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45), 0 3px 12px 0 rgba(0, 0, 0, 0.22);
}

/* 画像+音声スタイル用の追加CSS */
.story-image {
  position: absolute;
  max-width: 100vw;
  max-height: 100vh;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  height: var(--real-vh) !important;
  max-height: var(--real-vh) !important;
}

.story-image.active {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto;
}

img.story-image,
#storyPoster {
  max-width: 100vw;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  display: block;
  margin: auto;
  object-fit: contain;
  height: var(--real-vh) !important;
  max-height: var(--real-vh) !important;
}

.page-indicator {
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.8rem;
  z-index: 1000;
  position: absolute;
  top: auto;
  bottom: 8px;
  right: 8px;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  pointer-events: none;
  letter-spacing: 0.05em;
  display: block;
  visibility: visible;
  opacity: 1;
}

/* ===== overlay_partial用ナビゲーションボタン強制上書き ===== */
.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem !important;
  background-color: rgba(41, 34, 34, 0.3);
  color: #ffffff;
  border: none;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  border-radius: 50%;
  transition: background-color 0.3s ease;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.nav-button i {
  font-size: 2rem !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}

.nav-button:hover {
  background-color: rgba(41, 34, 34, 0.3);
}

.nav-button:active {
  background-color: rgba(41, 34, 34, 0.3);
}

#prevBtn {
  left: 10px;
}

#nextBtn {
  right: 10px;
}

/* ポスター再生ボタン */
.play-pause-btn {
  font-size: 2.5rem;
  color: #222;
  background: rgba(255, 255, 255, 0.35);
  border: none;
  border-radius: 50%;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.play-pause-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: translate(-50%, -50%) scale(1.1);
}

.play-pause-btn i {
  font-size: 3rem;
  color: #333;
  margin-left: 4px;
  /* 再生アイコンの視覚的バランス調整 */
}

.play-pause-btn.hidden {
  display: none !important;
}

.story-nav-wide {
  max-width: 100vw !important;
  width: 100vw !important;
  margin-left: calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;
  border-radius: 1.25rem;
}


/* レスポンシブ対応 */
@media (max-width: 768px) {
  .nav-button {
    font-size: 1.5rem !important;
    padding: 12px 16px !important;
  }
  .nav-button i {
    font-size: 1.2rem !important;
    line-height: normal !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }
  #prevBtn {
    left: 10px;
  }
  #nextBtn {
    right: 10px;
  }
  .play-pause-btn {
    width: 80px;
    height: 80px;
  }
  .play-pause-btn i {
    font-size: 2rem;
  }
}

#imageViewer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: var(--real-vh) !important;
  min-height: var(--real-vh) !important;
  max-height: var(--real-vh) !important;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  background: #f0f7fa !important;
}

@supports (-webkit-touch-callout: none) {
  .story-image {
    max-height: calc(100vh - 6vh);
    /* Safariだけマージン逃がす */
  }

  #storywrapper {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
  }
}

/* フェードインアニメーション */
.fade-in {
  animation: fadeIn 0.8s ease;
  opacity: 1 !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* フェードアウトアニメーション（将来の拡張用） */
.fade-out {
  animation: fadeOut 0.8s ease;
  opacity: 0 !important;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

