/* ========================================
   IIFF BG VIDEO — フロントエンドCSS
   ======================================== */

.iiffbv-block {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}

/* ========================================
   動画レイヤー
   ======================================== */
.iiffbv-video-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  /* CSS filter はインラインスタイルで付与 */
}

.iiffbv-video-layer iframe,
.iiffbv-video-layer video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 16 / 9;
  pointer-events: none;
  border: none;
}

.iiffbv-video-layer.iiffbv-cover iframe,
.iiffbv-video-layer.iiffbv-cover video {
  width: 177.78vh;
  height: 56.25vw;
  min-width: 100%;
  min-height: 100%;
}

/* ========================================
   テクスチャレイヤー（ドット・ブラシ共通）
   ======================================== */
.iiffbv-texture-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* ---- ドットパターン ---- */
.iiffbv-texture-dot {
  background-image: radial-gradient(
    circle,
    rgba(0, 0, 0, 0.9) 1.2px,
    transparent 1.2px
  );
  background-size: var(--iiffbv-dot-size, 6px) var(--iiffbv-dot-size, 6px);
  background-position: 0 0;
}

/* ---- ブラシテクスチャ（SVGはPHPで出力） ---- */
.iiffbv-texture-brush {
  /* SVG rect がブラシノイズを描画する */
}
.iiffbv-texture-brush svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ========================================
   カラーオーバーレイ
   ======================================== */
.iiffbv-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* ========================================
   モバイルフォールバック
   ======================================== */
.iiffbv-mobile-fallback {
  display: none;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 3;
}

/* ========================================
   シネマチックレターボックスバー
   ======================================== */
.iiffbv-cinematic-bars {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.iiffbv-cinematic-bars::before,
.iiffbv-cinematic-bars::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  background: #000;
  height: 11%;    /* 2.35:1 シネマスコープ比率 */
}

.iiffbv-cinematic-bars::before { top: 0; }
.iiffbv-cinematic-bars::after  { bottom: 0; }

/* シネマチック時はコンテンツをバーの内側に収める */
.iiffbv-has-cinematic .iiffbv-content {
  padding-top: 11%;
  padding-bottom: 11%;
}

/* ========================================
   コンテンツ層
   ======================================== */
.iiffbv-content {
  position: relative;
  z-index: 10;
  margin: 0 auto;
  width: 100%;
}

.iiffbv-content--normal {
  max-width: var(--content-width, 860px);
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.iiffbv-content--wide {
  max-width: var(--wide-content-width, 1200px);
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.iiffbv-content--full {
  max-width: 100%;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ========================================
   パララックス
   ======================================== */
.iiffbv-has-parallax .iiffbv-video-layer {
  inset: auto;
  top: -30%;
  left: 0;
  right: 0;
  height: 160%;
  position: absolute;
}

/* ========================================
   モバイル
   ======================================== */
@media (max-width: 767px) {
  .iiffbv-video-layer {
    display: none;
  }
  .iiffbv-mobile-fallback {
    display: block;
  }
  /* フォールバック画像なしの場合は動画を継続表示 */
  .iiffbv-block:not(:has(.iiffbv-mobile-fallback)) .iiffbv-video-layer {
    display: block;
  }
  /* スマホではシネマバーを縮小 */
  .iiffbv-cinematic-bars::before,
  .iiffbv-cinematic-bars::after {
    height: 7%;
  }
  .iiffbv-has-cinematic .iiffbv-content {
    padding-top: 7%;
    padding-bottom: 7%;
  }
}

/* ========================================
   Facade: ポスター / ローディング / フェードイン
   ======================================== */

/* ポスター画像をビデオレイヤー背景にセット（JS が dataset.poster から適用） */
.iiffbv-video-layer.iiffbv-has-poster {
  background-size: cover;
  background-position: center;
  background-image: var(--iiffbv-poster, none); /* JSで直接styleにも設定 */
}

/* 読み込み中: iframe/video は透明 */
.iiffbv-video-layer.iiffbv-loading iframe,
.iiffbv-video-layer.iiffbv-loading video {
  opacity: 0;
}

/* 再生開始後: フェードイン */
.iiffbv-video-layer.iiffbv-loaded iframe,
.iiffbv-video-layer.iiffbv-loaded video {
  opacity: 1;
  transition: opacity 0.9s ease;
}

/* ========================================
   エンプティ
   ======================================== */
.iiffbv-empty {
  background: #f0f0f0;
  padding: 2rem;
}

/* ========================================
   セクション内での調整
   ======================================== */
.l-section .iiffbv-block,
.p-section .iiffbv-block {
  margin-left: calc(-1 * var(--section-padding-x, 0px));
  margin-right: calc(-1 * var(--section-padding-x, 0px));
}
