/* 01-launch.css
   launch curves, controls, leaderboard, mobile header

   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.
   ======================================================================== */

/* ===========================================================================
   Launch curves
   ======================================================================== */

.launch-panel {
  margin-bottom: 20px;
}

.launch-panel .panel__body {
  padding-top: 2px;
}

.launch-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.launch-controls__note {
  font-size: 12px;
  color: var(--ink-faint);
}

.launch-controls__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-soft);
}

.launch-controls__select {
  appearance: auto;
  min-width: 150px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.launch-series {
  stroke-width: 1.65;
  opacity: 0.72;
  transition:
    opacity 120ms ease,
    stroke-width 120ms ease;
}

.launch-series:hover {
  opacity: 1;
  stroke-width: 3;
}

.launch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  max-height: 92px;
  overflow: auto;
  padding: 6px 16px 2px 56px;
  border-top: 1px solid var(--line);
}

.launch-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 190px;
  color: var(--ink-soft);
  font-size: 11px;
}

.launch-legend__item > i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.launch-legend__item > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .launch-controls__note {
    display: none;
  }

  .launch-controls {
    gap: 8px;
  }

  .launch-controls__select {
    min-width: 125px;
  }

  .launch-legend {
    padding-left: 14px;
  }
}


/* ===========================================================================
   Launch curve controls
   ======================================================================== */

.launch-controls {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 14px;
  margin-left: auto;
}

.launch-control {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.launch-control__label {
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .045em;
}

.launch-range {
  width: 245px;
}

.launch-range__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.launch-range__value {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 500;
}

.launch-range__bottom {
  display: flex;
  align-items: center;
  gap: 9px;
}

.launch-range__slider {
  width: 115px;
  accent-color: var(--accent);
  cursor: pointer;
}

.launch-range__presets {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.launch-range__preset {
  min-width: 33px;
  height: 27px;
  padding: 0 7px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.launch-range__preset:last-child {
  border-right: 0;
}

.launch-range__preset:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.launch-range__preset.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.launch-game-control {
  position: relative;
}

.launch-game-button {
  height: 31px;
  min-width: 132px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.launch-game-button:hover,
.launch-game-button[aria-expanded="true"] {
  border-color: var(--ink-faint);
  color: var(--ink);
}

.launch-game-button b {
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

.launch-game-button__chevron {
  color: var(--ink-faint);
}

.launch-game-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 30;
  width: 330px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28);
}

.launch-game-menu[hidden] {
  display: none;
}

.launch-game-menu__head {
  display: flex;
  gap: 7px;
  padding: 9px;
  border-bottom: 1px solid var(--line);
}

.launch-game-search {
  min-width: 0;
  flex: 1;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: 0;
  background: var(--surface-sunk);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.launch-game-search:focus {
  border-color: var(--accent);
}

.launch-game-actions {
  display: flex;
  gap: 4px;
}

.launch-game-actions button {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.launch-game-actions button:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.launch-game-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
}

.launch-game-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
}

.launch-game-option:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.launch-game-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.launch-game-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launch-game-empty,
.launch-empty {
  padding: 28px;
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 900px) {
  .launch-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin: 10px 0 0;
  }

  .launch-range {
    width: 100%;
  }

  .launch-range__slider {
    flex: 1;
  }

  .launch-game-menu {
    right: auto;
    left: 0;
    width: min(330px, calc(100vw - 40px));
  }
}


/* ===========================================================================
   Launch leaderboard
   ======================================================================== */

.launch-leaderboard-panel {
  margin-top: 16px;
}

.launch-leaderboard-panel .panel__body {
  padding: 0;
}

.launch-leaderboard-scroll {
  width: 100%;
  overflow-x: auto;
}

.launch-leaderboard {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
}

.launch-leaderboard th {
  height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 500;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: .045em;
  white-space: nowrap;
}

.launch-leaderboard th:nth-child(1),
.launch-leaderboard th:nth-child(2) {
  text-align: left;
}

.launch-leaderboard td {
  height: 45px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
}

.launch-leaderboard td:first-child,
.launch-leaderboard td:nth-child(2) {
  text-align: left;
}

.launch-leaderboard tbody tr {
  cursor: pointer;
  outline: none;
  transition:
    background 120ms ease,
    opacity 120ms ease;
}

.launch-leaderboard tbody tr:hover {
  background: var(--surface-hover);
}

.launch-leaderboard tbody tr:focus-visible {
  box-shadow: inset 3px 0 0 var(--accent);
}

.launch-leaderboard tbody tr.is-selected {
  background: color-mix(
    in srgb,
    var(--accent) 5%,
    transparent
  );
}

.launch-leaderboard tbody tr:not(.is-selected) {
  opacity: .58;
}

.launch-leaderboard tbody tr:not(.is-selected):hover {
  opacity: .85;
}

.launch-rank-cell {
  width: 78px;
}

.launch-rank-cell small {
  margin-left: 6px;
  color: var(--ink-faint);
  font-size: 10px;
}

.launch-rank {
  display: inline-flex;
  min-width: 30px;
  height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
}

.launch-rank--1 {
  color: var(--accent);
  background: var(--accent-soft);
}

.launch-game-cell {
  min-width: 210px;
  max-width: 270px;
  color: var(--ink) !important;
  font-weight: 500;
}

.launch-game-cell span {
  display: inline-block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.launch-game-state {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border: 1px solid var(--ink-faint);
  border-radius: 50%;
  vertical-align: middle;
}

.is-selected .launch-game-state {
  border-color: var(--accent);
  background: var(--accent);
}

.launch-current-cell strong {
  color: var(--ink);
  font-weight: 600;
}

.launch-current-cell small {
  display: block;
  margin-top: 2px;
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 400;
}

.launch-median-delta {
  font-size: 11px;
  font-weight: 500;
}

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

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

.launch-leaderboard .is-muted {
  color: var(--ink-faint);
}

@media (prefers-reduced-motion: reduce) {
  .launch-series,
  .launch-leaderboard tbody tr {
    transition: none !important;
    animation: none !important;
  }
}



/* Prevent layout shift while Launch chart redraws */

.launch-panel .panel__body {
  min-height: 500px;
}

.launch-panel .chart {
  display: block;
}

.launch-panel .launch-empty {
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Clickable launch-age links in leaderboard */

.launch-day-link {
  display: inline;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  text-decoration: none;
}

.launch-day-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.launch-day-link:focus-visible {
  color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.launch-current-cell .launch-day-link {
  display: block;
  margin: 2px 0 0;
}



/* MOBILE HEADER V2 */

@media (max-width: 760px) {

  /* ---------------------------------------------------------
     Main shell
     --------------------------------------------------------- */

  .shell {
    display: block;
    min-width: 0;
  }

  .main {
    width: 100%;
    min-width: 0;
  }

  /* ---------------------------------------------------------
     Mobile navigation
     --------------------------------------------------------- */

  .rail {
    position: sticky;
    top: 0;
    z-index: 50;

    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand foot"
      "nav nav";

    width: 100%;
    height: auto;

    background:
      color-mix(in srgb, var(--surface) 94%, transparent);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

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

    padding-top: env(safe-area-inset-top);
  }

  .rail__brand {
    grid-area: brand;

    min-width: 0;

    padding: 9px 14px 7px;

    display: flex;
    align-items: baseline;
    gap: 7px;
  }

  .rail__mark {
    flex: 0 0 auto;
    font-size: 15px;
  }

  .rail__model {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 10.5px;
  }

  .rail__foot {
    grid-area: foot;

    border: 0;
    padding: 7px 14px 6px 8px;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
  }

  .rail__who {
    display: none;
  }

  .rail__foot .linkish {
    white-space: nowrap;
    font-size: 11px;
  }

  .rail__nav {
    grid-area: nav;

    width: 100%;
    min-width: 0;

    padding: 2px 10px 8px;

    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;

    overflow-x: auto;
    overflow-y: hidden;

    scroll-snap-type: x proximity;
    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .rail__nav::-webkit-scrollbar {
    display: none;
  }

  .rail__section {
    display: none;
  }

  .rail__group,
  .rail__group[hidden] {
    display: contents;
  }

  .rail__link {
    flex: 0 0 auto;
    width: auto;

    min-height: 34px;

    padding: 7px 10px;

    gap: 6px;

    border-radius: 7px;

    white-space: nowrap;
    scroll-snap-align: center;

    font-size: 11.5px;
  }

  .rail__link svg {
    width: 14px;
    height: 14px;
  }

  /* ---------------------------------------------------------
     Page header
     --------------------------------------------------------- */

  .topbar {
    position: relative;
    top: auto;
    z-index: 10;

    padding: 12px 14px;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 10px;
  }

  .topbar > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .topbar__title {
    font-size: 18px;
    line-height: 1.15;
  }

  .topbar__meta {
    max-width: 100%;

    margin-top: 3px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 11px;
  }

  /* ---------------------------------------------------------
     Date controls
     --------------------------------------------------------- */

  .filters {
    width: 100%;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 7px;
  }

  .range {
    flex: 1 1 auto;
    min-width: 0;

    display: flex;
  }

  /* `auto` rather than `0`: equal thirds clipped "Today" against its
     neighbour once there were five presets, and the abbreviations beside it
     need nothing like the same room. */
  .range > button {
    flex: 1 1 auto;

    min-width: 0;

    padding: 7px 3px;

    font-size: 11px;

    white-space: nowrap;
  }

  .range__long {
    display: none;
  }

  .range__short {
    display: inline;
  }

  /* The calendar segment keeps its glyph's width while the presets share what
     is left — it has no label to shrink. */
  .date-picker {
    flex: 0 0 auto;
  }

  .date-picker__toggle {
    padding: 7px 7px;
  }

  .date-picker__pop {
    max-width: calc(100vw - 20px);
  }

  /* Icon-only refresh on mobile */
  .filters > .btn {
    flex: 0 0 34px;

    width: 34px;
    height: 32px;

    padding: 0;

    justify-content: center;

    font-size: 0;
  }

  .filters > .btn svg {
    width: 15px;
    height: 15px;
  }

  /* ---------------------------------------------------------
     Content
     --------------------------------------------------------- */

  .content {
    width: 100%;
    min-width: 0;

    padding: 14px 12px 40px;
  }

}


/* Very narrow phones */

@media (max-width: 370px) {

  .rail__model {
    display: none;
  }

  .rail__link {
    padding-left: 9px;
    padding-right: 9px;
  }

  /* Five presets, a two-state mode toggle and two icon buttons cannot share a
     320px row without clipping the labels — the mode toggle alone wants a
     third of it. A second row costs one button's height and keeps every
     label readable. */
  .filters {
    flex-wrap: wrap;
  }

  .data-mode {
    flex: 1 1 100%;
  }

  .range > button {
    font-size: 10.5px;
    padding-left: 2px;
    padding-right: 2px;
  }


}
