/* ============================================
   新作アニメページ専用CSS（最適化版）
   元サイズ: 254KB → 最適化後: ~15KB
   ============================================ */

/* ============================================
   基本設定
   ============================================ */
:root {
    --primary-cyan: #00ffff;
    --primary-dark: #0f2027;
    --secondary-dark: #203a43;
    --tertiary-dark: #2c5364;
    --text-light: #e0e0e0;
    --shadow-cyan: rgba(0, 255, 255, 0.4);
}

* { box-sizing: border-box; }

html, body {
    background: linear-gradient(to right, #0f2027, #203a43, #2c5364) !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

body {
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   新作アニメコンテナ
   ============================================ */
.new-anime-container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 20px 0;
    contain: layout style;
}

body.new-anime-page .new-anime-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 20px 0 !important;
    box-sizing: border-box !important;
}

/* ============================================
   タブナビゲーション - 固定表示
   ※base.htmlのCSSと競合する可能性があるため、ここで確実に設定
   ============================================ */
body.new-anime-page .tab-nav-wrapper {
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 999 !important;
    background: linear-gradient(180deg, rgba(15, 32, 39, 0.98) 0%, rgba(32, 58, 67, 0.95) 100%) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2) !important;
    padding: 0 10px !important;
    margin: 0 !important;
}

body.new-anime-page .tab-nav {
    margin: 6px auto !important;
    max-width: 850px !important;
}

/* mainコンテナ - タブナビ分のpadding-top確保 */
body.new-anime-page main.container-fluid {
    min-height: 100vh;
    padding-top: 125px !important;
}

body.new-anime-page .row {
    flex-grow: 1 !important;
}

/* モバイル用調整 */
@media (max-width: 768px) {
    body.new-anime-page .tab-nav-wrapper {
        top: 50px !important;
    }
    
    body.new-anime-page main.container-fluid {
        padding-top: 115px !important;
    }
}

/* ============================================
   カテゴリセクション
   ============================================ */
.anime-category {
    margin-bottom: 25px;
    padding: 0;
    contain: layout style;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 0 20px 8px 20px;
    border-bottom: 2px solid rgba(0, 255, 255, 0.3);
    /* CLS防止: 高さを固定 */
    min-height: 60px;
}

.category-icon {
    font-size: 1.4rem;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.category-title {
    font-size: 1.1rem;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    margin: 0;
    font-weight: 700;
}

.category-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: auto;
}

/* ============================================
   横スクロールコンテナ
   ============================================ */
.anime-scroll-wrapper {
    position: relative;
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.anime-scroll-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 10px 20px 15px 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #00ffff rgba(0, 255, 255, 0.1);
    /* CLS防止: コンテナの高さを固定（小サイズ用） */
    height: 285px;
    contain: layout style;
}

.anime-scroll-container > .anime-item {
    scroll-snap-align: start;
}

/* PC表示では滑らかなスクロール */
@media (min-width: 769px) {
    .anime-scroll-container {
        scroll-snap-type: none;
    }
    .anime-scroll-container > .anime-item {
        scroll-snap-align: none;
    }
}

/* スクロールバー */
.anime-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.anime-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 255, 255, 0.1);
    border-radius: 4px;
}

.anime-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #00ffff, #00bfbf);
    border-radius: 4px;
}

.anime-scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #00ffff, #00e5e5);
}

/* ============================================
   スクロールボタン
   ============================================ */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-70%);
    width: 44px;
    height: 44px;
    border: 2px solid #00ffff;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.95);
    color: #00ffff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

.scroll-btn:hover {
    background: rgba(0, 255, 255, 0.25);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.7);
    transform: translateY(-70%) scale(1.15);
}

.scroll-btn:active {
    transform: translateY(-70%) scale(0.95);
}

.scroll-btn.left {
    left: 10px;
}

.scroll-btn.right {
    right: 10px;
}

.scroll-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.scroll-btn:disabled:hover {
    transform: translateY(-50%) scale(1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

/* ============================================
   スクロールヒント（最初のカテゴリのみ表示）
   ============================================ */
.scroll-hint {
    display: none; /* デフォルトは非表示 */
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.65rem;
    color: #64748b;
    animation: hintFade 3s ease-in-out infinite;
}

/* 最初のカテゴリのヒントのみ表示 */
.anime-category:first-child .scroll-hint {
    display: flex;
}

.scroll-hint-arrow {
    animation: hintArrowMove 1.5s ease-in-out infinite;
}

@keyframes hintFade {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes hintArrowMove {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

/* スクロール進捗 */
.scroll-progress {
    height: 2px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.scroll-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #00bfbf);
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* ============================================
   アニメカード
   ============================================ */
.anime-item {
    position: relative;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.4s ease;
    cursor: pointer;
}

.anime-item:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(0, 255, 255, 0.8);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.5),
        0 15px 40px rgba(0, 0, 0, 0.6);
}

.anime-item:hover .anime-title {
    text-shadow: 
        0 0 15px rgba(0, 255, 255, 1),
        0 0 25px rgba(0, 255, 255, 0.8);
}

/* 新作アニメ用アイテム */
.new-anime-container .anime-item {
    flex: 0 0 auto;
    width: 160px;
    /* CLS防止: アイテムの高さを固定（縮小版） */
    height: 260px;
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow 0.4s ease,
                border-color 0.4s ease;
    border: 1px solid rgba(0, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.new-anime-container .anime-item:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 6px 20px rgba(0, 255, 255, 0.2);
}

/* Intersection Observer用 */
/* Intersection Observer用 - 初期状態は非表示 */
.anime-item {
    opacity: 0;
    transform: translateY(20px);
}

/* 表示状態 */
.anime-item.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* LCP改善: 最初の2カテゴリの最初の4枚は即座に表示 */
.anime-category:nth-child(-n+2) .anime-item:nth-child(-n+4) {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ============================================
   サムネイル
   ============================================ */
.anime-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 7;
    overflow: hidden;
    /* CLS防止: 画像読み込み前のプレースホルダー */
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 308px !important; /* 220px * 7/5 = 308px (PC) */
}

/* モバイルでのmin-height調整 */
@media (max-width: 767px) {
    .anime-thumbnail {
        min-height: 140px !important; /* 100px * 7/5 = 140px */
    }
}

/* タブレットでのmin-height調整 */
@media (min-width: 768px) and (max-width: 1023px) {
    .anime-thumbnail {
        min-height: 252px !important; /* 180px * 7/5 = 252px */
    }
}

.anime-thumbnail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        transparent 40%,
        rgba(0, 0, 0, 0.7) 100%);
    opacity: 0.5;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.anime-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.anime-item:hover .anime-thumbnail img,
.new-anime-container .anime-item:hover .anime-thumbnail img {
    transform: scale(1.1);
}

/* ============================================
   タイトルオーバーレイ
   ============================================ */
.anime-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
    z-index: 2;
}

.anime-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.new-anime-container .anime-title {
    font-size: 0.7rem;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   PC全幅表示（最優先）
   ============================================ */
@media (min-width: 768px) {
    /* コンテナ系は全幅表示 */
    body.new-anime-page .new-anime-container,
    body.new-anime-page .anime-category,
    body.new-anime-page .anime-scroll-wrapper,
    body.new-anime-page .row,
    body.new-anime-page .col-7,
    body.new-anime-page .col-12 {
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
    }

    body.new-anime-page .new-anime-container {
        padding-top: 20px !important;
        padding-bottom: 20px !important;
    }

    body.new-anime-page .category-header {
        padding: 0 20px 8px 20px !important;
    }

    body.new-anime-page .anime-scroll-container {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        width: 100% !important;
        gap: 12px !important;
        padding: 10px 0 15px 0 !important;
        scroll-snap-type: none !important;
        height: 285px !important;
    }

    body.new-anime-page .anime-item {
        flex: 0 0 auto !important;
        width: 160px !important;
        height: 260px !important;
        scroll-snap-align: none !important;
        flex-shrink: 0 !important;
    }

    body.new-anime-page .anime-item:first-child {
        margin-left: 15px !important;
    }

    body.new-anime-page .anime-item:last-child {
        margin-right: 15px !important;
    }

    body.new-anime-page .anime-thumbnail {
        aspect-ratio: 5 / 7 !important;
    }

    body.new-anime-page .scroll-btn {
        z-index: 100 !important;
    }

    body.new-anime-page .scroll-btn.left {
        left: 15px !important;
    }

    body.new-anime-page .scroll-btn.right {
        right: 15px !important;
    }
}

/* ============================================
   モバイル対応
   ============================================ */
@media (max-width: 767px) {
    .new-anime-container {
        padding: 10px 8px;
    }

    .anime-category {
        margin-bottom: 18px;
    }

    .category-header {
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .category-icon {
        font-size: 1.1rem;
    }

    .category-title {
        font-size: 0.95rem;
    }

    .category-subtitle {
        width: 100%;
        margin-left: 0;
        font-size: 0.65rem;
    }

    .anime-title-overlay {
        padding: 4px;
    }

    .scroll-btn {
        display: none;
    }

    .anime-scroll-container {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 4px 2px 10px 2px;
        gap: 8px;
        /* CLS防止: モバイルでの高さを固定（縮小版） */
        height: 150px;
    }
    
    .new-anime-container .anime-item {
        flex: 0 0 auto !important;
        width: 80px !important;
        height: 135px !important;
    }
    
    .new-anime-container .anime-title,
    .anime-title {
        font-size: 0.5rem !important;
    }

    .scroll-hint {
        font-size: 0.6rem;
        margin-top: 4px;
    }

    .scroll-progress {
        margin-top: 5px;
    }
}

/* タブレット */
@media (min-width: 768px) and (max-width: 1023px) {
    .anime-scroll-container {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        /* CLS防止: タブレットでの高さを固定（縮小版） */
        height: 255px;
    }

    .new-anime-container .anime-item {
        flex: 0 0 auto !important;
        width: 140px !important;
        height: 230px !important;
    }

    .scroll-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .scroll-btn.left {
        left: -16px;
    }

    .scroll-btn.right {
        right: -16px;
    }
}

/* 大画面 */
@media (min-width: 1400px) {
    .new-anime-container .anime-item {
        flex: 0 0 auto !important;
        width: 180px !important;
        height: 290px !important;
    }
    
    body.new-anime-page .anime-scroll-container {
        height: 315px !important;
    }
}

/* ============================================
   アニメーション
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes animePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.anime-item.loading {
    animation: animePulse 1.5s ease-in-out infinite;
}


/* ヘッダー関連スタイルはbase.htmlのクリティカルCSSを使用 */

/* PC用：モバイルボタングループを非表示 */
@media (min-width: 769px) {
  .mobile-button-group,
  .mobile-button-group.d-md-none {
    display: none !important;
  }
}

/* ============================================
   モバイル対応（768px以下）
   ============================================ */
@media (max-width: 768px) {
  /* モバイルボタングループの位置調整 */
  .mobile-button-group {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 99999;
    pointer-events: auto;
    min-height: 40px;
    contain: layout style;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px;
  }

  .mobile-button-group *,
  .mobile-button-group a,
  .lang-selector-mobile,
  .lang-selector-mobile a {
    pointer-events: auto !important;
  }

  #toggleMenu {
    position: static !important;
    top: auto !important;
    right: auto !important;
    background: transparent;
    border: none;
    color: #00ffff;
    padding: 0;
    font-size: 1.3rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #mobileMenu {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    bottom: 60px;
    right: 10px;
    width: 200px;
    max-height: 50vh;
    overflow-y: auto;
    background: linear-gradient(145deg, 
      rgba(15, 23, 42, 0.98) 0%, 
      rgba(30, 41, 59, 0.98) 100%);
    border: 2px solid #00ffff;
    border-radius: 8px;
    box-shadow: 
      0 15px 30px rgba(0, 0, 0, 0.8),
      0 0 40px rgba(0, 255, 255, 0.4);
    backdrop-filter: blur(15px);
    z-index: 10000;
  }

  .menu-list {
    list-style: none;
    padding: 4px 0;
    margin: 0;
  }

  .menu-list li {
    margin: 0;
    border-bottom: none;
    position: relative;
    overflow: hidden;
  }

  .menu-list a {
    display: block;
    padding: 10px 12px;
    color: #ffffff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
    letter-spacing: 0.3px;
    border-left: 2px solid transparent;
    background: rgba(0, 255, 255, 0.05);
    margin: 2px 4px;
    border-radius: 4px;
    text-align: left;
  }

  .menu-list a:active {
    background: linear-gradient(135deg, 
      rgba(0, 255, 255, 0.25) 0%, 
      rgba(0, 200, 200, 0.25) 100%);
    border-left-color: #00ffff;
    transform: scale(0.98);
  }
}