/* ============================================================================
   App-specific styles for the KrivAI Fraud Ring Detection.
   Built ONLY on design-system tokens (var(--ds-*)). No gradients / neon /
   decorative effects. Import AFTER tokens.css + components.css.
   These are layout + presentational helpers the shared component library does
   not ship (landing sections, hero, driver meters, stat cards, the network
   graph panel, ring list/detail, tour overlay).
   ============================================================================ */

/* ---- Generic page + section rhythm (strict 8-pt) ---- */
.app-main { padding: var(--ds-space-6) 0 var(--ds-space-8); }
.section { padding: var(--ds-space-8) 0; border-top: 1px solid var(--ds-border); }
.section:first-of-type { border-top: none; }
.section__head { max-width: var(--ds-container-narrow); margin: 0 auto var(--ds-space-6); text-align: center; }
.section__head .ds-eyebrow { margin-bottom: var(--ds-space-2); }
.section__head .ds-h2 { margin-bottom: var(--ds-space-3); }
.section__head .ds-muted { max-width: 620px; margin-inline: auto; }

/* Utility spacing (token-based) */
.mt-1 { margin-top: var(--ds-space-1); }
.mt-2 { margin-top: var(--ds-space-2); }
.mt-3 { margin-top: var(--ds-space-3); }
.mt-4 { margin-top: var(--ds-space-4); }
.mt-5 { margin-top: var(--ds-space-5); }
.mt-6 { margin-top: var(--ds-space-6); }
.mb-1 { margin-bottom: var(--ds-space-1); }
.mb-2 { margin-bottom: var(--ds-space-2); }
.mb-3 { margin-bottom: var(--ds-space-3); }
.mb-4 { margin-bottom: var(--ds-space-4); }
.wrap { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); align-items: center; }
.grow { flex: 1; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--ds-font-mono); }

/* ---- App header: brand + page intro ---- */
.ds-appbar__brand-btn > span > span:last-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw;
}
@media (max-width: 560px) { .ds-appbar__brand-btn > span > span:last-child { display: none; } }
.page-head { margin-bottom: var(--ds-space-5); }
.page-head .ds-muted { margin: var(--ds-space-2) 0 0; max-width: 760px; }

/* ---- Landing: hero ---- */
.hero { padding: var(--ds-space-8) 0 var(--ds-space-7); }
.hero__inner { max-width: 820px; }
.hero__eyebrow { display: inline-flex; align-items: center; gap: var(--ds-space-2); margin-bottom: var(--ds-space-4); padding: var(--ds-space-1) var(--ds-space-3) var(--ds-space-1) var(--ds-space-1); background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-pill); box-shadow: var(--ds-shadow-xs); }
.hero__eyebrow-text { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: var(--ds-text-muted); }
.hero__title { font-size: var(--ds-fs-3xl); font-weight: var(--ds-fw-semibold); line-height: var(--ds-lh-tight); letter-spacing: -.02em; margin: 0 0 var(--ds-space-4); }
.hero__sub { font-size: var(--ds-fs-md); line-height: 1.5; color: var(--ds-text-muted); max-width: 680px; margin: 0 0 var(--ds-space-6); }
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--ds-space-3); align-items: center; }

/* ---- Stat / capability band ---- */
.statband { margin-top: var(--ds-space-7); border-top: 1px solid var(--ds-border); padding-top: var(--ds-space-6); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ds-space-5); }
@media (max-width: 620px) { .statband { grid-template-columns: 1fr; gap: var(--ds-space-4); } }
.stat__value { font-size: var(--ds-fs-2xl); font-weight: var(--ds-fw-semibold); color: var(--ds-text); line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--ds-fs-sm); color: var(--ds-text-muted); margin-top: var(--ds-space-2); line-height: 1.4; }

/* ---- Feature / benefit grids ---- */
.feature__icon {
  width: 36px; height: 36px; border-radius: var(--ds-radius);
  background: var(--ds-primary-soft); color: var(--ds-primary);
  display: grid; place-items: center; margin-bottom: var(--ds-space-3);
  border: 1px solid var(--ds-primary-border);
}
.feature__title { font-size: var(--ds-fs-md); font-weight: var(--ds-fw-semibold); margin: 0 0 var(--ds-space-2); }
.feature__body { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); line-height: 1.5; margin: 0; }

/* ---- Architecture flow ---- */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--ds-space-3); }
.flow__node {
  flex: 1; min-width: 150px; background: var(--ds-surface); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius); padding: var(--ds-space-4); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--ds-space-2);
  box-shadow: var(--ds-shadow-xs);
}
.flow__node .ds-eyebrow { display: block; color: var(--ds-text-subtle); }
.flow__icon { color: var(--ds-primary); }
.flow__label { font-size: var(--ds-fs-sm); color: var(--ds-text); }
.flow__arrow { align-self: center; color: var(--ds-text-subtle); display: grid; place-items: center; }
@media (max-width: 900px) { .flow__arrow { transform: rotate(90deg); } }

/* ---- Definition rows (security / benefits lists) ---- */
.deflist { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.defrow { display: flex; gap: var(--ds-space-3); align-items: flex-start; }
.defrow__mark { color: var(--ds-success); flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--ds-radius-sm); background: var(--ds-success-soft); margin-top: 1px; }
.defrow__title { font-weight: var(--ds-fw-semibold); }
.defrow__body { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); line-height: 1.5; margin-top: 2px; }

/* ---- FAQ (hand-rolled accordion via <details>) ---- */
.faq { max-width: var(--ds-container-narrow); margin: 0 auto; display: flex; flex-direction: column; gap: var(--ds-space-2); }
.faq__item { border: 1px solid var(--ds-border); border-radius: var(--ds-radius); background: var(--ds-surface); overflow: hidden; transition: border-color var(--ds-transition), box-shadow var(--ds-transition); }
.faq__item[open] { border-color: var(--ds-border-strong); box-shadow: var(--ds-shadow-xs); }
.faq__q { cursor: pointer; list-style: none; padding: var(--ds-space-4); font-weight: var(--ds-fw-medium); display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-3); }
.faq__q::-webkit-details-marker { display: none; }
.faq__q:hover { background: var(--ds-surface-2); }
.faq__q:focus-visible { box-shadow: var(--ds-focus); border-radius: var(--ds-radius-sm); }
.faq__sign { color: var(--ds-text-subtle); flex: none; display: grid; place-items: center; transition: transform var(--ds-transition), color var(--ds-transition); }
.faq__item[open] .faq__q { border-bottom: 1px solid var(--ds-border); }
.faq__item[open] .faq__sign { transform: rotate(180deg); color: var(--ds-primary); }
.faq__a { padding: var(--ds-space-4); color: var(--ds-text-muted); font-size: var(--ds-fs-sm); line-height: 1.55; }

/* ---- CTA band (repeated conversion prompt) ---- */
.ctaband { max-width: var(--ds-container-narrow); margin: var(--ds-space-6) auto 0; text-align: center; background: var(--ds-primary-soft); border: 1px solid var(--ds-primary-border); border-radius: var(--ds-radius-lg); padding: var(--ds-space-6); }
.ctaband__title { font-size: var(--ds-fs-lg); font-weight: var(--ds-fw-semibold); margin: 0 0 var(--ds-space-2); }
.ctaband__sub { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); margin: 0 0 var(--ds-space-4); }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--ds-border); background: var(--ds-surface); margin-top: var(--ds-space-8); }
.footer__inner { padding: var(--ds-space-7) 0; display: grid; gap: var(--ds-space-6); }
.footer__cols { display: grid; gap: var(--ds-space-6); grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 900px) { .footer__cols { grid-template-columns: 1fr; } }
.footer__brand { margin-bottom: var(--ds-space-3); }
.footer__blurb { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); line-height: 1.5; max-width: 360px; margin: 0; }
.footer__col { display: flex; flex-direction: column; align-items: flex-start; }
.footer__title { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-semibold); text-transform: uppercase; letter-spacing: .06em; color: var(--ds-text-subtle); margin-bottom: var(--ds-space-3); }
.footer__link { display: inline-flex; align-items: center; gap: var(--ds-space-2); color: var(--ds-text-muted); padding: var(--ds-space-1) 0; font-size: var(--ds-fs-sm); }
.footer__link:hover { color: var(--ds-text); }
.footer__legal { border-top: 1px solid var(--ds-border); padding-top: var(--ds-space-4); color: var(--ds-text-subtle); font-size: var(--ds-fs-sm); display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--ds-space-2); }

/* ============================================================================
   Workspace: case bar → stats → network graph + ring detail
   ============================================================================ */

/* ---- Case-file selector bar ---- */
.casebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2); }
.casebar__meta { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2); color: var(--ds-text-subtle); font-size: var(--ds-fs-xs); font-variant-numeric: tabular-nums; }

/* ---- Stat cards row ---- */
.statgrid { display: grid; gap: var(--ds-space-3); grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1100px) { .statgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.statcard { border: 1px solid var(--ds-border); background: var(--ds-surface); border-radius: var(--ds-radius); padding: var(--ds-space-3) var(--ds-space-4); box-shadow: var(--ds-shadow-xs); }
.statcard__label { font-size: var(--ds-fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--ds-text-subtle); }
.statcard__value { margin-top: var(--ds-space-1); font-size: var(--ds-fs-xl); font-weight: var(--ds-fw-semibold); color: var(--ds-text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.statcard__value--danger { color: var(--ds-danger); }
.statcard__value--primary { color: var(--ds-primary); }

/* ---- Analyze layout: network graph beside ring panel ---- */
.analyze-grid { display: grid; gap: var(--ds-space-5); align-items: start; }
@media (min-width: 1100px) { .analyze-grid { grid-template-columns: minmax(0, 1fr) 420px; } }

/* ---- Network graph panel ---- */
.graph-panel { padding: 0; overflow: hidden; }
.graph-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4); border-bottom: 1px solid var(--ds-border);
  flex-wrap: wrap;
}
.graph-panel__title { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--ds-text-subtle); }
.graph-panel__body { padding: var(--ds-space-2); background: var(--ds-surface-2); }
.graph-svg { width: 100%; height: auto; display: block; }
.graph-svg .node--clickable { cursor: pointer; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: var(--ds-space-3); font-size: var(--ds-fs-xs); color: var(--ds-text-muted); }
.legend__item { display: inline-flex; align-items: center; gap: var(--ds-space-1); }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ds-success); background: color-mix(in srgb, var(--ds-success) 25%, transparent); }
.legend__sq { width: 9px; height: 9px; border-radius: 2px; border: 1.5px solid var(--ds-primary); background: var(--ds-primary-soft); }
.legend__line { width: 16px; height: 0; border-top: 2px solid var(--ds-text-subtle); }
.legend__line--device { border-top: 2px dashed var(--ds-primary); }
.legend__line--identity { border-top: 2px dotted var(--ds-info); }

/* ---- Ring list ---- */
.ring-list { max-height: 260px; overflow-y: auto; }
.ring-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-2);
  width: 100%; text-align: left; background: none; border: none;
  border-top: 1px solid var(--ds-border); padding: var(--ds-space-3) var(--ds-space-4);
  cursor: pointer; color: var(--ds-text); transition: background var(--ds-transition);
}
.ring-row:first-child { border-top: none; }
.ring-row:hover { background: var(--ds-surface-2); }
.ring-row--on { background: var(--ds-primary-soft); }
.ring-row:focus-visible { outline: none; box-shadow: var(--ds-focus-inset); }
.ring-row__id { font-family: var(--ds-font-mono); font-size: var(--ds-fs-xs); color: var(--ds-text-muted); }
.ring-row__pattern { font-size: var(--ds-fs-sm); }
.ring-row__score { font-size: var(--ds-fs-xs); color: var(--ds-text-muted); font-variant-numeric: tabular-nums; }

/* ---- Ring detail ---- */
.ring-detail__score { display: flex; align-items: baseline; gap: var(--ds-space-2); }
.ring-detail__pct { font-size: var(--ds-fs-3xl); font-weight: var(--ds-fw-semibold); color: var(--ds-text); line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ring-detail__meta { font-size: var(--ds-fs-xs); color: var(--ds-text-muted); }

/* ---- Evidence driver bars (signed contributions) ---- */
.driver { display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-2) 0; }
.driver + .driver { border-top: 1px solid var(--ds-border); }
.driver:first-child { padding-top: 0; }
.driver__name { font-size: var(--ds-fs-sm); color: var(--ds-text); text-transform: capitalize; }
.driver__value { font-size: var(--ds-fs-xs); color: var(--ds-text-subtle); }
.driver__bar-wrap { display: flex; align-items: center; justify-content: flex-end; gap: var(--ds-space-2); }
.driver__bar { height: 8px; border-radius: var(--ds-radius-pill); }
.driver__bar--pos { background: var(--ds-danger); }
.driver__bar--neg { background: var(--ds-success); }
.driver__num { width: 40px; text-align: right; font-variant-numeric: tabular-nums; font-size: var(--ds-fs-sm); font-weight: var(--ds-fw-medium); }
.driver__num--pos { color: var(--ds-danger); }
.driver__num--neg { color: var(--ds-success); }

/* ---- Meter (used in the ring risk gauge + reused elsewhere) ---- */
.meter { height: 8px; width: 100%; background: var(--ds-surface-3); border-radius: var(--ds-radius-pill); overflow: hidden; }
.meter__fill { height: 100%; background: var(--ds-primary); border-radius: var(--ds-radius-pill); transition: width var(--ds-transition-slow); }
.meter__fill--success { background: var(--ds-success); }
.meter__fill--warning { background: var(--ds-warning); }
.meter__fill--danger  { background: var(--ds-danger); }

/* ---- Member table ---- */
.member-scroll { max-height: 220px; overflow: auto; border: 1px solid var(--ds-border); border-radius: var(--ds-radius); }

/* ---- Reason codes list ---- */
.reasons { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--ds-space-2); }
.reasons li { display: flex; gap: var(--ds-space-2); font-size: var(--ds-fs-sm); color: var(--ds-text-muted); line-height: 1.5; }
.reasons li .reasons__mark { color: var(--ds-primary); flex: none; }

/* ---- AI narrative + Q&A blocks ---- */
.narrative-box {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-size: var(--ds-fs-sm); line-height: 1.6; color: var(--ds-text);
  background: var(--ds-surface-2); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius); padding: var(--ds-space-4);
}
.ask-row { display: flex; gap: var(--ds-space-2); align-items: stretch; }
.ask-row .ds-input { flex: 1; }

/* ---- Guided tour overlay (hand-rolled) ---- */
.tour__backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 70; }
.tour__spot { position: fixed; z-index: 71; border-radius: var(--ds-radius); box-shadow: 0 0 0 3px var(--ds-primary), 0 0 0 9999px rgba(16,24,40,.55); pointer-events: none; transition: all var(--ds-transition-slow); }
.tour__pop {
  position: fixed; z-index: 72; width: min(360px, 92vw); background: var(--ds-surface);
  border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-lg); padding: var(--ds-space-5);
}
.tour__step { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-semibold); letter-spacing: .06em; text-transform: uppercase; color: var(--ds-primary); }
.tour__title { font-size: var(--ds-fs-md); font-weight: var(--ds-fw-semibold); margin: var(--ds-space-1) 0 var(--ds-space-2); }
.tour__body { color: var(--ds-text-muted); font-size: var(--ds-fs-sm); line-height: 1.5; margin: 0 0 var(--ds-space-4); }
.tour__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-3); }
.tour__dots { display: flex; gap: var(--ds-space-1); }
.tour__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ds-border-strong); }
.tour__dot--on { background: var(--ds-primary); }

/* ---- Legacy a11y helper alias (kept so existing markup + DS class both work) ---- */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
