/* ==========================================================================
   Market Notes — editorial layer on top of styles.css (same tokens).
   ========================================================================== */

:root {
  --note-col: 700px;
  --bull: #4ade80;
  --bear: #f87171;
}

.note-col {
  max-width: var(--note-col);
  margin: 0 auto;
}

/* Shared bits
   ========================================================================== */

.page-header__label a { color: inherit; }
.page-header__label a:hover { color: var(--text-primary); }

.notes-header__links {
  display: flex;
  gap: var(--space-5);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: var(--space-5);
}
.notes-header__links a { color: var(--text-tertiary); border-bottom: 1px solid var(--border-visible); }
.notes-header__links a:hover { color: var(--text-primary); border-color: var(--text-primary); }

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  max-width: none;
}

.note-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.note-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  padding: 2px var(--space-2);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.note-tag:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* Index
   ========================================================================== */

.notes-filters {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-7);
  border-bottom: 1px solid var(--border);
}
.notes-filters__group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.notes-filters__group .label { width: 72px; color: var(--text-muted); }

.notes-chip {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  padding: var(--space-1) var(--space-3);
  transition: all 0.15s ease;
}
.notes-chip:hover { color: var(--text-primary); border-color: var(--text-muted); }
.notes-chip.is-active { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg-primary); }

.notes-empty { color: var(--text-muted); padding: var(--space-8) 0; }

.note-featured {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-7);
  align-items: center;
  padding-bottom: var(--space-8);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-visible);
}
.note-featured:not(:has(.note-featured__media)) { grid-template-columns: 1fr; }
.note-featured__media img,
.note-row__media img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
}
.note-featured__kicker { margin-bottom: var(--space-4); color: var(--text-muted); }
.note-featured__title {
  font-size: clamp(var(--text-2xl), 3vw, var(--text-3xl));
  margin-bottom: var(--space-4);
}
.note-featured__title a:hover,
.note-row__title a:hover,
.note-related__title a:hover { text-decoration: underline; text-decoration-color: var(--text-muted); text-underline-offset: 4px; }
.note-featured__dek { color: var(--text-secondary); line-height: var(--leading-relaxed); margin-bottom: var(--space-5); }

.note-list { list-style: none; }
.note-row {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: var(--space-6);
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border);
}
.note-row:not(:has(.note-row__media)) { grid-template-columns: 1fr; }
.note-row__title { font-size: var(--text-xl); margin: var(--space-3) 0; }
.note-row__dek { color: var(--text-tertiary); line-height: var(--leading-relaxed); font-size: var(--text-sm); }

.notes-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-top: var(--space-7);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.notes-pagination a { color: var(--text-secondary); }
.notes-pagination a:hover { color: var(--text-primary); }
.notes-pagination a[rel="next"] { justify-self: end; }
.notes-pagination__pos { color: var(--text-muted); }

/* Article
   ========================================================================== */

.note-preview-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1001;
  display: flex;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-3);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  background: #fbbf24;
  color: #111;
}
.note-preview-bar a { text-decoration: underline; }

.note__header {
  padding-top: calc(var(--space-10) + 40px);
  padding-bottom: var(--space-7);
}
.note__kicker a { color: inherit; }
.note__title {
  font-size: clamp(var(--text-3xl), 4.2vw, var(--text-4xl));
  font-weight: 500;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin-bottom: var(--space-5);
}
.note__dek {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}

.note__hero {
  max-width: 960px;
  margin: 0 auto var(--space-7);
}
.note__hero img { width: 100%; height: auto; display: block; border: 1px solid var(--border); }

/* Conviction board */
.conviction {
  border: 1px solid var(--border-visible);
  background: var(--bg-tertiary);
  margin-bottom: var(--space-7);
}
.conviction__title {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--text-xs);
}
.conviction__table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.conviction__table th,
.conviction__table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.conviction__table tbody tr:last-child > * { border-bottom: none; }
.conviction__table thead th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}
.conviction__table tbody th { color: var(--text-primary); font-weight: 500; }
.conviction__table td { color: var(--text-secondary); }
.conviction__table td.mono { font-size: var(--text-xs); white-space: nowrap; }
/* Optical row alignment: centre the contract and the badge on the product's first line. */
@media (min-width: 641px) {
  .conviction__table td.mono { padding-top: calc(var(--space-3) + 1px); }
  .conviction__table td[data-label="View"] .conviction-badge { position: relative; top: -1px; }
}

.conviction-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
  padding: 5px var(--space-2);
  border: 1px solid currentColor;
  /* Same width for every level (sized on "Bullish bias") so the column lines up.
     Left-aligned on purpose: symbols stack on one vertical down the column. */
  min-width: 18.5ch;
  box-sizing: border-box;
}
.conviction-badge__icon {
  width: 0.75em;
  height: 0.75em;
  flex-shrink: 0;
  display: block;
}
/* Centre the label on its capital letters (all caps, no descenders) rather
   than on the font's ascender/descender box. Older browsers fall back to a
   small nudge that gives the same result with JetBrains Mono. */
.conviction-badge__label { display: block; text-box: trim-both cap alphabetic; }
@supports not (text-box: trim-both cap alphabetic) {
  .conviction-badge__label { transform: translateY(0.04em); }
}
.conviction-badge--bullish { color: var(--bull); }
.conviction-badge--bearish { color: var(--bear); }
.conviction-badge--neutral { color: var(--text-tertiary); }
/* Leanings: same hue as their side, but muted text + faint dashed border so
   they read weaker than bullish/bearish yet clearly apart from neutral grey. */
.conviction-badge--lean-bullish { color: rgba(74, 222, 128, 0.72); border: 1px dashed rgba(74, 222, 128, 0.38); }
.conviction-badge--lean-bearish { color: rgba(248, 113, 113, 0.72); border: 1px dashed rgba(248, 113, 113, 0.38); }

/* Table of contents */
.note-toc {
  border-left: 1px solid var(--border-visible);
  padding: var(--space-2) 0 var(--space-2) var(--space-5);
  margin-bottom: var(--space-7);
}
.note-toc__title { margin-bottom: var(--space-3); color: var(--text-muted); font-size: var(--text-xs); }
.note-toc ol { list-style: decimal-leading-zero; padding-left: var(--space-6); }
.note-toc li { font-size: var(--text-sm); padding: 2px 0; color: var(--text-muted); }
.note-toc li::marker { font-family: var(--font-mono); font-size: 0.75rem; }
.note-toc a { color: var(--text-secondary); }
.note-toc a:hover { color: var(--text-primary); }

/* Prose */
.prose { font-size: 1.125rem; line-height: 1.75; color: var(--text-secondary); }
.prose > * + * { margin-top: 1.25em; }
.prose p { max-width: none; }
.prose h2 {
  font-size: var(--text-2xl);
  color: var(--text-primary);
  margin-top: 2.2em;
  scroll-margin-top: 90px;
}
.prose h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.8em;
  scroll-margin-top: 90px;
}
.prose h2 + *, .prose h3 + * { margin-top: 0.75em; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 3px;
}
.prose a:hover { text-decoration-color: var(--text-primary); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--text-muted); }
.prose blockquote {
  border-left: 2px solid var(--text-primary);
  padding-left: var(--space-5);
  color: var(--text-primary);
  font-size: var(--text-xl);
  line-height: 1.5;
}
.prose .note-insert {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-muted);
  padding: var(--space-5);
  font-size: var(--text-base);
}
.prose .note-insert > * + * { margin-top: 0.75em; }

/* Charts */
.note-figure { margin-top: 2em !important; margin-bottom: 2em; }
.note-figure img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.note-figure__caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}
.note-figure__text { color: var(--text-tertiary); }
.note-figure__credit { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.note-figure__cta {
  display: inline-flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-decoration: none !important;
}
.note-figure__cta:hover { color: var(--text-primary); }
.note-figure__cta:hover .btn__arrow { transform: translateX(3px); }

/* End of article */
.note-sources {
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.note-sources .label { color: var(--text-muted); font-size: var(--text-xs); }
.note-sources__list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.note-signature {
  margin-top: var(--space-7);
  padding: var(--space-5);
  border: 1px solid var(--border);
  display: grid;
  gap: var(--space-3);
}
.note-signature p { color: var(--text-secondary); line-height: var(--leading-relaxed); max-width: none; }
.note-signature strong { color: var(--text-primary); font-weight: 500; }
.note-signature .doc-cta__link { font-size: var(--text-sm); justify-self: start; }

.note-disclaimer { margin-top: var(--space-5); padding: var(--space-3) var(--space-4); font-size: var(--text-xs); }

.note-cta {
  margin-top: var(--space-9);
  border-top: 1px solid var(--border-visible);
  border-bottom: 1px solid var(--border-visible);
  background: #0c0c0e;
  padding: var(--space-8) 0;
}
.note-cta__inner {
  max-width: var(--note-col);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}
.note-cta .label { color: var(--text-primary); margin-bottom: var(--space-2); }
.note-cta__text { color: var(--text-tertiary); font-size: var(--text-sm); line-height: var(--leading-relaxed); }
.note-cta .btn { flex-shrink: 0; }

.note-related { border-top: none; padding-top: var(--space-9); }
.note-related .section-label { margin-bottom: var(--space-6); }
.note-related__grid { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.note-related__item { border-top: 1px solid var(--border); padding-top: var(--space-4); }
.note-related__title { font-size: var(--text-lg); margin: var(--space-3) 0; }
.note-related__dek {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: var(--leading-relaxed);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .note-featured { grid-template-columns: 1fr; gap: var(--space-5); }
  .note-row { grid-template-columns: 1fr 160px; gap: var(--space-4); }
  .note-related__grid { grid-template-columns: 1fr; }
  .note-cta__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  .note__header { padding-top: calc(var(--space-9) + 20px); }
  .prose { font-size: var(--text-base); }
  .prose blockquote { font-size: var(--text-lg); }
  .note-row { grid-template-columns: 1fr; }
  .note-row__media { order: -1; }
  .notes-filters__group .label { width: 100%; }

  /* Conviction table → stacked cards */
  .conviction__table thead { display: none; }
  .conviction__table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
  }
  .conviction__table tbody tr:last-child { border-bottom: none; }
  .conviction__table th, .conviction__table td { padding: 0; border: none; }
  .conviction__table, .conviction__table tbody { display: block; }
  .conviction__table th[scope="row"] { grid-column: 1; grid-row: 1; }
  .conviction__table td[data-label="Contract"] { grid-column: 2; grid-row: 1; color: var(--text-muted); align-self: center; }
  /* Own row: "Neutral · leaning higher" is too wide to sit next to the product. */
  .conviction__table td[data-label="View"] { grid-column: 1 / -1; grid-row: 2; }
  .conviction-badge { white-space: normal; }
  .conviction__table td[data-label="In one line"] { grid-column: 1 / -1; }
}
