/* Campaign report dashboards: /results/<slug>
   Rendered by js/case-report.js from /api/case-report (live) or
   /data/case-reports/<slug>.json (fallback snapshot).
   Palette mirrors the homepage case-study cards so the click-through from a
   card lands somewhere that clearly belongs to it. */

.cr {
  --cr-accent: #3556d4;
  --cr-accent-bg: rgba(85, 125, 255, 0.10);
  --cr-tile: rgba(85, 125, 255, 0.05);
  --cr-hot: rgba(85, 125, 255, 0.45);
  --cr-area-top: rgba(85, 125, 255, 0.28);
  --cr-area-bottom: rgba(85, 125, 255, 0);
  --cr-grid: rgba(14, 14, 12, 0.07);
}
[data-theme="dark"] .cr {
  --cr-accent: #7da6ff;
  --cr-accent-bg: rgba(125, 166, 255, 0.12);
  --cr-tile: rgba(255, 255, 255, 0.04);
  --cr-hot: rgba(125, 166, 255, 0.45);
  --cr-area-top: rgba(125, 166, 255, 0.32);
  --cr-area-bottom: rgba(125, 166, 255, 0);
  --cr-grid: rgba(255, 255, 255, 0.07);
}

/* --- Hero ------------------------------------------------------------ */
.cr-hero { padding: clamp(28px, 4vw, 48px) 0 clamp(20px, 3vw, 32px); }
.cr-back { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--muted); text-decoration: none; min-height: 44px; }
.cr-back:hover { color: var(--ink); }
.cr-back:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 3px; border-radius: 6px; }

.cr-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 28px; margin-top: 6px; }
.cr-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.cr-id > div { min-width: 0; }
.cr-avatar { flex: none; width: 64px; height: 64px; border-radius: 16px; background: var(--cr-accent-bg) center / cover no-repeat; border: 1px solid var(--line); }
.cr-title { margin: 0; font-size: clamp(1.9rem, 4.4vw, 2.9rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; color: var(--ink); text-wrap: balance; }
.cr-meta { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
/* scope note, e.g. "These stats cover 4 of the 7 campaigns..." */
.cr-note { display: flex; align-items: flex-start; gap: 10px; max-width: 640px; margin: 20px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--cr-accent-bg); border: 1px solid var(--cr-hot); font-size: 0.88rem; line-height: 1.5; color: var(--ink-soft); }
.cr-note svg { flex: none; margin-top: 2px; color: var(--cr-accent); }

/* --- KPIs ------------------------------------------------------------ */
.cr-kpis { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.cr-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; container-type: inline-size; }
.cr-kpi-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cr-kpi-value { margin-top: 6px; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cr-kpi-sub { margin-top: 2px; font-size: 0.8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.cr-kpi--hero { grid-row: span 2; display: flex; flex-direction: column; justify-content: space-between; background: var(--cr-accent-bg); border-color: var(--cr-hot); }
.cr-kpi--hero .cr-kpi-value { font-size: clamp(2.6rem, 6vw, 3.8rem); line-height: 1; color: var(--cr-accent); }
.cr-kpi--hero .cr-kpi-label { color: var(--cr-accent); }
.cr-kpi--accent .cr-kpi-value { color: var(--cr-accent); }
/* "approved / total" is the widest KPI value (up to ~7em, e.g. "1,234 / 23,481")
   and CuriousMike's count is still climbing, so size it to its own tile
   (cqi = 1% of the tile's width) rather than the viewport: it stays on one
   line whatever the count. The vw rules in the media queries below are the
   fallback for browsers without container units. */
.cr-kpi-value[data-cr="approved"] { font-size: 1.5rem; font-size: clamp(0.75rem, 13.8cqi, 1.5rem); }

/* --- Body cards ------------------------------------------------------ */
.cr-body { display: grid; gap: 16px; padding-bottom: clamp(40px, 6vw, 72px); }
.cr-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(16px, 2.4vw, 24px); min-width: 0; }
.cr-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cr-card-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ink); }
.cr-card-note { font-size: 0.8rem; color: var(--muted); }

/* chart */
.cr-chart-wrap { position: relative; height: clamp(220px, 32vw, 320px); }
.cr-chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; border-radius: 8px; }
.cr-chart-wrap svg:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 4px; }
.cr-chart-wrap .cr-axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.cr-tip { position: absolute; top: 0; pointer-events: none; transform: translateX(-50%); padding: 8px 10px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 0.78rem; line-height: 1.35; white-space: nowrap; opacity: 0; transition: opacity 120ms ease; font-variant-numeric: tabular-nums; z-index: 2; }
.cr-tip strong { display: block; font-size: 0.92rem; }
.cr-chart-wrap.is-hover .cr-tip { opacity: 1; }

/* platforms */
/* One column per platform (js sets data-n), so rows never leave one stranded. */
.cr-plats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px 32px; margin: 0; padding: 0; list-style: none; }
.cr-plats[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cr-plats[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cr-plats[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cr-plats[data-n="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cr-plat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.9rem; }
.cr-plat-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.cr-plat-name svg { flex: none; }
.cr-plat-num { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.cr-plat-num small { margin-left: 6px; color: var(--muted); font-weight: 600; }
.cr-bar { margin-top: 7px; height: 8px; border-radius: 999px; background: var(--cr-tile); overflow: hidden; }
.cr-bar span { display: block; height: 100%; border-radius: inherit; background: var(--cr-accent); transform-origin: left; transition: transform 700ms var(--ease-out); }
.cr-plat-posts { margin-top: 4px; font-size: 0.76rem; color: var(--muted); }

/* top clips */
.cr-clips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 0; padding: 0; list-style: none; }
.cr-clips > li { flex: 0 0 calc((100% - 6 * 12px) / 7); }
.cr-clip { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--cr-tile); border: 1px solid var(--line); color: #fff; text-decoration: none; isolation: isolate; }
.cr-clip img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform 500ms var(--ease-out); }
.cr-clip::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,0.35) 0, rgba(0,0,0,0) 64px), linear-gradient(to top, rgba(0,0,0,0.88) 0, rgba(0,0,0,0.6) 96px, rgba(0,0,0,0) 150px); }
.cr-clip:not(.cr-clip--blank) .cr-clip-bottom, .cr-clip:not(.cr-clip--blank) .cr-clip-rank { text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.cr-clip:hover img { transform: scale(1.04); }
.cr-clip:focus-visible { outline: 3px solid var(--cr-accent); outline-offset: 2px; }
.cr-clip--blank { background: linear-gradient(160deg, var(--cr-accent-bg), var(--cr-tile)); color: var(--ink); }
.cr-clip--blank::after { display: none; }
.cr-clip-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cr-clip-plat { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(0,0,0,0.45); backdrop-filter: blur(6px); color: #fff; }
.cr-clip--blank .cr-clip-plat { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.cr-clip-bottom { position: absolute; left: 12px; right: 12px; bottom: 12px; }
.cr-clip-views { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cr-clip-views small { font-size: 0.74rem; font-weight: 600; opacity: 0.8; margin-left: 4px; letter-spacing: 0; }
.cr-clip-meta { margin-top: 2px; font-size: 0.76rem; opacity: 0.88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-clip-rank { position: absolute; left: 12px; bottom: 58px; font-size: 0.7rem; font-weight: 800; }

/* tiles without a thumbnail: platform-tinted, big centred logo */
.cr-clip--blank[data-platform="tiktok"] { background: linear-gradient(160deg, rgba(37, 244, 238, 0.16), rgba(254, 44, 85, 0.14)); }
.cr-clip--blank[data-platform="instagram"] { background: linear-gradient(160deg, rgba(245, 133, 41, 0.16), rgba(221, 42, 123, 0.14) 55%, rgba(129, 52, 175, 0.16)); }
.cr-clip--blank[data-platform="youtube"] { background: linear-gradient(160deg, rgba(255, 0, 0, 0.14), rgba(255, 0, 0, 0.04)); }
.cr-clip--blank[data-platform="facebook"] { background: linear-gradient(160deg, rgba(24, 119, 242, 0.16), rgba(24, 119, 242, 0.04)); }
.cr-clip-glyph { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); color: var(--ink); opacity: 0.55; }

/* ranked list, used when a campaign has few thumbnails */
.cr-clips > li { min-width: 0; }
.cr-clips--list { gap: 8px; }
.cr-clips.cr-clips--list > li { flex-basis: calc((100% - 8px) / 2); } /* beats the tile widths at every breakpoint */
.cr-cliprow { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border-radius: 12px; background: var(--cr-tile); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color 200ms ease, background-color 200ms ease; }
.cr-cliprow:hover { border-color: var(--cr-hot); background: var(--cr-accent-bg); }
.cr-cliprow:hover .cr-cliprow-likes, .cr-cliprow:hover .cr-cliprow-rank, .cr-cliprow:hover .cr-cliprow-views small { color: var(--ink-soft); }
.cr-cliprow:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }
.cr-cliprow-rank { flex: none; width: 26px; font-size: 0.78rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.cr-cliprow-plat { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); }
.cr-cliprow-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cr-cliprow-handle { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-cliprow-likes { font-size: 0.76rem; color: var(--muted); }
.cr-cliprow-views { flex: none; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.cr-cliprow-views small { margin-left: 4px; font-size: 0.72rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }

/* source + empty states */
.cr-source { margin: 0; font-size: 0.8rem; color: var(--muted); text-align: center; line-height: 1.6; }
.cr-source a { display: inline-block; padding: 12px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.cr-source a:hover { color: var(--ink); }
.cr-empty { margin: 0; padding: 18px 0; font-size: 0.9rem; color: var(--muted); text-align: center; }
.cr-error { padding: 40px 20px; text-align: center; color: var(--muted); }

/* CTA */
.cr-cta { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; padding: clamp(20px, 3vw, 28px); border-radius: var(--radius-lg); background: var(--cr-accent-bg); border: 1px solid var(--cr-hot); }
.cr-cta h2 { margin: 0; font-size: clamp(1.2rem, 2.4vw, 1.5rem); letter-spacing: -0.02em; color: var(--ink); }
.cr-cta p { margin: 4px 0 0; font-size: 0.9rem; color: var(--ink-soft); }

/* loading shimmer for values not yet filled */
.cr [data-cr-pending] { color: transparent !important; border-radius: 6px; background: linear-gradient(90deg, var(--cr-tile), var(--cr-accent-bg), var(--cr-tile)); background-size: 200% 100%; animation: crShimmer 1.2s linear infinite; }
@keyframes crShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 1100px) {
  .cr-plats[data-n="5"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .cr-kpis { grid-template-columns: repeat(3, 1fr); }
  .cr-plats[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* "765 / 23,481" (about 6.13em wide) is the widest KPI value. Its tile's
     content width tracks the viewport linearly, so size the text to it with
     ~5% headroom and it stays on one line (other values fit at full size). */
  .cr-kpi-value[data-cr="approved"] { font-size: clamp(1rem, calc(4.8vw - 8.5px), 1.5rem); font-size: clamp(0.75rem, 13.8cqi, 1.5rem); }
  .cr-kpi--hero { grid-column: 1 / -1; grid-row: auto; flex-direction: row; align-items: flex-end; }
  .cr-clips > li { flex-basis: calc((100% - 3 * 12px) / 4); }
  .cr-clips.cr-clips--list > li { flex-basis: 100%; }
}
@media (max-width: 760px) {
  .cr-plats[data-n="3"], .cr-plats[data-n="5"] { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .cr-kpis { grid-template-columns: repeat(2, 1fr); }
  .cr-kpi-value[data-cr="approved"] { font-size: clamp(0.85rem, calc(7.6vw - 9.6px), 1.5rem); font-size: clamp(0.75rem, 13.8cqi, 1.5rem); }
  .cr-plats[data-n] { grid-template-columns: minmax(0, 1fr); }
  .cr-kpi--hero { flex-direction: column; align-items: flex-start; gap: 10px; }
  .cr-avatar { width: 52px; height: 52px; border-radius: 13px; }
  .cr-clip-views { font-size: 1.1rem; }
  .cr-clips > li { flex-basis: calc((100% - 12px) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  .cr [data-cr-pending] { animation: none; }
  .cr-bar span, .cr-clip img { transition: none; }
}

/* styles.css forces any link whose aria-label mentions "Instagram" or " on X"
   to 44x44px on phones (meant for footer social icons). Clip links name their
   platform, so without this they collapse into 44px squares. */
@media (max-width: 768px) and (pointer: coarse), (max-width: 540px) {
  .cr .cr-clips a.cr-clip,
  .cr .cr-clips a.cr-cliprow { width: auto !important; height: auto !important; }
}
