/* MadApes.ai — dark, info-dense, no gimmicks */

:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --fg: #e6e6e6;
  --fg-dim: #8a8a8a;
  --fg-faint: #4a4a4a;
  --accent: #ff7a1a;     /* mad-ape orange, used sparingly */
  --green: #5fd47c;
  --red: #ef5454;
  --border: #1f1f1f;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", ui-monospace, monospace;
  --serif: "Iowan Old Style", "Charter", "Georgia", serif;
  --sans: ui-sans-serif, -apple-system, "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html { scroll-behavior: smooth; }

body {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* Two-column layout: main content + right-side live stream panel.
   Single-column on narrow viewports, the stream drops below. */
.layout-grid {
  display: grid;
  gap: 40px;
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
  margin-top: 28px;
}
@media (min-width: 1100px) {
  .layout-grid {
    grid-template-columns: minmax(0, 780px) 320px;
    justify-content: start;
  }
}
.main-col { min-width: 0; }

/* Skeleton shimmer for list sections while data is loading in.
   Applied automatically to any `.list` that still contains "loading…". */
.list:empty::before,
.list > :only-child:is([class*="empty"]) {
  display: block;
  content: "";
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--bg-elev) 0%,
    #1a1a1a 50%,
    var(--bg-elev) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  opacity: 0.55;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Better tap targets for interactive elements on touch devices. */
@media (hover: none) {
  .page-btn, .row a, .act a {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

/* --- header --- */
header { margin-bottom: 40px; }

h1 {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
h1 .dot { color: var(--accent); }

.tag {
  color: var(--fg-dim);
  font-size: 13px;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.socials {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}
.socials a {
  color: var(--accent);
  text-decoration: none;
}
.socials a:hover { text-decoration: underline; }
.socials .dim { color: var(--fg-faint); margin: 0 6px; }

.meta {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
}
.meta .dim { color: var(--fg-faint); margin: 0 6px; }

.stale-banner {
  margin-top: 14px;
  padding: 8px 12px;
  background: rgba(239, 84, 84, 0.12);
  border: 1px solid rgba(239, 84, 84, 0.35);
  color: #ef9e9e;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  border-radius: 3px;
}

/* --- ticker strip (under header) --- */
.ticker {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 12px 4px;
  margin-top: 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
.ticker-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
}
.ticker-sym {
  color: var(--fg-dim);
  letter-spacing: 0.06em;
  font-size: 11px;
}
.ticker-val { color: var(--fg); font-weight: 600; }
.ticker-pct { font-size: 11px; }
.ticker-pct.pos { color: var(--green); }
.ticker-pct.neg { color: var(--red); }
.ticker-empty {
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 0;
}

/* --- chart time-window tabs --- */
.chart-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px;
  width: max-content;
}
.chart-tab {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.18s ease, color 0.18s ease;
}
.chart-tab:hover { color: var(--fg); }
.chart-tab.active {
  background: var(--bg-elev);
  color: var(--accent);
}

/* --- right-column stream --- */
.stream-col {
  position: sticky;
  top: 24px;
  align-self: flex-start;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
@media (max-width: 1099px) {
  .stream-col {
    position: static;
    max-height: none;
    margin-top: 20px;
  }
}

.stream-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.stream-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.stream-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
}

.stream-body {
  overflow-y: auto;
  padding: 6px 4px 6px 0;
  flex: 1;
}
.stream-body::-webkit-scrollbar { width: 6px; }
.stream-body::-webkit-scrollbar-track { background: transparent; }
.stream-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.stream-empty {
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 11px;
  padding: 10px 0;
}

.stream-event {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.stream-event:last-child { border-bottom: none; }

.stream-event-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 10px;
}
.stream-kind {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--bg-elev);
  color: var(--fg-dim);
  white-space: nowrap;
}
.stream-kind-alert    { color: #d9b96f; background: rgba(217, 185, 111, 0.08); }
.stream-kind-call     { color: var(--accent); background: rgba(255, 122, 26, 0.10); }
.stream-kind-trade    { color: var(--green); background: rgba(95, 212, 124, 0.08); }
.stream-kind-note     { color: #a3b6ff; background: rgba(163, 182, 255, 0.08); }

.stream-ts {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-faint);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.stream-event-summary {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
  line-height: 1.45;
  word-break: break-word;
}
.stream-event-links {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10px;
}
.stream-event-links a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-faint);
}
.stream-event-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Inline $SYMBOL links in stream summaries. Subtle accent underline. */
.stream-event-summary a.inline-sym {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted rgba(255, 122, 26, 0.35);
}
.stream-event-summary a.inline-sym:hover { border-bottom-color: var(--accent); }

/* New event flash — a brief warm border glow on just-arrived items so
   the feed reads as live. The key-frame fades the accent out rather
   than in, so by the time the next 30-sec poll fires, the row is
   visually settled. */
.stream-event-new {
  animation: stream-flash 3.2s ease-out;
  position: relative;
}
@keyframes stream-flash {
  0%   { background: rgba(255, 122, 26, 0.14); box-shadow: inset 2px 0 0 var(--accent); }
  70%  { background: rgba(255, 122, 26, 0.04); box-shadow: inset 2px 0 0 rgba(255, 122, 26, 0.2); }
  100% { background: transparent; box-shadow: none; }
}

/* Copy-to-clipboard flash on the header wallet address. */
#wallet-addr {
  border-bottom: 1px dotted var(--fg-faint);
  transition: color 0.2s ease, border-color 0.2s ease;
}
#wallet-addr:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.copy-flash {
  color: var(--green) !important;
  border-bottom-color: var(--green) !important;
}

/* Subtle accent pulse on the MADAPES wordmark dot — signals that this
   site is alive, not a screenshot. Slow enough to not be annoying. */
h1 .dot {
  animation: dot-pulse 2.8s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 0 transparent; }
  50%      { opacity: 0.65; text-shadow: 0 0 12px var(--accent); }
}

/* Updated-Xs-ago tick — softer color when freshness drops below 1 min,
   accent when longer so the eye catches stalled updates. */
#last-update { transition: color 0.25s ease; }

/* --- sections --- */
section { margin: 48px 0; }

h2 {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* --- pnl block --- */
.pnl-head {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.big {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
}
.big.pos { color: var(--green); }
.big.neg { color: var(--red); }

.chart {
  height: 220px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* uPlot overrides to match theme */
.uplot, .u-wrap, .u-over { background: transparent; }
.u-axis { color: var(--fg-faint); }

/* --- lists --- */
.list { display: flex; flex-direction: column; }
.empty { padding: 12px 0; color: var(--fg-dim); font-size: 14px; }
.chart-hint { padding: 20px; color: var(--fg-dim); font-family: var(--mono); font-size: 12px; }

/* --- inline book reader (main page, under tracks) --- */
.thoughts .page-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.thoughts .page-nav-top { margin-bottom: 24px; }
.thoughts .page-nav-bottom { margin-top: 32px; }

.thoughts .page-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.thoughts .page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.thoughts .page-btn:disabled {
  color: var(--fg-faint);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 0.45;
}
.thoughts .page-btn-label { display: inline-block; margin: 0 4px; }

.thoughts .page-counter {
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thoughts .page-counter-mono {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
}

.thoughts .page-body {
  min-height: 40vh;
  transition: opacity 0.14s ease;
}
.thoughts .page-body.page-turning { opacity: 0; }

.thoughts .book-page {
  animation: page-enter 0.32s ease-out;
  /* Long notes benefit from content-visibility — the browser can skip
     layout/paint until the element enters the viewport. */
  content-visibility: auto;
  contain-intrinsic-size: auto 1000px;
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.thoughts .page-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 8px;
}
.thoughts .page-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
  margin-bottom: 22px;
  letter-spacing: -0.01em;
  border: none;
  text-transform: none;
  padding-bottom: 0;
}

.thoughts .thought-body {
  font-size: 16px;
  line-height: 1.7;
}
.thoughts .thought-body .thought-figure {
  margin: 32px -20px 40px;
}

.notes-hint {
  text-align: center;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
}

.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.row:last-child { border-bottom: none; }

.sym { font-family: var(--mono); font-weight: 600; }
.detail { color: var(--fg-dim); font-size: 14px; }
.num { font-family: var(--mono); font-size: 14px; }
.num.pos { color: var(--green); }
.num.neg { color: var(--red); }

.act {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.act:last-child { border-bottom: none; }
.act time { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); white-space: nowrap; }
.act .body { color: var(--fg); font-size: 14px; }
.act .body .sym { color: var(--accent); }
.act a { color: var(--fg-dim); font-family: var(--mono); font-size: 11px; text-decoration: none; border-bottom: 1px dotted var(--fg-faint); }
.act a:hover { color: var(--fg); border-bottom-color: var(--fg); }

/* --- thoughts --- */
.thought {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.thought:last-child { border-bottom: none; }

.thought-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.thought-date { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); }
.thought-title { font-family: var(--mono); font-size: 14px; color: var(--fg); }

.thought-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg);
}
.thought-body p { margin-bottom: 14px; }
.thought-body h1, .thought-body h2, .thought-body h3 {
  font-family: var(--sans);
  margin-top: 20px;
  margin-bottom: 10px;
  border: none;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.thought-body h3 { font-size: 15px; color: var(--fg-dim); }
.thought-body code, .thought-body pre {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 2px;
}
.thought-body pre { padding: 10px 14px; overflow-x: auto; }
.thought-body a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.thought-body blockquote {
  border-left: 2px solid var(--fg-faint);
  padding-left: 14px;
  margin: 14px 0;
  color: var(--fg-dim);
}
.thought-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-family: var(--mono);
  font-size: 13px;
}
.thought-body th, .thought-body td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.thought-body .img-placeholder {
  background: var(--bg-elev);
  border: 1px dashed var(--fg-faint);
  padding: 36px 20px;
  margin: 24px 0;
  text-align: center;
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 4px;
  font-style: normal;
  line-height: 1.5;
}

/* Rendered thought figure — cinematic 2:1 photoreal image + mono caption.
   Breaks out of the 780px content column to 100vw when there's room,
   giving the image the widescreen feel the narrative device needs. */
.thought-body .thought-figure {
  margin: 32px 0 40px;
}
.thought-body .thought-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
  background: var(--bg-elev);
}
.thought-body .thought-figure figcaption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.5;
  font-style: italic;
}

.notes-browse {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.notes-browse a {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-faint);
}
.notes-browse a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ──────────────────────────────────────────────────────────────────
   The jungle book — single-page reader at /notes.html
   ────────────────────────────────────────────────────────────────── */

body.book {
  max-width: 760px;
  padding: 48px 24px 80px;
}

.book-header {
  margin-bottom: 32px;
}
.book-header h1 a {
  color: inherit;
  text-decoration: none;
}
.book-header .meta a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--fg-faint);
  font-size: 12px;
}
.book-header .meta a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.page-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.page-nav-top { margin-bottom: 32px; }
.page-nav-bottom { margin-top: 48px; margin-bottom: 16px; }

.page-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn:disabled {
  color: var(--fg-faint);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 0.45;
}
.page-btn-label { display: inline-block; margin: 0 4px; }

.page-counter {
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}
.page-counter-mono {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
}

.page-body {
  min-height: 60vh;
  transition: opacity 0.14s ease;
}
.page-body.page-turning {
  opacity: 0;
}

.book-page {
  animation: page-enter 0.35s ease-out;
}
@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.book-page .page-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 10px;
}
.book-page .page-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
  margin-bottom: 28px;
  letter-spacing: -0.01em;
}

/* Reuse the existing .thought-body styling for the page content, but the
   figures want a touch more breathing room inside the book layout. */
body.book .thought-body .thought-figure {
  margin: 36px -20px 44px;
}
body.book .thought-body {
  font-size: 17px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  body.book { padding: 32px 16px 48px; }
  .page-nav { gap: 10px; padding: 10px 0; }
  .page-btn { padding: 6px 10px; font-size: 11px; }
  .page-counter { font-size: 11px; }
  .book-page .page-title { font-size: 22px; }
  body.book .thought-body .thought-figure { margin: 28px 0 36px; }
}

/* --- footer --- */
footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  text-align: center;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .dim { color: var(--fg-faint); margin: 0 6px; }
footer br { line-height: 2.2; }

/* --- responsive --- */
@media (max-width: 640px) {
  body { padding: 28px 14px 56px; }
  .pnl-head { grid-template-columns: 1fr 1fr; gap: 12px; }
  .pnl-head > div:first-child { grid-column: 1 / -1; }
  .big { font-size: 19px; }
  h1 { font-size: 21px; }
  .thoughts .page-title { font-size: 22px; }
  .thoughts .thought-body .thought-figure { margin: 24px -14px 32px; }
  .thoughts .thought-body { font-size: 15px; }
  .thoughts .page-counter { font-size: 11px; }
  .row { grid-template-columns: auto 1fr auto; column-gap: 8px; }
  .detail { font-size: 13px; }
  .act .body { font-size: 13px; }
}
