/* Analytics: a dashboard panel whose engagement curve draws itself while the section scrolls (--draw 0 → 1 from
   js/features/retention.js), KPIs that count up, notes that appear as the line reaches them, and a scrubber that reads
   out "% still watching at m:ss". Without JS the finished curve is shown. */
@layer sections {
    .dash { --draw: 1; display: grid; gap: 30px; padding: 32px; }
    html.js .dash { --draw: 0; }
    .dash__head { display: flex; align-items: center; gap: 14px; }
    .dash__thumb { flex: none; width: 84px !important; height: auto !important; aspect-ratio: 16 / 9; border-radius: 10px; }
    .dash__head b { display: block; color: var(--text); font-size: 16px; }
    .dash__head small { color: var(--text-3); font-size: 13px; }
    .dash__sample { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; padding: 6px 12px; border-radius: 999px; background: var(--white-a4); border: 1px solid var(--line); color: var(--text-3); font-size: 12.5px; font-weight: 700; }
    .dash__sample .i { width: 14px; height: 14px; }

    .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; overflow: hidden; border-radius: var(--r-panel); background: var(--line); }
    .kpi { padding: 18px 20px; background: var(--surface-deep); }
    .kpi dt { color: var(--text-3); font-size: 13px; font-weight: 700; }
    .kpi dd { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
    .kpi dd b { color: var(--text); font-family: var(--font-display); font-size: clamp(26px, 2.8vw, 36px); font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
    .kpi dd small { color: var(--green-400); font-size: 12.5px; font-weight: 700; }

    .curve { margin: 0; }
    .curve__cap { margin-bottom: 14px; color: var(--text-3); font-size: 14px; }
    .curve__cap b { margin-right: 6px; color: var(--text); }
    .curve__plot { position: relative; height: 260px; touch-action: pan-y; cursor: crosshair; }
    .curve__svg { display: block; width: 100%; height: 100%; overflow: visible; }
    .curve__grid path { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
    .curve__drawn { clip-path: inset(0 calc((1 - var(--draw)) * 100%) -10px 0); }
    .curve__line { fill: none; stroke: var(--cyan-400); stroke-width: 3; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 8px rgb(61 220 255 / .6)); }
    .curve__note {
        position: absolute; left: calc(var(--x) * 1%); top: calc((260 - var(--y) * 2.4) / 260 * 100%); z-index: 2;
        display: grid; gap: 2px; width: max-content; max-width: 220px; padding: 8px 12px; translate: -50% calc(-100% - 16px);
        border-radius: 12px; background: var(--surface-raised); border: 1px solid var(--line-2); box-shadow: 0 14px 30px -12px var(--black-a80);
        color: var(--text-3); font-size: 12.5px; line-height: 1.4;
        opacity: clamp(0, (var(--draw) * 100 - var(--x)) / 6, 1);
        pointer-events: none;
    }
    .curve__note b { color: var(--text); font-size: 13.5px; }
    .curve__note::after { content: ''; position: absolute; left: 50%; bottom: -14px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--cyan-400); box-shadow: 0 0 0 4px var(--cyan-a25); }
    .curve__scrub { position: absolute; top: 0; bottom: 0; left: calc(var(--x) * 1%); z-index: 3; width: 0; pointer-events: none; }
    .curve__scrub[hidden] { display: none; }
    .curve__scrub i { position: absolute; top: 0; bottom: 0; left: 0; border-left: 1px dashed var(--white-a40); }
    .curve__scrub span { position: absolute; left: 10px; top: 0; padding: 6px 10px; border-radius: 10px; background: var(--white); color: #0B0D0E; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
    .curve__scrub:is([style*="--x: 7"], [style*="--x: 8"], [style*="--x: 9"]) span { left: auto; right: 10px; }
    .curve__axis { display: flex; justify-content: space-between; margin-top: 10px; color: var(--text-4); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

    .meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
    .meters__col h3 { margin-bottom: 12px; color: var(--text-3); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
    .meters__col ul { display: grid; gap: 10px; }
    .meters__col li { display: grid; grid-template-columns: 1fr auto; gap: 6px; color: var(--text-2); font-size: 14px; }
    .meters__col li b { color: var(--text); font-variant-numeric: tabular-nums; }
    .meters__col li i { grid-column: 1 / -1; height: 5px; border-radius: 9px; background: linear-gradient(90deg, var(--cyan-400) var(--w), var(--white-a8) var(--w)); }

    .analytics__foot { margin-top: 18px; color: var(--text-4); font-size: 13px; text-align: center; }
    .analytics .cta-row { justify-content: center; }

    @media (max-width: 900px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } .meters { grid-template-columns: 1fr; gap: 22px; } }
    @media (max-width: 560px) {
        .dash { padding: 20px 16px; gap: 22px; }
        .dash__sample { display: none; }
        .curve__plot { height: 200px; }
        .curve__note { display: none; }
        .kpi { padding: 14px; }
    }
}
