/* ========== HoloClip Station — Page Shell (Pop Style) ========== */
:root {
    /* Handled by style.css but keeping basics for shell */
    --page-font: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --header-height: 66px;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--holo-bg);
    color: var(--holo-text);
    font-family: var(--page-font);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 準備完了後にトランジションを有効化 */
body:not(.loading-state) {
    transition: background-color 0.4s ease, color 0.4s ease;
}

.site-main,
.site-footer {
    transition: opacity 0.5s ease-out;
}



/* Header (Pop Style) */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    z-index: 8000;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 3px solid var(--holo-primary);
    min-height: var(--header-height);
    padding: var(--space-2) 0;
    box-shadow: 0 4px 12px rgba(0, 184, 240, 0.1);
}

.header-container {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--space-10);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.site-logo {
    text-decoration: none;
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 2px;
}

.logo-text {
    color: var(--holo-text);
}

.logo-accent {
    color: var(--holo-primary);
    position: relative;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    min-width: 0;
    justify-content: flex-end;
}

.header-nav a {
    text-decoration: none;
    color: var(--holo-text);
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    padding: 8px 16px;
    border-radius: 100px;
    transition: all 0.2s;
}

.header-update-time {
    font-size: 0.75rem;
    color: #A0AEC0;
    font-weight: 600;
    line-height: 1;
}

/* ========== Theme Toggle & Header Elements (Enhanced) ========== */

.holo-header-link {
    text-decoration: none;
    color: var(--holo-text);
    font-weight: 800;
    font-size: 0.9rem;
    line-height: 1;
    height: 36px;
    padding: 0 18px;
    border-radius: 100px;
    background: var(--holo-card-bg);
    border: 2px solid var(--holo-border);
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--holo-shadow);
    flex-shrink: 0;
}

.holo-compact-toggle {
    appearance: none;
    border: 2px solid var(--holo-border);
    background: var(--holo-card-bg);
    color: var(--holo-text);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.9rem;
    line-height: 1;
    height: 36px;
    padding: 0 16px;
    border-radius: 100px;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--holo-shadow);
    flex-shrink: 0;
    cursor: pointer;
}

.holo-compact-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--holo-primary);
    color: var(--holo-primary);
    background: var(--holo-primary-light);
    box-shadow: 0 6px 15px rgba(0, 184, 240, 0.15);
}

.holo-compact-toggle[aria-pressed="true"] {
    border-color: var(--holo-primary);
    color: var(--holo-primary);
    background: var(--holo-primary-light);
}

[data-theme="dark"] .holo-compact-toggle {
    background: #1E293B;
    border-color: #334155;
    color: #F8FAFC;
}

[data-theme="dark"] .holo-compact-toggle:hover,
[data-theme="dark"] .holo-compact-toggle[aria-pressed="true"] {
    border-color: var(--holo-primary);
    background: rgba(0, 184, 240, 0.1);
    color: #F8FAFC;
}

.holo-compact-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

.holo-header-link:hover {
    transform: translateY(-2px);
    border-color: var(--holo-primary);
    color: var(--holo-primary);
    background: var(--holo-primary-light);
    box-shadow: 0 6px 15px rgba(0, 184, 240, 0.15);
}

/* 「あとで見る」ボタンは動画カードのミニボタンに合わせてピンク(secondary)に */
#watch-later-toggle:hover {
    border-color: var(--holo-secondary);
    color: var(--holo-secondary);
    background: var(--holo-secondary-light);
    box-shadow: 0 6px 15px rgba(255, 77, 141, 0.15);
}

[data-theme="dark"] .holo-header-link {
    background: #1E293B;
    border-color: #334155;
    color: #F8FAFC;
}

[data-theme="dark"] .holo-header-link:hover {
    border-color: var(--holo-primary);
    background: rgba(0, 184, 240, 0.1);
}

[data-theme="dark"] #watch-later-toggle:hover {
    border-color: var(--holo-secondary);
    background: rgba(255, 77, 141, 0.1);
}

@media (max-width: 959px) {
    .header-container {
        padding: 0 var(--space-4);
    }

    .site-logo {
        font-size: 1.45rem;
    }

    .header-nav {
        gap: 10px;
    }

    .header-nav a {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .holo-compact-toggle {
        padding: 0 12px;
        font-size: 0.8rem;
    }

    .header-update-time {
        display: none;
    }
}

@media (max-width: 768px) {
    .header-container {
        padding: 0 10px;
    }

    .header-nav {
        justify-content: flex-end;
        gap: 6px;
    }

    .site-logo {
        font-size: 1.22rem;
    }

    .holo-theme-toggle {
        width: 54px;
        height: 32px;
        margin-left: 2px;
    }

    .holo-toggle-thumb {
        width: 20px;
        height: 20px;
        left: 3px;
    }

    [data-theme="dark"] .holo-toggle-thumb {
        transform: translateX(22px);
    }

    .holo-toggle-bg-icons {
        padding: 0 6px;
        font-size: 10px;
    }

    .holo-header-link,
    .holo-compact-toggle {
        height: 32px;
        padding: 0 10px;
        font-size: 0.74rem;
        gap: 6px;
    }
}

/* Sleek Theme Toggle Switch */
.holo-theme-toggle {
    width: 60px;
    height: 36px;
    border-radius: 100px;
    border: 2px solid var(--holo-border);
    background: #EDF2F7;
    position: relative;
    cursor: pointer;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
    display: flex;
    align-items: center;
    margin-left: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .holo-theme-toggle {
    background: #1A202C;
    border-color: #2D3748;
}

.holo-toggle-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FBD38D;
    position: absolute;
    left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

[data-theme="dark"] .holo-toggle-thumb {
    transform: translateX(28px);
    background: #FFF;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.holo-toggle-bg-icons {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 8px;
    font-size: 12px;
    opacity: 0.6;
    filter: grayscale(1);
}

.holo-theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--holo-primary);
}

.holo-theme-toggle:hover .holo-toggle-thumb {
    box-shadow: 0 2px 8px rgba(0, 184, 240, 0.3);
}

.site-main {
    padding: 84px 0 var(--space-8);
    /* Offset for fixed header (approx 65-70px) */
    position: relative;
    flex: 1;
}

.content-wrapper {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.holo-page-edge-hint {
    position: fixed;
    top: 84px;
    bottom: 0;
    width: clamp(24px, 2.4vw, 40px);
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1200;
    opacity: 0.28;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--holo-primary);
}

.holo-page-edge-hint--prev {
    left: 0;
    background: linear-gradient(90deg, rgba(0, 168, 224, 0.22) 0%, rgba(0, 168, 224, 0) 100%);
    border-right: 1px solid rgba(0, 168, 224, 0.08);
}

.holo-page-edge-hint--next {
    right: 0;
    background: linear-gradient(270deg, rgba(0, 168, 224, 0.22) 0%, rgba(0, 168, 224, 0) 100%);
    border-left: 1px solid rgba(0, 168, 224, 0.08);
}

.holo-page-edge-hint__arrow {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
    transform: translateY(-1px);
    text-shadow: 0 0 16px rgba(0, 168, 224, 0.28);
    opacity: 0.75;
    user-select: none;
}

body.holo-page-edge-nav-enabled .holo-page-edge-hint {
    display: flex;
}

body.holo-page-edge-nav-enabled .holo-page-edge-hint:hover {
    opacity: 0.38;
}

[data-theme="dark"] .holo-page-edge-hint {
    opacity: 0.22;
    color: #7DD3FC;
}

[data-theme="dark"] .holo-page-edge-hint--prev {
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.18) 0%, rgba(125, 211, 252, 0) 100%);
    border-right-color: rgba(125, 211, 252, 0.08);
}

[data-theme="dark"] .holo-page-edge-hint--next {
    background: linear-gradient(270deg, rgba(125, 211, 252, 0.18) 0%, rgba(125, 211, 252, 0) 100%);
    border-left-color: rgba(125, 211, 252, 0.08);
}

/* Footer */
.site-footer {
    padding: var(--space-5) 0;
    background: var(--holo-card-bg);
    border-top: 1px solid var(--holo-border);
    color: var(--holo-text-muted);
    font-size: 0.85rem;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

[data-theme="dark"] .site-footer {
    background: #0F172A;
    /* Match body bg in dark mode */
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

@media (max-width: 768px) {
    .footer-top {
        flex-direction: column;
        align-items: center;
        gap: var(--space-4);
        text-align: center;
    }

    .footer-links-container {
        justify-content: center;
        width: 100%;
    }

    .footer-link-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-3) var(--space-4);
        /* 縦方向 12px, 横方向 20px */
    }

    .footer-bottom {
        padding-top: var(--space-4);
        /* 上部との境界を少し明確に */
    }
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-8);
        text-align: center;
    }

    .footer-brand .site-logo {
        justify-content: center;
    }
}

.footer-brand .site-logo {
    margin: 0;
    font-size: 1.3rem;
}

.footer-links-container {
    display: flex;
    gap: var(--space-4);
}

.footer-link-group {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.footer-link-group a {
    text-decoration: none;
    color: var(--holo-text-muted);
    font-weight: 700;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.footer-link-group a:hover {
    color: var(--holo-primary);
    transform: translateY(-2px);
}

.footer-bottom {
    padding-top: var(--space-5);
    border-top: 1px solid var(--holo-border);
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.footer-disclaimer {
    font-size: 0.72rem;
    line-height: 1.7;
    max-width: 820px;
    opacity: 0.7;
    margin: 0 auto;
}

.footer-disclaimer-line {
    display: block;
}

.footer-copyright {
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--holo-text-muted);
}

/* ============================================
    新着クリップ セクション (Marquee)
    ============================================ */
.new-clips-section,
.popular-clips-section {
    margin: var(--space-8) 0 var(--space-4);
    padding: var(--space-5) 0;
    /* backdrop-filterはモバイルや低スペック環境で重いため、透過度の高いグラデーションに変更 */
    background: linear-gradient(135deg, rgba(0, 184, 240, 0.12), rgba(255, 114, 180, 0.12));
    border-radius: var(--holo-radius-lg);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 184, 240, 0.15);
    position: relative;
    /* レイアウトの再計算を抑制 */
    contain: content;
}

[data-theme="dark"] .new-clips-section,
[data-theme="dark"] .popular-clips-section {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.85));
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}


.new-clips-container,
.popular-clips-container {
    width: 100%;
    overflow: hidden;
    position: relative;
    /* レンダリングの安定性を高め、Firefoxでのアニメーションのカクつきやループ落ちを防止 */
    contain: paint;
}

/* アニメーションのトラック */
.new-clips-track,
.popular-clips-track {
    display: inline-flex;
    gap: var(--space-5);
    /* 1セット分の最終ギャップを埋めるためのpadding-right。
       これにより、 track全体の幅が (1セットの幅) * 2 となり、
       -50% の移動が完璧に1セット分の移動（ギャップ含む）と一致します。 */
    padding-right: var(--space-5);
    width: max-content;
    /* デフォルトの速さ (240sからさらにゆっくり420sに変更、1週約7分)
       JSから --marquee-duration が設定されるとそちらが優先される */
    animation: holoMarquee var(--marquee-duration, 420s) linear infinite;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    /* Firefoxでの滑らかさと正確さを向上させるため translateX に変更しレイヤーを安定化 */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.new-clips-container:hover .new-clips-track,
.popular-clips-container:hover .popular-clips-track,
.new-clips-track:hover,
.popular-clips-track:hover {
    /* JSのインラインスタイルに負けないよう !important を付与して確実に停止させる */
    animation-play-state: paused !important;
}

@keyframes holoMarquee {
    0% {
        transform: translateX(0);
    }

    100% {
        /* JSで計算された幅（または全複製の-50%）へ移動。
           Firefoxでの爆速現象を回避するため、3dではなくXのみで安定させる */
        transform: translateX(var(--marquee-shift, -50%));
    }
}

.new-clip-card,
.popular-clip-card {
    flex: 0 0 260px;
    scroll-snap-align: start;
    background: var(--holo-card-bg);
    border-radius: var(--holo-radius);
    overflow: hidden;
    border: 2px solid var(--holo-border);
    /* ホバー時の挙動を安定させるため transform は一括管理 */
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    box-shadow: var(--holo-shadow);
    position: relative;
    /* GPUレイヤーを強制しつつズレを防止 */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.new-clip-card:hover,
.popular-clip-card:hover {
    /* 浮く量を少し調整し、スケールとのバランスを最適化 */
    transform: translateY(-10px) scale(1.02);
    border-color: var(--holo-secondary);
    box-shadow: 0 15px 35px rgba(255, 77, 141, 0.25);
}

.new-clip-thumb,
.popular-clip-thumb {
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
    background: #000;
}

.new-clip-thumb img,
.popular-clip-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    color: transparent;
    /* altテキストのフラッシュを防止 */
}

.new-clip-card:hover .new-clip-thumb img,
.popular-clip-card:hover .popular-clip-thumb img {
    /* ズーム量をさらに抑えてより洗練された印象に (1.05 -> 1.03) */
    transform: scale(1.03);
}

.new-clip-info,
.popular-clip-info {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.new-clip-title,
.popular-clip-title {
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.5;
    color: var(--holo-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 3em;
}

.new-clip-meta,
.popular-clip-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 4px;
    padding-right: 40px;
}

.new-clip-date,
.popular-clip-date {
    color: var(--holo-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.new-clip-views,
.popular-clip-views {
    color: var(--holo-secondary);
    background: var(--holo-secondary-light);
    padding: 3px 10px;
    border-radius: 100px;
    font-weight: 800;
}

/* Responsive */
@media (max-width: 768px) {
    .header-container {
        padding: 0 10px;
        gap: 6px;
    }

    .content-wrapper {
        padding: 0 10px;
    }

    .site-logo {
        font-size: 1.22rem;
        gap: 1px;
    }

    .header-nav {
        display: flex;
        width: auto;
        margin-left: auto;
        justify-content: flex-end;
        gap: 6px;
    }

    .holo-header-link {
        height: 32px;
        padding: 0 10px;
        font-size: 0.74rem;
    }

    .holo-compact-toggle {
        min-width: 40px;
        height: 32px;
        padding: 0 10px;
        justify-content: center;
        gap: 4px;
        font-size: 0.74rem;
        border-width: 2px;
    }

    .holo-compact-toggle-label {
        display: none;
    }

    /* Aggressive hide for mobile elements */
    #history-toggle span,
    #watch-later-toggle span,
    .header-nav .header-update-time,
    #holo-floating-pip {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        pointer-events: none !important;
    }

    /* Hide clips for mobile */
    .new-clips-section,
    .popular-clips-section {
        display: none !important;
    }

    .site-main {
        padding-top: 60px !important;
    }

    .holo-theme-toggle {
        width: 54px;
        height: 32px;
    }

    .holo-toggle-thumb {
        width: 20px;
        height: 20px;
    }

    [data-theme="dark"] .holo-toggle-thumb {
        transform: translateX(22px);
    }
}

/* スケルトンUI (プレースホルダ) */
.is-skeleton {
    pointer-events: none !important;
}

.skeleton-shimmer {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05) !important;
}

.skeleton-shimmer::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.08) 50%,
            transparent 100%);
    animation: holo-shimmer 1s infinite;
}

@keyframes holo-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.is-skeleton .holo-thumb,
.is-skeleton .holo-grid-thumb {
    background: rgba(255, 255, 255, 0.03) !important;
    position: relative;
    overflow: hidden;
}

.is-skeleton .holo-grid-thumb img {
    opacity: 0 !important;
}

.is-skeleton .holo-info,
.is-skeleton .holo-grid-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.is-skeleton .skeleton-text,
.is-skeleton .holo-grid-title,
.is-skeleton .holo-grid-meta,
.is-skeleton .holo-grid-main-channel,
.is-skeleton .holo-grid-channel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.is-skeleton .skeleton-text,
.is-skeleton .holo-grid-title {
    height: 1.4rem;
    width: 90%;
}

.is-skeleton .skeleton-text.short,
.is-skeleton .holo-grid-meta,
.is-skeleton .holo-grid-main-channel {
    height: 1.1rem;
    width: 60%;
}

.is-skeleton .holo-grid-channel {
    height: 1.1rem;
    width: 40%;
}

/* 日付ヘッダーのスケルトン */
.holo-date-header.skeleton-shimmer {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 4px;
    display: inline-block;
    min-width: 180px;
    height: 1.8rem;
    margin-bottom: 20px;
}

/* AdSense Section Styling */
.holo-ad-container {
    margin: 60px auto 20px;
    text-align: center;
    max-width: 1200px;
    min-height: 100px;
    padding: 30px 15px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--holo-radius-lg);
    border: 1px dashed var(--holo-border);
    transition: all 0.4s ease;
}

[data-theme="dark"] .holo-ad-container {
    background: rgba(30, 41, 59, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ========== End of Shell Styles ========== */
