/* ---------------------------------------------------------------
   Workouts · style.css
   Modern, dark-mode-default. Mobile-first.
   --------------------------------------------------------------- */

:root {
  --bg:           #0d1117;
  --bg-elevated: #161b22;
  --bg-card:     #1c2128;
  --border:      #30363d;
  --border-subtle: #21262d;
  --text:        #f0f6fc;
  --text-muted:  #8b949e;
  --accent:      #58a6ff;
  --accent-hover: #79b8ff;
  --green:       #3fb950;
  --orange:      #f0883e;
  --red:         #f85149;
  --purple:      #a371f7;
  --cyan:        #39c5cf;
  --yellow:      #e3b341;
  --pink:        #f778ba;

  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 24px rgba(0,0,0,0.4);
  --maxw:        1280px;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:           #ffffff;
    --bg-elevated: #f6f8fa;
    --bg-card:     #ffffff;
    --border:      #d0d7de;
    --border-subtle: #eaeef2;
    --text:        #1f2328;
    --text-muted:  #59636e;
    --accent:      #0969da;
    --accent-hover: #0550ae;
    color-scheme: light;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  position: relative;
}

/* ---------- Language Switcher ---------- */

.lang-switcher {
  position: absolute;
  top: 1.5rem;
  right: 1.25rem;
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
  z-index: 5;
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  transition: background 0.15s, color 0.15s;
}
.lang-btn:hover {
  color: var(--text);
}
.lang-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
}
.lang-btn .flag {
  font-size: 1rem;
  line-height: 1;
}

/* ---------- Hero ---------- */

.hero {
  padding: 2.5rem 0 3rem;
  text-align: center;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -2rem -50vw 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(88,166,255,0.15), transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 20%, rgba(63,185,80,0.08), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.hero-inner { max-width: 900px; margin: 0 auto; }

.kicker {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 50%, var(--green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

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

.stat {
  background: var(--bg-card);
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}
.stat:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.stat-value {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.fun-facts {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.fun-fact {
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.fun-fact strong { color: var(--text); font-weight: 600; }

/* ---------- Filters ---------- */

.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 2rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 0.75rem;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.filters select,
.filters input[type="search"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
}

.filters input[type="search"] {
  flex: 1;
  min-width: 160px;
}

.filters select:focus,
.filters input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.filter-count {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.filter-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
}
.filter-reset:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- Charts ---------- */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.chart-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.chart-card h2 {
  font-size: 0.9375rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-wrap {
  position: relative;
  height: 280px;
}

/* ---------- Activities ---------- */

.activities-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.activities h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.muted { color: var(--text-muted); font-size: 0.875rem; }
.small { font-size: 0.8125rem; }

.activity-list {
  display: grid;
  gap: 0.5rem;
}

.activity-item {
  display: grid;
  grid-template-columns: 100px 1fr auto auto auto;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.activity-item:hover {
  border-color: var(--border);
  background: var(--bg-elevated);
}

.activity-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.activity-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-type {
  background: var(--bg-elevated);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.activity-distance,
.activity-duration {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 60px;
  text-align: right;
}

.load-more {
  margin: 1.5rem auto 0;
  display: block;
  padding: 0.75rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.2s, background 0.2s;
}
.load-more:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

/* ---------- Footer ---------- */

footer {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.875rem;
}
footer p + p { margin-top: 0.5rem; }

/* ---------- Error banner ---------- */

#error-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  z-index: 100;
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  #app { padding: 1rem 0.875rem 2rem; }
  .lang-switcher { top: 0.75rem; right: 0.75rem; }
  .lang-btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
  .hero { padding: 3rem 0 2rem; }
  .activity-item {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "date    type"
      "name    name"
      "dist    dur";
    gap: 0.5rem 0.75rem;
  }
  .activity-date { grid-area: date; }
  .activity-type { grid-area: type; justify-self: end; }
  .activity-name { grid-area: name; }
  .activity-distance { grid-area: dist; text-align: left; min-width: 0; }
  .activity-duration { grid-area: dur; text-align: right; }
  .filters { padding: 0.75rem; }
  .chart-wrap { height: 240px; }
}
