/* ============================================================
   TheRunCloud — Liquid Glass Design System

   KEY INSIGHT: Glass needs colorful content behind it to look alive.
   We use animated gradient blobs + a vibrant base gradient so the
   frosted glass panels actually have something to refract.
   ============================================================ */

/* ── KRC Color Palette ──────────────────────────────────────── */
/* Primary teal:  #2dd4bf (from KRC logo runner silhouette)
   Dark navy:     #1b2838 (from KRC post backgrounds)
   Deep navy:     #0f1923 (darkest background)
   Accent teal:   #14b8a6 (slightly deeper teal for contrast)  */

/* ── Animated Background with Color Blobs ──────────────────── */
.bg-gradient-default {
    background: linear-gradient(135deg, #0f1923 0%, #1b2838 40%, #172535 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden; /* Only clip horizontal — allow vertical scrolling on mobile */
}

/* Colorful blobs that float behind the glass — KRC teal tones */
.bg-gradient-default::before,
.bg-gradient-default::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.4;
    z-index: 0;
    pointer-events: none;
    animation: float 20s ease-in-out infinite;
}

/* Top-right blob: bright KRC teal */
.bg-gradient-default::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #2dd4bf 0%, #14b8a6 40%, transparent 70%);
    top: -10%;
    right: -5%;
    animation-delay: 0s;
}

/* Bottom-left blob: deeper teal into blue */
.bg-gradient-default::after {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #0d9488 0%, #0891b2 40%, transparent 70%);
    bottom: -15%;
    left: -10%;
    animation-delay: -10s;
}

/* Third blob: subtle warm accent for depth */
.bg-blob-accent {
    position: fixed;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #2dd4bf 0%, #06b6d4 40%, transparent 70%);
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.2;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
    animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 30px) scale(1.02); }
}

/* All content sits above the blobs (but not the blob itself!) */
.bg-gradient-default > *:not(.bg-blob-accent) {
    position: relative;
    z-index: 1;
}

/* ── Glass Effect Base ─────────────────────────────────────── */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── Glass Navbar — floating, frosted ──────────────────────── */
.glass-nav {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 50;
    padding: 12px 20px;
    background: rgba(15, 25, 35, 0.7);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border: 1px solid rgba(45, 212, 191, 0.15);
    border-radius: 16px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: background 0.3s ease;
}

.glass-nav:hover {
    background: rgba(15, 25, 35, 0.85);
    border-color: rgba(45, 212, 191, 0.25);
}

/* ── Glass Cards ───────────────────────────────────────────── */
.glass-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.glass-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(45, 212, 191, 0.2);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.25),
        0 0 20px rgba(45, 212, 191, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ── Leaderboard Rows ──────────────────────────────────────── */
.glass-row {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 8px;
    transition: background 0.15s ease;
}

.glass-row:hover {
    background: rgba(255, 255, 255, 0.1);
}

.glass-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.06);
}

/* ── Podium Rows (Top 3) — more vibrant so they pop ────────── */
.glass-gold {
    background: rgba(255, 215, 0, 0.15) !important;
    border-color: rgba(255, 215, 0, 0.3) !important;
    box-shadow: 0 4px 24px rgba(255, 215, 0, 0.15);
}

.glass-silver {
    background: rgba(192, 192, 192, 0.12) !important;
    border-color: rgba(192, 192, 192, 0.25) !important;
    box-shadow: 0 4px 20px rgba(192, 192, 192, 0.1);
}

.glass-bronze {
    background: rgba(205, 127, 50, 0.12) !important;
    border-color: rgba(205, 127, 50, 0.25) !important;
    box-shadow: 0 4px 20px rgba(205, 127, 50, 0.1);
}

/* ── Glass Button ──────────────────────────────────────────── */
.glass-btn {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 24px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Apple 44pt minimum touch target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.glass-btn:active {
    transform: translateY(0);
}

.glass-btn-primary {
    background: rgba(45, 212, 191, 0.85); /* KRC teal */
    border-color: rgba(45, 212, 191, 0.5);
    box-shadow: 0 4px 16px rgba(45, 212, 191, 0.25);
    color: #0f1923;
    font-weight: 700;
}

.glass-btn-primary:hover {
    background: rgba(45, 212, 191, 1);
    box-shadow: 0 6px 24px rgba(45, 212, 191, 0.4);
    color: #0f1923;
}

/* Strava connect button — keeps Strava brand orange for recognition */
.glass-btn-strava {
    background: rgba(252, 76, 2, 0.9);
    border-color: rgba(252, 76, 2, 0.5);
    box-shadow: 0 4px 16px rgba(252, 76, 2, 0.25);
    color: white;
}

.glass-btn-strava:hover {
    background: rgba(252, 76, 2, 1);
    box-shadow: 0 6px 24px rgba(252, 76, 2, 0.4);
    color: white;
}

/* ── Typography — always light on dark ─────────────────────── */
.text-glass {
    color: rgba(255, 255, 255, 0.95) !important;
}

.text-glass-muted {
    color: rgba(255, 255, 255, 0.65) !important;
}

.text-glass-subtle {
    color: rgba(255, 255, 255, 0.4) !important;
}

/* ── Rank Badge ────────────────────────────────────────────── */
.rank-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
    box-shadow: 0 2px 12px rgba(255, 215, 0, 0.4);
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a2e;
    box-shadow: 0 2px 12px rgba(192, 192, 192, 0.3);
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #1a1a2e;
    box-shadow: 0 2px 12px rgba(205, 127, 50, 0.3);
}

.rank-default {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
}

/* ── Avatar ────────────────────────────────────────────────── */
.avatar-glass {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    object-fit: cover;
    flex-shrink: 0;
}

/* ── Streak Badge ──────────────────────────────────────────── */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.streak-active {
    background: rgba(45, 212, 191, 0.15);
    color: #2dd4bf;
    border: 1px solid rgba(45, 212, 191, 0.3);
}

.streak-inactive {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Position Arrow ────────────────────────────────────────── */
.arrow-up { color: #30d158; font-weight: 700; }
.arrow-down { color: #ff453a; font-weight: 700; }
.arrow-same { color: rgba(255, 255, 255, 0.3); }

/* ── Safe Area Insets (iOS) ────────────────────────────────── */
.safe-area-top { padding-top: env(safe-area-inset-top, 0); }
.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

/* ── Native App Helpers ────────────────────────────────────── */
.hide-on-native { display: block; }
.show-on-native { display: none; }

body.is-native .hide-on-native { display: none !important; }
body.is-native .show-on-native { display: block !important; }

/* ── Loading Skeleton ──────────────────────────────────────── */
.glass-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

/* ── HTMX Loading Indicator ───────────────────────────────── */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}

/* ── Responsive: stack on mobile ───────────────────────────── */
@media (max-width: 640px) {
    .glass-nav {
        top: 8px;
        left: 8px;
        right: 8px;
        padding: 10px 16px;
    }

    .glass-row {
        padding: 12px 14px;
    }

    .glass-card {
        border-radius: 16px;
    }

    .rank-badge {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .avatar-glass {
        width: 36px;
        height: 36px;
    }

    .bg-gradient-default::before {
        width: 300px;
        height: 300px;
    }
    .bg-gradient-default::after {
        width: 350px;
        height: 350px;
    }
}

/* ── Strava Attribution ────────────────────────────────────── */
.powered-by-strava {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.powered-by-strava:hover {
    opacity: 1;
}

/* ── Link Styles ───────────────────────────────────────────── */
a.no-underline {
    text-decoration: none !important;
}
