/* One column of monospace text. The colors are rime's own custom properties,
   written into theme.css by build.ts: rime when dark, rime frost when light. */

@font-face {
  font-family: "Maple Mono";
  src: url("fonts/maple-mono-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Maple Mono";
  src: url("fonts/maple-mono-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Maple Mono";
  src: url("fonts/maple-mono-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--rime-bg);
  color: var(--rime-fg);
  font: 15px/1.7 "Maple Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--rime-bg-sel) transparent;
}

body {
  max-width: 90ch;
  margin: 0 auto;
  padding: 1.25rem;
}

::selection {
  background: var(--rime-bg-sel);
}

:focus-visible {
  outline: 2px solid var(--rime-blue);
  outline-offset: 2px;
}

a {
  color: var(--rime-blue);
  text-decoration: underline dotted 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-style: solid;
}

/* secondary text. The comment color is too faint for text people read (about 3:1 against bg),
   so it is kept for decorative marks: separators, list markers, "##" and line numbers */
.dim {
  color: var(--rime-muted);
}

/* ------------------------------------------------------------------ header and footer */

header {
  padding-bottom: 1.25rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px dashed var(--rime-border);
}

/* the name over the links on the left; the star count over the theme switch on the right */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
}

.row > :last-child {
  margin: 0 0 0 auto; /* stays on the right, even when it wraps under the links */
}

.name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rime-fg-bright);
  text-decoration: none;
}

.stars {
  font-size: 13px;
  color: var(--rime-muted);
  text-decoration: none;
}

.stars:hover {
  color: var(--rime-fg);
  text-decoration: underline dotted 1px;
}

.theme {
  font-size: 13px;
  color: var(--rime-comment);
}

.theme button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--rime-muted);
  text-decoration: underline dotted 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.theme button[aria-pressed="true"] {
  color: var(--rime-fg-bright);
  text-decoration-style: solid;
}

nav {
  margin-top: 0.25rem;
  color: var(--rime-comment);
}

nav a {
  color: var(--rime-muted);
}

/* a little smaller on a phone, so the theme switch fits on the links' line */
@media (max-width: 440px) {
  nav {
    font-size: 13px;
  }

  .theme {
    font-size: 12px;
  }
}

nav a[aria-current="page"] {
  color: var(--rime-fg-bright);
  text-decoration-style: solid;
}

footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--rime-border);
  font-size: 13px;
  color: var(--rime-muted);
}

footer a {
  color: var(--rime-muted);
}

/* ------------------------------------------------------------------ text */

h1,
h2,
h3 {
  color: var(--rime-fg-bright);
  line-height: 1.3;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
}

h2 {
  margin: 3rem 0 1rem;
  font-size: 1.15rem;
}

h2::before {
  content: "## " / "";
  color: var(--rime-comment);
}

h3 {
  margin: 2rem 0 0.5rem;
  font-size: 1rem;
}

p,
ul,
ol {
  margin: 0.9rem 0;
}

ul {
  padding-left: 2ch;
  list-style: "- ";
}

li::marker {
  color: var(--rime-comment);
}

em {
  color: var(--rime-muted);
}

strong {
  color: var(--rime-fg-bright);
}

hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px dashed var(--rime-border);
}

blockquote {
  margin: 1.25rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--rime-border);
  color: var(--rime-muted);
}

code {
  padding: 0.1em 0.35em;
  border-radius: 3px;
  background: var(--rime-bg-alt);
  color: var(--rime-fg-bright);
  font-size: 0.9em;
}

/* Shiki writes the variant's own bg on each block; on a page it steps aside so the block shows */
pre.shiki {
  margin: 1rem 0;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--rime-border);
  border-radius: 6px;
  background-color: var(--rime-bg-dark) !important;
  font-size: 13px;
  line-height: 1.65;
}

/* a long path in a sentence wraps rather than widening the page */
:not(pre) > code {
  overflow-wrap: anywhere;
}

pre.shiki code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

details {
  margin: -0.4rem 0 1rem;
  font-size: 13px;
}

summary {
  color: var(--rime-muted);
  cursor: pointer;
}

details p {
  margin: 0.75rem 0 -0.5rem;
}

/* ------------------------------------------------------------------ tables */

.table {
  margin: 1.25rem 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  font-weight: 400;
  color: var(--rime-muted);
  text-align: left;
}

th,
td {
  padding: 0.35rem 1.25rem 0.35rem 0;
  border-bottom: 1px dashed var(--rime-border);
  white-space: nowrap;
}

/* the last column may hold a sentence, so it wraps, but not so narrow that a hex code breaks */
td:last-child {
  min-width: 16ch;
  white-space: normal;
}

.chip {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.5em;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.3);
  vertical-align: -0.05em;
}

/* ------------------------------------------------------------------ home */

/* the logo sits beside the title, and above it on a phone */
.logo {
  float: right;
  margin: 0 0 1rem 2rem;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.2;
  font-feature-settings: "calt" 0; /* Maple Mono would join a run of - into one line */
}

@media (max-width: 640px) {
  .logo {
    float: none;
    width: fit-content;
    margin: 0 auto 2rem;
  }
}

h2 {
  clear: both;
}

.variant h3 {
  margin-bottom: 0.75rem;
}

/* outlined, so a swatch the color of the page still shows its edge */
.swatches {
  display: flex;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--rime-border);
}

.swatches > div {
  display: flex;
  flex: 1;
  height: 0.7rem;
}

.swatches span {
  flex: 1;
}

/* a phone shows the base and the accents as two strips, and leaves out the preview */
@media (max-width: 640px) {
  .swatches {
    flex-direction: column;
    gap: 0.5rem;
    overflow: visible;
    box-shadow: none;
  }

  .swatches > div {
    flex: none; /* in a column, flex: 1 would set their height and override this one */
    height: 1.5rem;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--rime-border);
  }

  .preview {
    display: none;
  }
}

/* a preview: code, line numbers and a statusline, all in its variant's own colors */
.preview {
  margin-top: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--rime-border);
  background: var(--rime-bg);
}

.preview pre.shiki {
  margin: 0;
  padding-left: 0.9rem;
  border: 0;
  border-radius: 0;
  background-color: var(--rime-bg) !important;
}

.preview code {
  counter-reset: line;
}

/* the number column, one digit wide for the preview's nine lines */
.preview .line::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 1ch;
  margin-right: 1.5ch;
  text-align: right;
  color: var(--rime-comment);
}

.statusline {
  display: flex;
  margin: 0;
  background: var(--rime-bg-alt);
  color: var(--rime-fg);
  font-size: 12px;
  line-height: 1.9;
}

.statusline span {
  padding: 0 1ch;
}

.statusline .mode {
  background: var(--rime-blue);
  color: var(--rime-bg);
  font-weight: 700;
}

.statusline .pos {
  margin-left: auto;
  color: var(--rime-muted);
}

.list {
  padding: 0;
  list-style: none;
}

.list li {
  margin: 0.3rem 0;
}

.list li::before {
  content: "- " / "";
  color: var(--rime-comment);
}

.files {
  padding: 0.75rem 1rem;
  border: 1px dashed var(--rime-border);
  border-radius: 6px;
  font-size: 13px;
}
