/* CSS Custom Properties for Fluid Responsive Design */
:root {
    /* Fluid Typography Scale */
    --font-size-xs: clamp(0.75rem, 2vw, 0.875rem);
    --font-size-sm: clamp(0.875rem, 2.5vw, 1rem);
    --font-size-base: clamp(1rem, 3vw, 1.125rem);
    --font-size-lg: clamp(1.125rem, 3.5vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 4vw, 1.5rem);
    --font-size-2xl: clamp(1.5rem, 5vw, 2rem);
    --font-size-3xl: clamp(2rem, 6vw, 2.5rem);
    --font-size-4xl: clamp(2.5rem, 8vw, 3.5rem);
    --font-size-5xl: clamp(3rem, 10vw, 4.5rem);
    
    /* Fluid Spacing Scale */
    --space-xs: clamp(0.25rem, 1vw, 0.5rem);
    --space-sm: clamp(0.5rem, 2vw, 0.75rem);
    --space-md: clamp(0.75rem, 3vw, 1rem);
    --space-lg: clamp(1rem, 4vw, 1.5rem);
    --space-xl: clamp(1.5rem, 5vw, 2rem);
    --space-2xl: clamp(2rem, 6vw, 3rem);
    --space-3xl: clamp(3rem, 8vw, 4rem);
    --space-4xl: clamp(4rem, 10vw, 6rem);
    
    /* Fluid Component Sizes */
    --button-height: clamp(44px, 8vw, 56px);
    --button-padding-x: clamp(1rem, 4vw, 2rem);
    --button-padding-y: clamp(0.75rem, 2vw, 1rem);
    --input-height: clamp(44px, 8vw, 56px);
    --input-padding: clamp(0.75rem, 3vw, 1rem);
    
    /* Container Sizes */
    --container-sm: clamp(320px, 90vw, 640px);
    --container-md: clamp(640px, 90vw, 768px);
    --container-lg: clamp(768px, 90vw, 1024px);
    --container-xl: clamp(1024px, 90vw, 1280px);
    
    /* Border Radius Scale */
    --radius-sm: clamp(4px, 1vw, 6px);
    --radius-md: clamp(6px, 1.5vw, 8px);
    --radius-lg: clamp(8px, 2vw, 12px);
    --radius-xl: clamp(12px, 3vw, 16px);
    
    /* Shadow Scale */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* SF Pro Font Face Declarations */
@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Semibold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Heavy.otf') format('opentype');
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: 'SF Pro';
    src: url('assets/fonts/SF-Pro-Text-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: var(--font-size-base);
    line-height: 1.6;
    background-color: #171717;
    color: white;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Container with responsive margins */
.container {
    display: flex;
    min-height: 100vh;
    padding: var(--space-4xl);
    gap: var(--space-lg);
    max-width: 100vw;
}

/* Left Section */
.left-section {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.logo {
    position: fixed;
    top: var(--space-4xl);
    left: var(--space-4xl);
    z-index: 1000;
    margin-bottom: var(--space-2xl);
}

.logo-image {
    height: 24px;
    width: auto;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
    animation: logoGlow 2s ease-in-out infinite alternate;
}

@keyframes logoGlow {
    from {
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
    }
    to {
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.5));
    }
}

.main-content {
    max-width: 100%;
}

.main-title {
    font-size: var(--font-size-5xl);
    font-weight: 300;
    line-height: 1.1;
    margin-bottom: var(--space-xl);
    letter-spacing: -0.02em;
}

.description {
    font-size: var(--font-size-sm);
    line-height: 1.6;
    margin-bottom: var(--space-2xl);
    opacity: 0.5;
    max-width: 300px;
}

.cta-section {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.cta-button {
    background: white;
    color: #171717;
    border: none;
    padding: var(--button-padding-y) var(--button-padding-x);
    height: var(--button-height);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-lg);
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    animation: buttonGlow 2s ease-in-out infinite alternate;
    min-width: 44px;
    min-height: 44px;
}

@keyframes buttonGlow {
    from {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    }
    to {
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
    }
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
}

.user-count {
    font-size: var(--font-size-sm);
    opacity: 0.5;
}

/* Right Section - Leaderboard */
.right-section {
    flex: 0 0 clamp(300px, 40vw, 500px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.leaderboard {
    background: transparent;
    border-radius: var(--radius-xl);
    border: none;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
}

.header-label {
    font-size: var(--font-size-sm);
    font-weight: 300;
    opacity: 0.5;
}

.leaderboard-list {
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.leaderboard-list::-webkit-scrollbar {
    width: 1px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.04);
    padding: var(--space-xl);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-xl);
    transition: all 0.2s ease;
    min-height: 60px;
}

.leaderboard-entry:hover {
    transform: translateX(2px);
}

.leaderboard-entry.highlighted {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.entry-rank {
    font-weight: 300;
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.5);
    margin-right: var(--space-sm);
    min-width: 30px;
}

.entry-name {
    flex: 1;
    font-weight: 300;
}

.entry-score {
    font-weight: 300;
}

/* Entry actions container */
.entry-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Portfolio link button */
.portfolio-link-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.portfolio-link-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.portfolio-link-btn:hover .link-icon {
    opacity: 1;
}

.portfolio-link-btn:active {
    transform: scale(0.95);
}

.link-icon {
    width: 14px;
    height: 14px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

/* Skeleton loading state */
.leaderboard-entry.skeleton {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: default;
    animation: skeletonPulse 1.5s ease-in-out infinite alternate;
}

.leaderboard-entry.skeleton:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.05);
}

.skeleton-text {
    color: rgba(255, 255, 255, 0.2) !important;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.05) 25%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
    min-width: 60px;
}

@keyframes skeletonPulse {
    0% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        padding: var(--space-3xl);
        gap: var(--space-2xl);
    }
    
    .right-section {
        flex: 0 0 clamp(280px, 35vw, 350px);
    }
}

@media (max-width: 968px) {
    .container {
        flex-direction: column;
        padding: var(--space-2xl);
        gap: var(--space-2xl);
    }
    
    .left-section {
        order: 2;
    }
    
    .right-section {
        order: 1;
        flex: none;
        width: 100%;
    }
    
    .leaderboard {
        max-width: 100%;
    }
    
    .cta-section {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }
    
    .logo {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: var(--space-lg);
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--space-lg);
        gap: var(--space-xl);
    }
    
    .logo {
        margin-bottom: var(--space-xl);
    }
    
    .main-title {
        margin-bottom: var(--space-md);
    }
    
    .description {
        margin-bottom: var(--space-xl);
        max-width: 100%;
    }
    
    .leaderboard {
        padding: var(--space-lg);
    }
    
    .leaderboard-list {
        max-height: 50vh;
    }
    
    .leaderboard-entry {
        padding: var(--space-md);
        margin-bottom: var(--space-xs);
    }
    
    .portfolio-link-btn {
        width: 28px;
        height: 28px;
    }
    
    .link-icon {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--space-md);
    }
    
    .leaderboard-entry {
        padding: var(--space-sm);
        font-size: var(--font-size-sm);
        min-height: 50px;
    }
    
    .portfolio-link-btn {
        width: 24px;
        height: 24px;
    }
    
    .link-icon {
        width: 10px;
        height: 10px;
    }
    
    .cta-button {
        width: 100%;
        justify-content: center;
    }
    
    .cta-section {
        width: 100%;
    }
    
    .main-title {
        font-size: var(--font-size-4xl);
    }
}

/* Container Queries for Component-Level Responsiveness */
@container (max-width: 400px) {
    .leaderboard-entry {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
    
    .entry-rank {
        margin-right: 0;
    }
}

@container (max-width: 300px) {
    .cta-section {
        flex-direction: column;
        width: 100%;
    }
    
    .cta-button {
        width: 100%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .cta-button {
        min-height: 48px;
        min-width: 48px;
    }
    
    .leaderboard-entry {
        min-height: 64px;
        padding: var(--space-lg);
    }
    
    .leaderboard-entry:hover {
        transform: none;
    }
    
    .cta-button:hover {
        transform: none;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .logo-image {
        animation: none;
    }
    
    .cta-button {
        animation: none;
    }
}

/* Dark mode optimizations (already dark, but ensuring consistency) */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Mobile and Tablet Scrolling Improvements */
@media (max-width: 968px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .container {
        min-height: auto;
        height: auto;
    }
    
    .leaderboard-list {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .leaderboard-list {
        max-height: 50vh;
    }
    
    .container {
        padding-bottom: var(--space-2xl);
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition: all 0.2s ease;
}

/* Message Animation */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Focus states for accessibility */
.cta-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.leaderboard-entry:focus {
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: 2px;
}
