* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #F4F5F6;
}

.container {
    width: 90vw;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin: 0 auto;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 60px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    font-size: 16px;
    color: #666;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
    max-width: 1100px;
    perspective: 1000px; /* Lower perspective for more dramatic 3D depth */
}

.cards-container.animating .card {
    pointer-events: none;
}

.card {
    border-radius: 24px;
    aspect-ratio: 2/3.2;
    display: flex;
    position: relative;
    cursor: pointer;
    background: transparent;
    transition: transform 0.3s ease; /* For the hover lift */
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1); /* Smooth slow-fast-slow curve */
    transform-style: preserve-3d;
}

/* Staggered delay for each card to make the refresh feel more organic */
.card:nth-child(2) .card-inner { transition-delay: 0.05s; }
.card:nth-child(3) .card-inner { transition-delay: 0.1s; }

.card.is-flipped .card-inner {
    transform: rotateY(180deg); /* Perfectly straight finish */
}

.card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-front {
    transform: rotateY(0deg) translateZ(1px);
}

.card-back {
    transform: rotateY(180deg) translateZ(1px);
}

.card:not(.is-flipped) .card-back {
    pointer-events: none;
}

.card.is-flipped .card-front {
    pointer-events: none;
}

/* Desktop only: hover scale effect */
@media (min-width: 769px) {
    .card:hover {
        transform: scale(1.1);
    }

    .card:hover .card-inner {
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    }
}

/* Poster Background */
.card-poster {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

/* Dark Overlay */
.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        rgba(0, 0, 0, 0.3) 0%, 
        rgba(0, 0, 0, 0.5) 50%, 
        rgba(0, 0, 0, 0.9) 100%);
    z-index: 2;
}

/* Default State */
.card-default {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    padding: 24px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Desktop only: hide default on hover */
@media (min-width: 769px) {
    .card-face:hover .card-default {
        opacity: 0;
        pointer-events: none;
    }
}

/* Genre Tags */
.genre-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.genre-tag {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: white;
}

/* Card Info */
.card-info {
    color: white;
    width: 100%;
}

.movie-title {
    font-size: 20px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: white;
    line-height: 1.3;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.movie-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: #CECECE;
    margin-bottom: 16px;
}

.movie-rating {
    display: inline-block;
    width: 100%;
}

.rating-value {
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: #CECECE;
}

/* Hover State */
.card-hover {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: rgba(0, 0, 0, 0.33);
    backdrop-filter: blur(20px);
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    pointer-events: none;
}

/* Desktop hover */
@media (min-width: 769px) {
    .card-face:hover .card-hover {
        opacity: 1;
        pointer-events: all;
    }
}

/* Mobile tap to reveal */
@media (max-width: 768px) {
    .card-face.show-info .card-hover {
        opacity: 1;
        pointer-events: all;
        -webkit-overflow-scrolling: touch;
    }
    
    .card-face.show-info .card-default {
        opacity: 0;
        pointer-events: none;
    }
}

.hover-content {
    padding: 40px 24px;
    color: white;
    text-align: center;
}

.hover-title {
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

.hover-title:not(:first-child) {
    margin-top: 32px;
}

.movie-overview {
    font-size: 14px;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0;
}

/* Cast Grid */
.cast-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    justify-items: center;
}

.cast-member {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cast-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
}

.cast-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cast-tooltip {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translate(-50%, 100%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cast-tooltip span {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-top: 2px;
}

.cast-member:hover .cast-tooltip {
    opacity: 1;
}

.watch-providers {
    display: flex;
    justify-content: center;
    flex-direction: row;
    gap: 8px;
    width: 100%;
}

.provider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.provider-region {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.provider-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.provider-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: white;
}

.provider-item img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.provider-empty {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* Controls Bar */
.controls-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.controls-bar {
    background: #D6DADB;
    height: 42px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 0 4px;
}

.control-icon-btn {
    background: #ffffff;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1a1a1a;
    border-radius: 999px;
    transition: background-color 0.2s;
    margin: 0 6px 0 2px;
}

.control-icon-btn:hover {
    background-color: #f5f5f5;
}

.controls-filters {
    display: flex;
    align-items: center;
    gap: 2px;
}

.filter-main-btn {
    background: #ffffff;
    border: none;
    padding: 0 14px;
    height: 32px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    border-radius: 16px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filter-main-btn:hover {
    background-color: #f5f5f5;
}

.filter-main-btn .filter-label {
    color: #1a1a1a;
}

.filter-main-btn .filter-value {
    color: #1a1a1a;
}

.filter-main-btn.has-filter {
    padding-right: 8px;
}

.remove-filter-btn {
    background: transparent;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: #666;
    margin-left: 2px;
}

.remove-filter-btn:hover {
    color: #1a1a1a;
}

/* Dropdown Menu */
.dropdown-menu {
    position: fixed;
    max-width: 15dvw;
    max-height: 55dvh;
    background: #ffffff;
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    z-index: 10000;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dropdown-menu.active {
    visibility: visible;
    opacity: 1;
    pointer-events: all;
}

.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 3px;
}


.dropdown-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
    border-radius: 999px;
}

.dropdown-item:hover {
    background-color: #F1F3F3;
}

.dropdown-item.selected {
    background-color: #ECEEEE;
}

.dropdown-item.selected .remove-item-icon {
    display: flex;
}

.remove-item-icon {
    display: none;
    color: #999;
}

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

@media (max-width: 768px) {
    .controls-container {
        bottom: 20px;
    }
    
    .controls-bar {
        height: auto;
        padding: 8px;   
        justify-content: space-between;
        width: 95dvw;
    }
}

.control-icon-btn.spinning svg {
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-30px);
    }
}

.card.animating-out {
    animation: fadeOutDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.card.animating-in {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@media (max-width: 768px) {
    
    .cards-container {
        position: relative;
        display: block;
        height: 70vh;
        max-height: 600px;
        width: 100%;
        max-width: 400px;
    }

    .dropdown-menu {
        max-width: 60dvw;
    }
    
    .card {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        aspect-ratio: 4/5;
        cursor: grab;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .card:active {
        cursor: grabbing;
    }

    .controls-filters {
        flex-wrap: wrap;
    }    

    /* Stack cards - z-index managed by JavaScript */
    .card {
        transition: transform 0.3s ease, opacity 0.3s ease, z-index 0s;
    }

    /* When card is being swiped */
    .card.dragging {
        transition: none;
    }

    /* When card is dismissed */
    .card.dismissed {
        transition: transform 0.5s ease, opacity 0.5s ease;
        opacity: 0;
        pointer-events: none;
        z-index: 0 !important;
    }

    .card.dismissed-left {
        transform: translateX(-150%) rotate(-30deg) !important;
    }

    .card.dismissed-right {
        transform: translateX(150%) rotate(30deg) !important;
    }
    
    .container {
        gap: 0px;
        min-height: 90dvh;
    }
}

/* Trailer Button */
.trailer-btn {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(4px);
}

.trailer-btn.visible {
    display: inline-flex;
}

.trailer-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.trailer-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Trailer Modal */
.trailer-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.trailer-modal.active {
    display: flex;
}

.trailer-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.trailer-modal-content {
    position: relative;
    width: 90vw;
    max-width: 960px;
    z-index: 1;
}

.trailer-modal-close {
    position: absolute;
    top: -44px;
    right: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.trailer-modal-close:hover {
    color: white;
}

.trailer-modal-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
}

.trailer-modal-player iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}

@media (max-width: 768px) {
    .hover-content {
        padding: 24px 20px;
    }

    .hover-title:not(:first-child) {
        margin-top: 20px;
    }

    .hover-title {
        margin-bottom: 10px;
    }

    .cast-grid {
        gap: 10px;
    }

    .cast-photo {
        width: 48px;
        height: 48px;
    }

    .trailer-btn {
        margin-top: 20px;
    }

    .trailer-modal-content {
        width: 95vw;
    }

    .trailer-modal-player {
        border-radius: 12px;
    }

    .trailer-modal-close {
        top: -40px;
    }
}
