/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #E50914;
    --background-black: #141414;
    --background-dark: #181818;
    --text-white: #ffffff;
    --text-gray: #b3b3b3;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-red);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-black);
    color: var(--text-white);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Improve text rendering on Windows */
    font-feature-settings: "liga" 1, "calt" 1;
    /* Enable smooth scrolling for better UX */
    scroll-behavior: smooth;
}

/* Cross-browser compatibility */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    /* Remove default button styles on iOS */
    -webkit-appearance: none;
    appearance: none;
}

/* Focus styles for accessibility */
a:focus-visible,
button:focus-visible,
article:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

/* Remove outline when using mouse, keep for keyboard navigation */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    transition: background-color 0.4s ease;
}

.nav.scrolled {
    background-color: var(--background-black);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4%;
    height: 68px;
    max-width: 1920px;
    margin: 0 auto;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 50px;
}

.netflix-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 28px;
    color: var(--primary-red);
    letter-spacing: 2px;
    cursor: pointer;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 20px;
}

.nav-links a {
    color: var(--text-white);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-gray);
    font-weight: 500;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-btn,
.notification-btn {
    background: none;
    border: none;
    color: var(--text-white);
    cursor: pointer;
    padding: 8px;
    transition: transform 0.2s ease;
}

.search-btn:hover,
.notification-btn:hover {
    transform: scale(1.1);
}

.profile-menu {
    position: relative;
    cursor: pointer;
}

.profile-img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.profile-img:hover {
    transform: scale(1.05);
}

/* Hero Section */
.hero {
    position: relative;
    height: 85vh;
    min-height: 600px;
    max-height: 1080px;
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.hero-content {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.hero-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(20, 20, 20, 0.9) 0%,
        rgba(20, 20, 20, 0.6) 30%,
        rgba(20, 20, 20, 0.4) 50%,
        rgba(20, 20, 20, 0.2) 70%,
        rgba(20, 20, 20, 0.1) 100%
    );
}

.hero-gradient::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: linear-gradient(to top, var(--background-black) 0%, transparent 100%);
}

.hero-info {
    position: relative;
    z-index: 2;
    padding-left: 4%;
    max-width: 650px;
    animation: fadeIn 1s ease-in;
}

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

.hero-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 64px;
    line-height: 1;
    margin-bottom: 20px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

.hero-metadata {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
}

.match-score {
    color: #46d369;
    font-weight: 600;
}

.year,
.age-rating,
.seasons {
    color: var(--text-gray);
}

.hero-overview {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 30px;
    color: var(--text-white);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Content Rows */
.content {
    position: relative;
    z-index: 10;
    margin-top: -100px;
    padding-bottom: 60px;
}

.row {
    margin-bottom: 40px;
}

.row-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-left: 4%;
    color: var(--text-white);
    transition: color 0.3s ease;
}

.row:hover .row-title {
    color: var(--text-white);
}

.row-container {
    position: relative;
    display: flex;
    align-items: center;
}

.row-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 20px 4%;
    cursor: grab;
}

.row-scroll::-webkit-scrollbar {
    display: none;
}

.row-scroll:active {
    cursor: grabbing;
}

.movie-card-link {
    flex: 0 0 auto;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.3s ease;
    /* Larger touch targets for mobile */
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.movie-card-link:hover .movie-card {
    transform: scale(1.1);
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .movie-card-link:hover .movie-card {
        transform: none;
    }

    .movie-card-link:active .movie-card {
        transform: scale(0.98);
    }
}

.movie-card {
    width: 200px;
    height: 300px;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--background-dark);
    transition: all 0.3s ease;
}

.movie-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.movie-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.movie-card:hover .movie-card-overlay {
    opacity: 1;
}

.movie-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-white);
}

.movie-card-meta {
    font-size: 12px;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 8px;
}

.match-badge {
    color: #46d369;
    font-weight: 600;
}

.movie-card-rating {
    border: 1px solid var(--text-gray);
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 11px;
}

.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100%;
    background: rgba(20, 20, 20, 0.7);
    border: none;
    color: var(--text-white);
    cursor: pointer;
    z-index: 50;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row:hover .scroll-btn {
    opacity: 1;
}

.scroll-left {
    left: 0;
}

.scroll-right {
    right: 0;
}

.scroll-btn:hover {
    background: rgba(20, 20, 20, 0.9);
    transform: translateY(-50%) scale(1.1);
}

/* Footer */
.footer {
    background-color: var(--background-black);
    padding: 30px 4%;
    text-align: center;
    max-width: 1920px;
    margin: 0 auto;
}

.footer .copyright {
    color: var(--text-gray);
    font-size: 13px;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-gray);
    font-size: 14px;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-gray);
    border-top-color: var(--primary-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
}

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

/* Responsive Design */

/* Extra Large Screens (1200px - 1920px) */
@media (max-width: 1200px) {
    .hero-title {
        font-size: 48px;
    }

    .movie-card,
    .movie-card-link {
        width: 180px;
        height: 270px;
    }
}

/* Tablets and Small Laptops (768px - 1200px) */
@media (max-width: 992px) {
    .nav-left {
        gap: 30px;
    }

    .hero-title {
        font-size: 42px;
    }

    .hero-metadata {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* Tablets (768px - 992px) */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav-container {
        padding: 0 20px;
    }

    .hero-title {
        font-size: 36px;
    }

    .hero-overview {
        font-size: 14px;
        max-width: 100%;
    }

    .movie-card,
    .movie-card-link {
        width: 150px;
        height: 225px;
    }

    .row-scroll {
        gap: 8px;
        padding: 20px;
    }

    /* Improve touch targets on tablets */
    .scroll-btn {
        width: 44px;
        min-height: 44px;
    }
}

/* Mobile Landscape (480px - 768px) */
@media (max-width: 480px) {
    .nav-container {
        height: 56px;
        padding: 0 16px;
    }

    .netflix-logo {
        font-size: 24px;
    }

    .hero-title {
        font-size: 28px;
    }

    .hero-overview {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .movie-card,
    .movie-card-link {
        width: 120px;
        height: 180px;
    }

    .row-title {
        font-size: 18px;
        padding-left: 16px;
    }

    .row-scroll {
        padding: 20px 16px;
    }

    .footer {
        padding: 24px 16px;
    }
}

/* Small Mobile (320px - 480px) */
@media (max-width: 375px) {
    .hero-title {
        font-size: 24px;
    }

    .hero-metadata {
        font-size: 12px;
    }

    .movie-card,
    .movie-card-link {
        width: 100px;
        height: 150px;
    }

    .movie-card-title {
        font-size: 12px;
    }

    .movie-card-meta {
        font-size: 10px;
    }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .nav {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .hero {
        /* Fix iOS 100vh bug */
        height: 100vh;
        height: -webkit-fill-available;
    }

    /* Prevent rubber-banding on iOS */
    .row-scroll {
        -webkit-overflow-scrolling: touch;
        overflow-x: scroll;
        overflow-y: hidden;
    }
}

/* Android-specific fixes */
@supports (display: flex) and (-webkit-appearance: none) {
    .scroll-btn {
        /* Better button press feedback on Android */
        -webkit-tap-highlight-color: rgba(229, 9, 20, 0.3);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-background {
        /* Better image quality on retina displays */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode enhancement for OLED screens */
@media (prefers-color-scheme: dark) {
    :root {
        --background-black: #000000;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    body {
        scroll-behavior: auto;
    }
}

/* Print styles */
@media print {
    .nav,
    .scroll-btn,
    .footer {
        display: none;
    }

    .hero {
        page-break-inside: avoid;
    }

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