/*
 * Movie Card Component
 * Shared styles for movie card grids across all pages.
 * Ported from design_preview/components/movie-card.css
 */

/* === Grid Layout (default: 4 columns, pages can override) === */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

/* === Card Container === */
.movie-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.movie-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* === Thumbnail === */
.movie-thumbnail-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--input-bg, #222);
}

.movie-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === Channel Name Caption (Thumbnail Overlay) === */
/*
 * Semi-transparent dark overlay with high-contrast white text
 * ensures WCAG AA compliance (4.5:1+) across all backgrounds.
 * Contrast: rgba(0,0,0,0.78) on white = ~9.6:1 (passes AAA)
 */
.image-caption {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #f0f0f0;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    cursor: default;
}

.image-caption:hover {
    white-space: normal;
    line-height: 1.3;
    padding: 6px 12px;
    z-index: 3;
}

.image-caption[data-truncated="false"]:hover {
    white-space: nowrap;
    padding: 4px 10px;
}

/* === Type Badge (Thumbnail Overlay) === */
/*
 * Compact icon badge on top-right of thumbnail.
 * Expands on hover to show label text.
 * Uses icon shape (music note vs mic) for color-blind friendly differentiation.
 */
.type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 24px;
    border-radius: 12px;
    padding: 0;
    cursor: default;
    overflow: hidden;
    z-index: 2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: padding 0.25s ease, gap 0.25s ease;
    width: 24px;
}

.type-badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1;
}

.type-badge-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease 0.05s, max-width 0.3s ease;
}

.type-badge:hover,
.type-badge.expanded {
    width: auto;
    padding: 0 10px 0 0;
    gap: 2px;
}

.type-badge:hover .type-badge-label,
.type-badge.expanded .type-badge-label {
    opacity: 1;
    max-width: 60px;
}

.type-badge-official,
.type-badge-cover {
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.type-badge-official .type-badge-icon,
.type-badge-cover .type-badge-icon,
.type-badge-official .type-badge-label,
.type-badge-cover .type-badge-label {
    color: #f0f0f0;
}

/* === Movie Info === */
.movie-info {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.movie-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    overflow: hidden;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.movie-title-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    position: relative;
    transition: color 0.2s ease;
}

.movie-title-text:hover {
    color: var(--accent);
}

/* === Title Tooltip (full title on hover) === */
.movie-title-wrapper {
    position: relative;
}

.movie-title-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin-top: 0.25rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
}

@media (hover: hover) and (pointer: fine) {
    .movie-title-wrapper:hover .movie-title-tooltip {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.movie-title-wrapper.tooltip-visible .movie-title-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.movie-title-wrapper[data-truncated="false"] .movie-title-tooltip {
    display: none;
}

/* === Stats Grid (2x2) === */
.movie-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: auto;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.stat-item i {
    font-size: 0.8rem;
}

.level-rating {
    color: var(--text-secondary);
    font-weight: 600;
}

.level-rating .active {
    color: #ffb700;
    text-shadow: 0 0 2px rgba(255, 183, 0, 0.5);
}

/* === User Status (logged-in, vertical layout) === */
.user-status {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.trophy-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.trophy-gold   { color: #ffb700; filter: drop-shadow(0 0 3px rgba(255, 183, 0, 0.4)); }
.trophy-silver  { color: #d0d0d0; filter: drop-shadow(0 0 3px rgba(208, 208, 208, 0.3)); }
.trophy-bronze  { color: #b8722c; filter: drop-shadow(0 0 3px rgba(184, 114, 44, 0.3)); }
.trophy-white   { color: var(--text-primary); filter: drop-shadow(0 0 3px rgba(128, 128, 128, 0.2)); }
.lock-icon      { color: var(--text-secondary); opacity: 0.6; }

.status-table {
    width: 100%;
    font-size: 0.75rem;
}

.status-table table {
    width: 100%;
    border-collapse: collapse;
}

.status-table th,
.status-table td {
    padding: 2px 4px;
    text-align: center;
    white-space: nowrap;
}

.status-table th {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

/* === Responsive === */
@media (max-width: 768px) {
    .movie-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .movie-title {
        font-size: 0.85rem;
    }

    .movie-title-text {
        -webkit-line-clamp: 2;
    }

    .status-table {
        font-size: 0.7rem;
    }

    .image-caption {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .type-badge {
        width: 22px;
        height: 22px;
        border-radius: 11px;
    }

    .type-badge-icon {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }

    .type-badge-label {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .movie-info {
        padding: 0.75rem;
    }

    .movie-stats {
        font-size: 0.75rem;
    }

    .stat-item i {
        font-size: 0.75rem;
    }
}
