/* Clash Royale Stats 3.1.0 - Home screen (T4-002 / R-004 / R-005).

   Screen-specific layout only. Every colour, radius, font and control surface
   comes from web/css/tokens.css + web/css/components.css; nothing here
   redefines a token or a component class. Every rule is scoped to `#home-body`
   (the element web/screens/home.js mounts into) so it can never reach the
   #home-live partial slot above it, the shell, or another screen.

   Home is four things (the session/goal cards live in #home-live above it): the
   trophy hero, three tiles, a Takeaways card. The charts, tables and the
   compare panel it used to carry moved to Trends (web/css/trends.css).

   Layout ladder:
     <1024     one column, 10px gap (the phone and tablet reading order: hero,
               tiles, takeaways)
     >=1024    the twelve-column content grid: tiles span the full width, then
               the hero (8) beside the Takeaways (4)

   Type floor (R-002/R-005): 11px only for uppercase `.eyebrow`; every other
   string on this screen is >=12px. */

/* ---------- grid ---------- */

#home-body .home-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Empty state: one honest sentence instead of a page of empty blocks. */
#home-body .home-grid.home-no-data > *:not(.home-empty) { display: none; }
#home-body .home-empty {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-2);
}
#home-body .home-empty .h2 { margin-bottom: 6px; display: block; }

/* ---------- shared furniture ---------- */

/* CRUI.pctSpan output. `.good`/`.bad` come from components.css; the low-sample
   muting (grey + italic + the asterisk pctSpan already appends) is the honesty
   affordance and must win over both. */
#home-body .pct { font-weight: 800; font-variant-numeric: tabular-nums; }
#home-body .pct.low-sample,
#home-body .pct.low-sample.good,
#home-body .pct.low-sample.bad { color: var(--ink-3); font-style: italic; }

/* The one failure control on this screen: a small text button next to (or under)
   the sentence that says what failed. */
#home-body .home-retry {
  color: var(--gold);
  font-weight: 800;
  font-size: 12px;
  min-height: 32px;
  padding: 0 6px;
  border-radius: 8px;
}

#home-body .home-skel-bar { height: 12px; border-radius: 6px; }

/* ---------- headline tiles ---------- */

#home-body .home-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
/* Each tile is a link (<a>): it needs the link resets the global `a` rule
   would otherwise colour gold, a pressed/hover surface, a keyboard ring, and a
   chevron that only shows on hover/focus (a cue, not content). */
#home-body .home-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease, border-color .12s ease;
}
#home-body a.home-tile:hover { color: var(--ink); background: var(--s3); }
#home-body a.home-tile:active { background: var(--s3); }
#home-body a.home-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#home-body .home-tile-go {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  color: var(--gold);
  opacity: 0;
  transition: opacity .12s ease;
}
#home-body a.home-tile:hover .home-tile-go,
#home-body a.home-tile:focus-visible .home-tile-go { opacity: 1; }
#home-body .home-tile .home-tile-value { font-size: 24px; }
/* No colour here: the sub-line carries `.good`/`.bad`/`.muted` itself, and a
   colour set at this specificity would silently win over all three. */
#home-body .home-tile .home-tile-sub {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  min-width: 0;
}
#home-body .home-tile .home-tile-sub .i { flex: none; }
/* W/L/D is always text + colour (R-005) and must never be clipped: at 390px a
   three-up tile is ~113px, so the triplet wraps rather than overflowing. */
#home-body .home-wld {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
/* A failed /overview: the sentence and its Retry, across the whole tile row. */
#home-body .home-tiles .home-error {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 4px 2px;
}
#home-body .home-tiles .home-error .error-text { margin-top: 0; }

/* ---------- trophy hero ---------- */

#home-body .home-hero { padding-bottom: 10px; }
#home-body .home-hero .card-head { margin-bottom: 4px; align-items: center; }
#home-body .home-capped-slot { display: inline-flex; flex: none; }
#home-body .home-capped-slot:empty { display: none; }
#home-body .home-trends-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  min-height: 36px;
  padding: 0 4px 0 8px;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
}
#home-body .home-hero-figures {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-width: 0;
}
#home-body .home-trophy-value { font-size: 32px; }
#home-body .home-trophy-delta { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; }
#home-body .home-chart { position: relative; height: 120px; margin-top: 8px; }
/* Stands in for the chart when the filter leaves no Trophy Road series to draw. */
#home-body .home-chart-empty { margin: 8px 0 0; line-height: 1.4; }

/* ---------- takeaways ---------- */

#home-body .home-takeaways { padding-bottom: 6px; }
#home-body .home-takeaways .card-head { margin-bottom: 2px; }
#home-body .home-take-list { display: flex; flex-direction: column; }
/* A hairline between rows that are actually showing (a hidden row in between
   must not leave the first visible one with a rule above it). */
#home-body .home-take:not(.hidden) ~ .home-take:not(.hidden) { border-top: 1px solid var(--line); }
#home-body .home-take-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 0;
  color: var(--ink);
}
#home-body .home-take-link:hover { color: var(--ink); }
#home-body .home-take-lead { display: inline-flex; flex: none; align-items: center; justify-content: center; min-width: 32px; }
#home-body .home-take-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--s2);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#home-body .home-take-body { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; }
#home-body .home-take-text { font-size: 14px; font-weight: 600; line-height: 1.35; }
#home-body .home-take-text b { font-weight: 800; }
#home-body .home-take-extra { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#home-body .home-take-extra .art-row { flex-wrap: wrap; }
#home-body .home-take-go { display: inline-flex; flex: none; color: var(--ink-3); }
#home-body .home-take-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-height: 52px;
  padding: 6px 0;
}
#home-body .home-take-error .error-text { margin-top: 0; }

/* ---------- >=1024: sidebar layout, twelve columns ---------- */

@media (min-width: 1024px) {
  #home-body .home-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
  }
  #home-body .home-grid > * { grid-column: span 12; }
  /* DOM order is the phone's (hero, tiles, takeaways); here the tile band leads. */
  #home-body .home-grid > .home-tiles { order: 1; }
  #home-body .home-grid > .home-hero { order: 2; grid-column: span 8; }
  #home-body .home-grid > .home-takeaways { order: 3; grid-column: span 4; }
  #home-body .home-grid > .home-empty { order: 4; }

  /* The artboard's desktop KPI band: full card surface, 34px numerals. */
  #home-body .home-tile {
    background: var(--s1);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    gap: 6px;
    justify-content: center;
  }
  #home-body a.home-tile:hover { background: var(--s2); border-color: var(--line-2); }
  #home-body a.home-tile:active { background: var(--s3); }
  #home-body .home-tile-go { top: 12px; right: 12px; }
  #home-body .home-tile .home-tile-value { font-size: 34px; }
  #home-body .home-trophy-value { font-size: 36px; }
  #home-body .home-chart { height: 180px; }
}
