/* ─────────────────────────────────────────────────────────────
   IndustrialBriefs — Article Market Widget CSS
   File: assets/css/market-widget-article.css
   Scoped to .article-market-widget
   ───────────────────────────────────────────────────────────── */

/* ── Container ── */
.article-market-widget {
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  border: 0.5px solid #e2ddd5;
  border-radius: 10px;
  overflow: hidden;
  margin: 40px 0;
  container-type: inline-size;
}

/* ── Header ── */
.amw-header {
  background: #1a2e4a;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.amw-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.amw-title em {
  color: #e96d2e;
  font-style: normal;
}

.amw-subtitle {
  font-size: 9px;
  color: #6a85a0;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.amw-header-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.amw-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: amw-pulse 2s ease-in-out infinite;
}

@keyframes amw-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.amw-status {
  font-size: 9px;
  color: #6a85a0;
  white-space: nowrap;
}

/* ── Ticker strip ── */
.amw-ticker {
  background: #111d2e;
  padding: 5px 0;
  overflow: hidden;
  white-space: nowrap;
}

.amw-ticker-track {
  display: inline-flex;
  gap: 0;
  animation: amw-scroll 35s linear infinite;
  will-change: transform;
}

.amw-ticker:hover .amw-ticker-track {
  animation-play-state: paused;
}

@keyframes amw-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.amw-tick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.amw-tick-sym {
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
}

.amw-tick-price {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
}

.amw-tick-chg {
  font-size: 9px;
  font-weight: 700;
}

.amw-ticker-placeholder {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
  padding: 0 16px;
}

/* ── Body ── */
.amw-body {
  padding: 12px 14px;
}

/* ── Context label ── */
.amw-context-label {
  font-size: 9px;
  font-weight: 800;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.amw-context-label::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: #e2ddd5;
}

/* ── Row label (mentioned companies) ── */
.amw-row-label {
  font-size: 9px;
  font-weight: 800;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 14px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.amw-row-label::before {
  content: '';
  flex: 1;
  height: 0.5px;
  background: #e2ddd5;
}

.amw-row-label::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: #e2ddd5;
}

/* ── Cards grid ── */
.amw-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@container (max-width: 540px) {
  .amw-cards-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container (max-width: 320px) {
  .amw-cards-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Card ── */
.amw-card {
  background: #f8f7f4;
  border-radius: 7px;
  padding: 9px 10px 8px;
  cursor: pointer;
  border: 0.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  outline: none;
}

.amw-card:hover,
.amw-card:focus-visible {
  background: #fff;
  border-color: #d0ccc5;
}

.amw-card.featured {
  border-color: rgba(233, 109, 46, 0.4);
  background: #fdf8f5;
}

.amw-card.featured:hover {
  border-color: #e96d2e;
}

.amw-card-sym {
  font-size: 12px;
  font-weight: 800;
  color: #1a2e4a;
  line-height: 1;
}

.amw-card-name {
  font-size: 8px;
  color: #888;
  margin: 2px 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amw-card-price {
  font-size: 14px;
  font-weight: 700;
  color: #1a2e4a;
  line-height: 1;
}

.amw-card-chg {
  font-size: 9px;
  font-weight: 700;
  margin-top: 3px;
}

/* ── 52w bar ── */
.amw-card-bar {
  height: 3px;
  background: #e2ddd5;
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}

.amw-card-fill {
  height: 100%;
  border-radius: 2px;
}

/* ── AI badge ── */
.amw-ai-badge {
  display: inline-block;
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 2px;
  margin-top: 4px;
}

/* ── Direction colours ── */
.up   { color: #16a34a; }
.down { color: #dc2626; }
.neutral { color: #888; }

.amw-card-fill.up   { background: #4ade80; }
.amw-card-fill.down { background: #f87171; }

.amw-tick-chg.up   { color: #4ade80; }
.amw-tick-chg.down { color: #f87171; }

/* ── AI level badges ── */
.ai-high   { background: #dbeafe; color: #1e40af; }
.ai-medium { background: #d1fae5; color: #065f46; }
.ai-infra  { background: #f3e8ff; color: #6b21a8; }

/* ── Detail panel ── */
.amw-detail {
  background: #f8f7f4;
  border: 0.5px solid #e2ddd5;
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.amw-detail-inner {
  padding: 12px 14px;
}

.amw-detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.amw-detail-sym {
  font-size: 16px;
  font-weight: 800;
  color: #1a2e4a;
  line-height: 1;
}

.amw-detail-name {
  font-size: 10px;
  color: #888;
  margin-top: 3px;
}

.amw-detail-price-block {
  text-align: right;
}

.amw-detail-price {
  font-size: 16px;
  font-weight: 700;
  color: #1a2e4a;
  line-height: 1;
}

.amw-detail-chg {
  font-size: 10px;
  font-weight: 700;
  margin-top: 3px;
}

.amw-detail-close {
  font-size: 10px;
  color: #888;
  background: #fff;
  border: 0.5px solid #ddd;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  align-self: flex-start;
}

.amw-detail-close:hover {
  background: #f0ede7;
}

/* ── Detail stat row ── */
.amw-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

@container (max-width: 480px) {
  .amw-detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.amw-dstat {
  background: #fff;
  border-radius: 6px;
  padding: 7px 9px;
  border: 0.5px solid #e2ddd5;
}

.amw-dstat-label {
  font-size: 8px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.amw-dstat-val {
  font-size: 12px;
  font-weight: 700;
  color: #1a2e4a;
}

/* ── Why this stock ── */
.amw-detail-why {
  font-size: 10px;
  color: #555;
  line-height: 1.6;
  background: #fff;
  border-radius: 6px;
  padding: 9px 11px;
  border-left: 3px solid #e96d2e;
}

/* ── Footer ── */
.amw-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 0.5px solid #e2ddd5;
}

.amw-disclaimer {
  font-size: 8px;
  color: #bbb;
}

.amw-markets-link {
  font-size: 9px;
  font-weight: 700;
  color: #e96d2e;
  text-decoration: none;
  white-space: nowrap;
}

.amw-markets-link:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────
   INLINE TICKER CHIPS
   Appear inside article body text on company
   name mentions. Click → scroll to widget.
   ───────────────────────────────────────────── */

.amw-inline-ref {
  position: relative;
  border-bottom: 1px dotted #e96d2e;
  cursor: pointer;
  display: inline;
}

.amw-inline-chip {
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2e4a;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

.amw-inline-chip.up   { background: #14532d; }
.amw-inline-chip.down { background: #7f1d1d; }

.amw-inline-chip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1a2e4a;
}

.amw-inline-ref:hover .amw-inline-chip {
  display: block;
}

/* ─────────────────────────────────────────────
   DARK MODE
   ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  .article-market-widget { background: #1a2536; border-color: rgba(255,255,255,0.08); }
  .amw-body { background: transparent; }
  .amw-card { background: #243040; }
  .amw-card:hover, .amw-card:focus-visible { background: #2c3a4e; border-color: rgba(255,255,255,0.12); }
  .amw-card.featured { background: #2a2010; border-color: rgba(233,109,46,0.5); }
  .amw-card-sym, .amw-card-price { color: #e2ddd5; }
  .amw-card-name, .amw-status { color: #6a85a0; }
  .amw-card-bar { background: rgba(255,255,255,0.1); }
  .amw-detail { background: #1f2d3d; border-color: rgba(255,255,255,0.08); }
  .amw-detail-sym, .amw-detail-price, .amw-dstat-val { color: #e2ddd5; }
  .amw-dstat { background: #243040; border-color: rgba(255,255,255,0.08); }
  .amw-detail-why { background: #243040; color: #b0c4d8; }
  .amw-footer { border-color: rgba(255,255,255,0.08); }
  .amw-context-label, .amw-row-label { color: #4a6a8a; }
  .amw-context-label::after, .amw-row-label::before, .amw-row-label::after { background: rgba(255,255,255,0.08); }
}

.is-dark-mode .article-market-widget,
[data-theme="dark"] .article-market-widget {
  background: #1a2536;
  border-color: rgba(255, 255, 255, 0.08);
}
