/*
Theme Name: ヌキリール
Theme URI: https://eromanga-s.com
Author: eromanga-s
Author URI: https://eromanga-s.com
Description: AV作品を縦スワイプで探せるTikTok風ショートフィードテーマ。FANZA API連携、サンプル動画自動再生、ジャンル検索、いいね機能搭載。
Version: 2.6.0
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: nukireel
Tags: dark, one-column, full-width-template
*/

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif; font-size: 16px; -webkit-text-size-adjust: 100%; }
body { background: #0a0a0f; color: #e8e8ed; overflow: hidden; height: 100dvh; width: 100vw; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid #6c5ce7; outline-offset: 2px; }

/* WP admin bar */
body.admin-bar .topbar { top: 32px; }
body.admin-bar .feed-tabs { top: calc(32px + 56px); }
@media (max-width: 782px) {
  body.admin-bar .topbar { top: 46px; }
  body.admin-bar .feed-tabs { top: calc(46px + 56px); }
}

/* ===== 年齢認証ゲート ===== */
.age-dimmer {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9998;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.age-dimmer.is-hidden { display: none; }
.age-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: transparent; border: none; color: #e8e8ed;
}
.age-gate.is-hidden { display: none; }
.gate-card {
  background: #18181f; border-radius: 20px; padding: 40px 32px;
  text-align: center; max-width: 360px; width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.gate-brand {
  font-size: 1.5rem; font-weight: 800; letter-spacing: .04em;
  background: linear-gradient(135deg, #f97066, #e84393);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 24px;
}
.gate-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.gate-card p { font-size: .9rem; color: #9999a8; margin-bottom: 24px; }
.gate-actions { display: flex; flex-direction: column; gap: 12px; }
.btn-primary {
  display: block; width: 100%; padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, #e84393, #f97066); color: #fff;
  font-weight: 700; font-size: 1rem; transition: opacity .2s;
}
.btn-primary:hover { opacity: .85; }
.btn-secondary {
  display: block; padding: 12px; border-radius: 12px;
  background: #2a2a35; color: #9999a8; font-size: .9rem; transition: background .2s;
}
.btn-secondary:hover { background: #35354a; }
.gate-links { margin-top: 24px; display: flex; gap: 16px; justify-content: center; }
.gate-links a { font-size: .75rem; color: #666; transition: color .2s; }
.gate-links a:hover { color: #999; }

/* ===== アプリレイアウト ===== */
.app { display: flex; flex-direction: column; height: 100dvh; width: 100vw; position: relative; }
.app.is-hidden { display: none; }

/* ヘッダー */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: linear-gradient(to bottom, rgba(10,10,15,.95), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  font-size: 1.1rem; font-weight: 800; letter-spacing: .04em;
  background: linear-gradient(135deg, #f97066, #e84393);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand a { color: inherit; -webkit-text-fill-color: inherit; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(255,255,255,.1);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.2); }
.icon-btn svg { width: 20px; height: 20px; }

/* フィードタブ */
.feed-tabs {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 56px);
  left: 0; right: 0; z-index: 99;
  display: flex; justify-content: center; gap: 8px; padding: 4px 16px;
  pointer-events: none;
}
.feed-tabs > * { pointer-events: auto; }
.tab {
  padding: 6px 16px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  background: rgba(255,255,255,.08); color: #888; transition: all .2s;
}
.tab.is-active { background: rgba(255,255,255,.2); color: #fff; }
.tab:hover { background: rgba(255,255,255,.15); }

/* ===== リールフィード ===== */
.reel {
  flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.reel::-webkit-scrollbar { display: none; }
.reel-item {
  height: 100dvh; width: 100%; scroll-snap-align: start;
  position: relative; display: flex; align-items: center; justify-content: center;
  background: #0a0a0f; overflow: hidden;
}

/* ジャケット画像 — 画面中央に配置 */
.reel-cover {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 85%; max-height: 70%;
  width: auto; height: auto;
  object-fit: contain; pointer-events: none;
  transition: opacity .5s ease;
  z-index: 0;
}
.reel-cover.is-faded { opacity: 0; }

/* 動画スロット — 画面中央に配置 */
.video-slot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  /* 16:9 のプレーヤーを画面幅に収める、ただし高さは画面の60%まで */
  max-width: min(100%, calc(60dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  z-index: 1;
}
.reel-iframe {
  width: 100%; height: 100%; border: none;
  background: #000; border-radius: 8px;
}

/* 再生ボタンオーバーレイ — ジャケット画像の上に中央配置 */
.play-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: background .3s, transform .2s;
}
.play-overlay svg { width: 56px; height: 56px; }
.play-overlay span { color: #fff; font-size: .7rem; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.play-overlay:hover { background: rgba(0,0,0,.55); transform: translate(-50%, -50%) scale(1.05); }
.play-overlay:active { transform: translate(-50%, -50%) scale(.95); }
.play-overlay.is-hidden { display: none; }

/* バッジ */
.reel-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: .6rem; font-weight: 700; margin-bottom: 6px; letter-spacing: .03em;
}
.badge-video { background: rgba(233,67,147,.4); color: #fcc; }
.badge-local { background: rgba(46,213,115,.4); color: #afc; }

/* グラデーションオーバーレイ — 下部のみ（タイトル背景） */
.reel-item::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 40%; z-index: 2;
  background: linear-gradient(to top, rgba(10,10,15,.95) 0%, rgba(10,10,15,.5) 50%, transparent 100%);
  pointer-events: none;
}

/* 横画面（landscape）: プレーヤーを全画面化 */
@media (orientation: landscape) and (max-height: 500px) {
  .video-slot {
    top: 0; left: 0; transform: none;
    width: 100%; height: 100%; max-width: none;
    aspect-ratio: auto;
  }
  .reel-iframe { border-radius: 0; }
  .reel-info { display: none; }
  .reel-actions { display: none; }
  .reel-item::after { display: none; }
  .topbar { display: none; }
  .feed-tabs { display: none; }
  .bottom-nav { display: none; }
  .play-overlay { width: 80px; height: 80px; }
  .play-overlay svg { width: 40px; height: 40px; }
  .play-overlay span { display: none; }
}

/* 作品情報 — 下部ナビの上に配置 */
.reel-info {
  position: absolute; bottom: 0; left: 0; right: 60px; z-index: 3;
  padding: 16px 16px;
  /* 下部ナビ = padding 8px + icon 24px + text 10px + padding-bottom 8px + safe-area ≈ 50px〜70px */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
}
.reel-code {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  background: rgba(233,67,147,.4); font-size: .7rem; font-weight: 700;
  letter-spacing: .05em; margin-bottom: 8px;
}
.reel-title {
  font-size: .82rem; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.reel-actress { font-size: .75rem; color: #f97066; margin-top: 6px; font-weight: 600; }

/* サイドアクション — 下部ナビの上に配置 */
.reel-actions {
  position: absolute; right: 8px; bottom: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
}
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #ccc; transition: color .2s;
}
.action-btn svg { width: 28px; height: 28px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.action-btn span { font-size: .65rem; }
.action-btn.is-liked { color: #ff6b6b; }
.action-btn.is-liked svg { fill: #ff6b6b; }

/* ローディング */
.reel-loading { height: 100dvh; display: grid; place-items: center; text-align: center; }
.reel-loading p { color: #666; margin-top: 12px; font-size: .85rem; }
.spinner {
  width: 32px; height: 32px; border: 3px solid #333;
  border-top-color: #e84393; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* デスクトップ前後ボタン */
.reel-nav {
  position: fixed; right: 20px; top: 50%; transform: translateY(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: 12px;
}
.reel-nav-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.1); backdrop-filter: blur(8px);
  display: grid; place-items: center; transition: background .2s;
}
.reel-nav-btn:hover { background: rgba(255,255,255,.2); }
.reel-nav-btn:disabled { opacity: .3; cursor: default; }
.reel-nav-btn svg { width: 24px; height: 24px; }

/* ===== 下部ナビ ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 0; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: rgba(10,10,15,.97); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.08);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #666; transition: color .2s; position: relative; padding: 4px 20px;
}
.nav-item.is-active { color: #fff; }
.nav-item svg { width: 24px; height: 24px; }
.nav-item span { font-size: .65rem; font-weight: 600; }
.like-count {
  position: absolute; top: -2px; right: 10px;
  background: #ff6b6b; color: #fff; font-size: .6rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px;
}
.like-count.is-hidden { display: none; }

/* ===== 検索シート ===== */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; }
.sheet-backdrop.is-hidden { display: none; }
.search-sheet, .likes-sheet, .gacha-sheet {
  position: fixed; inset: 0; z-index: 200;
  background: #0f0f17; overflow-y: auto;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.search-sheet.is-hidden, .likes-sheet.is-hidden, .gacha-sheet.is-hidden { display: block; }
.search-sheet.is-open, .likes-sheet.is-open, .gacha-sheet.is-open { transform: translateX(0); pointer-events: auto; }
.sheet-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: rgba(15,15,23,.95); backdrop-filter: blur(16px);
}
.sheet-header h2 { font-size: 1rem; font-weight: 700; }
.search-form { flex: 1; display: flex; gap: 8px; }
.search-form input {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  background: #1e1e2a; border: 1px solid #2a2a3a; color: #fff;
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.search-form input:focus { border-color: #e84393; }
.search-form input::placeholder { color: #555; }
.search-form button[type="submit"] {
  padding: 10px 16px; border-radius: 10px;
  background: #e84393; color: #fff; font-weight: 600; font-size: .85rem; transition: opacity .2s;
}
.search-form button[type="submit"]:hover { opacity: .85; }

/* ジャンルチップ */
.genre-grid { padding: 16px; }
.genre-grid h3 { font-size: .85rem; font-weight: 600; margin-bottom: 12px; color: #888; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chip {
  padding: 8px 14px; border-radius: 20px; font-size: .8rem; font-weight: 500;
  background: #1e1e2a; border: 1px solid #2a2a3a; color: #ccc; transition: all .2s;
}
.genre-chip:hover { background: #2a2a3a; }
.genre-chip.is-active { background: #e84393; border-color: #e84393; color: #fff; }

/* 検索結果グリッド */
.search-results {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; padding: 16px;
}
.search-card { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 7/10; background: #1a1a24; display: block; }
.search-card img { width: 100%; height: 100%; object-fit: cover; }
.search-card-info {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
}
.search-card-code { font-size: .65rem; font-weight: 700; color: #f97066; }
.search-card-title {
  font-size: .7rem; line-height: 1.3; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ===== いいねリスト ===== */
.likes-list { padding: 16px; }
.likes-empty { text-align: center; color: #555; padding: 60px 20px; font-size: .9rem; }
.likes-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.likes-item img { width: 70px; height: 100px; object-fit: cover; border-radius: 6px; }
.likes-item-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.likes-item-code { font-size: .7rem; color: #f97066; font-weight: 700; }
.likes-item-title { font-size: .8rem; margin-top: 4px; line-height: 1.3; }
.likes-item-link {
  display: inline-block; margin-top: 8px; padding: 4px 10px;
  border-radius: 6px; background: #e84393; color: #fff; font-size: .7rem; font-weight: 600;
}

/* ===== トースト ===== */
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 10px 20px; border-radius: 10px;
  background: rgba(30,30,42,.95); backdrop-filter: blur(12px);
  color: #fff; font-size: .8rem; font-weight: 500;
  opacity: 0; transition: all .3s; pointer-events: none; z-index: 300; white-space: nowrap;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== ガチャシート ===== */
.gacha-body {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.gacha-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 50vh; gap: 16px;
}
.gacha-loading p { color: #555; font-size: .8rem; }
.gacha-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 50vh; gap: 16px; width: 100%; max-width: 320px; text-align: center;
}
.gacha-error p { color: #888; font-size: .85rem; line-height: 1.6; }
.gacha-result { width: 100%; max-width: 400px; }
.gacha-card {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden;
  background: #111; aspect-ratio: 2/3;
}
.gacha-jacket {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.gacha-player {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: none; align-items: center; justify-content: center; background: #000;
}
.gacha-player.is-active { display: flex; }
.gacha-player iframe { width: 100%; aspect-ratio: 16/9; border: none; }
.gacha-play-btn {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.3); z-index: 2;
}
.gacha-play-btn.is-hidden { display: none; }
.gacha-play-btn svg { width: 56px; height: 56px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.gacha-meta { padding: 14px 0; text-align: center; }
.gacha-code {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  background: rgba(232,67,147,.12); color: #e84393; font-size: .7rem; font-weight: 700;
}
.gacha-title { font-size: .85rem; font-weight: 600; margin: 6px 0 4px; line-height: 1.4; color: #eee; }
.gacha-actress { font-size: .75rem; color: #777; }
.gacha-genres { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 8px; }
.gacha-genres span { padding: 2px 7px; border-radius: 8px; font-size: .6rem; background: #1a1a26; color: #888; }
.gacha-actions { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.gacha-official-btn, .gacha-like-btn {
  padding: 9px 18px; border-radius: 8px;
  background: #1a1a26; color: #aaa; font-size: .8rem; font-weight: 500; transition: background .2s;
}
.gacha-official-btn:hover, .gacha-like-btn:hover { background: #252535; }
.gacha-like-btn.is-liked { background: rgba(232,67,147,.15); color: #e84393; }
.gacha-retry-btn {
  display: block; width: 100%; margin-top: 16px;
  padding: 13px; border-radius: 10px; text-align: center;
  background: #1a1a26; border: 1px solid #2a2a3a; color: #ccc;
  font-size: .85rem; font-weight: 600; transition: all .15s;
}
.gacha-retry-btn:active { background: #252535; transform: scale(.98); }

/* クレジット */
.site-credit { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 56px); left: 16px; z-index: 3; }
.site-credit small { font-size: .6rem; color: #444; }
.site-credit a { color: #555; text-decoration: underline; }

/* ===== 固定ページ ===== */
.page-wrap {
  max-width: 700px; margin: 0 auto; padding: 60px 20px 100px;
  overflow-y: auto; height: 100dvh;
}
.page-wrap h1 { font-size: 1.3rem; margin-bottom: 20px; }
.page-wrap h2 { font-size: 1.1rem; margin: 24px 0 12px; }
.page-wrap p, .page-wrap li { font-size: .9rem; line-height: 1.8; color: #bbb; margin-bottom: 12px; }
.page-wrap a { color: #f97066; text-decoration: underline; }
.page-back { display: inline-block; margin-bottom: 20px; color: #888; font-size: .85rem; }
.page-back:hover { color: #fff; }

/* ===== 404 ===== */
.not-found { height: 100dvh; display: grid; place-items: center; text-align: center; }
.not-found h1 { font-size: 4rem; color: #333; }
.not-found p { color: #666; margin: 12px 0 24px; }

/* ===== レスポンシブ ===== */
.desktop-only { display: none; }
@media (min-width: 768px) {
  .desktop-only { display: flex; }
  .reel-info { padding-right: 80px; right: 80px; }
  .search-sheet, .likes-sheet, .gacha-sheet { left: auto; width: 420px; border-left: 1px solid rgba(255,255,255,.06); }
}
@media (min-width: 1024px) {
  .search-results { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (pointer: fine) {
  .search-sheet::-webkit-scrollbar, .likes-sheet::-webkit-scrollbar { width: 6px; }
  .search-sheet::-webkit-scrollbar-track, .likes-sheet::-webkit-scrollbar-track { background: transparent; }
  .search-sheet::-webkit-scrollbar-thumb, .likes-sheet::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
}
