/* MarketBrief — "Wire" theme (house-design). Dark terminal story deck. */

/* ---- Wire theme tokens ---- */
:root {
  --bg:         #08080a;
  --bg-raise:   #101014;
  --surface:    #0d0d11;
  --border:     #26262e;
  --text:       #f2f1ec;
  --text-muted: #9a99a3;
  --accent:     #e01e1e;
  --value:      #ffffff;
  --pos:        #2ad4a6;
  --neg:        #ff5347;
  --warn:       #ffb224;
  --info:       #4db8ff;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Anton", "Arial Narrow", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

/* ---- LIVE bar ---- */
.livebar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 5px 12px;
  flex: 0 0 auto;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  flex: 0 0 auto;
  animation: blink 1.6s steps(2, start) infinite;
}
/* Session-state accents on the dot; steady (no blink) when the market is closed. */
.livebar[data-state="open"]   .live-dot { background: var(--pos); box-shadow: 0 0 6px var(--pos); }
.livebar[data-state="pre"]    .live-dot { background: var(--warn); }
.livebar[data-state="after"]  .live-dot { background: var(--info); }
.livebar[data-state="closed"] .live-dot { background: rgba(255,255,255,.55); animation: none; }
.livebar .spacer { flex: 1; }
.livebar select {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 4px;
  padding: 2px 6px;
  max-width: 40vw;
}
.livebar select option { color: var(--text); background: var(--bg-raise); }

/* LIVE-bar action buttons (refresh live stats / pull new stories) */
.bar-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  line-height: 1.3;
}
.bar-btn:hover { background: rgba(255,255,255,.14); }
.bar-btn:disabled { opacity: .5; cursor: default; }
.bar-btn.spin { animation: spin .8s linear infinite; }
.src-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.55);
}
.src-badge[data-src="claude"] { background: rgba(255,255,255,.16); }
.src-badge[data-src="rss"] { opacity: .8; }
#counter { font-weight: 400; opacity: .9; min-width: 52px; text-align: right; }
@keyframes blink { 50% { opacity: .25; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Deck ---- */
.deck {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow-y: auto;
  display: flex;
  padding: clamp(20px, 5vh, 56px) clamp(20px, 6vw, 72px) clamp(56px, 9vh, 84px);
  position: relative;
  --tone: var(--info);
}
.slide[data-tone="pos"]  { --tone: var(--pos); }
.slide[data-tone="neg"]  { --tone: var(--neg); }
.slide[data-tone="warn"] { --tone: var(--warn); }
.slide-inner { margin: auto 0; max-width: 980px; width: 100%; }

.kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.k-cat {
  color: var(--tone);
  border: 1px solid var(--tone);
  padding: 2px 9px;
  font-weight: 700;
}
.k-src { color: var(--text-muted); }

.headline {
  margin: 0 0 18px;
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(2.1rem, 6.5vw, 4.6rem);
  line-height: .99;
  letter-spacing: .005em;
  color: var(--value);
  overflow-wrap: break-word;
}
.headline em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
}

.narrative {
  margin: 0 0 26px;
  max-width: 62ch;
  font-size: clamp(.92rem, 1.4vw, 1.02rem);
  line-height: 1.65;
  color: #cbcad2;
}
.narrative strong { color: var(--value); }

.stat { margin: 0 0 22px; }
.stat-value {
  font-family: var(--display);
  font-size: clamp(3.2rem, 10vw, 6.4rem);
  line-height: 1;
  color: var(--tone);
}
.stat-label {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text);
}
.stat-sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tiles { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 24px; }
.tile {
  background: var(--bg-raise);
  border: 1px solid var(--border);
  padding: 8px 14px;
  min-width: 96px;
}
.tile-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.tile-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}
.t-pos { color: var(--pos); } .t-neg { color: var(--neg); }
.t-warn { color: var(--warn); } .t-neutral { color: var(--info); }
.tile-delta { font-family: var(--mono); font-size: 10px; font-weight: 700; margin-top: 2px; }

/* ---- Layout variants ---- */
.slide-media { margin-top: 26px; }
.slide-media img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border: 1px solid var(--border);
}
@media (min-width: 880px) {
  /* Full-bleed right panel: the photo runs edge to edge, LIVE bar to tape */
  .v-split .slide-media {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 42%;
    margin: 0;
    border-inline-start: 1px solid var(--border);
  }
  .v-split .slide-media img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border: 0;
  }
  .v-split .slide-inner {
    max-width: none;
    width: 100%;
    padding-inline-end: 46%;
  }
  .v-split .slide-copy { max-width: 720px; }
}
.v-bg .bg-wrap { position: absolute; inset: 0; overflow: hidden; }
.v-bg .bg-wrap img { width: 100%; height: 100%; object-fit: cover; }
.v-bg .bg-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,8,10,.55), rgba(8,8,10,.25) 45%, rgba(8,8,10,.94) 88%);
}
.v-bg .slide-inner { position: relative; z-index: 1; margin-top: auto; margin-bottom: 0; }
.v-bg .narrative { color: #e4e3e9; }

.src-link {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--tone);
  text-decoration: none;
  border-bottom: 1px solid var(--tone);
  padding-bottom: 2px;
}
.src-link:hover { opacity: .8; }

.cover-hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--text-muted);
}

/* Cover "TOP MOVERS" strip — biggest gainers/losers, mode-independent */
.movers { margin: 0 0 24px; }
.movers-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.movers-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mv {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  border: 1px solid var(--border);
  padding: 5px 10px;
  background: var(--bg-raise);
}
.mv b { font-weight: 700; margin-right: 6px; opacity: .85; }
.mv-pos { color: var(--pos); }
.mv-neg { color: var(--neg); }

.err-detail {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  max-width: 70ch;
}

/* ---- Nav arrows ---- */
.nav {
  position: fixed;
  right: 14px;
  bottom: 44px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.nav button {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(16, 16, 20, .8);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  cursor: pointer;
}
.nav button:hover { border-color: var(--text-muted); }
.nav button:disabled { opacity: .3; cursor: default; }
/* Jump-to-start: subtly smaller and quieter than the main arrows (#3) */
.nav .to-start { width: 28px; height: 28px; align-self: center; font-size: 12px; opacity: .55; }
.nav .to-start:hover { opacity: 1; }

/* ---- Ticker tape (live market movers) ---- */
.tape {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: #050507;
  overflow: hidden;
  white-space: nowrap;
  padding: 8px 0;
}
.tape-track {
  display: inline-flex;
  will-change: transform;
  animation: tapeMove var(--tape-dur, 45s) linear infinite;
}
.tape:hover .tape-track { animation-play-state: paused; }
.tp {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 0 18px;
  color: var(--text);
}
/* Direction color wins over the base .tp color (equal-specificity tie-breaker):
   whole entry green when up, red when down. */
.tp.t-pos { color: var(--pos); }
.tp.t-neg { color: var(--neg); }
.tp.t-neutral { color: var(--text-muted); }
.tp .tk { margin-right: 7px; opacity: .8; } /* ticker inherits the tone hue, a touch dimmer */
.tp-sep { color: #3a3a44; font-family: var(--mono); font-size: 10px; }
@keyframes tapeMove { to { transform: translateX(-50%); } }

/* ---- States ---- */
.state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 24px;
}
.state .big { font-family: var(--display); font-size: clamp(1.6rem, 5vw, 3rem); color: var(--value); letter-spacing: .01em; }
.state .detail { text-transform: none; letter-spacing: .02em; font-size: 11px; max-width: 60ch; overflow-wrap: anywhere; }
.state button {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 18px;
  cursor: pointer;
}
.state button:hover { border-color: var(--text-muted); }
.cursor { animation: blink 1.1s steps(2, start) infinite; }

/* Toast: brief status for on-demand collection (#5) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  z-index: 8;
  background: rgba(16, 16, 20, .95);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 4px;
  max-width: 80vw;
}
.toast.err { border-color: var(--neg); color: var(--neg); }

:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .tape { overflow-x: auto; }
}
