/* 基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a6fa5;
    --primary-dark: #345888;
    --secondary-color: #ff6b6b;
    --text-color: #333333;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.05);
    --shadow-medium: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-hover: 0 6px 16px rgba(0,0,0,0.15);
    --border-radius: 8px;
}

body {
    font-family: 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: all 0.3s ease-in-out;
}

.container {
    opacity: 0; /* 初期状態は非表示、JSで徐々に表示させる */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 0; /* ヘッダーが固定されるのでパディングを調整 */
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    text-align: center;
    margin-bottom: 30px;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow-medium);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    transition: padding 0.3s ease, box-shadow 0.3s ease;
}

/* スクロール時のヘッダースタイル */
.scrolled header {
    padding: 8px 0;
    box-shadow: var(--shadow-hover);
}

h1 {
    margin-bottom: 15px;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ナビゲーション */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-light);
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#manga-title {
    font-size: 1.2rem;
    font-weight: bold;
}

/* 漫画リスト */
#manga-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
}

.manga-item {
    width: 200px;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: fadeIn 0.5s ease-out forwards;
    animation-delay: calc(0.1s * var(--item-index, 0));
    opacity: 0;
}

.manga-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.manga-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--secondary-color);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: bottom right;
}

.manga-item:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.manga-cover {
    width: 100%;
    height: 280px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.manga-item:hover .manga-cover {
    filter: brightness(1.05);
}

.manga-info {
    padding: 15px;
    text-align: center;
}

.manga-title {
    font-size: 1.1rem;
    margin-bottom: 5px;
    font-weight: bold;
}

.manga-description {
    font-size: 0.9rem;
    color: #666;
}

/* 漫画ビューアー */
#manga-viewer {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-background);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    transition: all 0.3s ease;
    animation: fadeIn 0.3s ease-out forwards;
}

#manga-page {
    width: 100%;
    min-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#manga-page svg {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* object要素のスタイル設定 */
.manga-svg {
    width: 100%;
    height: auto;
    min-height: 80vh;
    border-radius: 4px;
}

/* ローディングスピナー */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(74, 111, 165, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* エラーメッセージ */
.error-message {
    text-align: center;
    padding: 30px;
    color: #e74c3c;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.error-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e74c3c;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.error-details {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #777;
}

#page-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

#page-info {
    font-size: 1rem;
    font-weight: 600;
    background-color: rgba(74, 111, 165, 0.1);
    padding: 8px 15px;
    border-radius: 20px;
    min-width: 80px;
    text-align: center;
}

.hidden {
    display: none !important;
}

footer {
    margin-top: 50px;
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    padding: 20px 0;
    border-top: 1px solid rgba(0,0,0,0.1);
}

/* ヘッダー固定時のメインコンテンツスタイル */
main {
    padding-top: 20px; /* ヘッダーの下に適切な空間を作る */
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    #manga-list {
        gap: 20px;
        padding: 0 10px;
    }
    
    .manga-item {
        width: 150px;
    }
    
    .manga-cover {
        height: 210px;
    }
      h1 {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 10px;
        padding-top: 0;
    }
    
    header {
        padding: 10px 0;
    }
    
    button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    #manga-viewer {
        padding: 15px;
    }
    
    #page-nav {
        gap: 10px;
    }
}

@media (max-width: 480px) {
    #manga-list {
        gap: 15px;
    }
    
    .manga-item {
        width: 130px;
    }
    
    .manga-cover {
        height: 180px;
    }
      nav {
        flex-direction: column;
        gap: 10px;
    }
    
    header {
        padding: 8px 0;
    }
    
    #page-nav {
        width: 100%;
        justify-content: space-between;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
}

/* ウェルカムメッセージとその他の追加スタイル */
.welcome-message {
    text-align: center;
    padding: 40px;
    background-color: rgba(74, 111, 165, 0.05);
    border-radius: var(--border-radius);
    max-width: 500px;
    margin: 0 auto;
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.welcome-message p {
    color: #666;
    font-size: 1.1rem;
}

/* アニメーションとトランジション */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* マンガホバーエフェクトの強化 */

/* マンガページ数表示 */
.manga-pages {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
