/* ============================================================
   Design system
   ============================================================ */
:root {
  --bg:          #eeecea;
  --surface:     #ffffff;
  --surface-2:   #f6f5f3;
  --text:        #0d0d0d;
  --text-2:      #555555;
  --text-3:      #999999;
  --accent:      #e5391f;
  --accent-dark: #c22d15;
  --blue:        #1a4fd6;
  --border:      rgba(0,0,0,0.08);
  --border-md:   rgba(0,0,0,0.14);
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.06);
  --shadow:      0 2px 14px rgba(0,0,0,0.07);
  --shadow-lg:   0 10px 40px rgba(0,0,0,0.11);
  --r:           8px;
  --r-lg:        14px;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  font-size: 15px;
}

h1, h2, h3 {
  font-family: 'Bricolage Grotesque', 'DM Sans', sans-serif;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

/* ============================================================
   Language toggle
   ============================================================ */
.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-md);
  border-radius: 999px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px 4px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.lang-btn.active { color: var(--accent); }
.lang-sep { color: var(--border-md); font-weight: 300; font-size: 0.9rem; }

/* ============================================================
   Hero — full-width, dark, photo-ready
   ============================================================ */
.hero {
  position: relative;
  width: 100%;
  min-height: 440px;
  display: flex;
  align-items: flex-end;

  /* Default: dark gradient. Add your photo by placing hero.jpg in client/assets/
     and setting background-image: url('assets/hero.jpg') here or via inline style */
  background-color: #020b1a;
  background-size: cover;
  background-position: center 40%;
  overflow: hidden;
}

/* Parallax scene */
.hero-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hero-scene-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.38; }
  50%       { opacity: 1;    }
}

.hero-scene-svg .star {
  animation: twinkle var(--tw, 3s) ease-in-out infinite;
  animation-delay: var(--td, 0s);
}

/* Dark overlay — fade from bottom to transparent at top */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(6, 10, 20, 0.92) 0%,
    rgba(6, 10, 20, 0.55) 45%,
    rgba(6, 10, 20, 0.12) 100%
  );
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

.hero-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(2.8rem, 7.5vw, 5.2rem);
  color: #ffffff;
  margin-bottom: 18px;
  max-width: 700px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.62);
  max-width: 480px;
  line-height: 1.6;
}

.hero-sub strong { color: rgba(255,255,255,0.90); font-weight: 600; }

/* ============================================================
   Container
   ============================================================ */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}

/* ============================================================
   Section headings
   ============================================================ */
.section-title {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 16px;
}

/* ============================================================
   Cards
   ============================================================ */
.stats-card,
.calculator-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

/* ============================================================
   Stats
   ============================================================ */
.stats-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  justify-content: center;
  padding: 20px 0;
  font-size: 0.875rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.stat-item {
  padding: 18px 12px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }

.stat-value {
  display: block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Progress bar */
.progress-wrapper { margin-bottom: 16px; }

.progress-track {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 6px;
  overflow: visible;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.progress-cyclist {
  position: absolute;
  top: 50%;
  font-size: 1.1rem;
  transform: translate(-50%, -50%);
  transition: left 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
  z-index: 2;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.progress-tagline {
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 500;
  padding: 12px 16px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r) var(--r) 0;
  margin-top: 14px;
  font-style: italic;
}

.last-updated {
  font-size: 0.68rem;
  color: var(--text-3);
  text-align: right;
  margin-top: 8px;
}

/* ============================================================
   Route / Mountain section
   ============================================================ */
.route-section { margin-bottom: 24px; }

.route-container {
  background: var(--text);
  border-radius: var(--r-lg);
  padding: 4px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.route-loading {
  display: flex;
  justify-content: center;
  padding: 40px;
  background: #111;
  border-radius: calc(var(--r-lg) - 4px);
}

.mountain-wrapper { width: 100%; }

.mountain-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--r-lg) - 4px);
}

.mountain-segment {
  cursor: pointer;
  transition: opacity 0.12s;
}

.mountain-segment:hover,
.mountain-segment:focus {
  opacity: 0.75;
  outline: none;
}

/* Difficulty legend */
.difficulty-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 6px 2px;
}

.diff-badge {
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
}

.diff-danger { background: rgba(229,57,31,0.12); color: #c0392b; }
.diff-snow   { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.55); }
.diff-flat   { background: rgba(78,138,48,0.20); color: #3a7a1c; }

/* Landmarks strip */
.route-landmarks {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.landmark-badge {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

/* Tooltip */
.segment-tooltip {
  position: fixed;
  background: #0d0d0d;
  color: #fff;
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 0.82rem;
  pointer-events: none;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  max-width: 220px;
  line-height: 1.5;
  transform: translateY(-110%);
  border: 1px solid rgba(255,255,255,0.08);
}

.segment-tooltip strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
  font-weight: 700;
}

.segment-tooltip span {
  display: block;
  color: rgba(255,255,255,0.45);
  font-size: 0.75rem;
}

.segment-tooltip span:first-of-type {
  color: #5eead4;
  font-weight: 600;
  font-size: 0.82rem;
}

/* ============================================================
   Badges
   ============================================================ */
.badges-section { margin-bottom: 24px; }

.badges-catalog-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  margin: 28px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

/* Earned badge cards */
.badges-earned {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 24px;
  margin-bottom: 4px;
}

.badge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--bc);
  border-radius: var(--r-lg);
  padding: 22px 16px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.16s, box-shadow 0.16s;
}

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

/* Rarity banner — sits above the top border */
.badge-rarity-tag {
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  padding: 2px 0;
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.badge-rarity-rare      { background: #b7950b; color: white; }
.badge-rarity-legendary {
  background: linear-gradient(90deg, #b7950b, #e5391f, #b7950b);
  background-size: 200% auto;
  color: white;
  animation: shimmer 2.8s linear infinite;
}

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

.badge-emoji-main {
  font-size: 2.8rem;
  line-height: 1;
  margin: 4px 0 8px;
}

.badge-tier-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--bc);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.badge-divider {
  height: 1px;
  background: var(--border);
  margin: 0 8px 10px;
}

.badge-donor-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  word-break: break-word;
}

.badge-amount {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--bc);
  margin-bottom: 4px;
}

.badge-kmrange {
  font-size: 0.68rem;
  color: var(--text-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.badge-landmark-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-top: 6px;
}

.badge-landmark-chip {
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  color: var(--text-2);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

/* Badge catalog */
.badges-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.catalog-card {
  border-radius: var(--r);
  padding: 14px 10px 12px;
  text-align: center;
  transition: transform 0.14s;
}

.catalog-claimed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--bc);
  box-shadow: var(--shadow-sm);
}

.catalog-claimed:hover { transform: translateY(-2px); }

.catalog-locked {
  background: var(--surface-2);
  border: 1px dashed var(--border-md);
  opacity: 0.65;
}

.catalog-landmark.catalog-locked {
  border-style: solid;
  border-color: var(--border-md);
  opacity: 0.70;
}

.catalog-emoji {
  font-size: 1.7rem;
  line-height: 1;
  margin-bottom: 6px;
}

.catalog-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.catalog-claimed .catalog-name { color: var(--bc); }

.catalog-req { font-size: 0.62rem; font-weight: 600; margin-bottom: 2px; }
.req-earned  { color: #16a34a; }
.req-lock    { color: var(--text-3); }

.catalog-rarity-tag {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-top: 2px;
}

/* Badge preview in calculator */
#calc-badge-preview { margin: 4px 0 8px; }

.calc-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  background: white;
  letter-spacing: 0.01em;
}

.calc-badge-chip em {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.7;
}

/* ============================================================
   Calculator
   ============================================================ */
.calculator-card h2 { margin-bottom: 4px; }

.calc-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calc-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.dollar-sign {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-2);
}

.calc-input {
  font-family: 'Bricolage Grotesque', 'DM Sans', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  padding: 8px 16px;
  width: 170px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
  background: var(--surface);
  letter-spacing: -0.02em;
}

.calc-input::-webkit-outer-spin-button,
.calc-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.calc-input:focus { border-color: var(--accent); }

.calc-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border-md);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 6px rgba(0,0,0,0.25);
  transition: transform 0.1s;
}

.calc-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.calc-result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  text-align: center;
}

.calc-km {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.calc-message {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.calc-landmark {
  font-size: 0.82rem;
  color: var(--text-2);
}

.donate-btn {
  display: block;
  text-align: center;
  background: var(--accent);
  color: white;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  padding: 16px 32px;
  border-radius: var(--r);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.15s, transform 0.12s;
}

.donate-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

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

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center;
  color: var(--text-3);
  font-size: 0.82rem;
  padding-top: 12px;
}

.footer strong { color: var(--text-2); font-weight: 600; }
.footer-small { font-size: 0.68rem; margin-top: 4px; }

/* ============================================================
   Utilities
   ============================================================ */
.hidden { display: none !important; }

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-md);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Confetti
   ============================================================ */
#confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  .hero { min-height: 320px; }
  .hero-inner { padding: 0 20px 36px; }

  .stats-row { grid-template-columns: repeat(3,1fr); }
  .stat-value { font-size: 1.4rem; }

  .stats-card, .calculator-card { padding: 20px 16px; }

  .calc-input { font-size: 2.2rem; width: 140px; }
  .calc-km    { font-size: 1.8rem; }
  .donate-btn { font-size: 0.9rem; padding: 14px 24px; }

  .badges-earned  { grid-template-columns: repeat(auto-fill, minmax(145px,1fr)); }
  .badges-catalog { grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); }

  .landmark-badge { font-size: 0.68rem; }
}
