/* Market Mood — global stylesheet (plain CSS, system fonts only) */

:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* Surfaces & text */
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3efe8;
  --text: #1f2933;
  --muted: #52606d;
  --border: #e4ded4;
  --border-strong: #cdc5b8;
  --shadow: 0 1px 2px rgba(31, 41, 51, 0.06);

  /* Accent */
  --accent: #0f6b6b;
  --accent-hover: #0b5353;
  --accent-ink: #ffffff;
  --accent-tint: #e8f3f2;
  --accent-border: #b8d9d8;
  --focus: #0f6b6b;

  /* Semantic */
  --amber-text: #7a4a00;
  --amber-bg: #fff6e0;
  --amber-border: #d99a1c;
  --green: #1b7a3d;
  --red: #b42318;

  /* Chart / dial */
  --band-extreme-fear: #d64545;
  --band-fear: #f08a3c;
  --band-neutral: #c9c6bf;
  --band-greed: #8fd19e;
  --band-extreme-greed: #2e8b57;
  --bar-pos: #1b7a3d;
  --bar-neg: #b42318;

  --gutter: 16px;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #161b24;
    --surface: #1e2530;
    --surface-2: #262e3a;
    --text: #e8e6e1;
    --muted: #9aa4b2;
    --border: #2b3340;
    --border-strong: #3a4452;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

    --accent: #5fc6c6;
    --accent-hover: #7ad4d4;
    --accent-ink: #10201f;
    --accent-tint: #1b2b33;
    --accent-border: #2f5f5f;
    --focus: #5fc6c6;

    --amber-text: #f2c14e;
    --amber-bg: #2d2513;
    --amber-border: #b98512;
    --green: #6fd39a;
    --red: #f08a82;

    --band-extreme-fear: #e05252;
    --band-fear: #f0a04b;
    --band-neutral: #4b5563;
    --band-greed: #8fd19e;
    --band-extreme-greed: #3cb371;
    --bar-pos: #4cc38a;
    --bar-neg: #ef6b6b;
  }
}

/* ---------- Reset & base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p,
li,
figcaption,
td,
th {
  overflow-wrap: break-word;
}

img,
svg {
  max-width: 100%;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.15em;
  transition: color 0.15s ease, background-color 0.15s ease;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* ---------- Layout containers ---------- */

header.site,
main,
footer.site {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

@media (min-width: 720px) {
  :root {
    --gutter: 24px;
  }
}

main {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

/* ---------- Header ---------- */

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

a.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

a.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

img.brand-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: block;
  border-radius: 7px;
}

nav.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  flex: 1 1 100%;
}

nav.site-nav a {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

nav.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

nav.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

@media (min-width: 720px) {
  header.site {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }

  nav.site-nav {
    flex: 0 1 auto;
  }
}

/* ---------- Typography ---------- */

h1 {
  margin: 1.5rem 0 0.75rem;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
}

p.lede {
  margin: 0 0 2rem;
  max-width: 62ch;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--muted);
}

h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 700;
}

h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 600;
}

p {
  margin: 0 0 1rem;
}

/* ---------- Cards ---------- */

section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

section.card > :first-child {
  margin-top: 0;
}

section.card > :last-child {
  margin-bottom: 0;
}

div.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

div.cards > section.card {
  margin-bottom: 0;
}

@media (min-width: 720px) {
  section.card {
    padding: 1.5rem;
  }

  div.cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }

  .card-wide {
    grid-column: 1 / -1;
  }
}

/* ---------- Readings ---------- */

div.reading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
  margin: 0.25rem 0 0.75rem;
}

span.value {
  font-size: clamp(2.6rem, 10vw, 3.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

span.unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

span.label {
  --pill-bg: var(--surface-2);
  --pill-fg: var(--muted);
  --pill-border: transparent;

  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  box-shadow: inset 0 0 0 1px var(--pill-border);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

span.label.regime-extreme-fear {
  --pill-bg: #b42318;
  --pill-fg: #ffffff;
  --pill-border: #8f1c13;
}

span.label.regime-fear {
  --pill-bg: #ffe4c7;
  --pill-fg: #7c3a00;
  --pill-border: #f3c48a;
}

span.label.regime-neutral {
  --pill-bg: #e6e8eb;
  --pill-fg: #2b333b;
  --pill-border: #cfd3d8;
}

span.label.regime-greed {
  --pill-bg: #dcf3d9;
  --pill-fg: #14532d;
  --pill-border: #a9dcae;
}

span.label.regime-extreme-greed {
  --pill-bg: #1b7a3d;
  --pill-fg: #ffffff;
  --pill-border: #14532d;
}

span.label.inverted {
  --pill-bg: #fff1c2;
  --pill-fg: #7a4a00;
  --pill-border: #e8c766;
}

span.label.normal {
  --pill-bg: #eceff2;
  --pill-fg: #3f4854;
  --pill-border: #d5dae0;
}

@media (prefers-color-scheme: dark) {
  span.label.regime-extreme-fear {
    --pill-bg: #4a1512;
    --pill-fg: #ffb4ab;
    --pill-border: #8a2a22;
  }

  span.label.regime-fear {
    --pill-bg: #3f2410;
    --pill-fg: #ffcf9e;
    --pill-border: #7a4a1e;
  }

  span.label.regime-neutral {
    --pill-bg: #2a3240;
    --pill-fg: #d6dde6;
    --pill-border: #3e4858;
  }

  span.label.regime-greed {
    --pill-bg: #1b3a25;
    --pill-fg: #a7e8b8;
    --pill-border: #2f5e3e;
  }

  span.label.regime-extreme-greed {
    --pill-bg: #0f3d22;
    --pill-fg: #8ef0b0;
    --pill-border: #1f7a44;
  }

  span.label.inverted {
    --pill-bg: #3a2a0c;
    --pill-fg: #ffd27a;
    --pill-border: #7a5a1c;
  }

  span.label.normal {
    --pill-bg: #2a3240;
    --pill-fg: #c8d0da;
    --pill-border: #3e4858;
  }
}

span.pending {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.5;
}

p.meta {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

p.credit {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

p.credit a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

p.stale {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid var(--amber-border);
  border-radius: 0 8px 8px 0;
  background: var(--amber-bg);
  color: var(--amber-text);
  font-size: 0.9rem;
}

/* ---------- Dial ---------- */

svg.dial {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto;
}

.band-extreme-fear {
  fill: var(--band-extreme-fear);
}

.band-fear {
  fill: var(--band-fear);
}

.band-neutral {
  fill: var(--band-neutral);
}

.band-greed {
  fill: var(--band-greed);
}

.band-extreme-greed {
  fill: var(--band-extreme-greed);
}

line.needle {
  stroke: var(--text);
  stroke-width: 4;
  stroke-linecap: round;
}

circle.hub {
  fill: var(--text);
}

text.dial-tick {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ---------- Charts ---------- */

svg.chart {
  display: block;
  width: 100%;
  height: auto;
}

path.line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

path.area {
  fill: var(--accent);
  fill-opacity: 0.12;
}

line.zero {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

line.grid {
  stroke: var(--border-strong);
  stroke-width: 1;
}

text.axis {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

rect.bar-pos {
  fill: var(--bar-pos);
}

rect.bar-neg {
  fill: var(--bar-neg);
}

circle.dot {
  fill: var(--accent);
}

figure.chart-figure {
  margin: 0.75rem 0 0;
}

figure.chart-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Tables ---------- */

div.table-wrap {
  margin: 0.75rem 0 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

table.data th,
table.data td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

table.data th {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--border-strong);
}

table.data tbody tr:nth-child(even) {
  background: var(--surface-2);
}

table.data td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- App callout ---------- */

aside.app-block {
  margin: 0 0 1.25rem;
  padding: 1.5rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-tint);
}

aside.app-block h2 {
  margin: 0 0 0.5rem;
}

aside.app-block p {
  margin: 0;
  max-width: 60ch;
}

a.app-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.6rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.2;
  transition: background-color 0.15s ease;
}

a.app-link:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
  text-decoration: none;
}

span.soon {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ---------- "More" links ---------- */

a.more {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a.more:hover {
  color: var(--accent-hover);
}

/* ---------- Prose (support / privacy pages) ---------- */

.prose {
  max-width: 68ch;
  line-height: 1.6;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose a {
  color: var(--accent);
}

/* ---------- Footer ---------- */

footer.site {
  margin-top: 2rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

footer.site p.disclaimer {
  margin: 0;
  max-width: 72ch;
}

nav.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.75rem;
}

nav.footer-nav a {
  color: var(--muted);
  text-decoration: none;
}

nav.footer-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
