/* Colors live in variables, so changing the whole theme means editing a few lines. */
:root {
  --bg: #ffffff;
  --text: #1d1d1f;
  --muted: #5f6368;
  --accent: #0b6e4f;
  --border: #e3e3e3;
  --max-width: 44rem;
}

/* Visitors whose system is in dark mode get these colors instead. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --text: #e8e8e8;
    --muted: #a0a4a8;
    --accent: #3ddc97;
    --border: #2a2d31;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

.site-header,
main,
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

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

.button {
  display: inline-block;
  margin: 0 0.5rem 0.5rem 0;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

/* Dates, tags and other small print. */
.meta {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Lists of journal entries and courses. */
.item-list {
  list-style: none;
  padding: 0;
}

.item-list li {
  margin-bottom: 1.25rem;
}

.item-list p {
  margin: 0.25rem 0 0;
}

.item-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.lesson-list li {
  margin-bottom: 0.5rem;
}

/* The position disclosure box on every journal entry. */
.disclosure {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 0.9rem;
}

/* Things you write in Markdown: images, tables, code. */
.body img {
  max-width: 100%;
  height: auto;
}

.body table {
  border-collapse: collapse;
  width: 100%;
}

.body th,
.body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}

/* Previous / next links under a lesson. */
.pager {
  justify-content: space-between;
  margin: 2rem 0 1rem;
}

/* ---------- Markets ---------- */

/* Colors for prices going up and down. They're kept here, apart from lines 1 to 20,
   so the Color Workshop's CSS still fits those lines exactly. */
:root {
  --up: #0b6e4f;
  --down: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --up: #3ddc97;
    --down: #ff8a80;
  }
}

.up {
  color: var(--up);
}

.down {
  color: var(--down);
}

.muted {
  color: var(--muted);
}

/* The row of sub-tabs: Overview, Indices, News, Watchlists, Portfolios. */
.subnav {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.subnav a {
  text-decoration: none;
}

.subnav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.4em;
}

.market-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.live-status {
  white-space: nowrap;
}

.live-status[data-state="live"] {
  color: var(--up);
}

.demo-banner {
  padding: 0.6rem 1rem;
  border-left: 3px solid #c58b00;
  background: color-mix(in srgb, #c58b00 12%, transparent);
}

/* "Nothing here yet" messages. */
.empty {
  color: var(--muted);
  font-style: italic;
}

/* Boxes in a row that wraps: index prices on the Overview, totals on a portfolio. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.card-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.card-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Price tables. Wide tables scroll sideways on a phone instead of squeezing. */
.table-scroll {
  overflow-x: auto;
}

table.quotes {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

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

/* Numbers line up on the right, with digits all the same width. */
table.quotes .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.symbol {
  font-weight: 600;
}

/* The "As of" column: wide enough to read on a phone (the table scrolls sideways). */
table.quotes td.meta {
  min-width: 8.5rem;
}
