/* Cricket ball-tracking showcase. Neutral: inherits the host's text colour (light or dark ground),
   one accent the host can set with --accent. Font: Archivo (load it on the host page). */
.cricket-showcase {
  --accent: #f2b200;
  --cs-radius: 14px;
  --cs-gap: clamp(12px, 2.2vw, 22px);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  color: inherit;
  display: grid;
  gap: var(--cs-gap);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.cricket-showcase *, .cricket-showcase *::before, .cricket-showcase *::after { box-sizing: border-box; }
.cricket-showcase[data-theme="light"] { color: #1d2125; }
.cricket-showcase[data-theme="dark"] { color: #e8ecf3; }

.cs-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cs-tab {
  font: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0.01em;
  color: inherit; background: transparent; cursor: pointer;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 999px; padding: 7px 14px; line-height: 1;
}
.cs-tab[aria-selected="true"] { background: color-mix(in srgb, currentColor 10%, transparent); border-color: color-mix(in srgb, currentColor 45%, transparent); }
.cs-tab:focus-visible, .cs-views button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cs-body {
  display: grid; gap: var(--cs-gap);
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: stretch;
}
.cricket-showcase[data-layout="3d"] .cs-body { grid-template-columns: minmax(0, 1fr); }
.cricket-showcase[data-layout="3d"] .cs-video { display: none; }

.cs-video {
  position: relative; margin: 0; border-radius: var(--cs-radius); overflow: hidden;
  background: color-mix(in srgb, currentColor 8%, transparent);
  aspect-ratio: 540 / 674; align-self: start;
}
.cs-video video { display: block; width: 100%; height: 100%; object-fit: cover; }
.cs-video figcaption {
  position: absolute; left: 10px; bottom: 10px; right: 10px;
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 11px; line-height: 1.2; color: #fff;
}
.cs-video figcaption span { background: rgba(10, 12, 16, 0.62); padding: 5px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; }
.cs-key { display: inline-block; width: 18px; height: 0; border-top: 2px solid #fff; }
.cs-key.dash { border-top-style: dashed; }
.cs-key.ring { width: 10px; height: 10px; border: 2px solid #f2b200; border-radius: 50%; }

.cs-3d { display: grid; gap: 12px; min-width: 0; grid-template-rows: auto auto; }
.cs-stage {
  position: relative; border-radius: var(--cs-radius); overflow: hidden;
  background: color-mix(in srgb, currentColor 5%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  aspect-ratio: 16 / 10; min-height: 240px;
}
.cs-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.cs-stage canvas:active { cursor: grabbing; }
.cs-hint { position: absolute; left: 12px; top: 10px; font-size: 11px; opacity: 0.6; pointer-events: none; }
.cs-views { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; }
.cs-views button {
  font: inherit; font-size: 11px; color: inherit; cursor: pointer; line-height: 1;
  background: color-mix(in srgb, currentColor 6%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 6px; padding: 6px 8px;
}
.cs-legend { position: absolute; left: 12px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; opacity: 0.85; pointer-events: none; }
.cs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cs-legend .cs-key { border-top-color: currentColor; }
.cs-legend .cs-key.meas { border-top: 3px solid var(--accent); }

.cs-metrics {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 18px; margin: 0;
  border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}
.cs-metric { margin: 0; min-width: 0; padding: 11px 0 12px; border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent); }
.cs-metric dt { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.66; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-metric dd { margin: 4px 0 0; }
.cs-val { font-size: clamp(20px, 2.3vw, 28px); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.cs-unit { font-size: 13px; font-weight: 500; opacity: 0.7; margin-left: 3px; }
.cs-note { display: block; font-size: 12px; opacity: 0.66; margin-top: 2px; line-height: 1.3; }
.cs-badge { font-size: 9.5px; letter-spacing: 0.06em; padding: 2px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: 0.9; text-transform: uppercase; }
.cs-badge.measured { border-color: var(--accent); }
.cs-badge.extrapolated, .cs-badge.modelled { border-style: dashed; }
.cs-foot { font-size: 12px; line-height: 1.45; opacity: 0.66; margin: 0; max-width: 72ch; }

@media (max-width: 820px) {
  .cs-body { grid-template-columns: minmax(0, 1fr); }
  .cs-video { max-width: 420px; width: 100%; justify-self: center; }
  .cs-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-stage { aspect-ratio: 4 / 3; }
}
@media (max-width: 420px) {
  .cs-views button { padding: 5px 6px; }
  .cs-hint { display: none; }
}
/* when native controls are shown (reduced motion), keep the key clear of them */
.cs-video video[controls] + figcaption { top: 10px; bottom: auto; }
@media (prefers-reduced-motion: reduce) { .cs-tab, .cs-views button { transition: none; } }
