/* xclip Phase 1 — Tailwind CSS で大半カバー、ここは補助 */

/* line-clamp polyfill (Tailwind に組込みあるが Safari 古い版対応) */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* fade-in for newly inserted tiles (motion でも上書きされる) */
.video-tile {
    animation: fadeInUp 0.4s ease-out backwards;
}
.video-tile:nth-child(2) { animation-delay: 0.04s; }
.video-tile:nth-child(3) { animation-delay: 0.08s; }
.video-tile:nth-child(4) { animation-delay: 0.12s; }
.video-tile:nth-child(5) { animation-delay: 0.16s; }
.video-tile:nth-child(6) { animation-delay: 0.20s; }
.video-tile:nth-child(7) { animation-delay: 0.24s; }
.video-tile:nth-child(8) { animation-delay: 0.28s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Cloudflare Turnstile — ダークテーマに馴染ませる */
.cf-turnstile {
    margin: 4px 0;
}

/* スクロールバー (Chromium 系) を細く + ダーク */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #13131a; }
::-webkit-scrollbar-thumb { background: #2a2a36; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a5e; }

/* モバイルナビ等のスクロールバー非表示 */
.scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-none::-webkit-scrollbar { display: none; }

/* タッチデバイス: hover を tap で出ないように軽減、active 強調 */
@media (hover: none) {
    .video-tile:hover { transform: none !important; }
    button:active, a:active { opacity: 0.7; }
}

/* iOS Safari の input ズーム抑止 (font-size 16px 以上必須) */
@media (max-width: 640px) {
    input[type="text"], input[type="url"], input[type="email"], textarea, select {
        font-size: 16px;
    }
}

/* ===== マイクロインタラクション ===== */
/* タイルの hover で軽い光彩 (Dark Neon ブランド強化) */
.video-tile {
    will-change: transform;
}
.video-tile:focus-within {
    outline: 2px solid rgba(139, 92, 246, 0.6);
    outline-offset: 2px;
}

/* ボタン押下時の触覚的フィードバック (active scale) */
button:not(:disabled):active, .btn-x-out:active {
    transform: scale(0.96);
}

/* スケルトンローディング (無限スクロール待機中の体感速度UP) */
.skeleton-tile {
    aspect-ratio: 16 / 9;
    background: linear-gradient(110deg, #1c1c25 30%, #2a2a36 50%, #1c1c25 70%);
    background-size: 200% 100%;
    border-radius: 1rem;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
}
@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* リンクの focus visible 強化 (キーボード操作 a11y) */
a:focus-visible, button:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== 広告スロット (Dark Neon に馴染ませる、過度に目立たない) ===== */
.xclip-adslot {
    margin: 1rem 0;
    padding: 0.5rem;
    border-radius: 0.75rem;
    background: rgba(28, 28, 37, 0.4);
    border: 1px solid rgba(124, 92, 246, 0.15);
    overflow: hidden;
    /* 広告本体は中央寄せ、外部スクリプトの幅自動調整に任せる */
    text-align: center;
    min-height: 50px;
}
.xclip-adslot iframe, .xclip-adslot ins, .xclip-adslot img {
    max-width: 100%;
    height: auto;
}
.xclip-adslot-tile {
    grid-column: 1 / -1; /* グリッド内では全幅取得 */
}

/* prefers-reduced-motion 対応 (アクセシビリティ規格) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== モバイル最適化 (33Agent並列リサーチ統合実装) ===== */

/* iOS Safari: tap時の青色フラッシュ抑止 */
* { -webkit-tap-highlight-color: transparent; }

/* iOS の text-size-adjust を 100% に固定(none禁止) — OS フォントスケール尊重 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Safe-area: ノッチ・Dynamic Island・iPhone ホームインジケータ対応 */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Cross-document View Transitions (Chrome 126+/Safari 18.2+で全ページ遷移にフェード、非対応はスキップ) */
@view-transition { navigation: auto; }

/* オーバースクロール抑制(モバイルbounceを抑える、コンテナ単位は別途) */
html, body { overscroll-behavior-y: none; }

/* ===== タイル aspect-ratio 自動判定 (JS で xclip-portrait/square/landscape 付与) ===== */
/* デフォルトは object-cover で 16:9、縦動画は object-position を top に寄せて顔切れ防止 */
.xclip-portrait img { object-position: center top; }
.xclip-portrait .absolute.top-2 { top: 0.25rem; }  /* category badge 干渉避け */

/* ===== 動画詳細 SP スティッキー下部アクションバー (md 以上では表示しない) ===== */
.xclip-detail-actionbar {
    position: fixed;
    bottom: 64px;  /* Bottom Nav の上に重ねる */
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 0; right: 0;
    z-index: 35;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(28, 28, 37, 0.6);
    padding: 0.5rem 0.75rem;
}

/* ===== Bottom Navigation Bar ===== */
.xclip-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 40;
}
/* メインコンテンツがボトムナビに隠れないよう下余白 (SP のみ表示) */
@media (max-width: 767px) {
    main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ===== Headroom: スクロール方向でヘッダー自動隠し/表示 ===== */
.xclip-header {
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
    will-change: transform;
}
.xclip-header.is-hidden { transform: translateY(-100%); }

/* ===== WCAG コントラスト補強 (white on neon-pink 3.53:1 → text-shadow で実効性UP) ===== */
.bg-gradient-to-r.from-neon-600,
.bg-gradient-to-r.from-neon-pink {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ===== Toast / Snackbar ===== */
.xclip-toast-container {
    position: fixed;
    bottom: max(72px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    width: min(92vw, 360px);
    pointer-events: none;
}
.xclip-toast {
    pointer-events: auto;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    background: rgba(28, 28, 37, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    border: 1px solid rgba(124, 92, 246, 0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
    animation: xclip-toast-slide-in 0.25s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.xclip-toast.is-success { border-color: rgba(34, 197, 94, 0.5); }
.xclip-toast.is-error   { border-color: rgba(239, 68, 68, 0.5); }
.xclip-toast.is-leaving { animation: xclip-toast-fade-out 0.25s ease forwards; }
@keyframes xclip-toast-slide-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes xclip-toast-fade-out {
    to { opacity: 0; transform: translateY(8px); }
}
