/* =================================================
   Mathracers – Main Stylesheet (Site Foundation)
   ================================================= */

/* ================================
   1. CSS VARIABLES
   ================================ */
:root {
  --bg-main: #f8fafc;
  --bg-panel: #f4f6fa;
  --bg-panel-alt: #eef1f7;

  --text-main: #1f2937;
  --text-muted: #6b7280;

  --border-light: #e5e7eb;

  --red:    #ef4444;
  --orange: #f97316;
  --yellow: #eab308;
  --green:  #22c55e;
  --blue:   #3b82f6;
  --purple: #8b5cf6;

  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1100px;
}

/* ================================
   2. RESET / BASE
   ================================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

img { max-width: 100%; display: block; }

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

/* ================================
   3. LAYOUT
   ================================ */
.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

section { margin: 64px 0; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 800; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }

p {
  margin: 0 0 16px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ================================
   4. HEADER
   ================================ */
.site-header {
  position: relative;   /* ← REQUIRED for z-index to work */
  background: white;
  border-bottom: 1px solid var(--border-light);
  z-index: 1001;        /* higher than overlay (998) */
}

.site-header .site-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
}

.logo img { height: 56px; width: auto; }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.coins {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: #1e3a8a;  /* deep blue */
  font-weight: 900;
}

.coin-icon {
  width: 18px;
  height: 18px;
/* filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); */
}

/* ================================
   5. BUTTONS
   ================================ */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn.primary { background: var(--blue); color: white; }
.btn.secondary { background: white; color: var(--blue); border: 2px solid var(--blue); }

/* ================================
   6. HERO
   ================================ */
.hero {
  margin-top: 24px;  /* tighter under header */
}
.hero { padding: 24px 0 80px; }
.hero h1 { max-width: 600px; }
.hero p { max-width: 520px; font-size: 1.1rem; }

.hero-actions {
  margin-top: 24px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* ================================
   7. FEATURED / CARDS / GRID
   ================================ */
.featured-card {
  display: flex;
  gap: 24px;
  background: var(--bg-panel);
  padding: 24px;
  border-radius: var(--radius);
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}

.card {
  background: var(--bg-panel);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
}

/* ================================
   8. FOOTER
   ================================ */
.site-footer {
  margin-top: 80px;
  padding: 32px 0;
  border-top: 1px solid var(--border-light);
  background: white;
  text-align: center;
  font-size: 0.9rem;
}

/* ================================
   9. RESPONSIVE
   ================================ */
@media (max-width: 900px) {
  section { margin: 48px 0; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  .featured-card { flex-direction: column; text-align: center; }
}

@media (max-width: 600px) {
  .logo img { height: 40px; }
  .site-header .site-wrapper { flex-direction: column; gap: 12px; }
  .hero { padding: 48px 0; }
  .hero-actions { flex-direction: column; }
  .btn { width: 100%; text-align: center; }
}

@media (max-width: 600px) {
  .avatar {
    width: 32px;
    height: 32px;
  }
}

/* Composite racer (character + vehicle stacked) */
.composite-racer {
  position: relative;
  width: 96px;     /* tweak to match your lane art */
  height: 64px;
}

.composite-racer img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
  image-rendering: auto; /* keep smooth */
}

.composite-racer .racer-character {
  z-index: 1;
	width: 39px;
  height: 39px;
}

.composite-racer .racer-vehicle {
  z-index: 2; /* vehicle on top of character */
  width: 39px;     /* max width */
  height: 39px;    /* max height */
}

/*.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-light);
}
*/
/* Header avatar container */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The injected composite racer should fill the avatar box */
.header-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Force composite racer to scale to container */
.header-avatar .composite-racer {
  width: 100%;
  height: 100%;
}

/* Make images fit inside without overflowing */
.header-avatar .composite-racer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Index mode button colors */
.mode-add { background: #22c55e; color: #fff; }
.mode-sub { background: #f97316; color: #fff; }
.mode-mul { background: #3b82f6; color: #fff; } /* your primary */
.mode-div { background: #8b5cf6; color: #fff; }

.mode-buttons .btn { border: none; }



/* ================================
   MODE BUTTON GRID (MOBILE)
   ================================ */
@media (max-width: 600px) {
  .mode-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .mode-buttons .btn {
    width: 100%;
    padding: 20px 0;
    font-size: 1.4rem;
    border-radius: 16px;
  }
}

/* ================================
   MOBILE HEADER COMPACT
   ================================ */
@media (max-width: 600px) {
  .site-header .site-wrapper {
    padding: 6px 0;          /* less vertical space */
  }

  .logo img {
    height: 36px;           /* smaller logo */
  }

  .coins {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }
}

/* ================================
   DESKTOP SPLIT LAYOUT
   ================================ */
@media (min-width: 900px) {
  .home-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 32px;
    align-items: start;
  }
}

@media (max-width: 600px) {
  .hero {
    padding: 20px 0 32px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero p {
    font-size: 1rem;
  }
}

/* ================================
   MODE BUTTON GRID (ALL DEVICES)
   ================================ */
.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 520px;
}

.mode-buttons .btn {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  border-radius: 16px;
}

@media (min-width: 900px) {
  .mode-buttons {
    max-width: 640px;
    gap: 20px;
  }

  .mode-buttons .btn {
    height: 110px;
    font-size: 1.6rem;
  }
}

