/* キャラクターページ用スタイル */

/* 水彩紙風デザイン用変数 */
:root {
    --color-primary: #305070;
    --color-secondary: #4a708a;
    --color-accent: #d4af37;
    --color-text: #333;
    --color-background: #f8f9fa;
    --color-light-text: #666;
    
    /* 水彩紙風デザイン用の変数 */
    --watercolor-blue: #6b8eb5;
    --watercolor-brown: #c4965a;
    --watercolor-green: #7d9c7c;
    --parchment: #f9f6f0;
    --ink-dark: #2c3e50;
    --soft-shadow: rgba(0, 0, 0, 0.1);
}

/* ページヘッダー */
.page-header {
    background: linear-gradient(rgba(48, 80, 112, 0.8), rgba(74, 112, 138, 0.8));
    color: white;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    margin-bottom: 2rem;
}

.page-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 2.5rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.page-subtitle {
    font-size: 1.1rem;
    margin-top: 0.5rem;
    opacity: 0.9;
}

/* 編切り替えタブ */
.story-tabs {
    max-width: 1400px;
    margin: 0 auto 2rem;
    padding: 1rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    position: sticky;
    top: 0;
    background: var(--color-background);
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
    transition: all 0.3s ease;
}

.story-tab {
    padding: 1rem 3rem;
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    will-change: transform;
}

.story-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.story-tab.active {
    background: var(--color-primary);
    color: white;
}

.story-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--color-accent);
}

/* キャラクターページ用コンテナ */
.character-page .content-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

/* キャラクター用サイドバー */
.character-page .sidebar {
    background: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    padding: 1.5rem;
    position: sticky;
    top: 120px;
    height: fit-content;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.3rem;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-accent);
}

/* キャラクターリスト */
.character-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.character-btn {
    padding: 0.8rem 1rem;
    background: var(--color-background);
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    color: var(--color-text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    will-change: transform, background-color;
}

.character-btn:hover {
    background: white;
    border-color: var(--color-secondary);
    transform: translateX(5px);
}

.character-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* メインコンテンツ */
.character-page .main-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    padding: 2.5rem;
}

/* キャラクター詳細 */
.character-detail {
    display: none;
    animation: fadeIn 0.5s ease;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.character-detail.active {
    display: block;
}

/* サイドバーコンテンツのトランジション */
#sidebarContent {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ストーリー切り替え用のスムーズトランジション */
@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.character-header {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

/* キャラクタービジュアル */
.character-visual {
    position: relative;
}

/* 画像コンテナ - 複数画像の重ね合わせ用 */
.image-container {
    position: relative;
    width: 350px;
    height: 350px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* キャラクター画像のスタイル更新 */
.character-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

/* アクティブな画像 */
.character-image.active {
    opacity: 1;
    position: relative;
}

/* トランジション中の画像 */
.character-image.transitioning {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ホバー効果の改善 - 削除済み */
/* .image-container:hover .character-image.active {
    transform: scale(1.02);
} */

.no-image {
    width: 100%;
    height: 350px;
    background: var(--color-background);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-light-text);
    font-size: 1.2rem;
}

.character-main-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.character-name {
    font-family: 'Noto Serif JP', serif;
    font-size: 2.8rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

/* キャラクター別名スタイル - 目立たない形で表示 */
.character-alias {
    font-size: 1rem;
    color: var(--color-light-text);
    font-style: italic;
    margin-bottom: 1.5rem;
    opacity: 0.8;
    font-weight: 400;
}

.character-story-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    background: var(--color-accent);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    width: fit-content;
}

.character-meta {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.meta-item {
    background: var(--color-background);
    padding: 1rem 1.5rem;
    border-radius: 6px;
    border-left: 4px solid var(--color-accent);
}

.meta-label {
    font-size: 0.9rem;
    color: var(--color-light-text);
    margin-bottom: 0.3rem;
}

.meta-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* 名言セクション - 水彩紙風デザイン */
.quotes-section {
    margin-bottom: 3rem;
}

.section-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.8rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    position: relative;
    padding-left: 20px;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: linear-gradient(180deg, var(--watercolor-blue), var(--watercolor-brown));
    border-radius: 2px;
}

/* 水彩紙風ブロックデザイン */
.quote-container {
    background: linear-gradient(145deg, 
        rgba(107, 142, 181, 0.20) 0%, 
        rgba(196, 150, 90, 0.15) 35%,
        rgba(125, 156, 124, 0.12) 70%,
        rgba(249, 246, 240, 0.95) 100%);
    border: none;
    border-radius: 16px;
    padding: 30px 35px;
    font-size: 1.15rem;
    color: var(--ink-dark);
    position: relative;
    box-shadow: 
        0 8px 25px rgba(107, 142, 181, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    line-height: 1.8;
    background-image: 
        radial-gradient(circle at 15% 25%, rgba(107, 142, 181, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 75%, rgba(196, 150, 90, 0.10) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(125, 156, 124, 0.08) 0%, transparent 50%);
    /* 固定の高さを維持 */
    height: 140px;
    min-height: 140px;
    max-height: 140px;
    /* テキストを左揃え・上下中央に配置 */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    overflow: hidden;
    font-style: normal;
    font-family: 'Noto Serif JP', serif;
}

/* テキスト部分のフェード効果 */
.quote-text {
    position: relative;
    z-index: 2;
    transition: opacity 0.8s ease;
}

/* 水彩風の微細なテクスチャ効果を追加 */
.quote-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(107, 142, 181, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(196, 150, 90, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(125, 156, 124, 0.04) 0%, transparent 30%);
    pointer-events: none;
    z-index: 1;
}



.no-quotes {
    padding: 2rem;
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(249, 246, 240, 0.85) 100%);
    border-radius: 16px;
    text-align: center;
    color: #5a6b7d;
    border: 1px solid rgba(107, 142, 181, 0.1);
    box-shadow: 0 4px 15px rgba(107, 142, 181, 0.1);
}

/* 人物紹介文セクション */
.description-section {
    margin: 3rem 0;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color, #e0e0e0);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.character-description {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
}

.character-description p {
    margin-bottom: 1rem;
}

.character-description p:last-child {
    margin-bottom: 0;
}

.character-description h4,
.character-description h5,
.character-description h6 {
    color: var(--color-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.character-description ul,
.character-description ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.character-description blockquote {
    border-left: 4px solid var(--color-accent);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--color-secondary);
}

/* タイムライン */
.timeline-section {
    margin-top: 3rem;
    position: relative;
}

/* 縦線をtimeline-sectionに移動してスクロールに対応 */
.timeline-section::before {
    content: '';
    position: absolute;
    left: 96px;
    top: 60px;
    bottom: 0;
    width: 2px;
    background: var(--color-accent);
    opacity: 0.3;
    z-index: 0;
}

.timeline {
    position: relative;
    padding-left: 40px;
    /* 年表の高さを400pxに増加 */
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

/* スクロールバーのスタイリング */
.timeline::-webkit-scrollbar {
    width: 8px;
}

.timeline::-webkit-scrollbar-track {
    background: var(--color-background);
    border-radius: 4px;
}

.timeline::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 4px;
}

.timeline::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

.timeline-item {
    position: relative;
    padding: 1.0rem;
    margin-bottom: 1.5rem;
    background: var(--color-background);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1;
}

.timeline-year {
    font-weight: bold;
    color: var(--color-secondary);
    font-size: 1.1rem;
    flex-shrink: 0;
    min-width: 80px;
}

.timeline-event {
    color: var(--color-text);
    line-height: 1.5;
    flex: 1;
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .character-page .content-container {
        grid-template-columns: 250px 1fr;
    }
}

@media (max-width: 768px) {
    .story-tabs {
        flex-direction: column;
        align-items: center;
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .story-tab {
        width: 100%;
        max-width: 300px;
    }
    
    .character-page .content-container {
        grid-template-columns: 1fr;
    }
    
    .character-page .sidebar {
        position: static;
        max-height: 300px;
        margin-bottom: 2rem;
    }
    
    .character-header {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .character-visual {
        max-width: 350px;
        margin: 0 auto;
    }
    
    /* モバイル用画像コンテナサイズ調整 */
    .image-container {
        width: 100%;
        max-width: 350px;
        height: 350px;
        margin: 0 auto;
    }
    
    .no-image {
        width: 100%;
        max-width: 350px;
        height: 350px;
        margin: 0 auto;
    }
    
    .character-name {
        font-size: 2rem;
    }
    
    .character-alias {
        font-size: 0.9rem;
        margin-bottom: 1.2rem;
    }
    
    /* モバイル用タイムライン調整 */
    .timeline-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .timeline-year {
        min-width: auto;
        margin-bottom: 0;
    }
    
    /* モバイル用画像コントロールの調整 */
    .image-controls {
        bottom: 10px;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .image-dot {
        width: 10px;
        height: 10px;
    }
    
    .image-dot.active {
        width: 25px;
    }
    
    .character-image {
        transition: opacity 0.6s ease, transform 0.2s ease;
    }
    
    /* 水彩紙風デザインのモバイル対応 */
    .quote-container {
        background: linear-gradient(145deg, 
            rgba(107, 142, 181, 0.20) 0%, 
            rgba(196, 150, 90, 0.15) 35%,
            rgba(125, 156, 124, 0.12) 70%,
            rgba(249, 246, 240, 0.95) 100%);
        background-image: 
            radial-gradient(circle at 15% 25%, rgba(107, 142, 181, 0.12) 0%, transparent 40%),
            radial-gradient(circle at 85% 75%, rgba(196, 150, 90, 0.10) 0%, transparent 40%),
            radial-gradient(circle at 50% 50%, rgba(125, 156, 124, 0.08) 0%, transparent 50%);
        padding: 20px 25px;
        font-size: 1rem;
        border-radius: 12px;
        /* モバイル用の固定高さを維持 */
        height: 120px;
        min-height: 120px;
        max-height: 120px;
        /* テキストの左揃え・上下中央を維持 */
        display: flex;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        overflow: hidden;
    }
    
    .quote-container::before {
        border-radius: 10px;
        background-image: 
            radial-gradient(circle at 20% 80%, rgba(107, 142, 181, 0.08) 0%, transparent 50%),
            radial-gradient(circle at 80% 20%, rgba(196, 150, 90, 0.06) 0%, transparent 50%),
            radial-gradient(circle at 40% 40%, rgba(125, 156, 124, 0.04) 0%, transparent 30%);
    }
    
    .no-quotes {
        padding: 1.5rem;
        border-radius: 12px;
    }
}

/* クロスフェード専用のアニメーション */
@keyframes crossfadeIn {
    from {
        opacity: 0;
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes crossfadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

/* スムーズなトランジション用のクラス */
.smooth-crossfade-in {
    animation: crossfadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.smooth-crossfade-out {
    animation: crossfadeOut 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ローディング状態のスタイル */
.character-image[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
    .character-image,
    .quote-container {
        transition: none;
    }
    
    .character-image.transitioning {
        transition: none;
    }
    
    @keyframes crossfadeIn,
    @keyframes crossfadeOut,
    @keyframes shimmer {
        animation-duration: 0.01ms;
    }
}

/* フォーカス状態の改善 */
.character-btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* 高コントラスト対応 */
@media (prefers-contrast: high) {
    .timeline-section::before {
        opacity: 0.6;
    }
}