/* Styles every page shares; each page's own sit beside it, like notes/notes.css. Light and dark follow the system setting. */
:root {
  color-scheme: light dark;
  /* Workout Logger's palette (src/theme/theme.ts) */
  --bg: #f7fbfd;
  --text: #10212b;
  --muted: #3b5564;
  --line: #d1e1e8;
  --card: #ffffff;
  --empty: #e7f1f6;
  --accent: #1976b8;
  --protein: #1976b8;
  --carbs: #c97810;
  --fat: #1f9d55;
  --met: #1f9d55;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1116;
    --text: #f4f8fa;
    --muted: #78919f;
    --line: #243743;
    --card: #121b22;
    --empty: #1b2a33;
    --accent: #4aa3df;
    --protein: #4aa3df;
    --carbs: #f2a03d;
    --fat: #42c77a;
    --met: #42c77a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--muted);
  text-underline-offset: 3px;
}

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

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
  max-width: 72rem;
  margin: 0 auto;
  padding: 24px 16px;
}

.site-id {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-name {
  font-weight: 600;
  text-decoration: none;
}

.social {
  display: flex;
  gap: 12px;
}

.social a {
  display: flex;
  color: var(--muted);
}

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

.social svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.site-header nav {
  display: flex;
  gap: 20px;
}

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

.site-header nav a[aria-current="page"],
.site-header nav a:hover {
  color: var(--text);
}

main {
  margin: 0 auto;
  padding: 0 16px 96px;
}

/* The blog's reading column: 46rem, growing with the window up to 60rem while that leaves 16rem each side for the
   contents and sidenotes. A 13" MacBook Air (1440px) gets 58rem. */
main.narrow {
  --column: clamp(46rem, 100vw - 32rem, 60rem);
  max-width: var(--column);
}

main.wide {
  max-width: 72rem;
}

main.full {
  max-width: none;
  padding: 0;
}

/* Footer, lined up with the header; under Notes' full-width panes it spans the window and closes them off */
.site-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 0.875rem;
}

main.full + .site-footer {
  max-width: none;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 24px 0 16px;
}

h2 {
  font-size: 1.25rem;
  margin: 48px 0 16px;
}

/* Anything a link jumps to stops a little below the top of the screen. */
[id] {
  scroll-margin-top: 16px;
}

/* Page sections (not headings inside articles) start with a full-width rule. */
main > h2 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

/* Every page's table of contents, in the left margin where it fits: beside narrow pages from 68rem, beside wide
   ones from 90rem. It grows into a wide margin and scrolls when taller than the screen. */
.toc-side {
  display: none;
  position: fixed;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-side,
.note-contents {
  flex-direction: column;
  font-size: 0.875rem;
  line-height: 1.4;
}

@media (min-width: 68rem) {
  main.narrow .toc-side {
    display: flex;
    right: calc(50% + var(--column) / 2);
    width: min(16rem, calc(50% - var(--column) / 2 - 16px));
  }
}

@media (min-width: 90rem) {
  main.wide .toc-side {
    display: flex;
    right: calc(50% + 36rem);
    width: min(16rem, calc(50% - 36rem - 16px));
  }
}

:is(.toc-side, .note-contents) a {
  padding: 3px 0 3px 12px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-left: 2px solid var(--line);
}

/* Nested entries: a page's subsections, a body part's exercises, a note's subheadings */
:is(.toc-side, .note-contents) a[data-depth] {
  padding: 2px 0 2px 24px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: normal;
}

:is(.toc-side, .note-contents) a[data-depth="2"] {
  padding-left: 36px;
}

:is(.toc-side, .note-contents) a[data-depth="3"] {
  padding-left: 48px;
}

:is(.toc-side, .note-contents) a:hover,
:is(.toc-side, .note-contents) a[aria-current] {
  color: var(--accent);
}

:is(.toc-side, .note-contents) a[aria-current] {
  border-left-color: var(--accent);
}

h3 {
  font-size: 1rem;
  margin: 0 0 12px;
}

h4 {
  font-size: 0.95rem;
  margin: 16px 0 4px;
}

.muted,
.meta,
.count {
  color: var(--muted);
  font-size: 0.875rem;
}

button,
select {
  font: inherit;
  font-size: 0.875rem;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

[hidden] {
  display: none !important;
}

/* Prose: blog posts and notes */
.prose {
  overflow-wrap: break-word;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose pre {
  background: var(--empty);
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.prose :not(pre) > code {
  background: var(--empty);
  padding: 1px 5px;
  border-radius: 4px;
}

.prose table {
  display: block;
  overflow-x: auto;
}

.prose blockquote {
  margin: 0;
  padding-left: 16px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
}

/* The list of blog posts */
.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  display: flex;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.post-list time {
  flex: none;
  width: 6.5rem;
  color: var(--muted);
}

/* Page intros, cards and charts: the dashboard's, shared with Workouts and Salsa */
/* The points under a page's title, muted, each with an accent dot. */
.intro {
  display: grid;
  gap: 6px;
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.intro li {
  position: relative;
  padding-left: 22px;
}

.intro li::before {
  content: "";
  position: absolute;
  top: calc(0.5lh - 3px);
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.plot {
  width: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: none;
  padding: 0;
  margin: 8px 0;
  font-size: 0.875rem;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
}

details summary {
  cursor: pointer;
  margin: 12px 0 8px;
  font-size: 0.875rem;
}

/* Each body part's sets this week: a table on Workouts and the dashboard */
.week-table {
  width: auto;
  table-layout: auto;
  font-size: 0.9375rem;
}

.week-table :is(th, td):first-child {
  padding-left: 0;
}

.week-table :is(th, td) + :is(th, td) {
  padding-left: 48px;
}

.week-table th {
  padding-top: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: normal;
}

.week-table td + td {
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.week-table tr:last-child td {
  border-bottom: 0;
}

/* Label-over-value figures, like "Past Year" over "93 sets on 11 days" */
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin: 0;
}

.figures dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.figures dd {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.figures small {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: normal;
}

.figures + .plot {
  margin-top: 8px;
}

/* The footer's hint at the hidden terminal (layout.mjs): its $ in the icon's green, a button that opens it too.
   Touch screens have no $ to press, so there it says tap instead of type. */
.terminal-hint button {
  padding: 0;
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.terminal-hint kbd {
  color: var(--met);
  font-family: var(--mono);
  font-weight: 700;
}

.hint-tap {
  display: none;
}

@media (pointer: coarse) {
  .hint-type {
    display: none;
  }

  .hint-tap {
    display: inline;
  }
}
