/* 会社沿革表示 - 洗練された完全版（線を年度アイコンの下に配置） */

.company-history-display {
    margin: 2rem 0;
    padding: 0;
    background: transparent;
}

/* 縦型タイムライン */
.timeline-vertical {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* タイムライン線 - 年度アイコンの後ろに表示 */
.timeline-vertical::before {
    content: '';
    position: absolute;
    left: 40px; /* 80px幅の年度アイコンの中央 */
    top: 40px; /* 最初のアイコンの中央から開始 */
    width: 2px;
    background: #404040;
    border-radius: 1px;
    z-index: -1; /* 負の値で確実に後ろに配置 */
    height: calc(100% - 160px); /* 上下のマージンを除いた高さ */
}

.history-item {
    position: relative;
    margin-bottom: 3rem;
    display: flex;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
    gap: 2rem;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 年度アイコン - 線より確実に上に表示 */
.history-year {
    width: 80px;
    height: 80px;
    background: var(--year-bg, linear-gradient(135deg, #f59e0b 0%, #d97706 100%));
    color: var(--year-color, #000);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    z-index: 20; /* より高い値で確実に線の上に表示 */
    flex-shrink: 0;
    position: relative;
    border: 3px solid var(--year-border, #f59e0b);
}

/* コンテンツカード */
.history-content {
    background: #2d3748;
    border-radius: 16px;
    padding: 2rem;
    flex: 1;
    position: relative;
    transition: all 0.3s ease;
    border: 1px solid #4a5568;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10; /* コンテンツも線より上に */
}

.history-content:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-color, #f59e0b);
}

/* 矢印 - 年度アイコンの中央から */
.history-content::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 40px; /* 年度アイコンの中央に合わせる */
    width: 0;
    height: 0;
    border: 12px solid transparent;
    border-right-color: #2d3748;
    z-index: 15; /* 矢印も線より上に */
}

.history-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.history-description {
    font-size: 1rem;
    color: #a0aec0;
    line-height: 1.6;
    margin: 0;
}

/* 横型タイムライン */
.timeline-horizontal {
    padding: 2rem 0;
    overflow-x: auto;
    background: transparent;
    border-radius: 16px;
}

.timeline-horizontal .history-items {
    display: flex;
    gap: 2rem;
    padding: 1rem 2rem;
    min-width: max-content;
}

.timeline-horizontal .history-item {
    flex-direction: column;
    align-items: center;
    min-width: 300px;
    margin-bottom: 0;
    gap: 1rem;
}

.timeline-horizontal .history-content {
    width: 100%;
    margin-top: 0;
}

.timeline-horizontal .history-content::before {
    display: none;
}

.timeline-horizontal .timeline-vertical::before {
    display: none;
}

/* カラーテーマ - CSS変数で柔軟に */
.color-theme-blue {
    --year-bg: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --year-color: #ffffff;
    --year-border: #3b82f6;
    --accent-color: #60a5fa;
}

.color-theme-green {
    --year-bg: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --year-color: #ffffff;
    --year-border: #10b981;
    --accent-color: #34d399;
}

.color-theme-purple {
    --year-bg: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --year-color: #ffffff;
    --year-border: #8b5cf6;
    --accent-color: #a78bfa;
}

.color-theme-orange {
    --year-bg: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --year-color: #000000;
    --year-border: #f59e0b;
    --accent-color: #fbbf24;
}

.color-theme-red {
    --year-bg: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --year-color: #ffffff;
    --year-border: #ef4444;
    --accent-color: #f87171;
}

.color-theme-teal {
    --year-bg: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    --year-color: #ffffff;
    --year-border: #14b8a6;
    --accent-color: #5eead4;
}

.color-theme-pink {
    --year-bg: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    --year-color: #ffffff;
    --year-border: #ec4899;
    --accent-color: #f9a8d4;
}

.color-theme-indigo {
    --year-bg: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --year-color: #ffffff;
    --year-border: #6366f1;
    --accent-color: #a5b4fc;
}

/* カスタムカラー（CSS変数で上書き可能） */
.color-theme-custom {
    --year-bg: var(--custom-year-bg, linear-gradient(135deg, #f59e0b 0%, #d97706 100%));
    --year-color: var(--custom-year-color, #000000);
    --year-border: var(--custom-year-border, #f59e0b);
    --accent-color: var(--custom-accent-color, #fbbf24);
}

/* ホバー効果でタイトル色変更 */
.history-content:hover .history-title {
    color: var(--accent-color, #f59e0b);
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
    .timeline-vertical::before {
        left: 30px; /* 60px幅アイコンの中央 */
        top: 30px;
        height: calc(100% - 120px);
        z-index: -1; /* モバイルでも確実に後ろに */
    }
    
    .history-item {
        gap: 1rem;
    }
    
    .history-year {
        width: 60px;
        height: 60px;
        font-size: 0.875rem;
        border-width: 2px;
        z-index: 20; /* モバイルでも高いz-index */
    }
    
    .history-content {
        padding: 1.5rem;
        z-index: 10;
    }
    
    .history-content::before {
        left: -8px;
        top: 30px; /* 60px年度アイコンの中央 */
        border-width: 8px;
        border-right-color: #2d3748;
        z-index: 15;
    }
    
    .timeline-horizontal .history-items {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .timeline-horizontal .history-item {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .history-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }
    
    .timeline-vertical::before {
        display: none;
    }
    
    .history-content::before {
        display: none;
    }
    
    .history-content {
        width: 100%;
        margin-top: 0;
    }
    
    .history-title {
        font-size: 1.25rem;
    }
    
    .history-description {
        font-size: 0.9rem;
    }
}

/* アニメーション無効時 */
.no-animation .history-item {
    opacity: 1;
    transform: none;
}

/* スクロールバー改善（横型） */
.timeline-horizontal::-webkit-scrollbar {
    height: 8px;
}

.timeline-horizontal::-webkit-scrollbar-track {
    background: #2d3748;
    border-radius: 4px;
}

.timeline-horizontal::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

.timeline-horizontal::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* アニメーション遅延 */
.history-item:nth-child(1) { animation-delay: 0.1s; }
.history-item:nth-child(2) { animation-delay: 0.2s; }
.history-item:nth-child(3) { animation-delay: 0.3s; }
.history-item:nth-child(4) { animation-delay: 0.4s; }
.history-item:nth-child(5) { animation-delay: 0.5s; }
.history-item:nth-child(6) { animation-delay: 0.6s; }
.history-item:nth-child(7) { animation-delay: 0.7s; }
.history-item:nth-child(8) { animation-delay: 0.8s; }
.history-item:nth-child(9) { animation-delay: 0.9s; }

/* アクセシビリティ改善 */
@media (prefers-reduced-motion: reduce) {
    .history-item {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .history-content {
        transition: none;
    }
    
    .history-content:hover {
        transform: none;
    }
}

/* フォーカス状態 */
.history-content:focus {
    outline: 2px solid var(--accent-color, #f59e0b);
    outline-offset: 2px;
}

/* 印刷対応 */
@media print {
    .company-history-display {
        background: white;
        color: black;
    }
    
    .history-content {
        background: white;
        border: 1px solid #000;
        color: black;
        box-shadow: none;
    }
    
    .history-title,
    .history-description {
        color: black;
    }
    
    .history-year {
        background: #f0f0f0;
        color: black;
        border-color: #000;
    }
    
    .timeline-vertical::before {
        background: #000;
    }
}

/* 高品質レンダリング */
.history-year,
.history-content {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* GPU加速 */
.history-item {
    will-change: transform, opacity;
}

.history-content {
    will-change: transform, box-shadow;
}

/* アンチエイリアシング */
.history-year {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.history-title {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}