/*
 * Author: Hariram S <ramhari4090@gmail.com>
 *
 * Styles for the visualization pages: the gallery of small vector charts on
 * the chart-types page, the visualization tiles on the features index, and
 * the drawn screens and scene steps for the AI chart chat, the role dashboard
 * and the chart editor.
 *
 * The small charts use the app's own dark-mode chart palette (Okabe-Ito based,
 * src/lib/chart-palette.ts), so the colours on the site are the colours in
 * the product, and every chart also carries direct labels so colour is never
 * the only cue. They draw in once when scrolled into view (.fill-on-view gets
 * .in from scenes.js); without JavaScript, or under reduced motion, they show
 * finished. Only transform, opacity and stroke-dashoffset animate.
 *
 * Scenes follow ui.css: scenes.js sets data-s on the figure, a figure without
 * data-s shows its final step, and the layers of each screen are stacked in
 * one grid cell so stepping never changes the height of the page.
 *
 * Used by:
 *     landing/features/chart-types.html, landing/features/ask-your-data.html,
 *     landing/features/interactive-dashboards.html
 *
 * Depends on:
 *     landing/assets/site.css  (tokens: --surface, --line, --muted, --ease, --r)
 *     landing/assets/ui.css    (u-* drawn-screen parts, .scene, .u-press, .u-float)
 *     landing/assets/scenes.js (data-s on scenes, .in on .fill-on-view)
 */

/* Chart gallery */
.vz-note { margin-top: 14px; font-size: var(--t5); color: var(--muted); }
.vz-gallery { list-style: none; padding: 0; margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr)); gap: 12px; }
.vz-card { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 18px 18px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.vz-card .vz-plot { margin: -4px -6px 4px; padding: 8px 6px 4px; border-radius: 12px; background: #111113; border: 1px solid rgba(255, 255, 255, .06); }
.vz-card h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; color: #fff; }
.vz-card .vz-grp { font: 500 11px/1.4 var(--mono); letter-spacing: .04em; color: var(--accent-ink); margin-bottom: -4px; }
.vz-card p { font-size: var(--t5); line-height: 1.55; color: var(--muted); }
.vz-card p b { color: var(--ink); font-weight: 600; }
.vz-svg { display: block; width: 100%; height: auto; font-family: var(--font); font-variant-numeric: tabular-nums; }

/* Draw-in: bars grow from the axis, lines draw along their length, marks fade up. */
.vz-g { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .9s var(--ease); transition-delay: calc(var(--i, 0) * 70ms + .1s); }
.vz-d { stroke-dashoffset: 0; transition: stroke-dashoffset 1.4s cubic-bezier(.4, 0, .2, 1) .15s; }
.vz-d:not([stroke-dasharray]) { stroke-dasharray: 1; }
.vz-f { transition: opacity .6s ease; transition-delay: calc(var(--i, 0) * 60ms + .2s); }
html.js .fill-on-view:not(.in) .vz-g { transform: scaleY(0); }
html.js .fill-on-view:not(.in) .vz-d { stroke-dashoffset: var(--o, 1); }
html.js .fill-on-view:not(.in) .vz-f { opacity: 0; }

/* Features index: visualization tiles with a small chart on top */
.vz-feat { list-style: none; padding: 0; margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.vz-feat a { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 18px 18px 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); text-decoration: none; transition: transform .3s var(--ease), border-color .25s ease; }
.vz-feat a:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, .5); }
.vz-feat .vz-plot { margin-bottom: 8px; padding: 8px 6px 4px; border-radius: 12px; background: #111113; border: 1px solid rgba(255, 255, 255, .06); }
.vz-feat b { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: #fff; }
.vz-feat span { font-size: var(--t5); line-height: 1.55; color: var(--muted); }

/* Two-column list of capabilities with a short heading each */
.vz-list { list-style: none; padding: 0; margin-top: clamp(28px, 3vw, 40px); display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 0 var(--gut); }
.vz-list li { padding: 18px 0; border-top: 1px solid var(--line); }
.vz-list b { display: block; color: #fff; font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.vz-list span { display: block; color: var(--muted); font-size: var(--t5); line-height: 1.6; }

/* Drawn screens: parts not in ui.css */
[data-ui] .vz-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
[data-ui] .vz-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #eef0f5; color: #3a4050; font-size: 11.5px; font-weight: 600; }
[data-ui] .vz-q { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border: 1px solid #ddd5fb; background: #f4f1fe; border-radius: 12px; font-size: 13px; }
[data-ui] .vz-q::before { content: "?"; flex: none; display: grid; place-items: center; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--u-violet); color: var(--u-violet); font-size: 10px; font-weight: 700; }
[data-ui] .vz-cap { margin-top: 8px; font-size: 12px; color: var(--u-muted); display: grid; gap: 2px; }
[data-ui] .vz-cap b { color: var(--u-text); font-weight: 600; }
[data-ui] .vz-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
[data-ui] .vz-mini-grid .u-card { margin: 0; padding: 12px; min-width: 0; }
[data-ui] .vz-mini-grid .u-h { font-size: 13px; }
[data-ui] .vz-reason { font-size: 11.5px; color: var(--u-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-ui] .vz-mbtn { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 9px; border: 1px solid var(--u-control); border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; position: relative; background: #fff; }
[data-ui] .vz-mbtn .ic { width: 12px; height: 12px; }
[data-ui] .vz-insight { margin-top: 8px; padding: 9px 10px; background: #f4f1fe; border-radius: 10px; font-size: 11.5px; line-height: 1.5; color: #2c2f3a; }
[data-ui] .vz-tabs { display: inline-flex; padding: 3px; background: #eef0f5; border-radius: 999px; gap: 2px; font-size: 12.5px; }
[data-ui] .vz-tabs span { padding: 4px 12px; border-radius: 999px; transition: background-color .3s ease; }
[data-ui] .vz-types-ui { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
[data-ui] .vz-types-ui span { display: grid; place-items: center; min-height: 30px; padding: 4px; border: 1px solid var(--u-border); border-radius: 9px; font-size: 11.5px; text-align: center; line-height: 1.2; }
[data-ui] .vz-types-ui span.on { border-color: #a99cf3; background: var(--u-lav); font-weight: 600; box-shadow: 0 0 0 1.5px #a99cf3; }
[data-ui] .vz-angles { display: flex; gap: 6px; }
[data-ui] .vz-angles span { padding: 3px 9px; border: 1px solid var(--u-border); border-radius: 8px; font-size: 12px; }
[data-ui] .vz-angles span.on { background: var(--u-lav); border-color: #a99cf3; }
[data-ui] .vz-coach { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid #f0d9a6; background: #fff8e6; border-radius: 12px; font-size: 12.5px; color: #4f3a08; }
[data-ui] .vz-coach .u-btns { margin-top: 0; }
[data-ui] .vz-coach .u-btn { min-height: 28px; font-size: 12px; }
[data-ui] .vz-chartbox { position: relative; height: 150px; display: flex; align-items: flex-end; gap: 9%; padding: 0 5%; border-bottom: 1px solid #d9dce5; }
[data-ui] .vz-chartbox i { flex: 1; height: 100%; background: #0072B2; border-radius: 4px 4px 0 0; transform-origin: bottom; transform: scaleY(var(--n, 1)); transition: transform .9s cubic-bezier(.16, 1, .3, 1); }
[data-ui] .vz-sum { display: grid; gap: 8px; font-size: 12.5px; line-height: 1.5; }
[data-ui] .vz-sum ul { list-style: disc; padding-left: 18px; display: grid; gap: 3px; }
[data-ui] .vz-sum .rec { padding: 8px 10px; background: #eaf6f0; border-radius: 10px; color: #0d4d36; }
[data-ui] .vz-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
[data-ui] .vz-pick > div { padding: 10px 12px; border: 1px solid var(--u-border); border-radius: 12px; background: #fff; font-size: 12px; color: var(--u-muted); }
[data-ui] .vz-pick b { display: block; color: var(--u-text); font-size: 13.5px; margin-bottom: 2px; }
[data-ui] .vz-frow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--u-border); background: #f7f8fb; border-radius: 10px; font-size: 12.5px; }
[data-ui] .vz-frow .u-field { min-height: 28px; border-radius: 8px; font-size: 12.5px; padding: 0 10px; }
[data-ui] .vz-link { display: inline-flex; align-items: center; gap: 3px; color: var(--u-violet); font-size: 11px; font-weight: 600; }
[data-ui] .vz-link .ic { width: 12px; height: 12px; }

/* Layers stacked in one grid cell: the tallest decides the height, so steps never move the page. */
.vz-stack { display: grid; }
.vz-stack > * { grid-area: 1 / 1; transition: opacity .45s ease, transform .55s var(--ease, cubic-bezier(.16, 1, .3, 1)); }

/* Scene: chat to a chart (ask-your-data). Final state = chart added. */
.sc-chat .ly-clar, .sc-chat .ly-empty { opacity: 0; transform: translateY(8px); pointer-events: none; }
.sc-chat[data-s="0"] .ly-empty { opacity: 1; transform: none; }
.sc-chat[data-s="0"] .ly-res, .sc-chat[data-s="1"] .ly-res { opacity: 0; transform: translateY(8px); }
.sc-chat[data-s="1"] .ly-clar { opacity: 1; transform: none; }
.sc-chat .q-ph, .sc-chat .q-1 { opacity: 0; }
.sc-chat[data-s="0"] .q-ph { opacity: 1; }
.sc-chat[data-s="0"] .q-2, .sc-chat[data-s="1"] .q-2 { opacity: 0; }
.sc-chat[data-s="1"] .q-1 { opacity: 1; }
.sc-chat[data-s="1"] .press-opt { opacity: 1; transform: none; }
.sc-chat[data-s="2"] .vz-d { animation: vz-draw 1.5s .25s cubic-bezier(.4, 0, .2, 1) both; }
.sc-chat .u-swap.add > * { display: inline-flex; align-items: center; gap: 5px; }
.sc-chat .u-swap.add > .alt { opacity: 1; }
.sc-chat .u-swap.add > .base { opacity: 0; }
.sc-chat:is([data-s="0"], [data-s="1"], [data-s="2"]) .u-swap.add > .alt { opacity: 0; }
.sc-chat:is([data-s="0"], [data-s="1"], [data-s="2"]) .u-swap.add > .base { opacity: 1; }
.sc-chat[data-s="2"] .press-add { opacity: 1; transform: none; }

/* Scene: describe yourself, get a dashboard (ask-your-data). Final state = insight open. */
.sc-role .rd { position: absolute; inset: calc(var(--wb) + 10px) 10px 10px; z-index: 3; transition: opacity .45s ease, transform .55s cubic-bezier(.16, 1, .3, 1); }
.sc-role[data-s="0"] .rd { opacity: 0; transform: translateY(12px) scale(.98); }
.sc-role .rd-load { opacity: 0; transition: opacity .35s ease; }
.sc-role[data-s="1"] .rd-load { opacity: 1; }
.sc-role[data-s="1"] .rd-body { opacity: 0; }
.sc-role .rd-body { transition: opacity .45s ease; }
.sc-role .note-open { opacity: 0; transition: opacity .3s ease; }
.sc-role[data-s="0"] .note-open { opacity: 1; }
.sc-role .vz-insight { transition: opacity .45s ease, transform .5s cubic-bezier(.16, 1, .3, 1); }
.sc-role:is([data-s="0"], [data-s="1"], [data-s="2"]) .vz-insight { opacity: 0; transform: translateY(-4px); }
.sc-role[data-s="2"] .press-ex { opacity: 1; transform: none; }
.sc-role .u-dim { opacity: 1; }
.sc-role[data-s="0"] .u-dim { opacity: 0; }

/* Scene: the chart editor and the coach (interactive-dashboards). Final state = axis reset, saved. */
.sc-edit .tab-c, .sc-edit .tab-d { opacity: 0; transform: translateY(6px); pointer-events: none; }
.sc-edit[data-s="0"] .tab-c, .sc-edit[data-s="1"] .tab-d { opacity: 1; transform: none; }
.sc-edit:is([data-s="0"], [data-s="1"]) .tab-x { opacity: 0; transform: translateY(6px); }
.sc-edit .vz-tabs .t-x { background: #fff; }
/* Only the background marks the open tab: a bolder label is wider and would rewrap the header on phones. */
.sc-edit[data-s="0"] .vz-tabs .t-c, .sc-edit[data-s="1"] .vz-tabs .t-d { background: #fff; }
.sc-edit:is([data-s="0"], [data-s="1"]) .vz-tabs .t-x { background: transparent; }
.sc-edit[data-s="2"] .vz-chartbox i { transform: scaleY(var(--m)); }
.sc-edit .u-swap.ym > .alt { opacity: 0; }
.sc-edit[data-s="2"] .u-swap.ym > .alt { opacity: 1; }
.sc-edit[data-s="2"] .u-swap.ym > .base { opacity: 0; }
.sc-edit .vz-coach { transition: opacity .4s ease, transform .5s cubic-bezier(.16, 1, .3, 1); }
.sc-edit:not([data-s="2"]) .vz-coach { opacity: 0; transform: translateY(6px); }
.sc-edit[data-s="2"] .press-rs { opacity: 1; transform: none; }
.sc-edit:not([data-s]) .press-sv, .sc-edit[data-s="3"] .press-sv { opacity: 1; transform: none; }

@keyframes vz-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

[data-ui] .u-dash.vz-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Editor layout: settings beside the preview; stacked on phones. */
[data-ui] .vz-ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; align-items: start; }
@media (max-width: 1100px) { .vz-feat { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  [data-ui] .vz-ed { grid-template-columns: 1fr; }
  [data-ui] .vz-mini-grid, [data-ui] .u-dash.vz-two { grid-template-columns: 1fr; }
  [data-ui] .vz-mini-grid .ph-more { display: none; }
  .vz-feat { grid-template-columns: 1fr; }
  .sc-role .rd { inset: calc(var(--wb) + 6px) 6px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .vz-g, .vz-d, .vz-f, .vz-stack > *, .vz-feat a { transition: none !important; animation: none !important; }
  html.js .fill-on-view:not(.in) .vz-g { transform: none; }
  html.js .fill-on-view:not(.in) .vz-d { stroke-dashoffset: 0; }
  html.js .fill-on-view:not(.in) .vz-f { opacity: 1; }
}
