/* ==========================================================================
 * Festival Studio - insights view
 *
 * Rules for this screen only (st-insights* classes); the shared kit is in
 * /studio/studio.css. Charts follow one small system:
 * - one accent hue. Single-series marks are --st-insights-series-1; the one
 *   two-series chart (page views / unique visitors, a whole and its part)
 *   adds a lighter step of the same hue, told apart by lightness, a legend
 *   and position, never by hue alone;
 * - thin marks, square on the baseline and rounded at the data end;
 * - hairline solid gridlines; text always in text tokens, never the series
 *   colour; tabular numerals wherever numbers line up.
 *
 * INDEX
 *  1. Page frame        st-insights  __body  __notices  __updated  __group
 *                       __heading  __lede  __note  __quiet  __split
 *  2. Figures row       st-insights-figures  st-insights-key
 *  3. Column chart      st-insights-chart  st-insights-tip  st-insights-daytable
 *  4. Bar list          st-insights-bars
 *  5. Funnel            st-insights-funnel
 *  6. Tables, who      st-insights-reg  st-insights-chips  st-insights-rank
 *                       st-insights-recent  st-insights-who
 *  7. Responsive, reduced motion
 * ========================================================================== */

/* ---------- 1. Page frame ---------- */
.st-insights {
  --st-insights-series-1: var(--st-violet);
  --st-insights-series-2: var(--st-lavender);
  --st-insights-grid: rgba(255, 255, 255, 0.07);
  --st-insights-axis: rgba(255, 255, 255, 0.2);
}

.st-insights__body { display: flex; flex-direction: column; gap: 32px; transition: opacity var(--st-ease); }
.st-insights__body.is-refreshing { opacity: 0.55; }
.st-insights__notices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.st-insights__updated { font-size: 12.5px; color: var(--st-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-insights__festival { color: var(--st-text); font-weight: 600; }

.st-insights__group { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.st-insights__group:empty { display: none; }
.st-insights__heading { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-height: 30px; }
.st-insights__heading h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.st-insights__heading .st-icon { color: var(--st-text-muted); }
.st-insights__heading-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.st-insights__heading-actions .st-btn .st-icon { color: inherit; }
.st-insights__lede { margin-top: -6px; font-size: 13px; line-height: 1.5; color: var(--st-text-muted); max-width: 96ch; }
.st-insights__note { font-size: 12.5px; line-height: 1.5; color: var(--st-text-muted); max-width: 110ch; }
.st-insights__quiet { font-size: 13.5px; color: var(--st-text-muted); }

/* The six ticket tiles hold one row, then fold to two rows of three (never four and two). */
.st-insights__tiles--six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
/* Five without Joined in the app (member passes off): one row, then three and two. */
.st-insights__tiles--five { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Ticket types beside the per-day chart: a third and two thirds. */
.st-insights__split { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 16px; }
.st-insights__split--solo { grid-template-columns: minmax(0, 1fr); }

/* ---------- 2. Figures row (the totals above a chart; doubles as its legend) ---------- */
.st-insights-figures { display: flex; flex-wrap: wrap; gap: 10px 36px; }
.st-insights-figures__item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-insights-figures dt { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--st-text-muted); }
.st-insights-figures dd { display: flex; align-items: baseline; gap: 8px; }
.st-insights-figures__value { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.st-insights-figures__note { font-size: 12.5px; color: var(--st-text-muted); white-space: nowrap; }

.st-insights-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.st-insights-key--1 { background: var(--st-insights-series-1); }
.st-insights-key--2 { background: var(--st-insights-series-2); }

/* ---------- 3. Column chart ---------- */
/* The height covers the plot and the date labels under it, so the card never
   grows a scrollbar of its own. */
.st-insights-chart { position: relative; height: 236px; border-radius: var(--st-r-8); touch-action: pan-y; }
.st-insights-chart:focus-visible { outline-offset: 4px; }
.st-insights-chart__plot { height: 100%; }
.st-insights-chart__svg { display: block; max-width: none; overflow: visible; }
.st-insights-chart__grid { stroke: var(--st-insights-grid); stroke-width: 1; shape-rendering: crispEdges; }
.st-insights-chart__axis { stroke: var(--st-insights-axis); stroke-width: 1; shape-rendering: crispEdges; }
.st-insights-chart__tick { fill: var(--st-text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.st-insights-chart__value { fill: var(--st-text-dim); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.st-insights-chart__bar { transition: opacity var(--st-ease); }
.st-insights-chart__bar--1 { fill: var(--st-insights-series-1); }
.st-insights-chart__bar--2 { fill: var(--st-insights-series-2); }
.st-insights-chart__band { fill: rgba(255, 255, 255, 0.05); }
.st-insights-chart.has-active .st-insights-chart__bar { opacity: 0.5; }
.st-insights-chart.has-active .st-insights-chart__bar.is-active { opacity: 1; }
.st-insights-chart.is-empty { height: 132px; }
.st-insights-chart__empty { height: 100%; display: grid; place-items: center; padding: 0 16px; text-align: center; font-size: 13.5px; color: var(--st-text-muted); }

.st-insights-tip {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; min-width: 132px; padding: 8px 10px;
  background: var(--st-bg-pop); border: 1px solid var(--st-border-strong); border-radius: var(--st-r-10);
  box-shadow: var(--st-shadow-pop); font-size: 12.5px; line-height: 1.5;
}
.st-insights-tip__title { margin-bottom: 2px; font-weight: 600; color: var(--st-text-dim); white-space: nowrap; }
.st-insights-tip__row { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--st-text-dim); }
.st-insights-tip__row strong { color: var(--st-text); font-variant-numeric: tabular-nums; }

/* Table view of a chart. The day is a row header; the kit styles every th
   as a sticky column header, which a row header must not be. */
.st-insights-daytable .st-table__scroll { max-height: 328px; }
.st-insights-daytable .st-table__table tbody th {
  position: static; height: 38px; padding: 6px 14px; background: transparent; border-bottom: 1px solid var(--st-border);
  font-size: 13.5px; font-weight: 500; letter-spacing: 0; color: var(--st-text); white-space: nowrap;
}
.st-insights-daytable .st-table__table td { height: 38px; }
.st-insights-daytable .st-table__row:last-child th { border-bottom: 0; }

/* ---------- 4. Bar list ---------- */
/* One grid for the whole list, so every bar starts on the same baseline and
   every value ends on the same edge. */
.st-insights-bars { display: grid; grid-template-columns: minmax(0, 44%) minmax(56px, 1fr) auto; column-gap: 14px; }
.st-insights-bars__row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center; min-height: 34px; }
.st-insights-bars__row--sub { min-height: 46px; }
.st-insights-bars__label { display: flex; flex-direction: column; justify-content: center; min-width: 0; line-height: 1.35; }
.st-insights-bars__title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; }
.st-insights-bars__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.st-insights-bars__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--st-text); }
/* Without a second line of its own, a long name may take two lines rather than lose its end. */
.st-insights-bars__row:not(.st-insights-bars__row--sub) { padding: 5px 0; }
.st-insights-bars__row:not(.st-insights-bars__row--sub) .st-insights-bars__name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow-wrap: anywhere; line-height: 1.3;
}
a.st-insights-bars__name:hover { text-decoration: underline; text-underline-offset: 3px; }
a.st-insights-bars__name:focus-visible { border-radius: 4px; outline-offset: 1px; }
.st-insights-bars__sub { font-size: 12.5px; color: var(--st-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Under a category dot the second line starts where the name does. */
.st-insights-bars__label--dot .st-insights-bars__sub { padding-left: 16px; }
.st-insights-bars__title .st-badge { height: 18px; padding: 0 6px; font-size: 11px; }
.st-insights-bars__bar { display: block; height: 12px; }
.st-insights-bars__bar rect { fill: var(--st-insights-series-1); }
.st-insights-bars__value { min-width: 3ch; text-align: right; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
@supports not (grid-template-columns: subgrid) {
  .st-insights-bars { display: block; }
  .st-insights-bars__row { grid-template-columns: minmax(0, 44%) minmax(56px, 1fr) minmax(5ch, auto); column-gap: 14px; }
}

/* ---------- 5. Funnel ---------- */
.st-insights-funnel { display: grid; grid-template-columns: repeat(var(--st-insights-steps, 5), minmax(0, 1fr)); }
.st-insights-funnel__step { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 0 36px 0 0; }
.st-insights-funnel__step:last-child { padding-right: 0; }
.st-insights-funnel__arrow { position: absolute; top: 30px; left: -27px; color: var(--st-text-muted); }
.st-insights-funnel__label { font-size: 12.5px; font-weight: 500; color: var(--st-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-insights-funnel__count { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.st-insights-funnel__step .st-insights-bars__bar { height: 8px; margin: 2px 0; }
.st-insights-funnel__share { font-size: 12.5px; line-height: 1.45; color: var(--st-text-muted); }
.st-insights-funnel__share strong { color: var(--st-text); font-variant-numeric: tabular-nums; }

/* ---------- 6. Tables, who can see this ---------- */
.st-insights-reg { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.st-insights-reg__name { font-weight: 600; overflow-wrap: anywhere; }
.st-insights-reg__email { font-size: 12.5px; color: var(--st-text-muted); overflow-wrap: anywhere; }
.st-insights-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-insights-rank { font-weight: 600; color: var(--st-text-dim); font-variant-numeric: tabular-nums; }
/* Folded: the last row shown already draws the line above the footer. */
.st-insights-recent.is-folded .st-table__footer { border-top: 0; }
.st-insights-recent .st-table__footer { padding-right: 10px; }

.st-insights-who { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.st-insights-who__icon { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--st-r-10); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--st-border); color: var(--st-text-dim); }
.st-insights-who__text { flex: 1 1 auto; min-width: 0; }
.st-insights-who__text .st-prose { margin-top: 2px; font-size: 13px; }

/* ---------- 7. Responsive, reduced motion ---------- */
@media (max-width: 1180px) {
  .st-insights__tiles--six, .st-insights__tiles--five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .st-insights__split { grid-template-columns: minmax(0, 1fr); }
  /* Steps stack: label and count on one line, the bar and its share under it. */
  .st-insights-funnel { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .st-insights-funnel__step { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 16px; padding: 0; }
  .st-insights-funnel__arrow { display: none; }
  .st-insights-funnel__label { font-size: 13.5px; color: var(--st-text); }
  .st-insights-funnel__count { font-size: 18px; text-align: right; }
  .st-insights-funnel__step .st-insights-bars__bar, .st-insights-funnel__share { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .st-insights__tiles--six, .st-insights__tiles--five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-insights-bars { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .st-insights-bars__row { padding: 6px 0; }
  .st-insights-bars__bar { grid-column: 1 / -1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .st-insights__body, .st-insights-chart__bar { transition: none; }
}
