/*
Theme Name: MRAV
Theme URI: https://example.com
Description: DMM API アフィリエイトサイト用 TikTok風テーマ
Version: 1.1.0
Author: MRAV
Text Domain: mrav
*/

/* ========================================
   リセット・基本設定
======================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, html {
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #fff;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  font-variant-emoji: text;
}

a { color: #3ea6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========================================
   3カラム共通レイアウト
======================================== */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.app-container.layout-b {
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
}

/* ========================================
   モバイル用ヘッダー
======================================== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 15px 20px;
  z-index: 100;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}
.mobile-header .logo { color: #e4007f; font-size: 24px; font-weight: bold; }
.mobile-header .logo a { color: inherit; text-decoration: none; }
.mobile-header .hamburger { color: #fff; cursor: pointer; background: none; border: none; display: flex; align-items: center; }

.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  padding: 60px 20px 20px;
  overflow-y: auto;
}
.mobile-menu-overlay.active { display: block; }
.mobile-menu-overlay .sidebar {
  display: block;
  width: 100%;
  border-right: none;
  padding: 0;
  background: transparent;
  overflow-y: visible;
}
.mobile-menu-close {
  position: absolute; top: 15px; right: 20px;
  color: #fff; cursor: pointer;
  background: none; border: none;
  display: flex; align-items: center;
}

/* ========================================
   左カラム: サイドバー
======================================== */
.sidebar {
  width: 240px;
  border-right: 1px solid #222;
  padding: 20px;
  background: #000;
  display: none;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar .site-logo { color: #e4007f; font-size: 28px; font-weight: bold; margin-bottom: 30px; }
.sidebar .site-logo a { color: inherit; text-decoration: none; }

.sidebar-search-wrap {
  position: relative;
  margin-bottom: 20px;
}
.sidebar-search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: #666;
  pointer-events: none;
}
.sidebar-search {
  width: 100%; padding: 10px 10px 10px 36px; border-radius: 20px;
  border: none; background: #222; color: #fff; outline: none;
}
.sidebar-search::placeholder { color: #666; }

.sidebar-menu { list-style: none; }
.sidebar-menu li {
  padding: 12px; font-weight: bold; cursor: pointer;
  border-radius: 8px; margin-bottom: 8px; color: #ccc;
}
.sidebar-menu li:hover { background: rgba(255,255,255,0.05); }
.sidebar-menu li.active { color: #e4007f; background: rgba(228,0,127,0.1); }
.sidebar-menu a {
  color: inherit; text-decoration: none;
  display: flex; align-items: center; gap: 12px;
}
.sidebar-menu a svg { flex-shrink: 0; }

/* ========================================
   中央カラム: メインコンテンツ
======================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.layout-a .main-content {
  overflow-y: auto;
  height: 100vh;
}

/* スクロールバー（Webkit: Chrome / Safari / Edge） */
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}
.main-content::-webkit-scrollbar-thumb:hover { background: #555; }

/* スクロールバー（Firefox） */
.main-content {
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

/* サイドバーのスクロールバーも統一 */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #222; border-radius: 2px; }
.sidebar { scrollbar-width: thin; scrollbar-color: #222 transparent; }

.layout-b .main-content {
  height: 100%;
  justify-content: center;
  align-items: center;
}

/* ========================================
   右カラム: 広告枠
======================================== */
.right-column {
  width: 240px;
  border-left: 1px solid #222;
  padding: 20px;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  background: #000;
  flex-shrink: 0;
}
.ad-placeholder {
  margin-top: auto;
  border: 1px dashed #444;
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 12px;
}

/* ========================================
   Swiper (作品ページ / レイアウトB)
======================================== */
.swiper { width: 100%; height: 100%; }
.swiper-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
}

.content-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  max-width: 100%;
  padding-bottom: 20px;
}

.video-info-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: flex-start;
  width: calc(50vh * 1.7778);
  position: relative;
}

.video-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.info-area {
  width: 100%;
  position: relative;
  user-select: text;
  -webkit-user-select: text;
}

h1.desc, .desc {
  font-size: 16px; font-weight: bold;
  margin: 0 0 10px 0; padding: 0; line-height: 1.4;
  color: #fff; overflow-wrap: break-word;
}

.accordion {
  background: rgba(0,0,0,0.95);
  border-radius: 8px; padding: 15px;
  display: none; font-size: 12px;
  border: 1px solid #333; line-height: 2;
  width: 100%;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.8);
  position: absolute; bottom: 100%; left: 0;
  z-index: 20; margin-bottom: 10px;
  user-select: text; -webkit-user-select: text;
}
.accordion.active { display: block; }
.accordion-row {
  margin-bottom: 6px; display: flex;
  flex-wrap: wrap; align-items: center; gap: 8px;
}
.accordion-desc {
  display: block;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  font-size: 0.9em;
  line-height: 1.6;
  color: #ccc;
}
.accordion-label { color: #aaa; min-width: 80px; font-weight: bold; }
.accordion a { color: #3ea6ff; text-decoration: underline; margin-right: 8px; }

.more-btn {
  cursor: pointer; color: #fff; font-size: 13px;
  font-weight: bold; text-decoration: underline;
  padding: 4px 0; display: inline-block;
  background: none; border: none;
}

/* モバイル用「もっと見る」（PC非表示） */
.mobile-more-btn {
  display: none;
}

/* モバイル用オーバーレイ（PC非表示） */
.detail-overlay {
  display: none;
}

.full-version-btn {
  display: block; width: 100%;
  background-color: #e4007f; color: #fff;
  text-align: center; padding: 14px 0;
  border-radius: 8px; font-size: 16px; font-weight: bold;
  text-decoration: none; margin-top: 15px;
  box-shadow: 0 4px 10px rgba(228,0,127,0.3);
  transition: background-color 0.2s;
}
.full-version-btn:hover { background-color: #c90070; text-decoration: none; }

.action-buttons {
  display: flex; flex-direction: column;
  gap: 20px; align-items: center;
}
.btn {
  background: none; border: none; color: #fff;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.btn-icon {
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
}
.btn span { font-size: 12px; font-weight: bold; }

/* お気に入りボタン アクティブ状態 */
.btn-fav.is-fav .btn-icon {
  background: rgba(228, 0, 127, 0.2);
}
.btn-fav.is-fav .btn-icon svg {
  fill: #e4007f;
  stroke: #e4007f;
}

/* お気に入りカード（一覧ページ） */
.fav-card { position: relative; }
.fav-remove {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.7); color: #fff;
  border: none; border-radius: 50%;
  font-size: 18px; line-height: 1;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  z-index: 5; transition: background 0.2s;
}
.fav-remove:hover { background: #e4007f; }

/* 履歴クリアボタン */
.history-clear-btn {
  background: none; border: 1px solid #444;
  color: #aaa; padding: 8px 16px;
  border-radius: 8px; font-size: 13px;
  cursor: pointer; transition: all 0.2s;
}
.history-clear-btn:hover { border-color: #e4007f; color: #e4007f; }

/* ========================================
   シェア フォールバックモーダル
======================================== */
.share-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
}
.share-modal {
  background: #1a1a1a;
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 420px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.share-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
  font-weight: bold; font-size: 15px; color: #fff;
}
.share-modal-close {
  background: none; border: none; color: #888; cursor: pointer;
  display: flex; align-items: center;
}
.share-modal-close:hover { color: #fff; }
.share-modal-body { padding: 12px 8px 20px; }
.share-modal-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  background: none; border: none; width: 100%;
  text-align: left;
  transition: background 0.15s;
}
.share-modal-item:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.share-modal-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #333;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.share-modal-icon-line { background: #06c755; }

@media (min-width: 600px) {
  .share-modal-overlay { align-items: center; }
  .share-modal { border-radius: 16px; }
}

/* ========================================
   トップページ・一覧ページ (レイアウトA)
======================================== */
.archive-header {
  padding: 30px 30px 0;
}
.archive-header h1 {
  font-size: 22px; font-weight: bold;
  color: #fff; margin-bottom: 10px;
}
.archive-header p {
  color: #888; font-size: 14px;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  padding: 30px;
}

.item-card {
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(228,0,127,0.15);
}
.item-card a { color: inherit; text-decoration: none; }

.item-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #222;
}

.item-card-body { padding: 12px; }
h2.item-card-title, .item-card-title {
  font-size: 13px; font-weight: bold;
  margin: 0; padding: 0;
  line-height: 1.4; color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.item-card-meta {
  font-size: 11px; color: #888;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.item-card-meta span { white-space: nowrap; }

.load-more-wrap { text-align: center; padding: 20px 30px 40px; }
.load-more-btn {
  background: #e4007f; color: #fff; border: none;
  padding: 12px 40px; border-radius: 8px;
  font-size: 14px; font-weight: bold; cursor: pointer;
  transition: background 0.2s;
}
.load-more-btn:hover { background: #c90070; }
.load-more-btn:disabled { background: #333; cursor: default; }

/* ========================================
   固定ページ
======================================== */
.page-content {
  padding: 40px 30px;
  max-width: 800px;
  line-height: 1.8;
}
.page-content h1 { font-size: 24px; font-weight: bold; margin-bottom: 20px; color: #fff; }
.page-content h2 { font-size: 18px; font-weight: bold; margin: 30px 0 10px; color: #fff; }
.page-content p { margin-bottom: 16px; color: #ccc; }
.page-content ul, .page-content ol { margin-bottom: 16px; padding-left: 24px; color: #ccc; }

/* ========================================
   ローディング
======================================== */
.loading-spinner {
  text-align: center; padding: 40px; color: #888;
}
.loading-spinner::after {
  content: '';
  display: inline-block;
  width: 24px; height: 24px;
  border: 2px solid #333;
  border-top-color: #e4007f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   PC版
======================================== */
@media (min-width: 1024px) {
  .sidebar { display: block; }
  .right-column { display: flex; }

  /* PC: accordion max-height with scroll */
  .layout-b .accordion.active {
    max-height: 40vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
  }
  .layout-b .accordion.active::-webkit-scrollbar { width: 4px; }
  .layout-b .accordion.active::-webkit-scrollbar-track { background: transparent; }
  .layout-b .accordion.active::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
}

/* ========================================
   モバイル・タブレット
======================================== */
@media (max-width: 1023px) {
  .mobile-header { display: flex; }
  .main-content { width: 100%; }

  .layout-a .main-content { padding-top: 60px; }
  .items-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px; padding: 15px;
  }
  .archive-header { padding: 15px 15px 0; }

  /* ========================================
     モバイル: layout-b 全画面レイアウト
  ======================================== */

  /* app-containerを縦並びに（ヘッダー→メイン） */
  .layout-b.app-container {
    flex-direction: column;
  }

  /* ヘッダー: 固定位置ではなくフロー内配置、不透明 */
  .layout-b .mobile-header {
    position: static;
    background: #0a0a0a;
    flex-shrink: 0;
    padding: 10px 14px;
  }

  /* メインコンテンツ: 残り全部 */
  .layout-b .main-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* スライド: 上詰め、overflow:hidden でスクロール伝播を防止 */
  .layout-b .swiper-slide {
    padding-top: 0;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
  }

  /* content-wrapper: スライドいっぱい */
  .layout-b .content-wrapper {
    flex-direction: column;
    padding-bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    gap: 0;
  }

  /* video-info-container: 縦flexで全体管理 */
  .layout-b .video-info-container {
    max-width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    gap: 0;
    display: flex;
    flex-direction: column;
  }

  /* 動画: 固定、16:9 */
  .layout-b .video-wrapper {
    border-radius: 0;
    flex-shrink: 0;
  }
  .layout-b .main-video {
    border-radius: 0;
  }

  /* タイトル: 固定（常に表示） */
  .layout-b .desc {
    flex-shrink: 0;
    font-size: 14px;
    margin-bottom: 0;
    padding: 10px 56px 6px 14px;
  }

  /* PC用アコーディオンボタン → モバイル非表示 */
  .layout-b .pc-accordion-btn { display: none !important; }

  /* 情報エリア: 残りスペースを埋める、溢れたら隠す */
  .layout-b .info-area {
    flex: 1;
    overflow: hidden;
    padding: 0 14px;
    position: relative;
    min-height: 0;
  }
  .layout-b .info-inner {
    overflow: hidden;
  }

  /* アコーディオン → モバイルでは常に展開・インライン表示 */
  .layout-b .accordion {
    display: block !important;
    position: static;
    box-shadow: none;
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 12px;
    line-height: 1.7;
  }
  .layout-b .accordion-row {
    margin-bottom: 2px;
  }
  .layout-b .accordion-desc {
    margin-top: 6px;
    padding-top: 6px;
    margin-bottom: 0;
  }

  /* モバイル用「もっと見る」ボタン（グラデフェード付き） */
  .layout-b .mobile-more-btn {
    display: none;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 14px 6px;
    background: linear-gradient(to bottom, rgba(10,10,10,0) 0%, rgba(10,10,10,1) 50%);
    color: #3ea6ff;
    font-size: 12px;
    text-decoration: underline;
    border: none;
    cursor: pointer;
    text-align: left;
    z-index: 5;
  }
  .layout-b .mobile-more-btn.visible {
    display: block;
  }

  /* 展開状態: info-area内スクロール（もっと見る→閉じる） */
  .layout-b .info-area.expanded {
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .layout-b .info-area.expanded .info-inner {
    overflow: visible;
  }
  .layout-b .info-area.expanded .mobile-more-btn {
    position: sticky;
    bottom: 0;
    display: block;
    background: linear-gradient(to bottom, rgba(10,10,10,0) 0%, rgba(10,10,10,1) 40%);
    padding: 20px 14px 8px;
    text-align: right;
    text-decoration: none;
  }

  /* CTA: 常に最下部に表示 */
  .layout-b .full-version-btn {
    flex-shrink: 0;
    margin-top: 0;
    border-radius: 0;
    z-index: 10;
    font-size: 14px;
    padding: 12px 0;
    width: 100%;
  }

  /* アクションボタン: 右端オーバーレイ */
  .layout-b .action-buttons {
    position: absolute;
    right: 6px;
    z-index: 50;
    gap: 10px;
  }
  .layout-b .action-buttons .btn-icon {
    width: 42px; height: 42px;
  }
  .layout-b .action-buttons .btn span {
    font-size: 10px;
  }

  /* ========================================
     モバイル: 詳細オーバーレイ（もっと見る → ×で閉じる）
  ======================================== */
  /* --- オーバーレイ本体（position:absolute でスライド基準） --- */
  .layout-b .detail-overlay {
    display: none;
    position: absolute;
    /* top はJSで設定（動画の下端、スライド基準） */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    background: rgba(10,10,10,0.97);
    flex-direction: column;
  }
  .layout-b .detail-overlay.open {
    display: flex;
  }
  /* --- ×ボタン（オーバーレイ内 absolute） --- */
  .detail-overlay-close {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 252;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
  }
  /* --- スクロール領域（flex:1 で残りスペースを埋める） --- */
  .detail-overlay-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 20px;
  }
  .detail-overlay-inner h3 {
    font-size: 15px;
    font-weight: bold;
    line-height: 1.4;
    margin-bottom: 14px;
    padding-right: 40px;
  }
  .overlay-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.8;
    color: #ccc;
  }
  .overlay-label {
    color: #777;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
    font-weight: bold;
  }
  .overlay-value a {
    color: #3ea6ff;
    text-decoration: underline;
    margin-right: 6px;
  }
  .overlay-desc {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #222;
    font-size: 13px;
    line-height: 1.8;
    color: #aaa;
  }
  .overlay-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 14px;
  }
  .overlay-images img {
    width: 100%;
    border-radius: 4px;
  }
  /* --- オーバーレイ内CTA: メインCTAが常に見えるため非表示 --- */
  .overlay-cta {
    display: none;
  }
}

/* ========================================
   モバイル（スマホ）: グリッドは2列
======================================== */
@media (max-width: 599px) {
  .items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }
}


/* ========================================
   数字ページネーション
======================================== */
.mrav-pagination {
  padding: 10px 30px 40px;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.mrav-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  color: #ddd;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.mrav-pagination .page-numbers:hover {
  background: #2a2a2a;
  border-color: #555;
}
.mrav-pagination .page-numbers.current {
  background: #e4007f;
  border-color: #e4007f;
  color: #fff;
  font-weight: 600;
}
.mrav-pagination .page-numbers.dots {
  background: transparent;
  border: none;
}
@media (max-width: 599px) {
  .mrav-pagination { padding: 6px 12px 30px; gap: 4px; }
  .mrav-pagination .page-numbers { min-width: 32px; height: 32px; font-size: 13px; padding: 0 8px; }
}
