/* ============================= Nifty market sentiment dashboard =============================
   Loaded on the homepage (and the 404 page for its small layout rules). Builds on the light theme
   variables and .m3x-terminal / .m3x-panel styles in main.css. */
.m3x-sent {
  --sent-bull: #15803d;
  --sent-bull-soft: rgba(22, 163, 74, 0.1);
  --sent-bear: #dc2626;
  --sent-bear-soft: rgba(220, 38, 38, 0.09);
  --sent-neutral: #64748b;
  --sent-neutral-soft: rgba(100, 116, 139, 0.12);
  text-align: left;
}
.m3x-sent .is-bullish { --tone: var(--sent-bull); --tone-soft: var(--sent-bull-soft); }
.m3x-sent .is-bearish { --tone: var(--sent-bear); --tone-soft: var(--sent-bear-soft); }
.m3x-sent .is-neutral { --tone: var(--sent-neutral); --tone-soft: var(--sent-neutral-soft); }

.m3x-sent-title {
  margin: 0 auto 0 8px;
  color: rgb(var(--t-ink-rgb) / 0.75);
  font: 500 14px/1.4 "Inter Tight", sans-serif;
}
.m3x-sent-status { font-size: 12px; white-space: nowrap; }
.m3x-sent-stale {
  color: var(--sent-bear);
  font: 500 11px/1.4 "IBM Plex Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.m3x-sent-body { display: grid; gap: 16px; padding: 16px; }
.m3x-sent-grid { display: grid; gap: 16px; }
@media (min-width: 1024px) {
  .m3x-sent-body { gap: 20px; padding: 24px; }
  .m3x-sent-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
}

/* ---------- overall sentiment ---------- */
.m3x-sent-score-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgb(var(--t-ink-rgb) / 0.08);
}
.m3x-sent-headline { display: flex; align-items: center; gap: 14px; }
.m3x-sent-kicker {
  display: block;
  margin-bottom: 4px;
  color: rgb(var(--t-ink-rgb) / 0.5);
  font: 500 11px/1.4 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.m3x-sent-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--tone-soft);
  color: var(--tone);
}
.m3x-sent-icon svg {
  display: none;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.m3x-sent-score.is-bullish .m3x-ico-up,
.m3x-sent-score.is-bearish .m3x-ico-down,
.m3x-sent-score.is-neutral .m3x-ico-flat { display: block; }
.m3x-sent-percent {
  display: block;
  color: var(--tone);
  font: 400 44px/1 "Sora", sans-serif;
  letter-spacing: -1.5px;
}
.m3x-sent-label {
  display: block;
  margin-top: 6px;
  color: var(--tone);
  font: 500 13px/1.3 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.m3x-sent-strength {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 8px 28px;
  margin: 0;
}
.m3x-sent-strength dt { color: rgb(var(--t-ink-rgb) / 0.55); font-size: 12px; line-height: 1.4; }
.m3x-sent-strength dd { margin: 2px 0 0; color: var(--t-ink); font: 400 22px/1.2 "Sora", sans-serif; }

/* ---------- breakdown ---------- */
.m3x-sent-breakdown { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }
.m3x-donut-wrap { position: relative; flex: none; width: 150px; height: 150px; margin: 4px auto; }
.m3x-donut { display: block; width: 100%; height: 100%; }
.m3x-donut circle { fill: none; stroke-width: 6; }
.m3x-donut-ring { stroke: var(--t-subtle-2); }
.m3x-donut-seg { transition: stroke-dasharray 0.5s ease, stroke-dashoffset 0.5s ease; }
.m3x-donut-seg.is-bullish { stroke: var(--sent-bull); }
.m3x-donut-seg.is-bearish { stroke: var(--sent-bear); }
.m3x-donut-seg.is-neutral { stroke: #94a3b8; }
.m3x-donut-wrap figcaption {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgb(var(--t-ink-rgb) / 0.55);
  font-size: 12px;
}
.m3x-donut-wrap figcaption strong { color: var(--t-ink); font: 400 30px/1 "Sora", sans-serif; }
.m3x-sent-counts { flex: 1 1 200px; margin: 0; padding: 0; list-style: none; }
.m3x-sent-counts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgb(var(--t-ink-rgb) / 0.06);
  color: rgb(var(--t-ink-rgb) / 0.75);
  font-size: 14px;
}
.m3x-sent-counts li:first-child { border-top: 0; }
.m3x-sent-counts li span { display: inline-flex; align-items: center; gap: 10px; }
.m3x-sent-counts li span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--tone, var(--t-ink));
}
.m3x-sent-counts li.is-neutral span::before { background: #94a3b8; }
.m3x-sent-counts b { color: var(--t-ink); font: 400 20px/1 "Sora", sans-serif; }

/* ---------- signal per alert (diverging bar chart) ---------- */
.m3x-sig-chart { padding-top: 16px; }
.m3x-sig-chart .m3x-panel-title { flex-wrap: wrap; gap: 4px 12px; }
.m3x-sig-rows { display: grid; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.m3x-sig-row,
.m3x-sig-axis {
  display: grid;
  grid-template-columns: minmax(96px, 32%) minmax(0, 1fr) 48px;
  align-items: center;
  gap: 14px;
}
.m3x-sig-name {
  overflow: hidden;
  color: var(--t-ink);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.m3x-sig-track { position: relative; height: 22px; border-radius: 4px; background: var(--t-subtle-2); }
.m3x-sig-track::before {
  content: "";
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 50%;
  width: 1px;
  background: rgb(var(--t-ink-rgb) / 0.35);
}
.m3x-sig-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: var(--w, 0%);
  background: var(--tone);
  transition: width 0.5s ease;
}
.m3x-sig-row.is-bullish .m3x-sig-bar { left: 50%; border-radius: 0 3px 3px 0; }
.m3x-sig-row.is-bearish .m3x-sig-bar { right: 50%; border-radius: 3px 0 0 3px; }
.m3x-sig-row.is-neutral .m3x-sig-bar { left: calc(50% - 3px); width: 7px; border-radius: 2px; background: #94a3b8; }
.m3x-sig-val { color: var(--tone); font: 500 13px/1 "IBM Plex Mono", monospace; text-align: right; }
.m3x-sig-axis { margin-top: 8px; }
.m3x-sig-axis-scale {
  display: flex;
  justify-content: space-between;
  color: rgb(var(--t-ink-rgb) / 0.5);
  font: 400 11px/1.4 "IBM Plex Mono", monospace;
}
.m3x-sig-axis-scale b { font-weight: 400; }
.m3x-sig-empty { padding: 22px 0; color: rgb(var(--t-ink-rgb) / 0.6); font-size: 14px; text-align: center; }
.m3x-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- states & disclaimer ---------- */
.m3x-sent-error {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
}
.m3x-sent-error[hidden] { display: none; }
.m3x-sent-disclaimer { margin: 0; color: rgb(var(--t-ink-rgb) / 0.55); font-size: 12px; line-height: 1.6; }

@media (max-width: 719px) {
  .m3x-sent-percent { font-size: 36px; }
  .m3x-sent-strength { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .m3x-sig-row,
  .m3x-sig-axis { grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) 40px; gap: 10px; }
  .m3x-sig-name { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .m3x-sig-bar,
  .m3x-donut-seg { transition: none; }
}

/* ---------- 404 page ---------- */
.m3x-error-page { display: grid; justify-items: center; gap: 14px; padding: 200px 0 140px; text-align: center; }
.m3x-error-link { color: var(--m3x-accent); font-weight: 500; }

/* ---------- sentiment card border pulse (green when bullish, red when bearish) ---------- */
.m3x-sent-score {
  border: 1px solid rgb(var(--t-ink-rgb) / 0.12);
  transition: border-color 0.4s ease;
}
.m3x-sent-score.is-bullish { --pulse-rgb: 21, 128, 61; border-color: rgba(21, 128, 61, 0.6); animation: m3x-card-pulse 2.4s ease-out infinite; }
.m3x-sent-score.is-bearish { --pulse-rgb: 220, 38, 38; border-color: rgba(220, 38, 38, 0.6); animation: m3x-card-pulse 2.4s ease-out infinite; }
.m3x-sent-score.is-neutral { border-color: rgba(100, 116, 139, 0.45); animation: none; }
@keyframes m3x-card-pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--pulse-rgb), 0.35); }
  70% { box-shadow: 0 0 0 10px rgba(var(--pulse-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--pulse-rgb), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .m3x-sent-score.is-bullish,
  .m3x-sent-score.is-bearish { animation: none; }
}
