/* This file is part of MaxRepTracker - Prevent direct access */
/* Performance Chart - Mobile Optimized CSS */

/* Global MRT Tap Highlight Reset */
[class^="mrt-"],
[class*=" mrt-"],
.stat-box {
    -webkit-tap-highlight-color: transparent;
}

.performance-chart-container {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 20px;
    padding: 60px 40px;
    width: 100%;
    max-width: 1200px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin: 40px auto;
    box-sizing: border-box;
    position: relative;
    min-height: 500px;
    overflow: hidden;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    /* CLS Fix: Contain for performance (aspect-ratio only on mobile) */
    contain: layout style;
}

/* Premium Gradient Overlay */
.performance-chart-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.7) 100%
    );
    z-index: 1;
    pointer-events: none;
    border-radius: inherit; /* Fix: clip to parent's rounded corners */
}

.performance-chart-wrapper,
.performance-stats {
    position: relative;
    z-index: 2;
}

/* Video background styling */
.performance-chart-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

/* Specific styles for different video fit modes */
.performance-chart-container video[style*="object-fit: contain"] {
    object-fit: contain;
}

.performance-chart-container video[style*="object-fit: fill"] {
    object-fit: fill;
}

.performance-chart-container video[style*="object-fit: none"] {
    object-fit: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}

.performance-chart-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    /* CLS Fix: Reserve space for chart before JS loads */
    min-height: 280px;
}

.performance-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    /* Fix: Allow vertical scroll (pan-y) so user doesn't get stuck on chart */
    touch-action: pan-y;
}

.performance-stats h3 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    /* Premium typing text glow */
    text-shadow:
        0 0 30px rgba(255, 255, 255, 0.3),
        0 0 60px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
}

.stat-box {
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    /* Premium glassmorphism enhancement */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.05) 100%
    );
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.stat-box:hover {
    transform: translateY(-8px);
    border-color: rgba(255, 255, 255, 0.3);
    /* Premium hover with subtle color glow */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.1) 100%
    );
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.25),
        0 0 40px rgba(78, 205, 196, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 5px;
    line-height: 1;
    letter-spacing: -0.03em;
    /* CLS Fix: Reserve width for counter animation */
    min-width: 2.5ch;
    text-align: center;
    /* Premium glow effect on numbers */
    text-shadow:
        0 0 20px currentColor,
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.stat-value-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mrt-arrow {
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.3s ease;
    display: inline-block;
}

.mrt-arrow.up {
    color: #10b981;
    transform: translateY(0);
}

.mrt-arrow.down {
    color: #ef4444;
    transform: translateY(0);
}

.mrt-arrow.same {
    color: #6b7280;
    transform: translateY(0);
}

.mrt-arrow.up::before {
    content: "↑";
}

.mrt-arrow.down::before {
    content: "↓";
}

.mrt-arrow.same::before {
    content: "-";
}

/* Animation for arrows */
.mrt-arrow.up {
    animation: pulseUp 0.6s ease;
}

.mrt-arrow.down {
    animation: pulseDown 0.6s ease;
}

@keyframes pulseUp {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.3) translateY(-2px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes pulseDown {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.3) translateY(2px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

/* Loading Spinner */
.fitness-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Tablet Styles */
@media (max-width: 1024px) and (min-width: 769px) {
    .performance-chart-container {
        padding: 40px 25px;
        min-height: 450px;
        gap: 20px;
    }

    .performance-chart-wrapper {
        height: 320px;
    }

    .stats-grid {
        gap: 12px;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }

    .performance-stats h3 {
        margin: 0 0 6px 0;
    }
}

/* Mobile Styles - STAT BOXES ALWAYS IN ONE ROW */
@media (max-width: 768px) {
    .performance-chart-container {
        flex-direction: column;
        padding: 30px 20px;
        margin: 30px 0;
        border-radius: 15px;
        min-height: 550px;
        gap: 15px;
        /* CLS Fix: Overriding aspect-ratio to allow taller content */
        aspect-ratio: auto;
    }

    .performance-chart-wrapper {
        height: 300px;
        min-height: 250px;
    }

    .performance-stats h3 {
        font-size: 1.5rem;
        font-weight: 800;
        letter-spacing: 0.02em;
        margin-bottom: 8px;
        text-shadow:
            0 0 40px rgba(255, 255, 255, 0.4),
            0 2px 4px rgba(0, 0, 0, 0.6);
    }

    /* KEEP 3 STAT BOXES IN ONE ROW */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .stat-box {
        padding: 12px 8px;
        min-height: 65px;
    }

    .stat-value {
        font-size: 1.6rem;
        margin-bottom: 3px;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .mrt-arrow {
        font-size: 1rem;
    }

    /* Adjust hover effects for touch devices */
    .stat-box:hover {
        transform: none;
    }

    .stat-box:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.2) !important;
    }
}

/* Small Mobile Styles - STILL KEEP 3 IN ROW */
@media (max-width: 480px) {
    .performance-chart-container {
        padding: 12px 15px 15px 15px;
        margin: 20px 0;
        min-height: auto;
        gap: 6px;
    }

    .performance-chart-wrapper {
        height: 250px;
        min-height: 200px;
    }

    .performance-stats h3 {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    /* STILL 3 STAT BOXES IN ONE ROW */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-box {
        padding: 10px 6px;
        min-height: 55px;
        border-radius: 6px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .mrt-arrow {
        font-size: 0.9rem;
    }
}

/* Very Small Mobile Styles - STILL KEEP 3 IN ROW */
@media (max-width: 360px) {
    .performance-chart-container {
        padding: 10px 12px 12px 12px;
        border-radius: 10px;
        gap: 4px;
    }

    .performance-chart-wrapper {
        height: 220px;
    }

    /* STILL 3 STAT BOXES IN ONE ROW */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .stat-box {
        padding: 8px 4px;
        min-height: 50px;
        display: flex;
        flex-direction: column;
        text-align: center;
    }

    .stat-value {
        font-size: 1.2rem;
        margin-bottom: 2px;
        justify-self: center;
    }

    .stat-label {
        font-size: 0.7rem;
        justify-self: center;
    }

    .performance-stats h3 {
        margin-bottom: 4px;
    }
}

/* Landscape Mobile Styles */
@media (max-width: 768px) and (orientation: landscape) {
    .performance-chart-container {
        flex-direction: row;
        align-items: center;
        min-height: 300px;
        background-origin: content-box;
        padding: 12px 15px 15px 15px;
        gap: 8px;
    }

    .performance-chart-wrapper {
        flex: 1;
        height: 250px;
        max-width: 60%;
    }

    .performance-stats {
        position: relative;
        z-index: 1; /* Above the video */
    }

    /* STILL 3 STAT BOXES IN ONE ROW */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-box {
        padding: 8px;
        min-height: 50px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .performance-stats h3 {
        margin-bottom: 6px;
    }
}

/* High DPI / Retina Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .performance-chart-container {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }

    .stat-box {
        backdrop-filter: blur(15px);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .performance-chart-container {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    .stat-box {
        transition: none;
    }

    .stat-box:hover {
        transform: none;
    }

    .loading-spinner {
        animation: none;
    }

    .mrt-arrow.up,
    .mrt-arrow.down {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .performance-chart-container {
        background: white !important;
        color: black !important;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .stat-value,
    .stat-label,
    .performance-stats h3 {
        color: black !important;
    }
}

/* Typing animation styles */
#typing-text-element {
    /* CLS Fix: Fixed height prevents layout shift during typing */
    height: 3em;
    min-height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#typing-text-element::after {
    content: "|";
    animation: blink 1s infinite;
    margin-left: 2px;
    color: currentColor;
}

@keyframes blink {
    0%,
    50% {
        opacity: 1;
    }
    51%,
    100% {
        opacity: 0;
    }
}

.performance-stats h3 {
    min-height: 2.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}
