/* ============================================================
   Tylus BI: home page
   Story: question -> private AI -> SQL -> database -> result -> chart -> report
   ============================================================ */

@keyframes blink { 50% { opacity: 0; } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.45); } 100% { box-shadow: 0 0 0 6px rgba(52,211,153,0); } }
@keyframes breathe { 50% { opacity: .45; } }
@keyframes flash { 0% { background: rgba(16,185,129,.28); } 100% { background: transparent; } }

/* ---------- shared bits ---------- */
.sp-note { font-size: 11.5px; color: var(--muted); }
.ok { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); flex: none; }
.caret { display: inline-block; width: 2px; height: 1.05em; background: var(--emerald-2); vertical-align: -0.15em; margin-left: 3px; animation: blink 1s steps(1) infinite; }
.onprem { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--emerald-2); border: 1px solid var(--emerald-line); background: var(--emerald-soft); padding: 3px 9px 3px 7px; border-radius: 999px; white-space: nowrap; }
.onprem svg { width: 12px; height: 12px; }

.code .ins { border-radius: 3px; animation: flash 1.4s var(--ease); }

/* ---------- hero ---------- */
.hero { position: relative; padding: 72px 0 96px; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(42% 55% at 78% 45%, rgba(16,185,129,.09), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(38px, 4vw, 54px); }
.hero-sub { margin-top: 22px; font-size: 19px; line-height: 1.55; color: var(--text-2); max-width: 40ch; }
.hero-cta { margin-top: 34px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- live demo window (.td) ---------- */
.td {
  border: 1px solid var(--border-2); border-radius: 12px; background: var(--sunken); overflow: hidden;
  box-shadow: 0 40px 90px -44px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.03);
  font-size: 14px; min-height: 520px;
}
.td noscript img { width: 100%; height: auto; }
.td-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.td-head img { width: 22px; height: 22px; }
.td-head b { font-weight: 500; font-size: 13.5px; }
.td-body { padding: 16px; display: grid; gap: 14px; }
.td-q { display: flex; gap: 12px; align-items: baseline; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); min-height: 48px; }
.td-q .sp-label { flex: none; }
.td-qtext { font-size: 15px; color: var(--text); }
.td-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.td-steps li { display: inline-flex; align-items: center; gap: 7px; transition: color .3s; }
.td-steps li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--border-2); transition: background .3s, border-color .3s; }
.td-steps li.active { color: var(--text); }
.td-steps li.active::before { border-color: var(--emerald-2); animation: ring 1s var(--ease) infinite; }
.td-steps li.done { color: var(--text-2); }
.td-steps li.done::before { background: var(--emerald); border-color: var(--emerald); }
.td-steps em { font-style: normal; color: var(--muted); }
.td .code { min-height: calc(6 * 1.75em + 26px); }
.td-res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.td-res-head .rows { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.bars { display: grid; gap: 8px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 116px minmax(0, 1fr) 56px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .lbl { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 14px; }
.bar-row .bar { height: 100%; border-radius: 3px; background: var(--emerald); opacity: .5; transform-origin: left center; transform: scaleX(0); transition: transform .9s var(--ease); transition-delay: calc(var(--n) * 80ms); }
.bar-row .bar.top { opacity: 1; }
.bar-row .val { text-align: right; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); opacity: 0; transition: opacity .4s; transition-delay: calc(var(--n) * 80ms + 300ms); }
.td-res.show .bar { transform: scaleX(var(--v)); }
.td-res.show .val { opacity: 1; }
.td-res.wait .bar-row .lbl { color: transparent; background: rgba(148,163,184,.08); border-radius: 3px; animation: breathe 1.6s ease-in-out infinite; }
.td-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.td-replay { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); font: 500 12.5px var(--sans); padding: 6px 11px; border-radius: var(--r-sm); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; transition: color .15s, border-color .15s; }
.td-replay:hover { color: #fff; border-color: rgba(148,163,184,.45); }
.td-replay svg { width: 13px; height: 13px; }
.td-replay[hidden] { display: inline-flex; visibility: hidden; }

/* ---------- trust line ---------- */
.trust { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.trust-row { display: flex; justify-content: space-between; align-items: center; gap: 12px 32px; padding-top: 20px; padding-bottom: 20px; flex-wrap: wrap; }
.trust-row p { color: var(--text-2); font-size: 15px; }

/* ---------- problem ---------- */
.problem-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 80px; align-items: start; }
.problem-head { position: sticky; top: 112px; }
.problem-head .lead { margin-top: 18px; }
.problem-list { list-style: none; margin: 0; padding: 0; }
.problem-list li { padding: 30px 0; border-top: 1px solid var(--border); }
.problem-list li:last-child { border-bottom: 1px solid var(--border); }
.problem-list h3 { font-size: 21px; letter-spacing: -.02em; }
.problem-list p { color: var(--text-2); margin-top: 8px; max-width: 52ch; }

/* ---------- story (sticky stage) ---------- */
.story-sec { padding-bottom: 72px; }
.story { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 72px; }
.story-steps { list-style: none; margin: 0; padding: 0; }
.st { min-height: 58vh; display: flex; flex-direction: column; justify-content: center; padding-left: 26px; border-left: 1px solid var(--border); position: relative; opacity: .34; transition: opacity .45s var(--ease); }
.st::before { content: ""; position: absolute; left: -1px; top: calc(50% - 36px); width: 2px; height: 72px; background: var(--emerald); transform: scaleY(0); transition: transform .45s var(--ease); }
.st.on { opacity: 1; }
.st.on::before { transform: scaleY(1); }
.st h3 { font-size: clamp(22px, 2.2vw, 28px); letter-spacing: -.03em; }
.st p { color: var(--text-2); margin-top: 12px; font-size: 17px; max-width: 40ch; }
.story-stage { position: sticky; top: calc(50vh - 236px); align-self: start; }
.stage-rail { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.stage-rail i { height: 2px; border-radius: 2px; background: var(--border-2); transition: background .3s; }
.stage-rail i.done { background: var(--emerald); }
.stage-box { position: relative; height: 456px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--sunken); overflow: hidden; }
.sp { position: absolute; inset: 0; padding: 32px; display: flex; flex-direction: column; justify-content: center; opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .45s var(--ease), transform .45s var(--ease), visibility 0s linear .45s; }
.sp.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.ask { margin-top: 16px; display: flex; align-items: flex-end; gap: 18px; padding: 22px 18px 18px 22px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 4px rgba(16,185,129,.05); }
.sp-question { margin: 0; flex: 1; font-size: clamp(21px, 2.1vw, 28px); letter-spacing: -.025em; line-height: 1.25; font-weight: 500; }
.ask-send { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--emerald); color: #04140E; }
.ask-send svg { width: 16px; height: 16px; }

.sp-ai-head { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.sp-ai-head img { width: 28px; height: 28px; }
.sp-ai-head b { font-weight: 500; }
.sp-ai-lines { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; font-size: 13.5px; color: var(--text-2); }
.sp-ai-lines li::before { content: "›"; color: var(--emerald-2); margin-right: 10px; }
.sp-ai.on .sp-ai-lines li { animation: rise .5s var(--ease) both; }
.sp-ai.on .sp-ai-lines li:nth-child(2) { animation-delay: .12s; }
.sp-ai.on .sp-ai-lines li:nth-child(3) { animation-delay: .24s; }
.sp-ai.on .sp-ai-lines li:nth-child(4) { animation-delay: .36s; }

.sp-sql .code { margin-top: 14px; font-size: 14px; padding: 18px 20px; }

.db-link { display: flex; align-items: center; gap: 0; }
.db-node { display: inline-flex; align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid var(--border-2); border-radius: var(--r); background: var(--surface); font-weight: 500; white-space: nowrap; }
.db-node img, .db-node svg { width: 24px; height: 24px; color: var(--emerald-2); flex: none; }
.db-wire { flex: 1; height: 2px; min-width: 40px; position: relative; overflow: hidden; background: var(--border); }
.db-wire i { position: absolute; inset: 0 0 0 -24px; background: repeating-linear-gradient(90deg, var(--emerald-2) 0 6px, transparent 6px 24px); animation: flowx 1s linear infinite; animation-play-state: paused; }
.sp-db.on .db-wire i { animation-play-state: running; }
.db-engines { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.db-engines li { border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.db-log { list-style: none; margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); display: grid; gap: 10px; font-size: 13px; color: var(--text-2); }
.db-log li { display: flex; align-items: center; gap: 10px; }
.db-log em { font-style: normal; color: var(--muted); margin-left: auto; }
.sp-db.on .db-log li { animation: rise .5s var(--ease) both; animation-delay: .5s; }
.sp-db.on .db-log li + li { animation-delay: 1s; }

.sp-res .res-rows { font-style: normal; color: var(--text-2); text-transform: none; letter-spacing: 0; margin-left: 6px; }
.res-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.res-table th { text-align: left; font-weight: 400; color: var(--muted); font-size: 11.5px; padding: 8px 10px; border-bottom: 1px solid var(--border-2); }
.res-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text); font-variant-numeric: tabular-nums; }
.res-table th:last-child, .res-table td:last-child { text-align: right; }
.sp-res.on .res-table tbody tr { animation: rise .4s var(--ease) both; animation-delay: calc(var(--n) * 70ms); }
.sp-res .sp-note { margin-top: 14px; }

.sp-shot { padding: 20px; justify-content: flex-start; }
.sp-shot .mock { height: 100%; display: flex; flex-direction: column; box-shadow: none; }
.sp-shot .mock img { flex: 1; min-height: 0; width: 100%; object-fit: cover; object-position: top left; }

/* ---------- live visualization bench ---------- */
.bench { border: 1px solid var(--border-2); border-radius: 12px; background: var(--sunken); overflow: hidden; }
.bench-top { display: flex; justify-content: space-between; align-items: center; gap: 14px 20px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.bench-q { display: flex; align-items: baseline; gap: 12px; font-size: 15px; }
.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chips-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.chip { font: 500 13px var(--sans); color: var(--text-2); background: transparent; border: 1px solid var(--border-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: color .15s, background .15s, border-color .15s; }
.chip:hover { color: #fff; border-color: rgba(148,163,184,.45); }
.chip.on { color: #04140E; background: var(--emerald); border-color: var(--emerald); }
.bench-body { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.3fr); }
.bench-sql { padding: 18px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.bench-sql .code { min-height: calc(6 * 1.75em + 26px); }
.bench-meta { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-2); }
.bench-chart { padding: 18px 22px 16px; min-width: 0; }
.readout { display: flex; align-items: baseline; gap: 12px; min-height: 40px; }
.readout span { font-size: 12px; color: var(--muted); }
.readout b { font-size: 28px; font-weight: 600; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.line-chart { position: relative; height: 240px; margin-top: 10px; touch-action: pan-y; cursor: crosshair; }
.line-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.line-chart .grid line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.line-chart .ln { fill: none; stroke: var(--emerald-2); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .ar { fill: url(#benchFill); transition: opacity .5s; }
.line-chart .draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
.line-chart .draw.go { stroke-dashoffset: 0; transition: stroke-dashoffset 1.3s var(--ease); }
.line-chart .vline { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--border-2); pointer-events: none; }
.line-chart .dot { position: absolute; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--emerald-2); box-shadow: 0 0 0 4px rgba(52,211,153,.18); pointer-events: none; transition: transform .25s var(--ease); }
.line-chart .ymax { position: absolute; right: 0; top: 4px; padding: 0 0 0 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--sunken); }
.line-x { display: grid; grid-template-columns: repeat(12, 1fr); margin-top: 10px; font-size: 11px; color: var(--muted); }
.line-x span { text-align: center; }
.bench-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); }

/* ---------- module explorer ---------- */
.explorer { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 48px; align-items: start; }
.ex-layers { border-left: 1px solid var(--border); }
.ex-layer { padding: 0 0 22px 20px; }
.ex-layer:last-child { padding-bottom: 0; }
.ex-layer-name { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ex-row { display: flex; flex-direction: column; gap: 2px; }
.ex-tab { position: relative; text-align: left; background: transparent; border: 0; color: var(--text-2); font: 500 15.5px var(--sans); letter-spacing: -.01em; padding: 8px 12px; margin-left: -12px; border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; gap: 10px; transition: color .15s, background .15s; }
.ex-tab:hover { color: #fff; background: rgba(148,163,184,.06); }
.ex-tab[aria-selected="true"] { color: #fff; background: var(--surface); }
.ex-tab[aria-selected="true"]::before { content: ""; position: absolute; left: -9px; top: 8px; bottom: 8px; width: 2px; background: var(--emerald); border-radius: 2px; }
.ex-tab.rel::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); opacity: .8; }
.ex-panel { min-width: 0; }
.ex-screen { position: relative; aspect-ratio: 16 / 10; background: var(--surface); }
.ex-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: opacity .3s var(--ease); }
.ex-screen img.swap { opacity: 0; }
.ex-flow { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 16px; color: var(--text); background: var(--sunken); }
.ex-flow[hidden] { display: none; }
.ex-text { margin-top: 26px; max-width: 62ch; }
.ex-text h3 { font-size: 24px; letter-spacing: -.03em; }
.ex-text p { color: var(--text-2); margin-top: 8px; font-size: 16.5px; }
.ex-rel { margin-top: 20px; display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.ex-rel > span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ex-rel-list { display: flex; gap: 6px; flex-wrap: wrap; }
.ex-rel-list .chip { font-size: 12.5px; padding: 5px 11px; }
.mods-more { margin-top: 40px; }

/* ---------- numbers ---------- */
.numbers-title { font-size: 18px; font-weight: 500; color: var(--text-2); letter-spacing: -.01em; margin-bottom: 26px; }
.numbers { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.numbers > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; padding: 32px 24px 32px 0; }
.numbers > div + div { padding-left: 24px; border-left: 1px solid var(--border); }
.numbers dd { margin: 0; font-size: clamp(28px, 3.1vw, 44px); font-weight: 600; letter-spacing: -.04em; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; }
.numbers dt { color: var(--text-2); font-size: 14.5px; margin-top: 10px; }

/* ---------- industries ---------- */
.ind { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 40px; }
.ind > div { padding-top: 22px; border-top: 1px solid var(--border-2); }
.ind h3 { font-size: 20px; letter-spacing: -.02em; }
.ind p { color: var(--text-2); margin-top: 10px; font-size: 15.5px; }

/* ---------- FAQ (home) ---------- */
.faq-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 72px; align-items: start; }
.faq-head .lead { margin-top: 16px; }
.faq-head .btn { margin-top: 28px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero-grid { gap: 40px; }
}

@media (max-width: 980px) {
  .hero { padding: 48px 0 72px; }
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero-sub { font-size: 18px; }
  .td { min-height: 0; }

  .problem-grid, .faq-grid { grid-template-columns: 1fr; gap: 36px; }
  .problem-head { position: static; }

  /* story: stage pins to the top, text scrolls beneath */
  .story { grid-template-columns: 1fr; gap: 0; }
  .story-stage { order: -1; top: 64px; z-index: var(--z-stage); background: var(--bg); padding: 12px 0 14px; }
  .stage-box { height: 300px; }
  .sp { padding: 20px; }
  .sp-shot { padding: 12px; }
  .st { min-height: 54vh; padding-left: 20px; }
  .st:last-child { min-height: 62vh; }
  .sp-sql .code { font-size: 12px; padding: 14px; }

  .bench-body { grid-template-columns: 1fr; }
  .bench-sql { border-right: 0; border-bottom: 1px solid var(--border); }

  .explorer { grid-template-columns: 1fr; gap: 28px; }
  .ex-layers { border-left: 0; display: grid; gap: 16px; }
  .ex-layer { padding: 0; }
  .ex-row { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .ex-tab { margin-left: 0; font-size: 14px; padding: 7px 12px; border: 1px solid var(--border-2); border-radius: 999px; }
  .ex-tab[aria-selected="true"] { background: var(--emerald-soft); border-color: var(--emerald-line); color: var(--emerald-2); }
  .ex-tab[aria-selected="true"]::before { display: none; }

  .numbers { grid-template-columns: repeat(2, 1fr); }
  .numbers > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .numbers > div:nth-child(n+3) { border-top: 1px solid var(--border); }

  .ind { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 560px) {
  .hero { padding: 36px 0 56px; }
  .hero h1 { font-size: clamp(34px, 9.6vw, 42px); }
  .hero-sub { font-size: 17px; margin-top: 18px; }
  .hero-cta { margin-top: 26px; }
  .hero-cta .btn { flex: 1 1 auto; }
  .td-body { padding: 12px; gap: 12px; }
  .td .code { font-size: 11.5px; padding: 10px 12px; }
  .td-q { padding: 10px 12px; flex-direction: column; gap: 4px; }
  .bar-row { grid-template-columns: 92px minmax(0, 1fr) 46px; gap: 8px; }
  .bar-row .lbl, .bar-row .val { font-size: 11px; }
  .td-foot { padding: 10px 12px; }

  .trust-row { flex-direction: column; align-items: flex-start; }

  .stage-box { height: 272px; }
  .sp-question { font-size: 19px; }
  .ask { padding: 16px 14px 14px 16px; }
  .sp-ai-lines { font-size: 12px; gap: 9px; }
  .db-node { padding: 10px 12px; font-size: 14px; }
  .db-engines, .db-log { margin-top: 14px; }
  .res-table { font-size: 12px; }
  .res-table td, .res-table th { padding: 6px 8px; }
  .st h3 { font-size: 21px; }
  .st p { font-size: 16px; }

  .bench-top, .bench-sql, .bench-chart, .bench-foot { padding-left: 14px; padding-right: 14px; }
  .bench-sql .code { font-size: 11.5px; }
  .line-chart { height: 200px; }
  .line-x span:nth-child(even) { visibility: hidden; }

  .numbers > div { padding: 24px 14px 24px 0; }
  .numbers > div + div { padding-left: 14px; }
  .numbers > div:nth-child(3) { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .td-steps li.active::before, .db-wire i, .td-res.wait .bar-row .lbl { animation: none !important; }
  .st { opacity: 1; }
}
