* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-color: #1e40af;
    --bg-dark: #0f172a;
    --bg-darker: #272B34;
    --bg-card: #1C2433;
    --bg-navbar: #272B34;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: #1A1D25;
  min-height: 100vh;
  overflow-x: hidden;
  scroll-padding-top: 64px;
}

html, body {
  display: flex;
  flex-direction: column;
}

.navbar {
  background: var(--bg-navbar);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  position: fixed;
  inset: 0 0 auto 0; /* top:0; left/right:0; */
  z-index: 1000;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between; /* pushes contact to the right */
  gap: 1rem;
}

.nav-left {
    flex: 1;
    display: flex;
    justify-content: flex-start;
}

.nav-center {
    flex: 2;
    display: flex;
    justify-content: center;
}

.nav-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: inline-block; /* Ensures proper spacing */
}

.nav-menu {
    display: flex;
    list-style: none; /* This removes bullet points */
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-menu li {
    display: inline-block; /* Makes list items behave like inline elements */
}

.logo-link {
  display: inline-block;
  transition: transform 0.3s ease;
}

.logo {
  height: 25px;
  width: auto;
  transition: all 0.3s ease;
}

.logo-link:hover .logo {
  transform: scale(1.05);
  filter: brightness(1.2); /* Makes it slightly brighter */
}
.contact-info {
  display: flex;
  align-items: center;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  position: relative;
  isolation: isolate;              /* contain the effect */
  transition: color 0.2s ease;     /* keep text color transition */
}

.contact-link::before {
  content: "";
  position: absolute;
  inset: 0;                        /* cover the link box */
  border-radius: inherit;
  background: var(--primary-color);
  opacity: 0;
  transform: scale(0.98);          /* subtle scale to avoid overflow */
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: -1;                     /* sit behind text */
}

.contact-link:hover {
  color: white;                    /* or var(--primary-contrast) */
}


.contact-link:hover::before {
  opacity: 0.12;                   /* soft highlight, tweak as needed */
  transform: scale(1);
}

/* Remove the underline animation that caused the dropdown-like effect */
.contact-link::after { content: none; }
/* Remove unused .nav-links unless you later add internal links */
.nav-links { display: none; }

/* Account for fixed navbar height in page layout (example) */
body { scroll-padding-top: 64px; }

.hero {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.9) 0%, rgba(59, 130, 246, 0.8) 100%),
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><polygon fill="%231e40af" points="0,1000 1000,0 1000,1000"/></svg>');
    background-size: cover;
    background-position: center;
    color: var(--text-primary);
    padding: 150px 2rem 100px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.3), transparent 50%);
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-content p {
    font-size: 1.3rem;
    margin-bottom: 2.5rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.cta-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.cta-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.cta-button:hover::before {
    left: 100%;
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.content-section {
    padding: 100px 2rem;
    background: var(--bg-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.content-section h2 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--text-primary);
    position: relative;
}

.content-section h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-card {
    background: var(--bg-card);
    padding: 2.5rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.stats-section {
    padding: 100px 2rem;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.stat-item {
    text-align: center;
    padding: 2.5rem 2rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-number {
    display: block;
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

.stat-box {
position: relative;
background-color: #f0f0f0;
padding: 15px;
border-radius: 10px;
text-align: center;
transition: background-color 0.3s;
cursor: pointer;
}

.stat-box:hover {
background-color: #522081;
}

/* Popup tooltip */
.popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #141414;
    padding: 10px;
    border-radius: 8px;
    width: 220px;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.stat-box:hover .popup {
display: block;
}


/* Footer */
footer {
    width: 100%;
    background: var(--bg-darker);
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: 2rem 1rem;
    margin-top: auto; /* ensures it sticks to bottom when content is short */
    box-sizing: border-box;
}

footer p {
    opacity: 0.8;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Selection Color */
::selection {
    background: var(--primary-color);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-links {
        display: flex;
        gap: 1rem;
    }
    
    .nav-links a {
        margin: 0;
    }
    
    .hero-content h1 {
        font-size: 2.5rem;
    }
    
    .hero-content p {
        font-size: 1.1rem;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .content-section, .stats-section {
        padding: 80px 1rem;
    }
    
    .content-section h2 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero {
        padding: 120px 1rem 80px;
    }
    
    .feature-card {
        padding: 2rem 1.5rem;
    }
    
    .stat-item {
        padding: 2rem 1rem;
    }
}

/* Loading Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feature-card, .stat-item {
    animation: fadeInUp 0.6s ease-out;
}

.feature-card:nth-child(2) {
    animation-delay: 0.1s;
}

.feature-card:nth-child(3) {
    animation-delay: 0.2s;
}

/* Focus states for accessibility */
.cta-button:focus,
.nav-links a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}


/* Chart wrapper with dark rounded background */
.chart-container {
    background: var(--bg-card); /* Dark card background */
    border: 1px solid var(--border-color);
    border-radius: 16px; /* Nice rounded corners */
    padding: 1.5rem;
    box-shadow: var(--shadow);
    min-height: 350px;
    height: 40vh;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Hover effect for charts */
.chart-container:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(59, 130, 246, 0.5);
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}
/* Update chart grid to add spacing */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: auto auto;
    grid-gap: 1.5rem;
    max-width: 1200px;
    margin: 2rem 0;
    padding: 0;
    box-sizing: border-box;
}


/* Individual chart positioning remains the same */
.chart-container:nth-child(1) { grid-column: 1 / 5; grid-row: 1; }
.chart-container:nth-child(2) { grid-column: 5 / 6; grid-row: 1; }
.chart-container:nth-child(3) { grid-column: 6 / 7; grid-row: 1; }
.chart-container:nth-child(4) { grid-column: 1 / 4; grid-row: 2; }
.chart-container:nth-child(5) { grid-column: 4 / 7; grid-row: 2; }


/* Responsive Design */
@media (max-width: 1024px) {
    .chart-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    grid-column: auto; 
    grid-row: auto;
    }
    
    #chart_years {
        grid-column: 1 / 3;
        grid-row: 1;
        height: 400px;
    }
    
    #chart_mode {
        grid-column: 1 / 2;
        grid-row: 2;
    }
    
    #chart_enviro {
        grid-column: 2 / 3;
        grid-row: 2;
    }
    
   #chart_rank {
        grid-column: 1 / 2;
        grid-row: 2;
        width: 100%;
   }
  
   #chart_record {
        grid-column: 2 / 3;
        grid-row: 2;
        width: 100%;
   }
}

@media (max-width: 768px) {
    .chart-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, auto);
        grid-gap: 0.75rem;
        padding: 0 0.5rem;
        grid-column: auto; 
        grid-row: auto;
    }
    
    #chart_years,
    #chart_mode,
    #chart_enviro,
    #chart_rank,
    #chart_record {
        grid-column: 1 / 2;
        height: 400px; /* Even smaller on mobile */
    }
    
    #chart_years { grid-row: 1; }
    #chart_mode { grid-row: 2; }
    #chart_enviro { grid-row: 3; }
    #chart_rank { grid-row: 4; }
    #chart_record { grid-row: 5; }
}

@media (max-width: 480px) {
    .chart {
        height: 250px;
    }
    
    .chart-grid {
        margin: 1rem auto;
        grid-gap: 0.5rem;
    }
}

/* Restore Latest Records Sidebar */
#latest-records-sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    width: 300px;
    max-width: 300px;
    height: calc(100vh - 70px);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 900;
    overflow-y: auto;
    padding: 0;
    flex-shrink: 0;
}

/* ONLY target images, not all elements */
#latest-records-sidebar img {
    width: 25px;
    height: 25px;
}

.sidebar-header {
    background: var(--bg-dark);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
    width: 100%; /* Full width of sidebar */
}

.sidebar-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.records-list {
    padding: 0.5rem;
    width: 100%; /* Full width of sidebar */
}


/* TMX Icon - Fix color and size */
.tmx-icon {
    width: 25px;
    height: 25px;
    object-fit: contain;
    filter: none; /* Don't filter colors */
}

/* TMX Button */
.tmx-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: #60a5fa;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.tmx-btn:hover {
    background: #a855f7;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.7);
    transform: translateY(-1px);
}

/* Record content */
.record-challenge {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.record-time {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

.record-date {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Ensure main content respects sidebar */
.search-container,
.dashboard {
    margin-left: 320px;
    transition: margin-left 0.3s ease;
}

.dashboard, .main-content {
  position: relative;
  z-index: 0;
}

/* Make sure canvas rules don't affect sidebar images */
.latest-records-sidebar img,
.latest-records-sidebar canvas {
    width: auto !important;
    height: auto !important;
}

/* Responsive design */
@media (max-width: 1200px) {
    #latest-records-sidebar {
        width: 280px;
    }
    
    .search-container,
    #dashboard {
        margin-left: 300px;
    }
}

@media (max-width: 768px) {
    #latest-records-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        top: 0;
        margin-bottom: 1rem;
    }
    
    .search-container,
    #dashboard {
        margin-left: 0;
    }
    
    .records-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .record-item {
        margin-bottom: 0;
    }
}

/* Rank-based styling for records */
.record-item.rank-1 {
    background: linear-gradient(135deg, var(--bg-dark) 0%, rgba(245, 158, 11, 0.15) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
    position: relative;
}

.record-item.rank-2 {
    background: linear-gradient(135deg, var(--bg-dark) 0%, rgba(156, 163, 175, 0.15) 100%);
    border: 1px solid rgba(156, 163, 175, 0.3);
    box-shadow: 0 2px 8px rgba(156, 163, 175, 0.1);
    position: relative;
}

.record-item.rank-3 {
    background: linear-gradient(135deg, var(--bg-dark) 0%, rgba(180, 83, 9, 0.15) 100%);
    border: 1px solid rgba(180, 83, 9, 0.3);
    box-shadow: 0 2px 8px rgba(180, 83, 9, 0.1);
    position: relative;
}

/* Rank badges - positioned in top right corner */
.rank-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; /* Bigger */
    height: 32px; /* Bigger */
    border-radius: 50%;
    font-size: 0.8rem; /* Bigger font */
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #1c1917;
    border: 2px solid #fbbf24;
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    color: white;
    border: 2px solid #d1d5db;
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #b45309, #92400e);
    color: white;
    border: 2px solid #f97316;
}

.rank-badge.rank-other {
    background: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem; /* Slightly bigger for other ranks */
    border: 1px solid var(--text-muted);
}

.rank-text {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1em;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 4px;
}

/* Updated record item layout */
.record-item {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    position: relative; /* Needed for absolute positioning of rank badge */
    padding-right: 3rem; /* Make space for the rank badge */
}

.record-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.record-challenge {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    padding-right: 0.5rem; /* Space between text and rank badge */
}

.record-time {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    margin-bottom: 0.25rem;
}

.record-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

#cal-heatmap {
    width: 80; /* Fixed width */
    margin: 0 auto; /* Center it */
}

#cal-heatmap {
    display: inline-block !important; /* Prevents full width */
    width: auto !important;
    margin: 0 auto;
}

/* Optional: Add horizontal scroll for very wide heatmaps */
.heatmap-scroll-wrapper {
    max-width: 80%;
    overflow-x: auto;
    padding: 10px 0;
}

.left-chart-container {
    width: 40%;
    height: 500px;
    box-sizing: border-box;
}

.main-content {
  margin-left: 320px; /* space for the sidebar */
  padding: 1rem;
  transition: margin-left 0.3s ease;
  z-index: 1; /* ensure it's below navbar but above background */
}

@media (max-width: 768px) {
  #latest-records-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    top: 0;
  }

  .main-content {
    margin-left: 0; /* sidebar moves above content on mobile */
  }
}


.hidden { display: none; } 