/* ============================================================
   KrapMaps — fixes layer
   Loaded AFTER css/styles.css so nothing in the original file
   needs editing. Safe to merge into styles.css later.
   ============================================================ */

/* ---- 1. Leaderboard: toggle down a touch, table up a touch ----
   Tweak these two numbers to taste. */
.lb-toggle {
  margin-top: 36px;
  margin-bottom: 18px;
}
.lb-table-wrap {
  margin-top: 0;
}
.lb-table-wrap .lb-table {
  margin-top: 0;
}

/* ---- 2. App screenshot frames: equal height so the
         Rewards / Quests / Games labels line up ---- */
.phone-frame {
  display: flex;
  flex-direction: column;
}
.phone-frame img {
  width: 100%;
  height: 440px;
  object-fit: contain;
  object-position: top center;
  border-radius: 14px;
}
.phone-frame-label {
  margin-top: auto;
  padding-top: 14px;
}
@media (max-width: 900px) {
  .phone-frame img { height: 360px; }
}

/* ---- 3. Team War: split red / blue with team crests ---- */
.team-war-vs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0;
  overflow: hidden;
  border-radius: 18px;
  isolation: isolate;
  padding: 34px 20px;
}
.team-war-vs::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    103deg,
    #D21F3C 0 49.5%,
    rgba(255, 255, 255, .92) 49.5% 50.5%,
    #1565D8 50.5% 100%
  );
}

.team-war-vs .team-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 0 14px;
  color: #fff;
}
.team-war-vs .team-name-label,
.team-war-vs .team-points,
.team-war-vs .team-stats {
  color: #fff;
}
.team-war-vs .team-name-label {
  font-size: 1.35rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.team-war-vs .team-points {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
}
.team-war-vs .team-stats {
  font-size: .9rem;
  opacity: .92;
}

.team-crest {
  width: 54px;
  height: 62px;
  display: block;
  color: #fff;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25));
}

.team-war-vs .vs-divider {
  position: relative;
  z-index: 1;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #1b1b1b;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .06em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}

@media (max-width: 640px) {
  .team-war-vs {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 28px 16px;
  }
  .team-war-vs::before {
    background: linear-gradient(
      178deg,
      #D21F3C 0 49.5%,
      rgba(255, 255, 255, .92) 49.5% 50.5%,
      #1565D8 50.5% 100%
    );
  }
  .team-war-vs .vs-divider { justify-self: center; }
}

/* ---- 4. Small print: sample data + affiliate disclosure ---- */
.sample-note {
  margin: 14px 0 28px;
  text-align: center;
  font-size: .82rem;
  opacity: .55;
}
.affiliate-disclosure {
  max-width: 620px;
  margin: 0 auto 32px;
  text-align: center;
  font-size: .88rem;
  opacity: .7;
}

/* ---- 5. Failsafe: if the scroll-reveal script never fires,
         show the content anyway instead of a blank page ---- */
html.reveal-failsafe .reveal {
  opacity: 1 !important;
  transform: none !important;
}

/* ---- 6. Focus states for keyboard users ---- */
a:focus-visible,
button:focus-visible {
  outline: 3px solid #1565D8;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   7. MOBILE OPTIMISATION
   Loaded after styles.css so these win on small screens.
   Additive + defensive — targets the real markup classes.
   ============================================================ */

/* ---- 7a. Kill horizontal scroll + the "zoomed" look ---- */
*, *::before, *::after { box-sizing: border-box; }
html {
  max-width: 100%;
  overflow-x: hidden;
  /* THE fix for "everything looks zoomed in" on iPhone:
     stop Safari auto-inflating text on a desktop-first layout. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { max-width: 100%; overflow-x: hidden; }
img, svg, video, iframe { max-width: 100%; height: auto; }

/* long usernames / emails / URLs must never blow out the layout */
.lb-username, .partner-email, .contact-email,
.activity-text, .activity-location, .footer-col a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---- 7b. Tablet & down: two-column hero stacks ---- */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr !important; }
  .hero-visual { margin-top: 26px; max-width: 100%; }
}

/* ---- 7c. Phones ---- */
@media (max-width: 768px) {
  .container { padding-left: 18px; padding-right: 18px; }
  .section { padding-top: 36px; padding-bottom: 36px; }

  /* every grid section collapses to one column, with tighter gaps */
  .bento-grid,
  .values-grid,
  .team-grid,
  .footer-grid { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* 12-col spans go full width */
  .span-4, .span-5, .span-6,
  .span-7, .span-8 { grid-column: 1 / -1 !important; }

  /* flex rows wrap + centre instead of overflowing
     (goal-numbers + partners-row handled separately in 7e) */
  .stats-bar,
  .stat-row,
  .goal-rewards,
  .featured-logos,
  .footer-socials,
  .btn-group { flex-wrap: wrap; justify-content: center; }

  /* leaderboard: fit all four columns on screen, tier badge never clipped */
  .lb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lb-table { width: 100%; min-width: 0; font-size: .88rem; }
  .lb-table th, .lb-table td { padding: 8px 6px; vertical-align: middle; }
  .lb-rank { width: 30px; text-align: center; }
  .lb-username { overflow-wrap: anywhere; word-break: break-word; }
  .lb-points { white-space: nowrap; text-align: right; }
  .tier-badge {
    display: inline-block;
    white-space: nowrap;
    font-size: .68rem;
    padding: 3px 7px;
    line-height: 1.3;
  }

  /* display numbers: capped so they never look blown-up */
  .stats-bar-number,
  .stat-number,
  .traction-number { font-size: clamp(1.6rem, 7vw, 2.2rem); }

  /* headings: gentle sizes, no oversized "zoomed" feel */
  h1 { font-size: clamp(1.85rem, 7vw, 2.5rem); line-height: 1.12; }
  h2 { font-size: clamp(1.35rem, 5vw, 1.9rem); line-height: 1.18; }
  .hero-sub { font-size: clamp(1rem, 4vw, 1.15rem); }

  /* comfy tap targets (Apple/Google both want 44px min) */
  .nav-links a, .footer-col a,
  .btn, .lb-toggle-btn, .social-link { min-height: 44px; }
  .btn { display: inline-flex; align-items: center; justify-content: center; }
}

/* ---- 7d. Small phones: full-width, stacked CTAs ---- */
@media (max-width: 480px) {
  .btn-group { flex-direction: column; align-items: stretch; }
  .btn-group .btn { width: 100%; }
  .hero .btn, .cta-section .btn, .partner-cta .btn { width: 100%; }
  .section { padding-top: 30px; padding-bottom: 30px; }
}

/* ---- 7e. Section-specific mobile polish ---- */
@media (max-width: 768px) {

  /* --- App demos: a swipeable row of properly-sized phones ---
     3 full-size phones can't fit across a phone screen, so they
     become a swipe row — each big and clear, 1½ visible at a time,
     equal height so the labels line up. Only this grid changes. */
  .bento-grid:has(.phone-frame) {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 14px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 18px;
    padding: 4px 2px 14px;
    margin: 0 -2px;
  }
  .phone-frame.span-4 {
    grid-column: auto !important;
    flex: 0 0 66%;
    max-width: 290px;
    scroll-snap-align: center;
  }
  .phone-frame img {
    width: 100%;
    height: 60vh !important;
    max-height: 480px;
    object-fit: contain;
    object-position: top center;
    border-radius: 16px;
  }
  .phone-frame-label {
    font-size: 1rem;
    font-weight: 700;
    padding-top: 10px;
    text-align: center;
  }

  /* --- Partner logos: clean 2 × 2 grid, even spacing --- */
  .partners-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px 16px !important;
    align-items: center;
    justify-items: center;
    max-width: 420px;
    margin: 0 auto;
  }
  .partner-badge {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .partner-logo {
    width: auto;
    height: auto;
    max-width: 120px;
    max-height: 46px;
    object-fit: contain;
  }

  /* --- Goal bar: numbers sit apart, not mushed together --- */
  .goal-numbers {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-top: 10px;
  }
  .goal-section h2 { margin-bottom: 10px; }
  .goal-subtitle { margin-bottom: 18px; }
  .goal-text { margin-top: 14px; }

  /* --- Hero map: let the phone frame control the image again
     (no size override here — styles.css fits it to the frame) --- */
  .hero-visual { margin-top: 20px; }
}

@media (max-width: 400px) {
  .phone-frame.span-4 { flex: 0 0 72%; }
}
