/* CSS Variables for theming */
:root {
    --bg-primary: #141414;
    --bg-secondary: #1f1f1f;
    --bg-card: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent: #e50914;
    --border: #404040;
    --quality-excellent: #22c55e;
    --quality-good: #86efac;
    --quality-average: #f97316;
    --quality-below-average: #fb923c;
    --quality-poor: #ff4444;
    --shadow: rgba(0, 0, 0, 0.5);
    --film-color: #3b82f6;
    --series-color: #f97316;
}

/* Light mode */
body.light-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 0;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 2rem;
    position: relative;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.logo-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.logo-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.logo h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin: 0;
    line-height: 1;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

#themeToggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

#themeToggle:hover {
    transform: scale(1.1);
}

/* Navigation Links */
.nav-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.nav-link {
    padding: 0.75rem 2rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.nav-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3);
}

/* Section Tabs */
.section-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.tab-btn {
    padding: 0.75rem 2rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 300px;
}

.tab-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.sort-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Region Filter */
.region-filter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.region-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.region-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent);
}

.toggle-label {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.hidden-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -0.25rem;
}

.sort-controls label {
    color: var(--text-secondary);
}

#sortSelect {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 4rem 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error message */
.error {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid var(--quality-red);
    border-radius: 10px;
    margin: 2rem 0;
}

/* Update info */
.update-info {
    text-align: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.update-info span {
    margin: 0 0.5rem;
}

/* Content grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Title card */
.title-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.title-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px var(--shadow);
}

/* Quality indicator border */
.title-card.quality-excellent {
    border-left: 5px solid var(--quality-excellent);
}

.title-card.quality-good {
    border-left: 5px solid var(--quality-good);
}

.title-card.quality-average {
    border-left: 5px solid var(--quality-average);
}

.title-card.quality-below-average {
    border-left: 5px solid var(--quality-below-average);
}

.title-card.quality-poor {
    border-left: 5px solid var(--quality-poor);
}

.card-content {
    position: relative;
    display: flex;
    gap: 1rem;
    padding: 1rem;
}

/* Rating badge - positioned above poster (half overlapping) */
.rating-badge {
    position: absolute;
    top: -0.8rem;
    left: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    z-index: 10;
}

.rating-badge.rating-excellent {
    background: rgba(34, 197, 94, 0.95);
    color: white;
    border: 2px solid var(--quality-excellent);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.rating-badge.rating-good {
    background: rgba(134, 239, 172, 0.95);
    color: #1a1a1a;
    border: 2px solid var(--quality-good);
    box-shadow: 0 2px 8px rgba(134, 239, 172, 0.4);
}

.rating-badge.rating-average {
    background: rgba(249, 115, 22, 0.95);
    color: white;
    border: 2px solid var(--quality-average);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
}

.rating-badge.rating-below-average {
    background: rgba(251, 146, 60, 0.95);
    color: white;
    border: 2px solid var(--quality-below-average);
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.4);
}

.rating-badge.rating-poor {
    background: rgba(255, 68, 68, 0.95);
    color: white;
    border: 2px solid var(--quality-poor);
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
}

.card-poster {
    flex-shrink: 0;
    position: relative;
}

.card-poster img {
    width: 100px;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    background: var(--bg-secondary);
}

/* Rank badge - positioned on poster */
.rank-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.card-poster .no-poster {
    width: 100px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 5px;
    color: var(--text-secondary);
    font-size: 3rem;
}

.card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}


.card-title {
    flex: 1;
}

.card-title h2 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.card-title .original-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-expanded .description {
    -webkit-line-clamp: unset;
}

/* Newsletter Section */
.newsletter-section {
    text-align: center;
    padding: 2rem 1rem;
    margin: 3rem 0 2rem;
    background: var(--bg-secondary);
    border-radius: 15px;
    border: 2px solid var(--border);
}

.newsletter-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.newsletter-form {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    max-width: 500px;
    margin: 0 auto;
}

.newsletter-form input[type="email"] {
    flex: 1;
    min-width: 250px;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.newsletter-form input[type="email"]:focus {
    outline: none;
    border-color: var(--accent);
}

.newsletter-form input[type="email"]::placeholder {
    color: var(--text-secondary);
}

.newsletter-form button {
    padding: 0.75rem 2rem;
    background: var(--accent);
    color: white;
    border: 2px solid var(--accent);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.newsletter-form button:hover {
    background: #c40812;
    border-color: #c40812;
    transform: translateY(-2px);
}

.newsletter-form button:active {
    transform: translateY(0);
}

.newsletter-form button:disabled {
    background: var(--border);
    border-color: var(--border);
    cursor: not-allowed;
    transform: none;
}

.newsletter-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.newsletter-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--quality-excellent);
    border: 1px solid var(--quality-excellent);
}

.newsletter-message.error {
    background: rgba(255, 68, 68, 0.1);
    color: var(--quality-poor);
    border: 1px solid var(--quality-poor);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */

/* === MOBILE FIRST: Small phones (320px - 640px) === */
@media (max-width: 640px) {
    /* Container */
    .container {
        padding: 0.75rem;
    }

    /* Header */
    .header {
        padding: 1.5rem 0;
    }

    .logo-header {
        gap: 0.5rem;
    }

    .logo-avatar {
        width: 2rem;
        height: 2rem;
    }

    .logo h1 {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .theme-toggle {
        top: 0.5rem;
        right: 0.5rem;
    }

    /* Navigation - Horizontal scroll */
    .nav-links {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        padding: 0 0.75rem;
        gap: 0.75rem;
        justify-content: flex-start;
        margin-bottom: 1rem;
    }

    .nav-links::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    .nav-link {
        scroll-snap-align: start;
        flex-shrink: 0;
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px;
        white-space: nowrap;
    }

    /* Section Tabs - Flex wrap */
    .section-tabs {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0 0.75rem;
        margin-bottom: 1rem;
    }

    .tab-btn {
        flex: 1;
        min-width: calc(50% - 0.375rem);
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Controls - Vertical stack */
    .controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 0 0.75rem;
        margin-bottom: 1rem;
    }

    .sort-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }

    .sort-controls label {
        font-size: 0.9rem;
        font-weight: 600;
    }

    #sortSelect,
    #typeFilter,
    #ratingFilter {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevent iOS zoom */
        min-height: 44px;
    }

    /* Region Filter */
    .region-filter {
        padding: 0 0.75rem;
        margin-bottom: 1.5rem;
    }

    .region-toggle {
        padding: 0.5rem;
        min-height: 44px;
        gap: 0.5rem;
    }

    .region-toggle input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    .toggle-label {
        font-size: 0.9rem;
    }

    .hidden-count {
        font-size: 0.8rem;
    }

    /* Update Info */
    .update-info {
        font-size: 0.85rem;
        padding: 0.75rem;
        margin-bottom: 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Content Grid */
    .content-grid {
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    /* Title Cards */
    .card-content {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .card-poster img,
    .card-poster .no-poster {
        width: 90px;
        height: 135px;
    }

    .card-title h2 {
        font-size: 1rem;
        line-height: 1.3;
    }

    .card-title .original-title {
        font-size: 0.8rem;
    }

    .meta {
        font-size: 0.85rem;
        gap: 0.4rem;
        line-height: 1.5;
    }

    .description {
        font-size: 0.85rem;
        line-height: 1.4;
        -webkit-line-clamp: 4;
    }

    .rating-badge {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
        gap: 0.25rem;
    }

    .rank-badge {
        font-size: 0.9rem;
        padding: 0.2rem 0.6rem;
    }

    /* Newsletter Section */
    .newsletter-section {
        padding: 1.5rem 0.75rem;
        margin: 2rem 0 1.5rem;
    }

    .newsletter-text {
        font-size: 0.95rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-form input[type="email"] {
        min-width: 100%;
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevent iOS zoom */
        min-height: 44px;
    }

    .newsletter-form button {
        width: 100%;
        padding: 0.75rem 1.5rem;
        min-height: 44px;
    }

    /* Footer */
    .footer {
        padding: 1.5rem 0;
        margin-top: 2rem;
    }

    .footer-links {
        font-size: 0.85rem;
        gap: 0.4rem;
    }

    .footer-note {
        font-size: 0.85rem;
    }

    /* Archive specific */
    .info-banner {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .info-banner h2 {
        font-size: 1rem !important;
    }

    .info-banner p {
        font-size: 0.9rem !important;
    }

    #statsInfo {
        font-size: 0.85rem !important;
    }

    .load-more-btn {
        width: 100%;
        min-height: 44px;
    }
}

/* === MEDIUM: Tablets (641px - 768px) === */
@media (min-width: 641px) and (max-width: 768px) {
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .section-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
}

/* === DESKTOP: Large screens (769px+) === */
@media (min-width: 769px) {
    .container {
        padding: 2rem;
    }

    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    }

    .card-poster img,
    .card-poster .no-poster {
        width: 120px;
        height: 180px;
    }

    .card-title h2 {
        font-size: 1.3rem;
    }

    .description {
        -webkit-line-clamp: 5;
    }
}

/* === EXTRA LARGE: Desktop (1024px+) === */
@media (min-width: 1024px) {
    .logo-avatar {
        width: 2.8rem;
        height: 2.8rem;
    }

    .logo h1 {
        font-size: 2.8rem;
    }

    .card-content {
        padding: 1.5rem;
    }
}

/* Print styles */
@media print {
    .header,
    .controls,
    .footer,
    .theme-toggle {
        display: none;
    }

    .title-card {
        break-inside: avoid;
    }
}
