/* ==========================================================
   Vapih FX — shared widgets (.w-*): sessions, risk, sparkline
   Tokens only (app.css). Works in dark + light.
   ========================================================== */

/* ---------- session colours ---------- */
.w-s-syd { --c: var(--info); }
.w-s-tok { --c: var(--accent-2); }
.w-s-lon { --c: var(--accent); }
.w-s-ny  { --c: var(--warn); }

/* ---------- sessions ---------- */
.w-ses { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.w-ses-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.w-clock { display: flex; flex-direction: column; gap: 2px; }
.w-clock-t { font: 600 34px/1 var(--mono); letter-spacing: -.04em; color: var(--text); }
.w-clock-d { font-size: 12px; color: var(--muted); }
.w-clock-d .num { font-size: 11px; color: var(--dim); }

.w-liq { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); }
.w-liq-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.w-liq-hi { background: var(--up-bg); border-color: transparent; color: var(--up); }
.w-liq-hi .w-liq-dot { background: var(--up); box-shadow: 0 0 0 0 var(--up); animation: w-ping 2s var(--ease) infinite; }
.w-liq-mid { background: var(--accent-bg); border-color: transparent; color: var(--accent); }
.w-liq-mid .w-liq-dot { background: var(--accent); }
.w-liq-low { color: var(--text-2); }
.w-liq-low .w-liq-dot { background: var(--info); }
.w-liq-off { color: var(--muted); }

.w-ses-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--warn-bg); color: var(--text); border: 1px solid var(--line); }
.w-ses-banner .ic { width: 22px; height: 22px; color: var(--warn); flex: none; }
.w-ses-banner b { display: block; font-size: 13.5px; }
.w-ses-banner span { font-size: 12px; color: var(--text-2); }

/* timeline (rendered LTR) */
.w-tl { --lab: 52px; position: relative; display: flex; flex-direction: column; gap: 5px; padding: 10px 10px 4px; border-radius: var(--r);
  background: var(--panel-2); border: 1px solid var(--line); direction: ltr; overflow: hidden; }
.w-tl-row { display: flex; align-items: center; height: 16px; }
.w-tl-lab { width: var(--lab); flex: none; font-size: 11px; color: var(--muted); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; unicode-bidi: plaintext; }
.w-tl-row.live .w-tl-lab { color: var(--text); font-weight: 600; }
.w-tl-track { position: relative; flex: 1; height: 100%; border-radius: 5px;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px calc(100% / 24)); }
.w-tl-blk { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; background: var(--c); opacity: .38; transition: opacity .3s var(--ease); }
.w-tl-row.live .w-tl-blk { opacity: .9; box-shadow: 0 0 12px -2px var(--c); }
.w-tl-blk.off, .w-tl-ov.off { opacity: .12 !important; box-shadow: none !important;
  background-image: repeating-linear-gradient(45deg, transparent 0 4px, var(--panel) 4px 6px); }
.w-tl-ovr { height: 12px; }
.w-tl-ov { position: absolute; top: 1px; bottom: 1px; border-radius: 3px; background: var(--text-2); opacity: .22;
  background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--panel-2) 3px 5px); }
.w-tl-ov.hot { background-color: var(--up); opacity: .7; }

.w-tl-axis { position: relative; height: 18px; margin-left: var(--lab); border-top: 1px solid var(--line); margin-top: 2px; }
.w-tick { position: absolute; top: 0; width: 1px; height: 3px; background: var(--line-2); transform: translateX(-.5px); }
.w-tick.major { height: 6px; background: var(--dim); }
.w-tick-l { position: absolute; top: 6px; font-size: 10px; color: var(--muted); transform: translateX(-50%); }
.w-tick-l[style^="left:0"] { transform: none; }

.w-now { position: absolute; top: 4px; bottom: 18px; width: 0;
  left: calc(10px + var(--lab) + (100% - 20px - var(--lab)) * var(--p)); border-left: 2px solid var(--down); pointer-events: none; z-index: 2; }
.w-now::before { content: ''; position: absolute; top: -2px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--down); box-shadow: 0 0 0 3px var(--down-bg); }
.w-now span { position: absolute; bottom: -17px; left: 0; transform: translateX(-50%); font-size: 10px; font-weight: 600; color: var(--panel);
  background: var(--down); padding: 0 4px; border-radius: 4px; line-height: 15px; }

/* session cards */
.w-ses-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.w-ses-card { position: relative; display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border-radius: var(--r); background: var(--panel-2);
  border: 1px solid var(--line); overflow: hidden; min-width: 0; transition: border-color .3s var(--ease); }
.w-ses-card.live { border-color: var(--c); background: linear-gradient(180deg, var(--panel-2), var(--panel)); }
.w-ses-h { display: flex; align-items: center; gap: 7px; min-width: 0; }
.w-ses-h b { font-size: 13px; font-weight: 600; }
.w-sw { width: 4px; height: 14px; border-radius: 2px; background: var(--c); flex: none; }
.w-city { font-size: 11px; color: var(--dim); }
.w-chip { margin-inline-start: auto; font-size: 10.5px; padding: 2px 8px; }
.w-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.w-dot.pulse { opacity: 1; animation: w-ping 2s var(--ease) infinite; box-shadow: 0 0 0 0 var(--up); }
.w-ses-cd { font-size: 12.5px; color: var(--text-2); }
.w-ses-cd .num { font-weight: 600; color: var(--text); margin-inline: 1px; }
.w-ses-card.live .w-ses-cd .num { color: var(--c); }
.w-ses-hrs { font-size: 11px; }
.w-ses-hrs .num { font-size: 11px; }
.w-ses-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); }
.w-ses-prog i { display: block; height: 100%; background: var(--c); margin-inline-start: 0; }

@keyframes w-ping { 0% { box-shadow: 0 0 0 0 var(--up-bg); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- risk monitor ---------- */
.w-risk { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.w-risk-top { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 16px; align-items: center; }
.w-gauge { position: relative; width: 100%; max-width: 220px; margin-inline: auto; }
.w-gauge-svg { display: block; width: 100%; height: auto; overflow: visible; }
.w-g-bg, .w-g-val { fill: none; stroke-width: 13; stroke-linecap: round; }
.w-g-bg { stroke: var(--panel-3); }
.w-g-val { transition: stroke-dasharray .6s var(--ease); }
.w-g-ticks line { stroke: var(--dim); stroke-width: 1.5; stroke-linecap: round; }
.w-g-knob { fill: var(--panel); stroke: var(--text); stroke-width: 2.5; }
.w-gauge-c { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; }
.w-gauge-v { font: 600 26px/1.1 var(--mono); letter-spacing: -.03em; }
.w-gauge-l { font-size: 11.5px; color: var(--muted); }

.w-risk-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.w-risk-kpis > div { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--panel-2); border: 1px solid var(--line); min-width: 0; }
.w-risk-kpis span { font-size: 11.5px; color: var(--muted); }
.w-risk-kpis b { font: 600 14.5px/1.2 var(--mono); text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-risk-kpis b.num { text-align: end; }
.w-risk-kpis .meter { height: 4px; margin-top: 3px; }

.w-warns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.w-warn { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.55;
  background: var(--panel-2); border: 1px solid var(--line); border-inline-start: 3px solid var(--dim); color: var(--text-2); }
.w-warn b.num { color: var(--text); font-weight: 600; }
.w-warn-ic { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--panel-3); color: var(--muted); }
.w-warn-ic .ic { width: 14px; height: 14px; }
.w-warn.w-high { border-inline-start-color: var(--down); background: var(--down-bg); color: var(--text); }
.w-warn.w-high .w-warn-ic { background: var(--down); color: var(--panel); }
.w-warn.w-med { border-inline-start-color: var(--warn); }
.w-warn.w-med .w-warn-ic { background: var(--warn-bg); color: var(--warn); }
.w-warn.w-info { border-inline-start-color: var(--info); }
.w-warn.w-info .w-warn-ic { color: var(--info); }

.w-risk-ok { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border-radius: var(--r); background: var(--up-bg); color: var(--up); font-weight: 600; font-size: 13px; }
.w-risk-ok .ic { width: 20px; height: 20px; }
.w-risk-wait { padding: 8px 0; }

.w-exp-h { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: -6px; }
.w-exp-legend { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; font-size: 11px; }
.w-exp-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-inline-start: 6px; }
.w-exp-legend i.dn { background: var(--down); }
.w-exp-legend i.upc { background: var(--up); }
.w-exp { display: flex; flex-direction: column; gap: 6px; direction: ltr; }
.w-exp-row { display: grid; grid-template-columns: 64px 1fr 72px; align-items: center; gap: 10px; }
.w-exp-c { font: 600 12px/1 var(--mono); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.w-exp-bar { position: relative; display: flex; height: 10px; border-radius: 5px; background: var(--panel-3); }
.w-exp-bar::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
.w-exp-half { flex: 1; display: flex; }
.w-exp-half.l { justify-content: flex-end; }
.w-exp-half i { display: block; height: 100%; transition: width .5s var(--ease); }
.w-exp-half.l i { background: var(--down); border-radius: 5px 0 0 5px; opacity: .85; }
.w-exp-half.r i { background: var(--up); border-radius: 0 5px 5px 0; opacity: .85; }
.w-exp-v { font-size: 11.5px; text-align: right; }

/* ---------- sparkline ---------- */
.w-spark { display: inline-block; vertical-align: middle; overflow: visible; }
.w-spark-flat { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .w-ses-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .w-clock-t { font-size: 28px; }
  .w-tl { --lab: 42px; padding: 8px 8px 4px; }
  .w-now { left: calc(8px + var(--lab) + (100% - 16px - var(--lab)) * var(--p)); }
  .w-tl-lab { font-size: 10px; }
  .w-tick-l.minor { display: none; }
  .w-risk-top { grid-template-columns: 1fr; }
  .w-gauge { max-width: 200px; }
  .w-exp-row { grid-template-columns: 52px 1fr 62px; gap: 8px; }
}
@media (max-width: 420px) {
  .w-ses-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .w-ses-card { padding: 9px 10px; }
  .w-city { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .w-liq-hi .w-liq-dot, .w-dot.pulse { animation: none; }
  .w-tl-blk, .w-g-val, .w-exp-half i { transition: none; }
}
