/* Insights */

:root {
  --chart-1: #5b125b;
  --chart-2: #4f9ee8;
  --chart-3: #d6a11f;
  --chart-4: #268878;
  --hit-1: #5b125b;
  --hit-2: #62a9ec;
  --hit-3: #1768a4;
  --hit-4: #e9a91a;
  --insight-ring: 0 0 0 1px rgba(50, 37, 56, 0.08), 0 2px 7px rgba(50, 37, 56, 0.04);
}

:root[data-theme="dark"] {
  --chart-1: #d083d0;
  --chart-2: #74b9f5;
  --chart-3: #efc457;
  --chart-4: #60c6b5;
  --hit-1: #b963b9;
  --hit-2: #74b9f5;
  --hit-3: #2f87c9;
  --hit-4: #efb735;
  --insight-ring: 0 0 0 1px rgba(255, 255, 255, 0.09);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html[data-active-view="insights"] .page-shell {
  width: min(1420px, calc(100% - 32px));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.insights-section {
  min-width: 0;
}

.insights-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 16px;
}

.insights-heading h2 {
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 880;
  letter-spacing: -0.045em;
  line-height: 0.96;
  text-wrap: balance;
}

.insights-heading p,
.insight-panel-head p {
  color: var(--muted);
  text-wrap: pretty;
}

.insights-heading p {
  margin-top: 10px;
  font-size: 15px;
}

.insights-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 10px 0 18px;
}

.player-control-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.control-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.selected-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-player-chip,
.add-player-select select,
.top-three-button,
.top-three-inline,
.metric-switcher button {
  min-height: 42px;
  border: 0;
  font-size: 13px;
  font-weight: 780;
  transition-property: scale, background-color, color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.selected-player-chip:active:not(:disabled),
.top-three-button:active,
.top-three-inline:active,
.metric-switcher button:active {
  scale: 0.96;
}

.selected-player-chip {
  --series-color: var(--chart-1);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 106px;
  border-radius: 10px;
  background: var(--series-color);
  box-shadow: var(--insight-ring);
  color: white;
  cursor: pointer;
  padding: 0 13px 0 15px;
}

.selected-player-chip span {
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
}

.selected-player-chip:disabled {
  cursor: default;
  opacity: 1;
}

.selected-player-chip:focus-visible,
.top-three-button:focus-visible,
.top-three-inline:focus-visible,
.metric-switcher button:focus-visible,
.add-player-select select:focus-visible,
.insight-chart-scroll:focus-visible,
.insight-point:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-blue) 72%, white);
  outline-offset: 2px;
}

.add-player-select {
  position: relative;
}

.add-player-select select {
  min-width: 126px;
  border: 1px dashed color-mix(in srgb, var(--muted) 58%, transparent);
  border-radius: 10px;
  appearance: none;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 34px 0 14px;
}

.add-player-select::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  pointer-events: none;
  rotate: 45deg;
  translate: 0 -70%;
}

.add-player-select:has(select:disabled) {
  opacity: 0.48;
}

.top-three-button,
.top-three-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  box-shadow: var(--insight-ring);
  color: var(--accent);
  cursor: pointer;
  padding: 0 14px;
}

.top-three-button.is-active,
.top-three-inline.is-active {
  background: var(--accent);
  color: white;
}

.podium-dots {
  display: flex;
  align-items: end;
  gap: 2px;
  height: 14px;
}

.podium-dots i {
  width: 4px;
  border-radius: 3px 3px 1px 1px;
  background: currentColor;
}

.podium-dots i:nth-child(1) { height: 8px; }
.podium-dots i:nth-child(2) { height: 14px; }
.podium-dots i:nth-child(3) { height: 10px; }

.metric-switcher {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  overflow: hidden;
  border-radius: 10px;
  box-shadow: var(--insight-ring);
  background: var(--surface);
}

.metric-switcher button {
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 15px;
}

.metric-switcher button:last-child {
  border-right: 0;
}

.metric-switcher button.is-active {
  background: var(--accent);
  color: white;
}

.insight-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.insight-stat,
.insight-panel {
  background: var(--surface);
  box-shadow: var(--insight-ring);
}

.insight-stat {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 13px;
  min-height: 126px;
  border-radius: 14px;
  padding: 17px;
}

.insight-stat-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 82%, transparent);
  color: var(--accent);
}

.insight-stat-icon svg {
  width: 22px;
  height: 22px;
}

.insight-stat > div > span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.insight-stat-name {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-stat-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 7px;
}

.insight-stat-value strong {
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 880;
  letter-spacing: -0.045em;
  line-height: 0.9;
}

.insight-stat-value small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-main-grid,
.insight-detail-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.insight-main-grid {
  grid-template-columns: minmax(0, 1.82fr) minmax(330px, 0.9fr);
}

.insight-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.insight-panel {
  min-width: 0;
  overflow: hidden;
  border-radius: 14px;
}

.insight-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px 12px;
}

.insight-panel-head h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
  text-wrap: balance;
}

.insight-panel-head p {
  margin-top: 4px;
  font-size: 11px;
}

.insight-legend,
.hit-profile-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.insight-legend-item,
.hit-profile-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.insight-legend-item {
  --series-color: var(--chart-1);
}

.insight-legend-item i {
  width: 20px;
  height: 3px;
  border-radius: 99px;
  background: var(--series-color);
}

.insight-chart-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.insight-trend-chart {
  display: block;
  width: 100%;
  min-width: 700px;
  height: auto;
  padding: 0 8px 2px;
}

.insight-grid-line {
  stroke: var(--line);
  stroke-dasharray: 2 3;
  stroke-width: 1;
}

.insight-axis-label {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.insight-trend-line {
  fill: none;
  stroke: var(--series-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.insight-point {
  fill: var(--series-color);
  stroke: var(--surface);
  stroke-width: 2;
  transition-property: r, filter;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
  vector-effect: non-scaling-stroke;
}

.insight-point:hover,
.insight-point:focus {
  r: 7px;
  filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--series-color) 36%, transparent));
}

.insight-series-1 { --series-color: var(--chart-1); }
.insight-series-2 { --series-color: var(--chart-2); }
.insight-series-3 { --series-color: var(--chart-3); }
.insight-series-4 { --series-color: var(--chart-4); }

.comparison-metrics {
  display: grid;
  gap: 15px;
  padding: 4px 18px 18px;
}

.comparison-metric {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
}

.comparison-metric > strong {
  padding-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.comparison-bars,
.time-split-bars {
  display: grid;
  gap: 6px;
}

.comparison-bar-row,
.time-bar-row {
  display: grid;
  grid-template-columns: 66px minmax(60px, 1fr) 42px;
  align-items: center;
  gap: 7px;
  font-size: 10px;
}

.comparison-bar-row span,
.time-bar-row span {
  overflow: hidden;
  color: var(--muted);
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-bar-row b,
.time-bar-row b {
  font-size: 11px;
  text-align: right;
}

.comparison-track,
.time-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--accent-soft);
}

.comparison-track i,
.time-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--series-color);
  transition-property: width;
  transition-duration: 280ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.hit-profile-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.hit-profile-rows,
.time-split-rows {
  display: grid;
  gap: 14px;
  padding: 6px 18px 20px;
}

.hit-profile-row {
  display: grid;
  grid-template-columns: 72px minmax(150px, 1fr) 48px;
  align-items: center;
  gap: 10px;
}

.hit-profile-row > strong,
.hit-profile-row > b {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-profile-row > b {
  text-align: right;
}

.hit-profile-track {
  display: flex;
  height: 30px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--accent-soft);
}

.hit-profile-track > i {
  display: grid;
  place-items: center;
  min-width: 2px;
  color: white;
  font-style: normal;
  transition-property: width;
  transition-duration: 280ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.hit-profile-track span {
  font-size: 10px;
  font-weight: 850;
}

.hit-type-1 { background: var(--hit-1); }
.hit-type-2 { background: var(--hit-2); }
.hit-type-3 { background: var(--hit-3); }
.hit-type-4 { background: var(--hit-4); }

.time-split-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
}

.time-split-label strong,
.time-split-label span {
  display: block;
}

.time-split-label strong {
  font-size: 12px;
}

.time-split-label span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.insight-footnote {
  border-top: 1px solid var(--line);
  padding: 10px 18px 13px;
  color: var(--muted);
  font-size: 10px;
}

.insight-leaders-panel {
  margin-top: 12px;
}

.top-three-inline {
  min-height: 36px;
}

.insight-leaders-frame {
  overflow-x: auto;
}

.insight-leaders-table {
  min-width: 650px;
}

.insight-leaders-table th,
.insight-leaders-table td {
  height: 38px;
  padding: 0 16px;
}

.insight-leaders-table th {
  font-size: 10px;
}

.insight-leaders-table td {
  font-size: 12px;
}

.insight-leaders-table .rank-number {
  width: 22px;
  height: 22px;
}

.insight-leaders-table tr.insight-podium {
  background: color-mix(in srgb, var(--accent-blue-soft) 46%, transparent);
}

@media (max-width: 1050px) {
  .insight-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .comparison-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  html[data-active-view="insights"] .page-shell {
    width: min(1180px, calc(100% - 20px));
  }

  .view-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insights-heading {
    padding-top: 10px;
  }

  .insights-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-switcher {
    width: min(100%, 420px);
  }

  .insight-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .insights-heading h2 {
    font-size: 36px;
  }

  .insights-heading p {
    font-size: 13px;
  }

  .selected-player-list {
    flex-wrap: wrap;
    margin: 0;
    overflow: visible;
    padding: 2px 0 8px;
  }

  .selected-player-chip,
  .add-player-select,
  .top-three-button {
    flex: 0 0 auto;
  }

  .insight-stats-grid {
    display: flex;
    margin: 0 -10px;
    overflow-x: auto;
    padding: 2px 10px 10px;
    scroll-snap-type: x proximity;
  }

  .insight-stat {
    flex: 0 0 224px;
    min-height: 116px;
    scroll-snap-align: start;
  }

  .insight-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .insight-legend,
  .hit-profile-legend {
    justify-content: start;
  }

  .comparison-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .hit-profile-row {
    grid-template-columns: 58px minmax(170px, 1fr) 42px;
  }

  .insight-leaders-table th,
  .insight-leaders-table td {
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .selected-player-chip,
  .top-three-button,
  .top-three-inline,
  .metric-switcher button,
  .comparison-track i,
  .time-track i,
  .hit-profile-track > i,
  .insight-point {
    transition-duration: 0.01ms;
  }
}

