/* ---------------- statistics page, site style ---------------- */
.stats-page {
  width: min(1180px, 100%);
}

.stats-head {
  margin-bottom: clamp(1rem, 2.4vw, 1.6rem);
}

.stats-head h1 span {
  font-weight: 500;
  background: linear-gradient(100deg, #f2c879 5%, #ffe9bd 54%, #f2c879 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- project picker ---------- */
.stats-picker .project-card {
  align-items: center;
}

.stats-picker .pc-icon {
  position: relative;
}

.stats-picker .pc-state {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  margin-left: auto;
  flex: 0 0 auto;
  font-size: .52rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6f6b62;
}

.stats-picker .pc-state svg {
  width: 10px;
  height: 10px;
}

.pc-live-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(38, 217, 127, .8);
  animation: stats-live 1.8s ease-out infinite;
}

.stats-picker .project-card.is-active .pc-state {
  color: color-mix(in srgb, var(--accent) 76%, white);
}

.pc-lock-badge {
  position: absolute;
  right: 1px;
  bottom: 1px;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 5px;
  background: rgba(8, 8, 11, .9);
  color: var(--muted);
}

.pc-lock-badge svg {
  width: 8px;
  height: 8px;
}

/* ---------- project panel ---------- */
.stats-view .project-banner {
  height: clamp(145px, 18vw, 200px);
}

.stats-view .project-body {
  padding-top: 1rem;
}

.stats-view .chips {
  margin-bottom: 1rem;
}

.stats-dashboard {
  min-width: 0;
}

/* chart range switch */
.stats-range {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .25rem;
  margin-bottom: .5rem;
}

.stats-range-btn {
  font: inherit;
  font-size: .56rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8f8a81;
  background: rgba(255, 255, 255, .025);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 999px;
  padding: .3rem .58rem;
  transition:
    color .2s ease,
    border-color .2s ease,
    background-color .2s ease,
    box-shadow .2s ease;
}

.stats-range-btn:hover,
.stats-range-btn:focus-visible {
  color: var(--gold);
  border-color: rgba(242, 200, 121, .38);
  background: rgba(242, 200, 121, .06);
  outline: none;
}

.stats-range-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .14);
}

.stats-range-btn.is-active {
  color: color-mix(in srgb, var(--gold) 88%, white);
  border-color: rgba(242, 200, 121, .45);
  background: rgba(242, 200, 121, .1);
  box-shadow: 0 0 16px -8px rgba(242, 200, 121, .5);
}

/* main live cards */
.stats-main-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.stats-main-card {
  --card-accent: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: .9rem 1rem .75rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background:
    radial-gradient(90% 95% at 0% 0%, color-mix(in srgb, var(--card-accent) 12%, transparent), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .012));
}

.stats-main-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: .9rem;
  right: .9rem;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    color-mix(in srgb, var(--card-accent) 58%, transparent),
    transparent);
  opacity: .7;
}

.stats-main-card.is-bots {
  --card-accent: #2ee6c4;
}

.stats-main-card .stats-big {
  margin: .4rem 0 .1rem;
  font-size: clamp(2.6rem, 5vw, 4.1rem);
  text-shadow: 0 0 32px color-mix(in srgb, var(--card-accent) 28%, transparent);
}

.stats-main-record {
  display: block;
  margin-bottom: .1rem;
  font-size: .58rem;
  letter-spacing: .02em;
  color: #6f6b62;
}

.stats-main-record strong {
  color: #c9c4b9;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stats-main-record span {
  color: #5f5b54;
}

.stats-main-card .stats-graph {
  min-height: 86px;
  margin-top: .55rem;
  padding: .45rem .5rem .35rem;
  border-radius: 12px;
}

.stats-main-card .stats-graph svg {
  height: 56px;
}

.stats-main-card.is-bots .stats-graph-line {
  stroke: var(--card-accent);
  filter: drop-shadow(0 0 4px rgba(46, 230, 196, .5));
}

.stats-main-card.is-bots .stats-graph-dot {
  stroke: #b9fff3;
  filter: drop-shadow(0 0 5px rgba(46, 230, 196, .75));
}

.stats-secondary {
  margin-top: .5rem;
}

/* primary readout */
.stats-primary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(215px, .9fr);
  gap: 1rem;
  align-items: stretch;
  padding: 1rem 1.1rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background:
    radial-gradient(82% 100% at 0% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .012));
}

.stats-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 1rem;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    color-mix(in srgb, var(--accent) 55%, transparent),
    transparent);
  opacity: .65;
}

.stats-primary-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stats-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-eyebrow svg {
  width: 14px;
  height: 14px;
  color: color-mix(in srgb, var(--accent) 75%, white);
}

.stats-big {
  display: block;
  margin: .55rem 0 .1rem;
  font-size: clamp(2.9rem, 6.4vw, 4.7rem);
  font-weight: 300;
  line-height: .9;
  letter-spacing: -.055em;
  color: #f8f4ea;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 32px color-mix(in srgb, var(--accent) 28%, transparent);
}

.stats-sub {
  margin-top: auto;
  color: #8f8a81;
  font-size: .7rem;
  line-height: 1.5;
}

.stats-graph {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 112px;
  padding: .55rem .6rem .45rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, .005)),
    rgba(8, 8, 11, .28);
}

.stats-graph::before {
  content: "";
  position: absolute;
  inset: .55rem .55rem 1.4rem;
  z-index: 0;
  pointer-events: none;
  opacity: .65;
  background-image: repeating-linear-gradient(180deg,
    rgba(255, 255, 255, .035) 0 1px,
    transparent 1px 15px);
}

.stats-graph svg,
.stats-graph-label {
  position: relative;
  z-index: 1;
}

.stats-graph-empty {
  position: absolute;
  inset: 0 0 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: .54rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6f6b62;
  pointer-events: none;
}

.stats-graph-empty[hidden] { display: none; }

.stats-graph svg {
  display: block;
  width: 100%;
  height: 68px;
  overflow: visible;
}

.stats-graph-area {
  fill: url(#statsSparkFill);
  opacity: .7;
  transition: opacity .4s ease;
}

.stats-graph-line {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 72%, white);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 45%, transparent));
}

.stats-graph-dot {
  fill: #fff;
  stroke: color-mix(in srgb, var(--accent) 80%, white);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 75%, transparent));
  transition: opacity .4s ease;
  transform-box: fill-box;
  transform-origin: center;
  animation: stats-dot 2.4s ease-out infinite;
}

.stats-graph-label {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 1.15rem;
  margin-top: .3rem;
  font-size: .52rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6f6b62;
}

.stats-graph-label > [data-chart-label] {
  transition: opacity .15s ease;
}

.stats-graph.is-hovering .stats-graph-label > [data-chart-label] {
  opacity: 0;
}

.stats-graph-readout {
  position: absolute;
  right: 0;
  bottom: -.05rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem .46rem .2rem .38rem;
  border: 1px solid color-mix(in srgb, var(--card-accent) 32%, rgba(255, 255, 255, .08));
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .012)),
    rgba(8, 8, 11, .88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .055),
    0 0 18px -12px var(--card-accent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(2px) scale(.97);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}

.stats-graph-readout.is-visible {
  opacity: 1;
  transform: none;
}

.stats-graph-readout::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--card-accent);
  box-shadow: 0 0 8px var(--card-accent);
}

.readout-time {
  font-size: .46rem;
  letter-spacing: .05em;
  color: #8f8a81;
}

.readout-value {
  display: inline-flex;
  align-items: baseline;
  gap: .18rem;
}

.readout-value strong {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: -.02em;
  color: color-mix(in srgb, var(--card-accent) 55%, white);
  font-variant-numeric: tabular-nums;
}

.readout-value small {
  font-size: .43rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6f6b62;
}

/* hover readout */
.stats-graph {
  cursor: crosshair;
}

.stats-graph-hover-line {
  stroke: color-mix(in srgb, var(--card-accent) 62%, white);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--card-accent) 45%, transparent));
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: none;
}

.stats-graph-hover-halo {
  fill: color-mix(in srgb, var(--card-accent) 30%, transparent);
  stroke: none;
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: none;
}

.stats-graph-hover-dot {
  fill: #fff;
  stroke: color-mix(in srgb, var(--card-accent) 82%, white);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--card-accent) 65%, transparent));
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: none;
}

.stats-main-card.is-bots .stats-graph-hover-dot {
  stroke: #b9fff3;
  filter: drop-shadow(0 0 5px rgba(46, 230, 196, .75));
}

/* compact stat rows */
.stats-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
  margin-top: .55rem;
}

.stat-line {
  --tone: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: .6rem;
  padding: .62rem .72rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .033), rgba(255, 255, 255, .007)),
    rgba(9, 9, 13, .28);
  transition: border-color .22s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}

.stat-line:hover {
  border-color: color-mix(in srgb, var(--tone) 28%, transparent);
  transform: translateY(-1px);
}

.stat-line.is-teal { --tone: #2ee6c4; }
.stat-line.is-violet { --tone: #9a7bff; }

.stat-line-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--tone) 24%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 10%, transparent);
  color: color-mix(in srgb, var(--tone) 82%, white);
}

.stat-line-icon svg { width: 14px; height: 14px; }

.stat-line-main {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}

.stat-line-label {
  font-size: .55rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-line-record {
  font-size: .53rem;
  letter-spacing: .01em;
  color: #6f6b62;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-line-record strong {
  color: #a7a298;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stat-line-value {
  justify-self: end;
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.035em;
  color: #f2eee6;
  font-variant-numeric: tabular-nums;
}

.stat-line-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, .04);
}

.stat-line-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--tone), #2ee6c4);
  box-shadow: 0 0 8px color-mix(in srgb, var(--tone) 45%, transparent);
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}

/* footer */
.stats-foot {
  display: flex;
  align-items: center;
  gap: .4rem 1.1rem;
  flex-wrap: wrap;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
  font-size: .68rem;
  color: #6f6b62;
}

.stats-foot-item {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  white-space: nowrap;
}

.stats-foot-item strong {
  color: #d8d3c9;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stats-foot-live {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(38, 217, 127, .8);
  animation: stats-live 1.8s ease-out infinite;
}

.stats-stale {
  margin: .75rem 0 0;
  padding: .55rem .72rem;
  border: 1px dashed rgba(255, 190, 110, .24);
  border-radius: 10px;
  background: rgba(255, 190, 110, .04);
  color: #bda98c;
  font-size: .72rem;
  line-height: 1.55;
}

.stats-stale[hidden] { display: none; }

/* loading */
.stats-view.is-waiting .stats-big,
.stats-view.is-waiting .stat-line-value {
  color: transparent;
  background: linear-gradient(100deg,
    rgba(255, 255, 255, .09) 20%,
    rgba(255, 255, 255, .24) 42%,
    rgba(255, 255, 255, .09) 64%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: stats-shimmer 1.15s linear infinite;
}

/* value updates */
.stats-big.is-bumped,
.stat-line-value.is-bumped {
  animation: stats-bump .46s cubic-bezier(.2, .8, .2, 1);
}

/* locked statistics */
.stats-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .65rem;
  margin-top: .35rem;
  padding: 2.5rem 1rem;
  border: 1px dashed rgba(255, 255, 255, .14);
  border-radius: 16px;
  background: rgba(255, 255, 255, .02);
  text-align: center;
  color: var(--muted);
}

.stats-lock-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: color-mix(in srgb, var(--accent) 80%, white);
}

.stats-lock-mark svg {
  width: 24px;
  height: 24px;
}

.stats-locked h3 {
  margin: .15rem 0 0;
  font-size: 1.08rem;
  font-weight: 500;
  letter-spacing: -.01em;
  color: #f1ece2;
}

.stats-locked p {
  max-width: 46ch;
  margin: 0;
  font-size: .88rem;
  line-height: 1.65;
}

.stats-locked small {
  font-size: .6rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6f6b62;
}

/* animation */
@keyframes stats-live {
  0% { box-shadow: 0 0 0 0 rgba(38, 217, 127, .45); }
  70% { box-shadow: 0 0 0 7px rgba(38, 217, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(38, 217, 127, 0); }
}

@keyframes stats-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.45); }
}

@keyframes stats-bump {
  0% { transform: translateY(0); filter: brightness(1); }
  35% { transform: translateY(-2px); filter: brightness(1.25); }
  100% { transform: translateY(0); filter: brightness(1); }
}

@keyframes stats-shimmer {
  from { background-position: 180% 0; }
  to { background-position: -80% 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .stats-primary {
    grid-template-columns: 1fr;
  }

  .stats-graph {
    min-height: 98px;
  }

  .stats-graph svg {
    height: 58px;
  }
}

@media (max-width: 700px) {
  .stats-view .project-banner {
    height: 158px;
  }
}

@media (max-width: 560px) {
  .stats-picker .project-card {
    flex: 1 1 0;
    min-width: 0;
  }

  .stats-picker .pc-state {
    display: none;
  }
}

@media (max-width: 460px) {
  .stats-picker .pc-state {
    font-size: .48rem;
    letter-spacing: .1em;
  }

  .stats-main-card {
    padding: .7rem .65rem .6rem;
    border-radius: 14px;
  }

  .stats-main-card .stats-big {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }

  .stats-main-card .stats-graph {
    min-height: 72px;
    padding: .35rem .4rem .3rem;
  }

  .stats-main-card .stats-graph svg {
    height: 44px;
  }

  .stats-main-record {
    font-size: .52rem;
  }

  .stats-graph-label {
    font-size: .45rem;
    letter-spacing: .1em;
  }

  .stats-graph-readout {
    gap: .28rem;
    padding: .18rem .38rem;
  }

  .readout-time {
    font-size: .42rem;
    letter-spacing: .02em;
  }

  .readout-value strong {
    font-size: .64rem;
  }

  .readout-value small {
    display: none;
  }

  .stat-line {
    grid-template-columns: 26px minmax(0, 1fr) auto;
    gap: .5rem;
    padding: .55rem .62rem;
  }

  .stat-line-label {
    font-size: .52rem;
    letter-spacing: .1em;
  }

  .stat-line-record {
    font-size: .5rem;
  }

  .stat-line-icon {
    width: 26px;
    height: 26px;
  }

  .stat-line-value {
    font-size: 1.18rem;
  }

  .stats-big {
    font-size: clamp(2.7rem, 16vw, 3.8rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pc-live-dot,
  .stats-foot-live,
  .stats-graph-dot,
  .stats-big.is-bumped,
  .stat-line-value.is-bumped,
  .stats-view.is-waiting .stats-big,
  .stats-view.is-waiting .stat-line-value {
    animation: none !important;
  }
}
