/* AI Stats Panel Demo — flat viewport layout, no perspective */

/* Panel palette: on shell so homepage embed keeps the designed look
   without overriding the site’s :root / html.theme-light tokens. */
html.theme-light,
.asp-shell {
  --background-1: #dbdbdb;
  --background-2: #e7e7e7;
  --background-3: #ffffff;
  --background-4: #d1d1d1;
  --foreground: #3e4244;
  --foreground-diminished: #3e424499;
  --selected: #000000;
  --accent: #288cef;
  --red: #e5524f;
  --yellow: #c48941;
  --green: #4db35c;
  --gray: #bfbfbf;
  --contour: #121212;
  --shadow: #c6c6c6;
  color-scheme: light;
}

html.theme-light *,
html.theme-light *::before,
html.theme-light *::after {
  box-sizing: border-box;
}

html.theme-light,
body.asp-page {
  height: 100%;
}

body.asp-page {
  margin: 0;
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background-1);
}

/* Shell: header + panel filling remaining viewport (standalone) */
.asp-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background-1);
  box-sizing: border-box;
}

.asp-shell *,
.asp-shell *::before,
.asp-shell *::after {
  box-sizing: border-box;
}

/* Homepage embed: content-height, sits inside a .section */
.asp-shell--embed {
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: visible;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--contour) 12%, transparent);
}

.asp-shell--embed .asp-panel {
  overflow: visible;
  flex: none;
}

.asp-header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem) 0 0.75rem;
}

/* Search */
.asp-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(640px, 100%);
  margin-inline: auto;
  min-height: calc(2rem + 4px);
  padding: 0.35rem 0.5rem;
  border-radius: 0.25rem;
  border-style: solid;
  border-width: 0 0 2px;
  border-bottom-color: var(--shadow);
  background-color: var(--background-2);
  color: var(--foreground);
  transition:
    background-color 0.125s,
    border-color 0.125s,
    outline-color 0.125s;
}

.asp-search.is-thinking {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.asp-search-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.asp-search-field {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 1.4em;
}

.asp-search-placeholder {
  position: absolute;
  inset: 0;
  font-size: inherit;
  font-weight: 700;
  color: var(--foreground-diminished);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.asp-search-placeholder[hidden],
.asp-search-field.is-typing .asp-search-placeholder,
.asp-search-field.has-text .asp-search-placeholder {
  display: none;
}

.asp-search-text {
  position: relative;
  margin: 0;
  min-height: 1.4em;
  font-weight: 700;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asp-cursor {
  flex: 0 0 auto;
  width: 2px;
  height: 1.1em;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

.asp-cursor.is-visible {
  opacity: 1;
  animation: asp-blink 1s step-end infinite;
}

@keyframes asp-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Recent scenario chips */
.asp-recent {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.asp-recent-btn {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: calc(2rem + 4px);
  padding: 0 0.5rem;
  border-style: solid;
  border-width: 0 0 2px;
  border-bottom-color: var(--shadow);
  border-radius: 0.25rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--foreground);
  background-color: var(--background-2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background-color 0.125s,
    border-color 0.125s;
}

@media (hover: hover) {
  .asp-recent-btn:hover {
    background-color: var(--background-3);
  }
}

.asp-recent-btn.is-active {
  background-color: var(--background-3);
  border-color: var(--background-3);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Panel sits under the header; content top-aligned (no stretch-to-fill) */
.asp-panel {
  flex: 1 1 auto;
  min-height: 0;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0.5rem clamp(0.75rem, 2.5vw, 1.25rem) clamp(0.75rem, 2vw, 1.25rem);
  overflow: auto;
  align-self: stretch;
}

.asp-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: minmax(8.5rem, auto);
  gap: 0.5rem;
  width: 100%;
  height: auto;
  align-content: start;
}

/* Tiles */
.asp-tile {
  min-height: 8.5rem;
  min-width: 0;
  padding: 1rem;
  border-radius: 0.25rem;
  border: 2px solid var(--background-2);
  background: var(--background-2);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: hidden;
}

.asp-tile--hero {
  min-height: 9.5rem;
  justify-content: center;
  background: var(--background-3);
  border-color: var(--background-3);
}

.asp-tile--wide {
  min-height: 9.5rem;
}

.asp-tile--tall {
  min-height: 12rem;
}

.asp-tile-label {
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--foreground-diminished);
}

.asp-tile-value {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.asp-tile-value--sm {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

.asp-tile-value--text {
  font-size: clamp(1.35rem, 3vw, 2rem);
  color: var(--accent);
}

.asp-tile-sub,
.asp-tile-delta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--foreground-diminished);
}

.asp-tile-delta {
  font-weight: 700;
}

.asp-tile-delta--up,
.asp-tile-delta--down {
  color: var(--green);
}

/* Bars */
.asp-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.55rem;
  flex: 1;
  min-height: 0;
}

.asp-bar-row {
  display: grid;
  grid-template-columns: minmax(5rem, 8rem) 1fr 4.25rem;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
}

.asp-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asp-bar-track {
  height: 0.55rem;
  border-radius: 0.125rem;
  background: var(--background-4);
  overflow: hidden;
}

.asp-bar-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.asp-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--foreground-diminished);
}

/* Columns */
.asp-columns {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.35rem;
  flex: 1;
  min-height: 0;
  padding-top: 0.25rem;
}

.asp-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  font-size: 0.75rem;
  color: var(--foreground-diminished);
}

.asp-col-bar {
  display: block;
  width: 100%;
  max-width: 2rem;
  margin-top: auto;
  height: 0;
  border-radius: 0.125rem 0.125rem 0 0;
  background: var(--accent);
  opacity: 0.85;
}

.asp-col--peak .asp-col-bar {
  background: var(--yellow);
  opacity: 1;
}

.asp-col--peak {
  color: var(--foreground);
  font-weight: 700;
}

/* Heatmap */
.asp-heatmap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  flex: 1;
  min-height: 0;
}

.asp-heat-cell {
  border-radius: 2px;
  background: var(--background-2);
  transform-origin: center;
}

.asp-heatmap-axis {
  display: flex;
  justify-content: space-between;
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--foreground-diminished);
}

/* Donut */
.asp-donut-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

.asp-donut {
  width: clamp(4.5rem, 12vh, 6.5rem);
  height: clamp(4.5rem, 12vh, 6.5rem);
  flex: 0 0 auto;
  transform: rotate(-90deg);
}

.asp-donut-ring,
.asp-donut-seg {
  fill: none;
  stroke-width: 14;
}

.asp-donut-ring {
  stroke: var(--background-4);
}

.asp-donut-seg--a {
  stroke: var(--accent);
}

.asp-donut-seg--b {
  stroke: var(--yellow);
}

.asp-donut-seg--c {
  stroke: var(--gray);
}

.asp-legend {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--foreground);
}

.asp-swatch {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 2px;
  vertical-align: middle;
}

.asp-swatch--a {
  background: var(--accent);
}

.asp-swatch--b {
  background: var(--yellow);
}

.asp-swatch--c {
  background: var(--gray);
}

/* Sparkline */
.asp-sparkline {
  flex: 1;
  width: 100%;
  min-height: 0;
}

.asp-sparkline-area {
  fill: color-mix(in srgb, var(--accent) 18%, transparent);
}

.asp-sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Narrow screens: allow scroll instead of crushing tiles */
@media (max-width: 720px) {
  body.asp-page {
    overflow: auto;
  }

  body.asp-page .asp-shell:not(.asp-shell--embed) {
    height: auto;
    min-height: 100dvh;
    max-height: none;
  }

  .asp-panel {
    overflow: visible;
    flex: none;
  }

  .asp-grid {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .asp-tile {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    min-height: 9rem;
  }

  .asp-tile--wide,
  .asp-tile--hero {
    min-height: 11rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asp-cursor.is-visible {
    animation: none;
  }
}
