/*
 * CPA UI v7 — Quiet Luxury
 * Principle: a calm, near-flat canvas + a small set of precisely tuned
 * motions (count-up numbers, bars growing from the baseline, page fade-rise,
 * breathing live dot). Decoration is reserved for state; everything else is
 * quiet. Stacks on v6; remove the `ui-v7` body class to compare/revert.
 */

:root {
  --v7-ease: cubic-bezier(.16, 1, .3, 1);
  --v7-line: rgba(38, 67, 101, .16);
  --v7-blue: #2f6f92;
}

/* ============ QUIET BASE ============ */

/* one texture only: keep the pixel grid backplane, but fainter */
body.ui-v7.ui-v5 .console-content {
  background-color: #f4f9f2;
  background-size: 28px 28px;
}

/* cards go near-flat: plain surface, single 1px border, two radii */
body.ui-v7 .newapi-card,
body.ui-v7 .dashboard-hourly-card,
body.ui-v7 .channel-card,
body.ui-v7 .newapi-metric,
body.ui-v7 .mini-leaderboard-panel {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--v7-line);
  border-radius: 10px;
}

body.ui-v7 .newapi-button,
body.ui-v7 .newapi-input,
body.ui-v7 .newapi-select,
body.ui-v7 .newapi-status-pill {
  border-radius: 6px;
}

/* retire the remaining shine: scan light + decorative rails/brackets */
body.ui-v7 .hourly-chart::before,
body.ui-v7 .dashboard-hourly-card::before,
body.ui-v7 .dashboard-hourly-card::after {
  content: none;
}

/* color is information: the chart wears the data-blue, the board wears mint */
body.ui-v7 .hourly-chart {
  background: rgba(252, 254, 255, .9);
  border: 1px solid rgba(79, 167, 222, .55);
}

body.ui-v7 .dashboard-hourly-card {
  border-color: rgba(79, 167, 222, .35);
}

body.ui-v7 .mini-leaderboard-panel {
  border-color: rgba(42, 185, 146, .5);
}

/* metric spine: one color only (state colors stay reserved for states) */
body.ui-v7 .dashboard-usage-metrics .newapi-metric:nth-child(even)::before {
  background: linear-gradient(180deg, #4fa7de, var(--v7-blue));
}

/* the LIVE ROUTE ribbon (v3 relay theme) is retired.
   CRITICAL: v3 mounts the ribbon as the first child of .console-content and
   sets grid-template-rows: 38px minmax(0,1fr). If we only hide the ribbon
   with display:none, the dashboard page falls into the 38px first track and
   the main console appears blank. Collapse the grid to a single flexible row. */
body.ui-v7 .packet-route-ribbon {
  display: none !important;
}

body.ui-v7[data-packet-frontier-mounted="true"] .console-content {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

/* quiet-card styles must NOT paint the transparent login-gate card opaque */
body.ui-v7 .console-gate-card.newapi-card,
body.ui-v7 .newapi-card.console-gate-card {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* title mascot: pixel rocket, sized to the flattened header */
body.ui-v7 .title-mascot {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: -5px;
}

/* rank list header lines up with the row grid (34 / flexible / 86 + row border) */
body.ui-v7 .mini-leaderboard-panel .rank-list-head {
  grid-template-columns: 34px minmax(0, 1fr) 86px;
  gap: 7px;
  align-items: center;
  padding: 4px 10px 5px;
  border-bottom: 1px dashed var(--v7-line);
  margin-bottom: 3px;
  color: #51637f;
  letter-spacing: .05em;
}

body.ui-v7 .mini-leaderboard-panel .rank-list-head span:first-child {
  text-align: center;
}

body.ui-v7 .rank-list-head {
  letter-spacing: .08em;
}

/* ============ THE MOTION SET ============ */

@media (prefers-reduced-motion: no-preference) {

  /* one entrance, not two: the v6 per-card staggers yield to the page-level rise */
  body.ui-v7 .dashboard-page.active .dashboard-overview,
  body.ui-v7 .dashboard-page.active .dashboard-leaderboard,
  body.ui-v7 .dashboard-page.active .dashboard-usage-metrics .newapi-metric {
    animation: none;
  }

  /* 1) page switch: fade-rise, runs each time a console page is shown */
  body.ui-v7 .console-page {
    animation: v7-page-in .24s var(--v7-ease);
  }

  /* 2) chart bars grow from the baseline on every render */
  body.ui-v7 .hourly-svg-bar {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: v7-grow-y .55s var(--v7-ease) both;
  }

  body.ui-v7 .hourly-svg-cap,
  body.ui-v7 .hourly-svg-glow {
    animation: v7-fade-in .5s ease-out .3s both;
  }

  /* 3) live dot breathes slowly — the page feels alive, not busy */
  body.ui-v7 .dashboard-hourly-title::before {
    animation: v7-breathe 2.8s ease-in-out infinite;
  }

  /* 4) channel mini-bars inherit the same grow (hour-roll keeps its slide) */
  body.ui-v7 .channel-bar {
    transform-origin: center bottom;
    animation: v7-grow-y .4s var(--v7-ease) both;
  }

  /* 5) count-up numbers get a subtle settle highlight when they land */
  body.ui-v7 .v7-counted {
    animation: v7-settle .5s ease-out;
  }

  /* 6) mascot: flame flickers in pixel steps, hull bobs one pixel */
  body.ui-v7 .title-mascot {
    animation: v7-bob 2.4s steps(2, end) infinite;
  }

  body.ui-v7 .title-mascot .px-f1 {
    animation: v7-flick .5s steps(2, end) infinite;
  }

  body.ui-v7 .title-mascot .px-f2 {
    animation: v7-flick .5s steps(2, end) .12s infinite;
  }

  body.ui-v7 .title-mascot .px-f3 {
    animation: v7-flick .4s steps(2, end) .2s infinite;
  }
}

@keyframes v7-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-1px);
  }
}

@keyframes v7-flick {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .25;
  }
}

@keyframes v7-page-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes v7-grow-y {
  from {
    transform: scaleY(.02);
  }

  to {
    transform: scaleY(1);
  }
}

@keyframes v7-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes v7-breathe {

  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(42, 185, 146, .1);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(42, 185, 146, .22);
  }
}

@keyframes v7-settle {
  from {
    color: var(--v7-blue);
  }

  to {
    color: inherit;
  }
}
