/* ============================================
   Game Detail Side Panel
   Design: Spotify/Linear inspired side panel
   Font: Instrument Sans
   Colors: Blue theme (#3b82f6, #eff6ff, #2563eb)
   ============================================ */

/* Overlay backdrop */
.game-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.game-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Side panel container */
.game-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 600px;
    max-width: 90vw;
    height: 100vh;
    background: var(--color-surface);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    font-family: 'Instrument Sans', sans-serif;
}

.game-detail-panel.active {
    transform: translateX(0);
}

/* Panel header */
.panel-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.panel-title {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
}

.panel-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.panel-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Panel body - scrollable */
.panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Image section */
.panel-image-section {
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #eff6ff 0%, #f9fafb 100%);
}

.panel-image-section img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Stats grid - 2x2 */
.panel-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e5e7eb;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.panel-stat-box {
    background: var(--color-surface);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.panel-stat-box:hover {
    background: var(--color-accent-light);
}

.panel-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #3b82f6;
    background: var(--color-accent-light);
    flex-shrink: 0;
}

.panel-stat-content {
    flex: 1;
    min-width: 0;
}

.panel-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.panel-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-primary);
}

/* Content sections */
.panel-content-section {
    padding: 24px;
}

.panel-content-block {
    margin-bottom: 28px;
}

.panel-content-block:last-child {
    margin-bottom: 0;
}

.panel-content-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.panel-content-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.panel-content-text p {
    margin: 0 0 12px 0;
}

.panel-content-text p:last-child {
    margin-bottom: 0;
}

.panel-content-text ul {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.panel-content-text li {
    margin-bottom: 6px;
}

/* Curriculum objectives */
.panel-objectives-by-tier {
    margin-top: 16px;
}

.panel-tier-group {
    margin-bottom: 16px;
}

.panel-tier-heading {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.panel-objectives-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.panel-objective-tag {
    display: inline-block;
    padding: 5px 10px;
    background: var(--color-accent-light);
    color: #3b82f6;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.panel-objective-tag:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

html[data-theme="dark"] .panel-objective-tag {
    color: var(--color-accent-hover);
    border-color: var(--color-border);
}

html[data-theme="dark"] .panel-objective-tag:hover {
    background: var(--color-accent-light);
}

html[data-theme="dark"] .panel-topic-tag {
    color: var(--color-text-primary);
}

html[data-theme="dark"] .panel-topic-tag:hover {
    background: var(--color-surface-raised);
}

/* Topic tags */
.panel-topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-topic-tag {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.panel-topic-tag:hover {
    background: #e5e7eb;
}

/* Panel footer - action buttons */
.panel-footer {
    padding: 20px 24px;
    border-top: 2px solid var(--color-border);
    background: var(--color-surface-raised);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.panel-action-btn {
    flex: 1;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-family: 'Instrument Sans', sans-serif;
}

.panel-action-btn.primary {
    background: #3b82f6;
    color: #ffffff;
}

.panel-action-btn.primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    color: #ffffff;
    text-decoration: none;
}

.panel-action-btn.disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* Dark mode: lift the button and tag text, muted/dark-blue foregrounds go
   murky on dark surfaces. */
html[data-theme="dark"] .panel-action-btn.primary {
    color: #ffffff;
}

html[data-theme="dark"] .panel-action-btn.disabled {
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

/* Loading state */
.panel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: var(--color-text-muted);
}

.panel-loading i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .game-detail-panel {
        width: 100%;
        max-width: 100%;
    }

    .panel-header {
        padding: 20px;
    }

    .panel-title {
        font-size: 20px;
    }

    .panel-content-section {
        padding: 20px;
    }

    .panel-footer {
        padding: 16px 20px;
        flex-direction: column;
    }
}
