/* Web-only desktop layout enhancements.
   Scoped to html.web-app so Capacitor/native UI remains unchanged. */

/* Countdown normalization for WEB only (fixes cases where dynamic Tailwind classes
   from JS templates aren't present in the prebuilt CSS on web).
   Native app remains unchanged because of html.web-app scope. */
html.web-app .rw-home-countdown [data-cd] {
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

html.web-app .rw-home-countdown [data-cd-label] {
  font-size: 0.55rem; /* ~9px */
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (max-width: 640px) {
  /* Schedule (mobile web): keep EN size, shrink PT/ES to match */
  html.web-app .rw-home-countdown [data-cd-grid] {
    gap: 8px;
  }

  html.web-app .rw-home-countdown [data-cd-grid] > div {
    padding: 8px;
  }

  html.web-app .rw-home-countdown [data-cd] {
    font-size: 1.1rem;
  }

  html.web-app .rw-home-countdown [data-cd-label] {
    font-size: 0.5rem; /* ~8px */
  }
}

/* Race Details (web): ensure labels are smaller than numbers on the session timeline. */
html.web-app .rd-session-countdown [data-cd] {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  line-height: 1;
}

html.web-app .rd-session-countdown [data-cd-label] {
  font-size: 0.6rem;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  html.web-app body {
    /* Give the desktop page some breathing room */
    background: #f1f5f9; /* slate-100 */
  }

  html.web-app.dark body {
    background: #0b1220;
  }

  /* Expand the app frame on desktop web */
  html.web-app .app-container {
    max-width: 1440px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    border-left: 1px solid rgba(148, 163, 184, 0.30) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.30) !important;
    box-shadow: none !important;
  }

  html.web-app.dark .app-container {
    border-left-color: rgba(51, 65, 85, 0.75) !important;
    border-right-color: rgba(51, 65, 85, 0.75) !important;
  }

  /* Desktop web nav: show top nav, hide bottom nav */
  html.web-app [data-desktop-only] {
    display: block !important;
  }

  html.web-app [data-mobile-only] {
    display: none !important;
  }

  /* When bottom nav is hidden, avoid extra safe padding */
  html.web-app .app-safe-main {
    padding-bottom: 2rem !important;
  }

  /* Desktop grids (3 columns) for card lists */
  html.web-app .grid-3-desktop {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }

  /* Neutralize mobile vertical spacing when rendered as grid */
  html.web-app .grid-3-desktop > * {
    margin-bottom: 0 !important;
  }

  /* Race Details (desktop web): center content and reduce "spread out" layout */
  html.web-app #raceDetails {
    /* Keep the outer app frame wide, but center actual content */
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
  }

  html.web-app #circuitCard {
    max-width: 1040px;
    margin-left: auto;
    margin-right: auto;
  }

  html.web-app #sessionsContainer {
    max-width: 1040px;
    margin-left: auto;
    margin-right: auto;
  }

  html.web-app #sessionsContainer [data-session-item] {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.35);
  }

  html.web-app.dark #sessionsContainer [data-session-item] {
    background: rgba(2, 6, 23, 0.35);
    border-color: rgba(51, 65, 85, 0.75);
  }

  /* Countdown grid: stop stretching across the whole row */
  html.web-app #sessionsContainer [data-session-countdown] [data-cd-grid] {
    grid-template-columns: repeat(4, max-content);
    justify-content: start;
    width: max-content;
    gap: 10px;
  }

  html.web-app #sessionsContainer [data-session-countdown] [data-cd-grid] > div {
    min-width: 64px;
  }
}
