/* Base stylesheet. Colours come only from the Monkeytype theme tokens in
   themes.css (generated), so the page is themed by whichever [data-theme] block
   is active. The defaults below are the site default theme, godspeed, and they are
   what applies if themes.css has not been generated yet. Keep them in step with
   DEFAULT_THEME in render.py.

   Which token paints what, following Monkeytype's own meaning for each token:

     --bg        the page background
     --text      body copy: the theme's typed-text colour, the bulk of the reading
     --accent    the theme's signature colour (Monkeytype's "main"): section
                 headings, the name, links, active nav. Themes often set main for a
                 caret or a filled button rather than for type, so the build lifts
                 it to 4.5:1 in OKLCH when it has to move, keeping hue and chroma.
     --accent-soft  the same hue at 3:1, for things that must be seen, not read
     --muted     secondary text: metadata, tags, years, footer (from the theme's
                 "sub", lifted to 4.5:1 because "sub" is tuned for untyped words)
     --line      hairlines and borders, from "sub"
     --caret     kept from the theme for fidelity, though the page has no caret
     --error     reserved for errors, as upstream uses it

   The point of the split: 187 themes should not all read as the same grey page.

   Layout follows the reference: one wide grid that uses the full width, with two
   columns of sections, year-grouped rows and hairline rules. Density comes from
   tight vertical rhythm, not from small type. */

:root {
  /* godspeed, the default theme */
  --bg: #eae4cf;
  --main: #9abbcd;
  --caret: #f4d476;
  --sub: #ada998;
  --sub-alt: #ded9c9;
  --text: #646669;
  --error: #ca4754;
  --error-extra: #7e2a33;
  --colorful-error: #ca4754;
  --colorful-error-extra: #7e2a33;

  /* derived, and per theme in themes.css: --muted, --accent, --accent-soft are
     computed for every theme at build time by tools/build_themes.py */
  --muted: #6c664f;
  --accent: #3b6c84;
  --accent-soft: #5788a2;
  --line: color-mix(in srgb, var(--sub) 45%, transparent);
  --line-soft: color-mix(in srgb, var(--sub) 25%, transparent);
  --hover-bg: color-mix(in srgb, var(--accent) 9%, transparent);
  --roundness: 6px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { overflow-y: scroll; }

body {
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3.5rem;
  max-width: 1320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .18s ease, color .18s ease;
}

/* Anything with display:flex/grid would otherwise ignore the hidden attribute. */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- typography */

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0; }

p { margin: 0 0 .7em; max-width: 34rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }

code, kbd, .mono { font-family: var(--mono); font-size: .87em; }

kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: .05em .35em;
  color: var(--muted);
}

.dim { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* -------------------------------------------------------------------- header */

.site-header {
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 2.5rem;
}

.site-header .brand,
.site-header .brand-sub { grid-column: 1; margin-bottom: .1rem; }

.brand {
  color: var(--accent);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.015em;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.brand-name, .brand-inner { display: inline-block; }

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: .9rem;
  max-width: none;
}

.header-links {
  grid-column: 1;
  font-family: var(--mono);
  font-size: .8rem;
  display: flex;
  flex-wrap: wrap;
  gap: .1rem 1.1rem;
  margin-top: .55rem;
  color: var(--muted);
}

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

/* ----------------------------------------------------------------------- nav */

.site-nav {
  grid-column: 2;
  grid-row: 1 / span 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .1rem .35rem;
  padding: 0;
  margin: .1rem 0 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: var(--roundness);
  color: var(--muted);
  font-size: .875rem;
  transition: color .15s ease, background-color .15s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="true"] {
  color: var(--accent);
  background: var(--hover-bg);
  text-decoration: none;
}

/* ------------------------------------------------------------- works grid */

.works-row {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.works-col { flex: 1 1 0; min-width: 0; }

/* ------------------------------------------------------------------ sections */

.section { margin-bottom: 1.75rem; scroll-margin-top: 1.5rem; }

.section > h2 {
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: .5rem;
  display: flex;
  align-items: baseline;
  gap: .75rem;
}

.section > h2 .section-note {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  opacity: .8;
  white-space: nowrap;
}

/* prose lines up with the entry text column, so the two columns share one
   left edge instead of stacking against the year gutter */
.section > p { margin-left: 4.6rem; }

/* ------------------------------------------------------- list rows / listings */

.listing { margin: 0; padding: 0; }

.entry {
  display: flex;
  gap: 1rem;
  padding: .42rem 0;
  border-top: 1px solid var(--line-soft);
}

.entry:first-child { border-top: 0; }

.entry:hover { background: var(--hover-bg); }

.year-col {
  flex: 0 0 3.6rem;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
  padding-top: .2rem;
}

.entry-body { flex: 1 1 auto; min-width: 0; }

.entry-title { font-weight: 600; font-size: .93rem; line-height: 1.4; }

.entry-title a { color: var(--text); }
.entry-title a:hover { color: var(--accent); }

.entry-meta {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .05rem;
  line-height: 1.45;
}

.entry-meta em { font-style: italic; }

.entry-note { font-size: .82rem; color: var(--muted); }

.entry-links {
  font-family: var(--mono);
  font-size: .74rem;
  margin-top: .15rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
}

.bullets { margin: .3rem 0 0; padding-left: 1rem; }
.bullets li { margin-bottom: .1rem; font-size: .87rem; line-height: 1.5; }

/* --------------------------------------------------------------- controls */

button, .btn {
  font: inherit;
  font-size: .82rem;
  font-family: var(--mono);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--roundness);
  padding: .2rem .6rem;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}

button:hover, .btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* ------------------------------------------------------------ theme switcher */

/* a live mock of the page, so hovering a theme shows what it really looks like */
.theme-preview {
  border: 1px solid var(--line);
  border-radius: calc(var(--roundness) * 1.2);
  padding: .7rem .85rem .8rem;
  margin-bottom: .9rem;
  background: var(--bg);
  color: var(--text);
  position: relative;
}

.theme-preview::before {
  content: "live preview";
  position: absolute;
  top: -.62em;
  left: .7rem;
  padding: 0 .4rem;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.theme-preview .brand { font-size: 1.35rem; margin-bottom: .1rem; }
.theme-preview .site-nav { margin: .1rem 0 .55rem; gap: .2rem .3rem; }
.theme-preview .site-nav a { pointer-events: none; font-size: .82rem; }
.theme-preview .brand-sub { margin: 0 0 .4rem; font-size: .85rem; }
.theme-preview .preview-line { font-size: .82rem; margin-bottom: .2rem; max-width: none; }

.theme-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  margin-bottom: .75rem;
}

.theme-toolbar input[type="search"] {
  flex: 1 1 16rem;
  font: inherit;
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--text);
  background: color-mix(in srgb, var(--sub-alt) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--roundness);
  padding: .28rem .6rem;
}

.theme-toolbar input[type="search"]:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.theme-toolbar select {
  font: inherit;
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--text);
  background: color-mix(in srgb, var(--sub-alt) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--roundness);
  padding: .28rem .4rem;
}

.theme-count {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
  margin-left: auto;
}

/* The picker now has its own page, so the list flows with the page instead of
   scrolling inside a box. */
.theme-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: .15rem .6rem;
}

.theme-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .22rem .4rem;
  border-radius: var(--roundness);
  color: var(--text);
  font-size: .8rem;
  font-family: var(--mono);
  cursor: pointer;
  border: 1px solid transparent;
  width: 100%;
  background: transparent;
  text-align: left;
  line-height: 1.4;
  font-weight: normal;
}

.theme-item:hover { background: var(--hover-bg); text-decoration: none; }

.theme-item[aria-current="true"] {
  border-color: var(--accent-soft);
  color: var(--accent);
}

.theme-item .theme-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.theme-item .fx {
  margin-left: auto;
  font-size: .62rem;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0 .35rem;
}

.swatches {
  display: inline-flex;
  border-radius: 3px;
  overflow: hidden;
  flex: 0 0 auto;
  /* an outline, not a border, so light swatches still read on a dark theme */
  box-shadow: 0 0 0 1px var(--line);
}
.swatches i { display: block; width: 6px; height: 13px; background: var(--sub); }
.swatches i:nth-child(1) { background: var(--sw1, var(--bg)); }
.swatches i:nth-child(2) { background: var(--sw2, var(--main)); }
.swatches i:nth-child(3) { background: var(--sw3, var(--sub)); }
.swatches i:nth-child(4) { background: var(--sw4, var(--text)); }
.swatches i:nth-child(5) { background: var(--sw5, var(--caret)); }
.swatches i:nth-child(6) { background: var(--sw6, var(--error)); }

.theme-empty { color: var(--muted); font-size: .85rem; padding: .5rem 0; }

/* ------------------------------------------------------------------- footer */

.site-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1.2rem;
}

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

.theme-current { color: var(--accent); }

/* ------------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  .works-row { flex-direction: column; gap: 0; }
  .works-col { width: 100%; }
}

@media (max-width: 640px) {
  body { padding: 2rem 1.1rem 3rem; }
  .site-header { grid-template-columns: minmax(0, 1fr); }
  .site-nav {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    justify-content: flex-start;
    margin-top: .7rem;
  }
  .brand { font-size: 1.45rem; }
  .entry { gap: .75rem; padding: .45rem 0; }
  .year-col { flex: 0 0 3rem; }
  .theme-list { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  body { transition: none; }
}
