/* ============================================================================
   ServeHub · Website analytics — the owner-facing traffic dashboard
   Ported from the Claude Design "servehub / Website Analytics" mockup.

   SCOPED UNDER `.wan`, WHICH ONLY EVER RENDERS INSIDE `.shd`.
   Unlike website_builder.css this file defines NO design tokens: every colour,
   radius and shadow the mockup's analytics.css declared (--paper, --ink, --steel,
   --line, --blue*, --amber, --green, --red, --r, --shadow…) is already defined on
   `.shd` in dashboard.css, and re-declaring them here would fork the palette and
   break the dark theme, which works by remapping those same tokens. Verified
   token-for-token against dashboard.css before this file was written — nothing was
   missing, so nothing is redefined.

   Likewise the mockup's shared-shell primitives are NOT re-implemented here. Its
   `.card` / `.card-head` / `.card-body` / `.page-head` / `.btn` are the same
   components as dashboard.css's `.shd-card` / `.shd-card-head` / `.shd-card-body`
   / `.shd-page-head` / `.shd-btn`, so the view uses those and this file adds only
   what is genuinely new: the stat strip, the panel grid, the bar lists, the metric
   rows and the chart.

   Loaded page-only via `content_for :head` in app/views/website_analytics/show.

   DELIBERATELY NOT PORTED, because the panels they styled have no data source in
   this app and were dropped rather than stubbed (see the view's header comment):
   `.ai-ask` / `.ai-chip` (AI stat chat), `.postsby` / `.tabrail` / `.ptbl` /
   `.pcell` / `.thumb` (blog performance), `.heat*` / `.hlegend` (post views by
   hour), `.qrows` / `.bigstat` / `.stale` (Search Console + AI queries),
   `.promo` (upsells with no destination), `.sel` and `.grid-tbl`.
   ============================================================================ */

.wan { padding: 24px 16px 48px; }

/* ---- page head ------------------------------------------------------------ */
.wan .wan-head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.wan .wan-head .ttl { flex: 1 1 420px; min-width: 0; }
.wan .wan-head .sub { font-size: 14px; color: var(--steel); margin-top: 9px; max-width: 62ch; line-height: 1.5; }
.wan .wan-head .sub a { color: var(--blue-deep); font-weight: 600; }
.wan .wan-head-actions { display: flex; gap: 9px; flex: 0 0 auto; padding-top: 8px; flex-wrap: wrap; }

/* ---- live visitors ------------------------------------------------------- */
.wan .rv { display: flex; flex-direction: column; gap: 10px; }
.wan .rv-top { display: flex; align-items: flex-start; gap: 12px; }
.wan .rv-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: 0 0 auto; margin-top: 7px;
  box-shadow: 0 0 0 4px rgba(24, 121, 78, .16);
}
.wan .rv-dot.idle { background: var(--steel-2); box-shadow: 0 0 0 4px rgba(139, 144, 153, .16); }
.wan .rv-n { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 23px; line-height: 1.05; flex: 1 1 auto; color: var(--ink); }
.wan .rv-help { font-size: 13px; color: var(--steel); line-height: 1.5; }
.wan .rv-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.wan .rv-stamp { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--steel-2); letter-spacing: .02em; }

/* ---- date range bar ------------------------------------------------------ */
.wan .wan-range { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.wan .rangebtn {
  display: inline-flex; align-items: center; gap: 9px; border: 2px solid var(--ink); border-radius: var(--r-sm);
  background: var(--white); box-shadow: var(--shadow-sm); padding: 9px 13px; cursor: pointer; color: var(--ink);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 16px; text-transform: uppercase;
  letter-spacing: .01em; text-decoration: none;
}
.wan .rangebtn:hover { background: var(--paper-2); }
.wan .rangebtn.on { background: var(--blue-wash); border-color: var(--blue-ink); color: var(--blue-ink); }
.wan .rangebtn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.wan .wan-range .cmp { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--steel); letter-spacing: .02em; }
[data-theme="dark"] .wan .rangebtn.on, .dark .wan .rangebtn.on { color: #8fd3f5; border-color: var(--blue-deep); }

/* ---- key stats ----------------------------------------------------------- */
.wan .kstats { display: grid; grid-template-columns: repeat(4, 1fr); }
.wan .kstat { padding: 17px 18px; border-right: 2px solid var(--line); min-width: 0; }
.wan .kstat:last-child { border-right: none; }
.wan .kstat .kl {
  display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; color: var(--steel);
}
.wan .kstat .krow { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 10px; }
.wan .kstat .kv {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 36px; line-height: .9;
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; color: var(--ink);
}
.wan .kstat .spark { width: 96px; height: 30px; flex: 0 0 auto; color: var(--blue); }
.wan .kstat .spark svg { width: 100%; height: 100%; display: block; }
.wan .kstat .spark svg rect { fill: currentColor; }
.wan .kstat .spark.amber { color: var(--amber); }
.wan .kstat .kf { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--steel); margin-top: 9px; line-height: 1.5; }

/* delta chip */
.wan .dl {
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.wan .dl.up { color: #136a45; }
.wan .dl.down { color: var(--red); }
.wan .dl.flat { color: var(--steel-2); }
[data-theme="dark"] .wan .dl.up, .dark .wan .dl.up { color: #52cf95; }

/* ---- section card with band head ---------------------------------------- */
.wan .wan-sec { margin-bottom: 24px; }
.wan .band { display: flex; align-items: baseline; gap: 14px; padding: 16px 22px; border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.wan .band h2 { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 27px; line-height: 1; color: var(--ink); flex: 0 0 auto; }
.wan .band .bnote { font-size: 12.5px; color: var(--steel); flex: 1 1 240px; min-width: 0; }

/* 3-up panel grid with hard dividers */
.wan .tri { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.wan .tri.duo { grid-template-columns: 1.3fr 1fr; }
.wan .tri > .pn { padding: 19px 20px 17px; border-right: 2px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.wan .tri > .pn:last-child { border-right: none; }
.wan .pn-t {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 20px; line-height: 1.05;
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 15px; color: var(--ink);
}
.wan .pn-t .cap {
  margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em; color: var(--steel); border: 1.5px solid var(--line-2);
  border-radius: 5px; padding: 3px 6px; white-space: nowrap; flex: 0 0 auto;
}
.wan .pn-body { flex: 1 1 auto; min-width: 0; }
.wan .pn-note { font-size: 12px; color: var(--steel); margin-top: 14px; line-height: 1.5; }

/* ---- bar lists (sources / pages / regions / contact kinds) --------------- */
.wan .blist { display: grid; gap: 14px; }
.wan .blist .brow { display: grid; gap: 5px; min-width: 0; }
.wan .blist .bhead { display: flex; align-items: baseline; gap: 10px; }
.wan .blist .bname {
  font-size: 13.5px; font-weight: 600; color: var(--ink); flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wan .blist .bname.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.wan .blist .bval { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 19px; line-height: 1; flex: 0 0 auto; color: var(--ink); }
/* Wraps rather than truncating. A caption cut off mid-word ("…or tapped a lin…")
   tells the reader less than nothing; an uneven row height costs nothing. */
.wan .blist .bsub {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--steel); letter-spacing: .01em;
  line-height: 1.4; overflow-wrap: anywhere;
}
.wan .blist .btrack { height: 9px; border: 1.5px solid var(--line-2); border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.wan .blist .btrack i { display: block; height: 100%; background: var(--blue); }
.wan .blist .btrack.amber i { background: var(--amber); }
.wan .blist .btrack.green i { background: var(--green); }

/* ---- metric rows (session quality) -------------------------------------- */
.wan .mrows { display: grid; }
.wan .mrow { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.wan .mrow:first-child { padding-top: 0; }
.wan .mrow:last-child { border-bottom: none; }
.wan .mrow .mi {
  width: 34px; height: 34px; flex: 0 0 auto; border: 2px solid var(--line-2); border-radius: 9px;
  background: var(--paper-2); display: grid; place-items: center; color: var(--steel);
}
.wan .mrow .mi svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.wan .mrow .ml { flex: 1 1 auto; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.wan .mrow .ml span { display: block; font-weight: 400; font-size: 11.5px; color: var(--steel); margin-top: 3px; line-height: 1.45; }
.wan .mrow .mv { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 21px; line-height: 1; white-space: nowrap; color: var(--ink); }

/* ---- bar chart ---------------------------------------------------------- */
.wan .chart { width: 100%; }
.wan .chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.wan .chart .gl { stroke: var(--line); stroke-width: 1.5; }
.wan .chart .ax { stroke: var(--line-2); stroke-width: 2; }
.wan .chart .gt { font-family: 'JetBrains Mono', monospace; font-size: 11px; fill: var(--steel-2); }
.wan .chart .br { fill: var(--blue); }
.wan .chart .br:hover { fill: var(--blue-deep); }

/* ---- per-panel zero state ----------------------------------------------- */
/* Not the same thing as a dropped panel. "Nobody clicked to contact you" is a REAL
   and arguably the most actionable fact this page can report, so it gets stated in
   words rather than shown as an empty box or hidden. */
.wan .blank {
  border: 1.5px dashed var(--line-2); border-radius: var(--r-sm); background: var(--paper-2);
  padding: 18px 16px; font-size: 13px; color: var(--steel); line-height: 1.5;
}
.wan .blank b { color: var(--ink); font-weight: 600; }

/* ---- inline notice strip ------------------------------------------------ */
.wan .notice {
  display: flex; align-items: center; gap: 13px; padding: 13px 20px; border-top: 2px solid var(--line);
  background: var(--blue-wash); flex-wrap: wrap;
}
.wan .notice .nt { flex: 1 1 260px; font-size: 13px; color: var(--blue-ink); font-weight: 500; line-height: 1.5; }
.wan .notice.warn { background: var(--red-wash); }
.wan .notice.warn .nt { color: #7d2b22; }
[data-theme="dark"] .wan .notice .nt, .dark .wan .notice .nt { color: #a8daf2; }
[data-theme="dark"] .wan .notice.warn .nt, .dark .wan .notice.warn .nt { color: #f0a99f; }

/* ---- whole-page states (locked / not live / waiting) -------------------- */
.wan .state { max-width: 720px; }
.wan .state .shd-card-body { padding: 26px 24px; }
.wan .state h2 { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 27px; line-height: 1.05; color: var(--ink); }
.wan .state p { font-size: 14px; color: var(--steel); margin-top: 10px; line-height: 1.55; max-width: 62ch; }
.wan .state p b { color: var(--ink); font-weight: 600; }
.wan .state ul { margin-top: 14px; display: grid; gap: 8px; }
.wan .state li { font-size: 13.5px; color: var(--steel); line-height: 1.5; padding-left: 16px; position: relative; }
.wan .state li::before { content: ""; position: absolute; left: 0; top: 8px; width: 7px; height: 2px; background: var(--amber); }
.wan .state .acts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.wan .state .figure {
  margin-top: 18px; border: 2px solid var(--line-2); border-radius: var(--r-sm); background: var(--paper-2);
  padding: 14px 16px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.wan .state .figure .qv { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 30px; line-height: .9; color: var(--ink); }
.wan .state .figure .qt { font-size: 13px; color: var(--steel); flex: 1 1 200px; line-height: 1.45; }

/* ---- measurement footnote ---------------------------------------------- */
/* The honest-limits block. It is a real part of the page, not fine print: three of
   the numbers above it are approximations by construction and the page has to say
   which and why. */
.wan .caveats { margin-top: 4px; }
.wan .caveats .band h2 { font-size: 22px; }
.wan .caveats dl { display: grid; gap: 16px; padding: 20px 22px; }
.wan .caveats dt {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--steel); margin-bottom: 5px;
}
.wan .caveats dd { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; max-width: 90ch; }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 1180px) {
  .wan .kstats { grid-template-columns: 1fr 1fr; }
  .wan .kstat:nth-child(2) { border-right: none; }
  .wan .kstat:nth-child(1), .wan .kstat:nth-child(2) { border-bottom: 2px solid var(--line); }
  .wan .tri, .wan .tri.duo { grid-template-columns: 1fr; }
  .wan .tri > .pn { border-right: none; border-bottom: 2px solid var(--line); }
  .wan .tri > .pn:last-child { border-bottom: none; }
}
@media (max-width: 820px) {
  .wan .kstats { grid-template-columns: 1fr; }
  .wan .kstat { border-right: none; border-bottom: 2px solid var(--line); }
  .wan .kstat:last-child { border-bottom: none; }
  .wan .kstat .spark { display: none; }
}
