/* ══════════════════════════════════════════════
   RESULTS > SUMMARY (Analyse charts per question)
   Views: app/views/studies/results/. Ported from SurveySwap's
   _results_summary.css and re-skinned to "Builder C · Glass and dock":
   glass cards on the app wash, Albert Sans, indigo first.
   Loaded by layouts/builder after survey_builder.css.
   ══════════════════════════════════════════════ */

.rs-summary {
  --rs-ink: #05061c;
  --rs-ink-2: #3a3f55;
  --rs-muted: #5a5f78;
  --rs-faint: #9296b5;
  --rs-line: #ececf3;
  --rs-track: #eeeff9;
  --rs-soft: #f5f5fc;
  --rs-brand: #3b40c4;
  --rs-brand-soft: #ebecf9;
  --rs-good: #137a67;

  flex: 1;
  min-height: 0;
  overflow-y: auto;
  color: var(--rs-ink);
  font-family: "Albert Sans", "Helvetica Neue", Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding: 4px 4px 48px;
  /* Room for the card shadows inside the scroll area */
  margin: 0 -4px;
}

.builder-results-shell--loading { opacity: 0.6; pointer-events: none; transition: opacity 120ms ease; }

/* Toolbar */
.rs-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.rs-toolbar-spacer { flex: 1; }
.rs-pill {
  display: inline-flex; align-items: center; max-width: 100%;
  background: rgba(255, 255, 255, 0.7); border-radius: 13px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  transition: background 120ms ease;
}
.rs-pill:hover { background: #fff; }
.rs-pill:focus-within { outline: 2px solid rgba(59, 64, 196, 0.35); outline-offset: 2px; }
.rs-pill select {
  appearance: none; -webkit-appearance: none; border: 0; background-color: transparent;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--rs-ink);
  height: 42px; padding: 0 34px 0 14px; max-width: 300px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a5f78' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px;
}
.rs-pill select:focus { outline: none; box-shadow: none; }
.rs-button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 13px; background: #fff; color: var(--rs-ink);
  font-size: 14.5px; font-weight: 600; text-decoration: none;
  box-shadow: 0 1px 2px rgba(5, 6, 28, 0.1), 0 0 0 0.5px rgba(5, 6, 28, 0.04);
  transition: color 120ms ease, box-shadow 120ms ease;
}
.rs-button:hover { color: var(--rs-brand); box-shadow: 0 4px 12px -4px rgba(5, 6, 28, 0.18), 0 0 0 0.5px rgba(5, 6, 28, 0.04); }

/* Stat tiles */
.rs-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.rs-kpi {
  background: rgba(255, 255, 255, 0.55); border-radius: 22px; padding: 16px 20px 15px;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}
.rs-kpi-n { font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.rs-kpi-l { margin-top: 2px; font-size: 14px; color: var(--rs-muted); }
.rs-kpi-d { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--rs-good); }

/* Cards */
.rs-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rs-card {
  min-width: 0; padding: 24px 26px; border-radius: 28px; scroll-margin-top: 16px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 30px 60px -36px rgba(5, 6, 28, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.9);
  animation: rs-rise 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.rs-card--wide { grid-column: 1 / -1; }
.rs-card--flash { animation: rs-flash 1.2s ease; }
@keyframes rs-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rs-flash {
  0%, 40% { box-shadow: 0 0 0 3px rgba(59, 64, 196, 0.35), 0 30px 60px -36px rgba(5, 6, 28, 0.3); }
  100% { box-shadow: 0 30px 60px -36px rgba(5, 6, 28, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.9); }
}

.rs-card-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.rs-card-heading { min-width: 0; }
.rs-qnum { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--rs-brand); }
.rs-qtype { padding: 2px 9px; border-radius: 999px; background: var(--rs-brand-soft); color: #2e329e; font-size: 12px; font-weight: 600; }
.rs-card-title { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; color: var(--rs-ink); overflow-wrap: anywhere; }
.rs-card-menu { display: flex; gap: 4px; flex-shrink: 0; margin: -4px -6px 0 0; }
.rs-icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 11px;
  background: transparent; color: var(--rs-faint); transition: background 120ms ease, color 120ms ease;
}
.rs-icon-btn:hover { background: var(--rs-soft); color: var(--rs-ink); }
.rs-icon-btn:focus-visible { outline: 2px solid rgba(59, 64, 196, 0.4); outline-offset: 1px; }
.rs-meta { margin: 4px 0 18px; font-size: 14px; color: var(--rs-muted); }
.rs-note { margin: 12px 0 0; font-size: 13px; color: var(--rs-muted); }
.rs-empty-q { margin: 0; padding: 16px 18px; border-radius: 16px; background: var(--rs-soft); color: var(--rs-muted); font-size: 14.5px; }
.rs-empty-filter { text-align: center; padding: 44px 24px; }
.rs-gap { margin-top: 18px; }

.rs-statline { display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 18px; }
.rs-big { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.rs-big small { margin-left: 6px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--rs-muted); }
.rs-stat-l { margin-top: 6px; font-size: 13px; color: var(--rs-muted); }

/* Bars */
.rs-bars { display: grid; gap: 10px; }
.rs-bar-row { display: grid; grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.rs-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rs-ink-2); }
.rs-bar-track { position: relative; height: 24px; overflow: hidden; border-radius: 8px; background: var(--rs-track); }
.rs-bar-fill {
  position: absolute; inset: 0 auto 0 0; min-width: 4px; border-radius: 8px; cursor: pointer;
  transform-origin: left; animation: rs-grow 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rs-grow { from { transform: scaleX(0); } }
.rs-bar-val { min-width: 76px; text-align: right; white-space: nowrap; font-size: 14px; color: var(--rs-muted); font-variant-numeric: tabular-nums; }
.rs-bar-val b, .rs-legend-val b { font-weight: 700; color: var(--rs-ink); }

/* Donut */
.rs-donut { display: flex; flex-wrap: wrap; gap: 28px; align-items: center; }
.rs-donut-svg { flex-shrink: 0; }
.rs-num-svg { font-family: "Albert Sans", "Helvetica Neue", Helvetica, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.rs-slice { cursor: pointer; outline: none; }
.rs-legend { display: grid; flex: 1; gap: 10px; min-width: 180px; }
.rs-legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.rs-legend-label { overflow-wrap: anywhere; color: var(--rs-ink-2); }
.rs-swatch { width: 12px; height: 12px; border-radius: 4px; }
.rs-legend-val { white-space: nowrap; font-size: 14px; color: var(--rs-muted); font-variant-numeric: tabular-nums; }

/* Columns */
.rs-cols { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.rs-cols-axis {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  height: var(--rs-cols-h); padding-bottom: 24px; font-size: 11px; color: var(--rs-faint); font-variant-numeric: tabular-nums;
}
.rs-cols-axis span { line-height: 0; }
.rs-cols-plot { position: relative; height: var(--rs-cols-h); }
.rs-cols-grid { position: absolute; inset: 0 0 24px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.rs-cols-grid i { display: block; height: 1px; background: var(--rs-line); }
.rs-cols-bars { position: absolute; inset: 0; display: flex; gap: 6px; }
.rs-cols-bars--dense { gap: 2px; }
.rs-col { display: flex; flex: 1 1 0; flex-direction: column; min-width: 0; cursor: pointer; outline: none; }
.rs-col-stage { display: flex; flex: 1; align-items: flex-end; justify-content: center; padding-top: 16px; }
.rs-col-fill {
  position: relative; width: min(70%, 44px); min-height: 2px; border-radius: 6px 6px 0 0;
  transform-origin: bottom; animation: rs-rise-col 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.rs-cols-bars--dense .rs-col-fill { width: 80%; border-radius: 3px 3px 0 0; }
@keyframes rs-rise-col { from { transform: scaleY(0); } }
.rs-col-val {
  position: absolute; bottom: 100%; left: 50%; margin-bottom: 3px; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--rs-ink-2); font-variant-numeric: tabular-nums;
}
.rs-col-label { height: 24px; line-height: 24px; overflow: visible; text-align: center; white-space: nowrap; font-size: 12px; color: var(--rs-muted); }
.rs-col:hover .rs-col-fill, .rs-col:focus-visible .rs-col-fill,
.rs-bar-fill:hover, .rs-bar-fill:focus-visible, .rs-seg:hover, .rs-seg:focus-visible,
.rs-slice:hover, .rs-slice:focus-visible { filter: brightness(1.1); }
.rs-col:focus-visible .rs-col-fill, .rs-bar-fill:focus-visible, .rs-seg:focus-visible { outline: 2px solid var(--rs-ink); outline-offset: 1px; }

/* Stacked rows */
.rs-stack-rows { display: grid; gap: 12px; }
.rs-stack-row--labelled { display: grid; grid-template-columns: minmax(90px, 30%) minmax(0, 1fr); gap: 14px; align-items: center; }
.rs-stack-label { color: var(--rs-ink-2); overflow-wrap: anywhere; }
.rs-stack { display: flex; gap: 2px; height: 28px; overflow: hidden; border-radius: 9px; background: var(--rs-track); }
.rs-seg {
  display: grid; place-items: center; height: 100%; min-width: 0; overflow: hidden; cursor: pointer; outline: none;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.rs-seg--empty { flex: 1; color: var(--rs-muted); font-weight: 500; cursor: default; }
.rs-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 2px; font-size: 13px; color: var(--rs-muted); }
.rs-key i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }

/* Text answers */
.rs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.rs-chip {
  padding: 5px 12px; border: 0; border-radius: 999px; background: var(--rs-brand-soft); color: #2e329e;
  font: inherit; font-size: 14px; font-weight: 500; transition: background 120ms ease;
}
.rs-chip:hover { background: #e4e6f8; }
.rs-chip span { margin-left: 5px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.rs-search {
  width: 100%; margin-bottom: 10px; padding: 10px 14px; border: 1px solid var(--rs-line); border-radius: 14px;
  background: #fff; color: var(--rs-ink); font: inherit; font-size: 15px;
}
.rs-search:focus { outline: none; border-color: var(--rs-brand); box-shadow: 0 0 0 3px rgba(59, 64, 196, 0.16); }
.rs-answers { display: grid; gap: 8px; max-height: 280px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.rs-answers--short { max-height: none; }
.rs-answers li { padding: 11px 14px; border-radius: 14px; background: var(--rs-soft); overflow-wrap: anywhere; }
.rs-answers li[hidden] { display: none; }
.rs-answers time { display: block; margin-top: 2px; font-size: 12px; color: var(--rs-faint); }
.rs-answers .rs-answers-empty { background: transparent; color: var(--rs-muted); }

.rs-other { margin-top: 14px; font-size: 14px; color: var(--rs-muted); }
.rs-other summary { font-weight: 600; color: var(--rs-ink-2); }
.rs-other ul { display: grid; gap: 4px; margin: 8px 0 0; padding-left: 18px; }

/* Timeline */
.rs-timeline { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; }
.rs-timeline-axis {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  height: 140px; font-size: 11px; color: var(--rs-faint); font-variant-numeric: tabular-nums;
}
.rs-timeline-axis span { line-height: 0; }
.rs-timeline-plot { position: relative; height: 140px; }
.rs-timeline-plot .rs-cols-grid { inset: 0; }
.rs-timeline-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rs-timeline-hits { position: absolute; inset: 0; }
.rs-timeline-hit { position: absolute; top: 0; bottom: 0; width: 28px; transform: translateX(-50%); cursor: pointer; outline: none; }
.rs-timeline-hit::after {
  content: ""; position: absolute; left: 50%; top: var(--rs-dot-top); width: 10px; height: 10px;
  border-radius: 50%; background: var(--rs-brand); box-shadow: 0 0 0 2px #fff;
  transform: translate(-50%, -50%) scale(0); transition: transform 100ms ease;
}
.rs-timeline-hit:hover::after, .rs-timeline-hit:focus-visible::after { transform: translate(-50%, -50%) scale(1); }
.rs-timeline-labels { position: relative; grid-column: 2; height: 24px; font-size: 12px; color: var(--rs-muted); }
.rs-timeline-labels span { position: absolute; top: 7px; transform: translateX(-50%); white-space: nowrap; }
.rs-timeline-labels span:first-child { transform: none; }
.rs-timeline-labels span:last-child { transform: translateX(-100%); }

/* Tooltip + toast */
.rs-tip {
  position: fixed; z-index: 160; max-width: 280px; padding: 8px 11px; border-radius: 12px; pointer-events: none;
  background: var(--rs-ink); color: #fff; font-size: 13px; line-height: 1.45;
  box-shadow: 0 10px 24px -6px rgba(5, 6, 28, 0.35);
}
.rs-tip[hidden], .rs-toast[hidden] { display: none; }
.rs-tip b { font-weight: 600; }
.rs-toast {
  position: fixed; z-index: 160; left: 50%; bottom: 104px; max-width: calc(100vw - 32px); transform: translateX(-50%);
  padding: 11px 18px; border-radius: 999px; background: var(--rs-ink); color: #fff; text-align: center;
  font-size: 14px; font-weight: 500; box-shadow: 0 12px 28px -8px rgba(5, 6, 28, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .rs-card, .rs-bar-fill, .rs-col-fill, .rs-card--flash { animation: none; }
}

@media (max-width: 760px) {
  .rs-cards { grid-template-columns: minmax(0, 1fr); }
  .rs-card { padding: 18px; border-radius: 22px; }
  .rs-toolbar-spacer { display: none; }
  .rs-pill select { max-width: 200px; }
  .rs-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .rs-bar-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .rs-bar-row .rs-bar-track { grid-column: 1 / -1; grid-row: 2; }
  .rs-stack-row--labelled { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .rs-donut { justify-content: center; }
  .rs-legend { min-width: 100%; }
  .rs-big { font-size: 30px; }
}
