/* Commodity Insight Journey — 9:16 story cards */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600;700;800;900&family=Sarabun:wght@300;400;500;600;700;800&display=swap');

.com-view-toggle {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.com-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.com-view-btn i {
  font-size: 0.75rem;
}

.com-view-btn:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .04);
}

.com-view-btn.active {
  background: rgba(124, 58, 237, .18);
  color: var(--purple-light);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, .25);
}

@media (max-width: 640px) {
  .com-view-btn span {
    display: none;
  }
  .com-view-btn {
    padding: 5px 8px;
  }
}

#gridView.cj-hidden {
  display: none !important;
}

#journeyView {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#journeyView.cj-visible {
  display: flex;
  flex: 1;
  min-height: 0;
}

body.commodity-journey-active .content-area {
  overflow: hidden;
}

body.commodity-journey-active .main-inner {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  gap: 0;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}

body.commodity-journey-active .content-area {
  display: flex;
  flex-direction: column;
}

body.commodity-journey-active .main-content {
  max-width: 100%;
  width: 100%;
}

body.commodity-journey-active .cj-carousel-wrap.journey-hero,
body.commodity-journey-active #cjTrack.journey-track {
  width: 100%;
  max-width: 100%;
}

/* Journey shell */
.cj-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--jc-bg, rgba(8, 8, 22, .95));
}

.cj-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-toolbar, rgba(8, 8, 22, .92));
  flex-shrink: 0;
}

.cj-topbar-title {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text-primary);
}

.cj-topbar-sub {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.cj-back-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.cj-back-btn:hover {
  border-color: rgba(124, 58, 237, .35);
  color: var(--purple-light);
}

.cj-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cj-badge-preview {
  font-size: 0.5625rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(245, 158, 11, .12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, .25);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cj-refresh-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text-muted);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 0.625rem;
  font-weight: 700;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cj-refresh-btn:hover {
  color: var(--purple-light);
  border-color: rgba(124, 58, 237, .35);
}

.cj-refresh-btn[disabled] {
  opacity: .6;
  cursor: wait;
}

.cj-refresh-btn.is-loading i {
  animation: cj-spin 1s linear infinite;
}

@keyframes cj-spin {
  to { transform: rotate(360deg); }
}

.cj-carousel-wrap .jc-progress-bar {
  transition: width linear;
}

.cj-carousel-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
  background: var(--jc-bg, rgba(8, 8, 22, .95));
}

/* Journey track — aligned with home #journeyTrack */
#cjTrack.journey-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  gap: 0;
  scroll-behavior: smooth;
  padding: 16px 0 90px;
  min-height: 0;
  align-items: stretch;
  touch-action: pan-x;
  width: 100%;
}

#cjTrack.journey-track::-webkit-scrollbar {
  display: none;
}

/* Large story cards (home journey style) */
.cj-story {
  flex: 0 0 90%;
  max-width: 560px;
  scroll-snap-align: center;
  scroll-margin-inline: 10px;
  margin: 0 10px;
  padding: 28px 24px;
  border-radius: 20px;
  background: var(--jc-card-bg, rgba(255, 255, 255, .04));
  border: 1.5px solid var(--jc-card-border, rgba(255, 255, 255, .08));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  min-height: 0;
  align-self: stretch;
  max-height: 100%;
  transition: transform .4s cubic-bezier(.4, 0, .2, 1), opacity .4s, box-shadow .4s;
  opacity: .45;
  transform: scale(.92);
  cursor: pointer;
}

.cj-story.cj-active {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 50px var(--jc-glow, rgba(124, 58, 237, .15)), 0 12px 40px rgba(0, 0, 0, .25);
  border-color: rgba(124, 58, 237, .35);
  cursor: default;
}

.cj-story--hook {
  background: linear-gradient(165deg, rgba(124, 58, 237, .14), rgba(6, 182, 212, .06) 55%, var(--jc-card-bg));
}

.cj-story--analysis {
  background: linear-gradient(165deg, rgba(6, 182, 212, .1), rgba(124, 58, 237, .05) 60%, var(--jc-card-bg));
}

.cj-story--impact {
  background: linear-gradient(165deg, rgba(16, 185, 129, .08), rgba(239, 68, 68, .06) 60%, var(--jc-card-bg));
}

.cj-story--sector {
  background: linear-gradient(165deg, rgba(245, 158, 11, .1), rgba(124, 58, 237, .05) 60%, var(--jc-card-bg));
}

.cj-card-type {
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--jc-text-muted, #94a3b8);
}

.cj-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.cj-card-headline {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -.2px;
  color: var(--jc-text, #f1f5f9);
}

.cj-card-sub {
  font-family: 'Sarabun', 'Nunito Sans', sans-serif;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--jc-text-secondary, #cbd5e1);
}

.cj-price-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.cj-price-val {
  font-size: 1.25rem;
  font-weight: 900;
}

.cj-price-chg {
  font-size: 0.75rem;
  font-weight: 700;
}

.cj-price-chg.up { color: var(--green, #10b981); }
.cj-price-chg.down { color: var(--red, #ef4444); }
.cj-price-chg.neutral { color: var(--text-muted); }

.cj-spark-slot {
  height: 140px;
  min-height: 96px;
  margin-top: auto;
  border-radius: 10px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
  position: relative;
}

.cj-spark-slot--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  color: var(--text-muted, #64748b);
}

.cj-tv-spark {
  width: 100%;
  height: 100%;
}

.cj-quote-box {
  padding: 12px;
  border-radius: 12px;
  background: rgba(6, 182, 212, .08);
  border: 1px solid rgba(6, 182, 212, .2);
  font-family: 'Sarabun', 'Nunito Sans', sans-serif;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--jc-text-secondary);
}

/* Clickable events — navigate to sector card or drill commodity */
.cj-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.cj-event-btn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--text-secondary);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.cj-event-btn:hover {
  border-color: rgba(124, 58, 237, .35);
  background: rgba(124, 58, 237, .08);
  color: var(--purple-light);
}

.cj-event-icon {
  flex-shrink: 0;
  font-size: 0.9rem;
  line-height: 1.2;
}

.cj-event-body {
  flex: 1;
  min-width: 0;
}

.cj-event-title {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  font-weight: 700;
  color: var(--jc-text, #f1f5f9);
}

.cj-event-chg {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

.cj-event-chg.up { color: var(--green); }
.cj-event-chg.down { color: var(--red); }
.cj-event-chg.neutral { color: var(--text-muted); }

.cj-event-hint {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Item mode — step navigation Hook / Insight / Impact */
.cj-step-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.cj-step-btn {
  padding: 4px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.5625rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}

.cj-step-btn.active,
.cj-step-btn:hover {
  border-color: rgba(124, 58, 237, .35);
  color: var(--purple-light);
  background: rgba(124, 58, 237, .1);
}

.cj-drivers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.cj-driver-chip {
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(124, 58, 237, .1);
  border: 1px solid rgba(124, 58, 237, .2);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.625rem;
  color: var(--purple-light);
}

.cj-impact-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.cj-impact-col {
  border-radius: 10px;
  padding: 8px;
  overflow-y: auto;
  min-height: 0;
}

.cj-impact-col--up {
  background: rgba(16, 185, 129, .08);
  border: 1px solid rgba(16, 185, 129, .2);
}

.cj-impact-col--dn {
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .2);
}

.cj-impact-col-title {
  font-size: 0.5625rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.cj-impact-col--up .cj-impact-col-title { color: var(--green); }
.cj-impact-col--dn .cj-impact-col-title { color: var(--red); }

.cj-stock-mini-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.cj-stock-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 108px;
  flex: 1 1 108px;
  max-width: 148px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color .15s, background .15s, transform .15s;
}

.cj-stock-mini:hover {
  border-color: rgba(124, 58, 237, .35);
  background: rgba(124, 58, 237, .08);
  transform: translateY(-1px);
}

.cj-stock-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.cj-stock-mini-sym {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--purple-light);
  letter-spacing: .2px;
}

.cj-stock-mini-chg {
  font-size: 0.625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cj-stock-mini-chg.up { color: var(--green, #10b981); }
.cj-stock-mini-chg.down { color: var(--red, #ef4444); }
.cj-stock-mini-chg.neutral { color: var(--text-muted); }

.cj-stock-mini-price {
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.2;
}

.cj-stock-mini-name,
.cj-stock-mini-hint {
  font-size: 0.5625rem;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cj-stock-mini-spark {
  height: 28px;
  margin-top: 2px;
  display: flex;
  align-items: center;
}

.cj-stock-mini-spark svg {
  width: 100%;
  height: 28px;
  display: block;
}

.cj-stock-mini-spark-ph {
  font-size: 0.5625rem;
  color: var(--text-muted);
  opacity: .65;
}

.cj-impact-col .cj-stock-mini {
  max-width: none;
  width: 100%;
  flex: 0 0 auto;
  margin-bottom: 6px;
}

.cj-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.cj-chip {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.cj-chip:hover {
  border-color: rgba(124, 58, 237, .35);
  color: var(--purple-light);
}

.cj-rail {
  display: flex;
  gap: 6px;
  padding: 8px 14px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cj-rail::-webkit-scrollbar { display: none; }

.cj-rail-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.cj-rail-btn.active,
.cj-rail-btn:hover {
  border-color: rgba(124, 58, 237, .35);
  color: var(--purple-light);
  background: rgba(124, 58, 237, .1);
}

.cj-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

@media (max-width: 768px) {
  .cj-story {
    flex: 0 0 92%;
    max-width: none;
    padding: 22px 18px;
  }

  .cj-card-headline {
    font-size: 1.2rem;
  }

  .cj-badge-preview {
    max-width: 120px;
  }
}