/**
 * NFL Game Rater - Card Component Styles
 * v3.5 - Modern card-based layout for game displays
 */

/* ============================================================================
   CARD GRID LAYOUT
   ============================================================================ */

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin: 0;
    background: #fafafa;
    padding: 15px;
    border-radius: 0;
    align-items: start;
}

/* ============================================================================
   CARD ANIMATIONS
   ============================================================================ */

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

/* ============================================================================
   GAME CARDS
   ============================================================================ */

.game-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    transition: transform 0.2s, box-shadow 0.2s, border 0.2s;
    cursor: pointer;
    position: relative;
    animation: fadeInUp 0.4s ease-out forwards;
    opacity: 0;
    isolation: isolate;
}

/* Staggered animation delays */
.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.1s; }
.game-card:nth-child(3) { animation-delay: 0.15s; }
.game-card:nth-child(4) { animation-delay: 0.2s; }
.game-card:nth-child(5) { animation-delay: 0.25s; }
.game-card:nth-child(6) { animation-delay: 0.3s; }
.game-card:nth-child(7) { animation-delay: 0.35s; }
.game-card:nth-child(8) { animation-delay: 0.4s; }

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

/* Game of the week special styling */
.game-card.game-of-week {
    border: 2px solid #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}

.game-card:not(.game-of-week) {
    border: 1px solid var(--border-color);
}

/* ============================================================================
   CARD BADGES
   ============================================================================ */

/* Game of the Week Badge */
.game-of-week-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    white-space: nowrap;
    z-index: 5;
}

/* Week Badge (season page) */
.card-week-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #f3f4f6;
    color: #4b5563;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    white-space: nowrap;
    z-index: 5;
}

/* Hide week badge when game-of-week badge is shown */
.game-card.game-of-week .card-week-badge {
    display: none;
}

/* Rank Badge */
.card-rank {
    position: absolute;
    top: 6px;
    left: 6px;
    font-weight: 700;
    font-size: 0.85em;
    color: #6b7280;
}

.card-rank.medal {
    font-size: 1.2em;
}

/* Rating Badge */
.card-rating-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-weight: 700;
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: 12px;
    color: white;
}

.card-rating-badge.instant-classic { background: #fbbf24; }
.card-rating-badge.must-watch { background: #22c55e; }
.card-rating-badge.entertaining { background: #86efac; color: #166534; }
.card-rating-badge.decent { background: #3b82f6; }
.card-rating-badge.skip { background: #ef4444; }
.card-rating-badge.average { background: #eab308; }

/* ============================================================================
   CARD CONTENT
   ============================================================================ */

/* Card Expansion/Collapse */
.card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    padding-top: 0;
}

.game-card.expanded .card-details {
    max-height: 600px;
    margin-top: 8px;
    padding-top: 8px;
}

.card-details-content {
    font-size: 0.85em;
}

.card-component-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-component-label {
    font-weight: 600;
    color: #4b5563;
    font-size: 0.85em;
}

.card-component-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.card-component-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--highlight-gradient-start), var(--highlight-gradient-end));
}

/* Matchup Display */
.card-matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

/* Team Logos */
.card-team-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.card-team-logo::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 60%, rgba(0,0,0,0.03) 100%);
    z-index: 0;
}

.game-card:hover .card-team-logo {
    transform: scale(1.1);
}

.card-team-logo img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    position: relative;
    z-index: 1;
    transition: filter 0.2s ease;
}

.game-card:hover .card-team-logo img {
    filter: brightness(1.1) drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* VS Text */
.card-vs {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.9em;
}

/* Game Title */
.card-game-title {
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
    color: #1f2937;
    margin-bottom: 5px;
}

/* Indicator Icons */
.card-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 1.1em;
}

.indicator-icon {
    opacity: 0.3;
}

.indicator-icon.active {
    opacity: 1;
}

/* ============================================================================
   CARD ACTIONS
   ============================================================================ */

.card-actions {
    margin-top: 16px;
}

.spoiler-container {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px;
    position: relative;
    padding-top: 18px;
    background: #f9fafb;
}

.spoiler-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #6b7280;
    color: white;
    padding: 3px 14px;
    border-radius: 10px;
    font-size: 0.65em;
    font-weight: 600;
    white-space: nowrap;
}

.spoiler-buttons {
    display: flex;
    gap: 8px;
}

/* Remove any browser-added disclosure triangles from table rows */
.card-details table tr::marker,
.card-details table tr::before,
.card-details table tr::after {
    display: none !important;
    content: none !important;
}

.card-details table tbody {
    list-style: none;
}

.card-details table tr {
    list-style-type: none;
}

.card-button {
    flex: 1;
    padding: 5px;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.75em;
    transition: opacity 0.2s;
}

.card-button:hover {
    opacity: 0.8;
}

.card-button.primary {
    background: var(--accent-color);
    color: white;
}

.card-button.secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-highlights {
    background: rgba(0, 51, 102, 0.75);
    color: white;
}

.btn-details {
    background: rgba(200, 16, 46, 0.75);
    color: white;
}

/* ============================================================================
   LEVEL SECTIONS (Collapsible Groups)
   ============================================================================ */

.level-section {
    margin: 20px 0;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.level-section.collapsed .games-grid {
    display: none;
}

.level-section .games-grid {
    overflow: hidden;
}

.level-header {
    padding: 10px 20px;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #fafafa;
    font-family: 'Quicksand', sans-serif;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.level-header:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.level-header::after {
    content: '▼';
    margin-left: 8px;
    font-size: 0.7em;
    transition: transform 0.3s ease;
    color: #9ca3af;
}

.level-section.collapsed .level-header::after {
    transform: rotate(-90deg);
}

.level-text {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    flex: 1;
}

.level-title {
    font-size: 0.95em;
    font-weight: 700;
    color: #003D7A;
    letter-spacing: 0.015em;
}

.level-commentary {
    font-size: 0.8em;
    color: #9ca3af;
    font-style: normal;
    font-weight: 400;
}

.level-count {
    font-size: 0.9em;
    color: #6b7280;
    font-weight: 600;
    background: white;
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-left: auto;
    flex-shrink: 0;
}

/* ============================================================================
   LEVEL TABS (Quick Navigation)
   ============================================================================ */

.level-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    background: white;
    padding: 10px 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

.level-tab {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.2s;
    color: var(--text-dark);
}

.level-tab:hover {
    background: var(--light-bg);
    border-color: var(--accent-color);
}

.level-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* ============================================================================
   SEARCH CONTAINER
   ============================================================================ */

.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-box {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
    transition: border-color 0.2s;
}

.search-box:focus {
    outline: none;
    border-color: var(--accent-color);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   MOBILE RESPONSIVE STYLES
   ============================================================================ */

@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .level-commentary,
    .level-count {
        display: none;
    }

    .level-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .level-tab {
        flex-shrink: 0;
    }

    .card-team-logo {
        width: 38px;
        height: 38px;
    }

    .card-team-logo img {
        width: 28px;
        height: 28px;
    }
}
