/* 03-game-stats.css
   game stats drill-down, market maps, shared chart area

   Split out of styles.css. The numeric prefix is load-bearing: the server
   loads styles.css first, then styles/*.css alphabetically, and the cascade
   here is the original file's order. Renaming these out of sequence changes
   which rule wins.

   A few blocks are filed by position rather than by subject — the mobile
   header sits inside launch, a shared chart rule inside game stats — because
   moving them would reorder the cascade. Worth relocating one at a time with
   a visual check, not in bulk.
   ======================================================================== */

/* ===========================================================================
   Game Stats drill-down V2
   ======================================================================== */

.game-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}


/* Game selector */

.game-stats__picker {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  padding: 16px 18px;

  border:
    1px solid var(--line);

  border-radius: 9px;

  background:
    var(--surface);
}


.game-stats__picker h2 {
  margin:
    2px 0 0;

  color:
    var(--ink);

  font-size: 20px;
}


.game-stats__picker p {
  margin:
    4px 0 0;

  color:
    var(--ink-faint);

  font-size: 10px;
}


.game-stats__eyebrow {
  color:
    var(--ink-faint);

  font-size: 8px;

  font-weight: 600;

  text-transform: uppercase;

  letter-spacing: .08em;
}


.game-stats__select {
  min-width: 260px;
  max-width: 420px;

  height: 36px;

  padding:
    0 10px;

  border:
    1px solid var(--line-strong);

  border-radius: 7px;

  background:
    var(--surface);

  color:
    var(--ink);

  font: inherit;

  font-size: 11px;
}


/* Headline cards */

.game-stats__cards {
  display: grid;

  grid-template-columns:
    repeat(
      4,
      minmax(0, 1fr)
    );

  overflow: hidden;

  border:
    1px solid var(--line);

  border-radius: 9px;

  background:
    var(--surface);
}


.game-stats__card {
  min-width: 0;

  padding:
    13px 15px;

  border-right:
    1px solid var(--line);

  border-bottom:
    1px solid var(--line);
}


.game-stats__card:nth-child(4n) {
  border-right: 0;
}


.game-stats__card:nth-child(n+5) {
  border-bottom: 0;
}


.game-stats__card-label {
  display: block;

  color:
    var(--ink-faint);

  font-size: 8px;

  font-weight: 600;

  text-transform: uppercase;

  letter-spacing: .05em;
}


.game-stats__card strong {
  display: block;

  margin-top: 4px;

  overflow: hidden;

  color:
    var(--ink);

  font-size: 20px;

  font-weight: 600;

  text-overflow: ellipsis;

  white-space: nowrap;
}


.game-stats__card small {
  display: block;

  margin-top: 3px;

  color:
    var(--ink-faint);

  font-size: 9px;
}


.game-stats__card small.is-up,
.game-stats__variance.is-up {
  color:
    var(--positive, #23865b);
}


.game-stats__card small.is-down,
.game-stats__variance.is-down {
  color:
    var(--negative, #b84d4d);
}


/* Charts */

.game-stats__chart-grid {
  display: grid;

  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(0, 1fr);

  align-items: stretch;

  gap: 14px;
}


.game-stats__chart-grid .panel {
  min-width: 0;
  margin: 0;
}


.game-stats__metric-nav {
  display: flex;
  flex-wrap: wrap;

  justify-content: flex-end;

  gap: 4px;

  margin-left: auto;
}


.game-stats__metric-nav button {
  min-height: 25px;

  padding:
    0 7px;

  border:
    1px solid var(--line);

  border-radius: 5px;

  background:
    transparent;

  color:
    var(--ink-faint);

  font: inherit;

  font-size: 8px;

  cursor: pointer;
}


.game-stats__metric-nav button[aria-pressed="true"] {
  border-color:
    var(--accent);

  background:
    var(--accent-soft);

  color:
    var(--accent);
}


.game-stats__variance {
  margin-left: auto;

  font-size: 9px;

  font-weight: 600;

  white-space: nowrap;
}


/* Benchmark */

.game-stats__benchmark {
  margin: 0;
}


.game-stats__benchmark-badge {
  padding:
    5px 7px;

  border-radius: 6px;

  background:
    var(--accent-soft);

  color:
    var(--accent);

  font-size: 9px;

  font-weight: 600;
}


.game-stats__benchmark-grid {
  display: grid;

  grid-template-columns:
    repeat(
      4,
      minmax(0, 1fr)
    );

  border-top:
    1px solid var(--line);
}


.game-stats__benchmark-item {
  min-width: 0;

  padding:
    12px 15px;

  border-right:
    1px solid var(--line);
}


.game-stats__benchmark-item:last-child {
  border-right: 0;
}


.game-stats__benchmark-item span,
.game-stats__benchmark-item small {
  display: block;

  color:
    var(--ink-faint);

  font-size: 8px;
}


.game-stats__benchmark-item strong {
  display: block;

  margin:
    4px 0 2px;

  color:
    var(--ink);

  font-size: 17px;

  font-weight: 600;
}


.game-stats__table {
  min-width: 0;
}


/* Tablet */

@media (max-width: 1000px) {

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


  .game-stats__card:nth-child(2n) {
    border-right: 0;
  }


  .game-stats__card:nth-child(n+5) {
    border-bottom:
      1px solid var(--line);
  }


  .game-stats__card:nth-child(n+7) {
    border-bottom: 0;
  }


  .game-stats__chart-grid {
    grid-template-columns:
      1fr;
  }


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


  .game-stats__benchmark-item:nth-child(2n) {
    border-right: 0;
  }


  .game-stats__benchmark-item:nth-child(-n+2) {
    border-bottom:
      1px solid var(--line);
  }

}


/* Mobile */

@media (max-width: 700px) {

  .game-stats__picker {
    align-items: stretch;

    flex-direction: column;
  }


  .game-stats__select {
    width: 100%;

    min-width: 0;
    max-width: none;

    font-size: 16px;
  }


  .game-stats__cards {
    grid-template-columns:
      1fr 1fr;
  }


  .game-stats__metric-nav {
    width: 100%;

    justify-content:
      flex-start;
  }


  .game-stats__benchmark-grid {
    grid-template-columns:
      1fr;
  }


  .game-stats__benchmark-item {
    border-right: 0;

    border-bottom:
      1px solid var(--line);
  }


  .game-stats__benchmark-item:last-child {
    border-bottom: 0;
  }

}


/* ===========================================================================
   Game Stats market map V1
   ======================================================================== */

.game-stats__operator-geo-grid {
  display: grid;

  grid-template-columns:
    minmax(0, .9fr)
    minmax(0, 1.35fr);

  align-items: stretch;

  gap: 14px;
}


.game-stats__operator-geo-grid
.panel {
  min-width: 0;
  margin: 0;
}


.game-stats__operator-geo-grid
.panel__body {
  min-height: 330px;
}


.game-stats__operator-geo-grid
.js-plotly-plot,
.game-stats__operator-geo-grid
.plot-container,
.game-stats__operator-geo-grid
.svg-container {
  width: 100% !important;
}


.game-stats__map-filter {
  margin-left: auto;

  min-height: 27px;

  padding:
    0 8px;

  border:
    1px solid var(--accent);

  border-radius: 6px;

  background:
    var(--accent-soft);

  color:
    var(--accent);

  font: inherit;

  font-size: 9px;

  cursor: pointer;
}


.game-stats__map-filter[hidden] {
  display: none;
}


.game-stats__map-loading {
  display: flex;

  align-items: center;
  justify-content: center;

  gap: 8px;

  min-height: 320px;

  color:
    var(--ink-faint);

  font-size: 10px;
}


.game-stats__map-spinner {
  width: 15px;
  height: 15px;

  border:
    2px solid var(--line-strong);

  border-top-color:
    var(--accent);

  border-radius: 50%;

  animation:
    game-stats-map-spin
    .7s
    linear
    infinite;
}


@keyframes game-stats-map-spin {

  to {
    transform:
      rotate(360deg);
  }

}


@media (max-width: 1000px) {

  .game-stats__operator-geo-grid {
    grid-template-columns:
      1fr;
  }

}


@media (prefers-reduced-motion: reduce) {

  .game-stats__map-spinner {
    animation-duration:
      1.5s;
  }

}


/* ===========================================================================
   Shared line area opacity V2
   Line remains strong; area is exactly 50% transparent.
   ======================================================================== */

.chart .series-area {
  opacity: 0.2;
}


/*
 * Generic .fade-in finishes at opacity:1.
 * Area charts need their own end-state so the animation does not make
 * the fill fully opaque again.
 */

.chart .series-area.fade-in {
  animation-name:
    line-area-fade;
}


@keyframes line-area-fade {

  from {
    opacity: 0;
  }

  to {
    opacity: 0.2;
  }

}


@media (prefers-reduced-motion: reduce) {

  .chart .series-area {
    opacity: 0.5;
  }

}


/* ===========================================================================
   USA state drilldown V1
   ======================================================================== */

.game-stats__map-toolbar {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 8px;

  min-height: 31px;

  padding:
    3px 4px 5px;

  color:
    var(--ink-faint);

  font-size:
    9px;
}


.game-stats__map-view-title {
  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}


.game-stats__map-back {
  flex:
    0 0 auto;

  min-height:
    25px;

  padding:
    0 8px;

  border:
    1px solid var(--line-strong);

  border-radius:
    6px;

  background:
    var(--surface);

  color:
    var(--ink-soft);

  font: inherit;

  font-size:
    9px;

  cursor:
    pointer;
}


.game-stats__map-back:hover {
  border-color:
    var(--accent);

  color:
    var(--accent);
}


.game-stats__map-back[hidden] {
  display:
    none;
}


.game-stats__map-plot {
  width:
    100%;

  min-height:
    295px;
}


/* ===========================================================================
   Game Stats Markets Map Layout V3
   ======================================================================== */

.game-stats__operator-geo-grid {
  display:
    grid;

  grid-template-columns:
    minmax(390px, .85fr)
    minmax(0, 1.45fr);

  gap:
    14px;

  align-items:
    stretch;
}


.game-stats__operator-geo-grid > .panel {
  display:
    flex;

  flex-direction:
    column;

  height:
    430px;

  min-width:
    0;

  min-height:
    0;

  overflow:
    hidden;
}


.game-stats__operator-geo-grid
.panel__head {
  flex:
    0 0 auto;
}


.game-stats__operator-geo-grid
.panel__body {
  flex:
    1 1 auto;

  min-height:
    0;
}


/* Map --------------------------------------------------------------- */

.game-stats__map-panel
.panel__body {
  display:
    flex;

  flex-direction:
    column;

  overflow:
    hidden;
}


.game-stats__map-toolbar {
  flex:
    0 0 34px;

  box-sizing:
    border-box;

  min-height:
    34px;

  height:
    34px;

  padding:
    3px 7px 4px;
}


.game-stats__map-plot {
  flex:
    1 1 auto;

  width:
    100%;

  height:
    auto !important;

  min-height:
    0;

  overflow:
    hidden;
}


.game-stats__map-plot
.js-plotly-plot,
.game-stats__map-plot
.plot-container,
.game-stats__map-plot
.svg-container,
.game-stats__map-plot
.main-svg {
  width:
    100% !important;

  height:
    100% !important;
}


/* Markets table ----------------------------------------------------- */

.game-stats__market-panel
.panel__body {
  padding:
    0;

  overflow:
    hidden;
}


.game-stats__market-mini-wrap {
  width:
    100%;

  height:
    100%;

  overflow:
    auto;
}


.game-stats__market-mini {
  width:
    100%;

  border-collapse:
    collapse;

  font-size:
    11px;
}


.game-stats__market-mini thead {
  position:
    sticky;

  top:
    0;

  z-index:
    3;

  background:
    var(--surface);
}


.game-stats__market-mini th {
  padding:
    10px 11px;

  border-bottom:
    1px solid var(--line);

  color:
    var(--ink-faint);

  font-size:
    9px;

  font-weight:
    600;

  text-align:
    left;

  white-space:
    nowrap;
}


.game-stats__market-mini
th:not(:first-child) {
  text-align:
    right;
}


.game-stats__market-mini td {
  padding:
    9px 11px;

  border-bottom:
    1px solid var(--line);

  color:
    var(--ink-soft);

  white-space:
    nowrap;
}


.game-stats__market-mini
td:first-child {
  color:
    var(--ink);

  font-weight:
    500;
}


.game-stats__market-mini td.num {
  text-align:
    right;

  font-variant-numeric:
    tabular-nums;
}


.game-stats__market-mini tbody tr {
  cursor:
    pointer;

  transition:
    background-color .12s ease;
}


.game-stats__market-mini
tbody tr:hover {
  background:
    var(--surface-sunk);
}


.game-stats__market-mini
tbody tr.is-selected {
  background:
    var(--accent-soft);
}


.game-stats__market-mini
tbody tr.is-selected td:first-child {
  color:
    var(--accent);
}


/* Plotly tooltip fallback ------------------------------------------- */

.game-stats__map-panel
.hoverlayer
.hovertext text {
  fill:
    var(--ink) !important;
}


@media (max-width: 1050px) {

  .game-stats__operator-geo-grid {
    grid-template-columns:
      1fr;
  }


  .game-stats__operator-geo-grid > .panel {
    height:
      390px;
  }

}


/* ===========================================================================
   Social performance parity V2
   ======================================================================== */

.operator-table-host {
  min-width:
    0;

  animation:
    rise-in .42s ease both;
}


.operator-table-host > .panel {
  height:
    100%;
}


.operator-table-host
.table-wrap {
  max-height:
    300px;
}


.operator-table-host
.table-tools {
  display:
    none;
}


.cell-delta[hidden] {
  display:
    none;
}


.cell-delta {
  display:
    block;

  margin-top:
    2px;

  font-size:
    10px;

  font-weight:
    500;

  line-height:
    1;

  white-space:
    nowrap;
}


.cell-delta.is-up {
  color:
    var(--positive);
}


.cell-delta.is-down {
  color:
    var(--negative);
}
