/* ==========================================================================
   Analytics & AI · 4 — What you get today
   A bento of product vignettes (the language of Rules Studio's "Use it
   your way" scenes): each tile opens on a small, real-UI scene, resolved
   at rest, and hovering a tile plays its sentence once.
       ┌ "Show PAR30 by branch" [Build] ┐ ┌ [Web|WhatsApp|…]      ┐
       │ PAR30 by branch   🔒 Published │ │ me: Top branches…     │
       │ ▇▇▇▇▇▇▇ ▇▇▇▇▇ ▇▇▇▇ ▇▇▇ ▇▇      │ │ 1 Northgate   7.4%    │
       │ Dashboards without SQL         │ │ Conversational …      │
       ┌ normal band ══╲══ ▲ Unusual ┐ ┌ ▤ Credit Policy v4 │ Q → A [6.2] ┐
       │ Smart alerts                 │ │ Policy and compliance Q&A       │
   Tiles sit on a 12-column grid: 7 + 5, then 5 + 7.
   Prefixed .tb- and scoped to .tb.
   ========================================================================== */

.tb {
  --tb-frame: #FFFFFF;
  --tb-dot:   rgba(10,47,107,0.13);
  --tb-pop:   cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
:root[data-theme="dark"] .tb { --tb-frame: #0B1F42; --tb-dot: rgba(147,190,240,0.12); }

.tb-inner { max-width: var(--container); margin: 0 auto; }
.tb-title { margin-bottom: clamp(32px, 4vw, 48px); font-size: var(--fs-section-title); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; }
.tb-title em { font-style: normal; color: var(--accent); }

.tb-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.tb-tile {
  grid-column: span 5;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 24px;
  background: var(--tb-frame);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.tb-tile--wide { grid-column: span 7; }
.has-js .tb-tile.anim-el { transition: opacity 0.65s var(--ease-out), transform 0.65s var(--ease-out), border-color 0.25s ease-out; }
.tb-tile:hover { border-color: var(--border-strong); }
.tb-t { margin: 20px 12px 0; font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.tb-p { margin: 8px 12px 0; max-width: 60ch; font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* the well: a quiet stage with a soft dot grid */
.tb-well {
  position: relative;
  isolation: isolate;
  height: 220px;
  padding: 18px;
  background: color-mix(in srgb, var(--surface-raised) 60%, var(--tb-frame));
  border-radius: 10px;
  overflow: hidden;
}
.tb-well::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(circle, var(--tb-dot) 0.9px, transparent 1.3px);
  background-size: 14px 14px;
  background-position: 7px 7px;
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 30%, transparent 90%);
          mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 30%, transparent 90%);
}
/* shared mini surfaces */
.tb-win, .tb-me, .tb-rank, .tb-ans, .tb-doc {
  background: var(--tb-frame);
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 28px -22px rgba(10,47,107,0.35);
}

/* ─── 1 · Dashboards without SQL ──────────────────────────────────────── */
.tb-win { max-width: 470px; margin: 0 auto; border-radius: 10px; overflow: hidden; }
.tb-prompt { display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 12px; border-bottom: 1px solid var(--border); }
.tb-prompt .ti { font-size: 15px; color: var(--accent); }
.tb-typed { flex: 1; overflow: hidden; white-space: nowrap; font-size: 12.5px; color: var(--text-primary); }
.tb-prompt b { padding: 3px 10px; font-size: 11.5px; font-weight: 600; color: #FFFFFF; background: var(--accent); border-radius: 6px; }
:root[data-theme="dark"] .tb-prompt b { color: #0B1F42; }
.tb-chart { padding: 10px 12px 10px; }
.tb-chart-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.tb-chart-h b { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.tb-pub { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; color: var(--good); background: var(--good-soft); border-radius: 99px; white-space: nowrap; }
.tb-pub .ti { font-size: 11px; }
.tb-bar { display: grid; grid-template-columns: 64px minmax(0, 1fr) 34px; align-items: center; gap: 8px; height: 18px; font-size: 11px; color: var(--text-secondary); }
.tb-bar i { display: block; height: 7px; width: calc(var(--w) * 100%); background: var(--accent); border-radius: 4px; transform-origin: left; }
.tb-bar i.is-up { background: var(--warn); }
.tb-bar b { font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; text-align: right; color: var(--text-primary); }
.tb-refresh { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 10.5px; color: var(--text-muted); }
.tb-refresh .ti { font-size: 11px; }

/* ─── 2 · Conversational analytics ────────────────────────────────────── */
.tb-well--chat { display: flex; flex-direction: column; gap: 9px; }
.tb-chans { display: flex; gap: 4px; }
.tb-chans span { padding: 2px 8px; font-size: 10.5px; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border); border-radius: 99px; background: var(--tb-frame); }
.tb-chans span.is-on { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }
.tb-me { align-self: flex-end; max-width: 85%; padding: 7px 11px; font-size: 12px; line-height: 1.4; color: #FFFFFF; background: var(--accent); border-color: transparent; border-radius: 12px 12px 4px 12px; }
:root[data-theme="dark"] .tb-me { color: #0B1F42; }
.tb-rank { align-self: flex-start; width: 78%; margin: 0; padding: 4px 0; list-style: none; border-radius: 12px 12px 12px 4px; }
.tb-rank li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 12px; color: var(--text-primary); }
.tb-rank li + li { border-top: 1px solid var(--border); }
.tb-rank em { display: grid; place-items: center; width: 18px; height: 18px; font-style: normal; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-secondary); background: var(--surface-raised); border-radius: 5px; }
.tb-rank b { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--warn); }
.tb-rank li:last-child b { color: var(--text-primary); }

/* ─── 3 · Smart alerts ────────────────────────────────────────────────────
   The point: the line leaves its normal band and stays out for six weeks,
   yet never crosses the fixed threshold; the alert still fires. */
.tb-well--alert { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px; }
.tb-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 9px;
  background: var(--tb-frame);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 14px 28px -22px rgba(10,47,107,0.35);
}
.tb-alert-ic { display: grid; place-items: center; flex: none; width: 28px; height: 28px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; }
.tb-alert-ic .ti { font-size: 15px; }
.tb-alert-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.tb-alert-txt small { font-size: 10.5px; color: var(--text-muted); }
.tb-alert-txt b { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-flag { margin-left: auto; flex: none; padding: 2px 8px; font-size: 10.5px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 99px; }

/* the pattern grid: weekday rows × week columns; every cell a calm tint
   of normal, except Tuesday for the last six weeks, outlined as a streak */
.tb-grid-h {
  position: relative;
  display: grid;
  grid-template-columns: 26px repeat(12, minmax(0, 1fr));
  grid-auto-rows: 13px;
  gap: 3px;
  align-items: center;
}
.tb-gw { font-family: var(--font-mono); font-size: 8.5px; color: var(--text-muted); text-align: center; white-space: nowrap; }
.tb-gd { font-size: 9.5px; color: var(--text-muted); }
.tb-c { display: block; height: 100%; border-radius: 3px; background: var(--tb-c, var(--border)); }
.tb-c--a { --tb-c: color-mix(in srgb, var(--accent) 10%, var(--tb-frame)); }
.tb-c--b { --tb-c: color-mix(in srgb, var(--accent) 16%, var(--tb-frame)); }
.tb-c--c { --tb-c: color-mix(in srgb, var(--accent) 22%, var(--tb-frame)); }
.tb-c--d { --tb-c: color-mix(in srgb, var(--accent) 28%, var(--tb-frame)); }
.tb-c--low { --tb-c: color-mix(in srgb, var(--warn) 55%, var(--tb-frame)); }
/* an overlay grid with the same tracks carries the streak, so it never
   takes cells away from the auto-placed squares */
.tb-grid-o { position: absolute; inset: 0; display: grid; grid-template-columns: inherit; grid-auto-rows: inherit; gap: inherit; pointer-events: none; }
/* the streak: Tuesday, weeks 7–12 (row 3, columns 8–13) */
.tb-streak {
  grid-row: 3;
  grid-column: 8 / 14;
  align-self: stretch;
  margin: -3px -3px;
  border: 1.5px solid var(--warn);
  border-radius: 6px;
  pointer-events: none;
}
.tb-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 10px; color: var(--text-secondary); }
.tb-key span { display: inline-flex; align-items: center; gap: 5px; }
.tb-key .tb-c { width: 12px; height: 9px; }
.tb-key-note { margin-left: auto; color: var(--text-muted); }

/* ─── 4 · Policy and compliance Q&A ───────────────────────────────────── */
.tb-well--policy { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 18px; }
.tb-doc { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 8px; }
.tb-doc .ti { font-size: 18px; color: var(--accent); }
.tb-doc b { font-size: 11.5px; font-weight: 600; color: var(--text-primary); }
.tb-doc small { font-size: 10.5px; color: var(--text-muted); }
.tb-doc-l { height: 5px; margin-top: 2px; background: var(--border); border-radius: 3px; }
.tb-doc-l--hi { background: color-mix(in srgb, var(--accent) 35%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tb-doc-l--s { width: 60%; }
.tb-qa { display: flex; flex-direction: column; gap: 8px; }
.tb-qa .tb-me { max-width: 100%; }
.tb-ans { align-self: flex-start; display: flex; flex-direction: column; gap: 7px; padding: 9px 12px; border-radius: 12px 12px 12px 4px; }
.tb-ans b { font-size: 12px; font-weight: 500; line-height: 1.45; color: var(--text-primary); }
.tb-src { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 99px; }
.tb-src .ti { font-size: 11px; }

/* ─── Hover: each tile plays its sentence once ────────────────────────── */
.tb-tile:hover .tb-typed { animation: tb-type 0.7s steps(20) both; }
.tb-tile:hover .tb-prompt b { animation: tb-press 0.25s ease 0.75s; }
.tb-tile:hover .tb-bar i { animation: tb-grow 0.55s cubic-bezier(0.22, 1, 0.36, 1) calc(0.9s + var(--i) * 70ms) both; }
.tb-tile:hover .tb-pub { animation: tb-pop 0.45s var(--tb-pop) 1.4s both; }
.tb-tile:hover .tb-me { animation: tb-rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }
.tb-tile:hover .tb-rank li { animation: tb-rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) calc(0.45s + var(--i) * 0.12s) both; }
.tb-tile:hover .tb-grid-h .tb-c { animation: tb-cell 0.3s ease calc(var(--w) * 55ms) both; }
.tb-tile:hover .tb-streak { animation: tb-ring 0.5s var(--tb-pop) 0.8s both; }
.tb-tile:hover .tb-flag { animation: tb-pop 0.45s var(--tb-pop) 1.05s both; }
.tb-tile:hover .tb-doc-l--hi { animation: tb-hi 0.6s ease 0.5s both; }
.tb-tile:hover .tb-ans { animation: tb-rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.4s both; }
.tb-tile:hover .tb-src { animation: tb-pop 0.45s var(--tb-pop) 0.9s both; }

@keyframes tb-type  { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes tb-press { 50% { transform: scale(0.92); } }
@keyframes tb-grow  { from { transform: scaleX(0); } }
@keyframes tb-pop   { from { opacity: 0; transform: scale(0.6); } }
@keyframes tb-rise  { from { opacity: 0; transform: translateY(8px); } }
@keyframes tb-draw  { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes tb-fade { from { opacity: 0; } }
@keyframes tb-cell { from { opacity: 0; transform: scale(0.6); } }
@keyframes tb-ring { from { opacity: 0; transform: scale(1.08); } }
@keyframes tb-hi    { from { box-shadow: 0 0 0 0 var(--accent-soft); background: var(--border); } }
.tb-dot, .tb-flag, .tb-pub, .tb-src { transform-box: fill-box; transform-origin: center; }

@media (max-width: 960px) {
  .tb-tile, .tb-tile--wide { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .tb-well { height: auto; min-height: 200px; }
  .tb-well--policy { grid-template-columns: minmax(0, 1fr); }
  .tb-doc { display: none; }
  .tb-chart-h { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-tile:hover * { animation: none !important; }
}
