/* ============================================
   Manga Atlas - Chapter List Page Styles (Dark Theme)
   ============================================ */

/* Import shared variables from home.css concept */
:root {
    /* Color Palette - Dark Theme */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1f3460;

    /* Accent Colors */
    --accent-primary: #e94560;
    --accent-secondary: #0f3460;
    --accent-gradient: linear-gradient(135deg, #e94560 0%, #0f3460 100%);
    --accent-glow: rgba(233, 69, 96, 0.3);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.chapter-page {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header Navigation */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-primary);
    text-decoration: none;
    margin-bottom: 25px;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 10px 18px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.back-link:hover {
    background: var(--bg-card-hover);
    transform: translateX(-3px);
}

/* Manga Header Section */
.manga-header {
    display: flex;
    gap: 35px;
    margin-bottom: 40px;
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.manga-poster {
    flex-shrink: 0;
}

.manga-poster img {
    width: 220px;
    height: 320px;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.manga-poster-placeholder {
    width: 220px;
    height: 320px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 72px;
    box-shadow: var(--shadow-lg);
}

.manga-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.manga-details h1 {
    margin: 0 0 15px 0;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.manga-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.manga-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.manga-description {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
    max-height: 120px;
    overflow-y: auto;
}

.manga-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.manga-tags .tag {
    background: rgba(233, 69, 96, 0.15);
    color: var(--accent-primary);
    padding: 6px 14px;
    border-radius: var(--radius-lg);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(233, 69, 96, 0.3);
    transition: var(--transition-fast);
}

.manga-tags .tag:hover {
    background: rgba(233, 69, 96, 0.25);
}

/* Chapter List Section */
.chapter-section {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
}

.chapter-section h2 {
    margin: 0 0 25px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Ad Banner Container */
.ad-container {
    text-align: center;
    margin: 30px 0;
}

/* Desktop ad visible by default, mobile ad hidden */
.ad-desktop {
    display: block;
}

.ad-mobile {
    display: none;
}

/* Switch ads on mobile devices */
@media (max-width: 768px) {
    .ad-desktop {
        display: none;
    }

    .ad-mobile {
        display: block;
        margin: 20px 0;
    }
}

.chapter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.chapter-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    text-align: center;
}

.chapter-item:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

/* Similar Manga Section */
.similar-section {
    margin-top: 40px;
}

.similar-section h2 {
    margin-bottom: 25px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.similar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

.similar-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    text-decoration: none;
    color: inherit;
}

.similar-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.similar-card img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    transition: var(--transition-normal);
}

.similar-card:hover img {
    transform: scale(1.05);
}

.similar-card .title {
    padding: 12px 15px;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    body.chapter-page {
        padding: 15px;
    }

    .manga-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
    }

    .manga-poster img,
    .manga-poster-placeholder {
        width: 180px;
        height: 260px;
    }

    .manga-details h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    .manga-meta {
        justify-content: center;
    }

    .chapter-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .similar-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

/* ============================================
   Mobile-Specific Styles (Touch Optimized)
   ============================================ */

body.chapter-page.is-mobile {
    -webkit-user-select: none;
    user-select: none;
}

body.is-mobile .chapter-item {
    /* Larger touch targets - minimum 48px per WCAG */
    min-height: 48px;
    padding: 16px 12px;
    font-size: 1rem;
}

body.is-mobile .chapter-item:active {
    background: var(--accent-primary);
    color: white;
    transform: scale(0.98);
}

body.is-mobile .similar-card {
    /* Remove hover transform on mobile */
    transform: none !important;
}

body.is-mobile .similar-card:active {
    transform: scale(0.98) !important;
}

body.is-mobile .manga-tags .tag {
    /* Larger touch targets for tags */
    padding: 10px 16px;
    font-size: 0.9rem;
}

body.is-mobile .back-link {
    /* Larger back button */
    padding: 14px 22px;
    font-size: 1rem;
}

/* Collapsible description on mobile */
body.is-mobile .manga-description {
    max-height: 80px;
    overflow: hidden;
    position: relative;
}

body.is-mobile .manga-description::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--bg-card));
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body.chapter-page.is-mobile {
        padding-bottom: env(safe-area-inset-bottom);
    }
}