/*
 * recvmail.net site style. The page should read as a file a machine would consume:
 * one monospace face, an 80-column measure, markdown markers drawn in the margin
 * colour. The markers are CSS content, so they never end up in a selection or a copy.
 */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1c1e21;
  --dim: #6a7078;
  --faint: #9aa0a6;
  --border: #dcdcd5;
  --link: #0a55c5;
  --code-bg: #f1f1ec;
  --key: #7a3e9d;
  --string: #2f6f44;
  --number: #a0530a;
  --paid-fg: #7a4100;
  --paid-bg: #fde9c4;
  --paid-border: #e9c483;
  --free-fg: #14593a;
  --free-bg: #d8f1e1;
  --free-border: #9fd4b5;
  --get: #0a55c5;
  --post: #7a3e9d;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f11;
    --surface: #14171a;
    --text: #d9dcdf;
    --dim: #8b929a;
    --faint: #5d646c;
    --border: #262b30;
    --link: #7db8ff;
    --code-bg: #1b1f23;
    --key: #c79bea;
    --string: #8fd6a8;
    --number: #f0b370;
    --paid-fg: #ffc875;
    --paid-bg: #35270d;
    --paid-border: #5e4517;
    --free-fg: #84e2ab;
    --free-bg: #0f2e1e;
    --free-border: #1d5236;
    --get: #7db8ff;
    --post: #c79bea;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px / 1.65 var(--mono);
  font-variant-ligatures: none;
}

code,
pre,
button {
  font-family: inherit;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

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

.c {
  color: var(--faint);
}

.k {
  color: var(--key);
}

.s {
  color: var(--string);
}

.n {
  color: var(--number);
}

/* --- page frame ------------------------------------------------------------------ */

.bar,
main,
footer {
  width: min(100% - 2rem, 92ch);
  margin-inline: auto;
}

footer {
  padding-block: 1.5rem 3rem;
  color: var(--dim);
}

/* On the paragraph, not the footer: the footer's width is in ch. */
footer p {
  margin: 0;
  font-size: 0.87rem;
}

footer a {
  color: inherit;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-block: 1.25rem 0.75rem;
}

.bar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1.25ch;
}

.bar a {
  color: var(--dim);
  text-decoration: none;
}

.bar a:hover,
.bar a[aria-current] {
  color: var(--text);
}

.bar a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.bar .host {
  color: var(--text);
  font-weight: 700;
}

.bar .sep {
  color: var(--faint);
  margin-inline: -0.5ch;
}

.status {
  color: var(--paid-fg);
  font-size: 0.87rem;
}

.status::before {
  content: "● ";
}

.lede {
  margin: 0.75rem 0 1.5rem;
  color: var(--dim);
  max-width: 84ch;
}

/* --- the file -------------------------------------------------------------------- */

.file {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.file-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 2ch;
  min-height: 2.75rem;
  padding: 0.35rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  font-size: 0.87rem;
}

.file-name {
  font-weight: 700;
}

.file-meta {
  color: var(--dim);
}

.file-actions {
  display: flex;
  margin-left: auto;
}

.file-actions[hidden] {
  display: none;
}

.file-actions button {
  margin: 0 0 0 -1px;
  padding: 0.2rem 1.5ch;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--dim);
  font: inherit;
  cursor: pointer;
}

.file-actions button:first-child {
  border-radius: 4px 0 0 4px;
}

.file-actions button:hover {
  color: var(--text);
}

.file-actions button[aria-pressed="true"] {
  background: var(--code-bg);
  color: var(--text);
}

.file-actions button[data-copy] {
  margin-left: 1ch;
  border-radius: 4px;
  min-width: 9ch;
  color: var(--text);
}

.file-actions button[data-copy].done {
  background: var(--free-bg);
  border-color: var(--free-border);
  color: var(--free-fg);
}

/* --- raw view -------------------------------------------------------------------- */

.raw {
  border-top: 1px solid var(--border);
}

.raw summary {
  padding: 0.6rem 1rem;
  color: var(--dim);
  cursor: pointer;
}

.raw-view {
  display: flex;
  overflow-x: auto;
  padding-block: 1rem;
  font-size: 0.87rem;
}

.raw-view pre {
  margin: 0;
  font: inherit;
  line-height: 1.6;
  white-space: pre;
}

.raw-view .ln {
  position: sticky;
  left: 0;
  flex: none;
  padding-inline: 1.5ch 1.5ch;
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--faint);
  text-align: right;
  user-select: none;
}

#skill-raw {
  padding-inline: 2ch;
}

/* With JavaScript the head bar's rendered | raw control drives the view instead. */
.js .raw {
  border-top: 0;
}

.js .raw summary {
  display: none;
}

/* --- rendered markdown ----------------------------------------------------------- */

.md {
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 2.5rem;
  overflow-wrap: break-word;
}

.md > * {
  max-width: 84ch;
}

.md > .table-wrap,
.md > pre {
  max-width: none;
}

.md h1,
.md h2,
.md h3 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.md h1 {
  margin-top: 1.5rem;
  font-size: 1.35rem;
}

.md h2 {
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  font-size: 1.1rem;
}

.md h1::before,
.md h2::before,
.md h3::before {
  color: var(--faint);
  font-weight: 400;
}

.md h1::before {
  content: "# ";
}

.md h2::before {
  content: "## ";
}

.md h3::before {
  content: "### ";
}

.md .anchor {
  color: inherit;
  text-decoration: none;
}

.md .anchor:hover {
  text-decoration: underline;
  text-decoration-color: var(--faint);
}

.md p,
.md ul,
.md ol,
.md pre,
.md blockquote,
.md .table-wrap {
  margin: 0 0 1.1rem;
}

.md ul,
.md ol {
  padding-left: 0;
  list-style: none;
}

.md li {
  position: relative;
  padding-left: 3ch;
  margin-bottom: 0.35rem;
}

.md li::before {
  position: absolute;
  left: 0;
  color: var(--faint);
}

.md ul > li::before {
  content: "-";
  left: 1ch;
}

.md ol {
  counter-reset: item;
}

.md ol > li {
  counter-increment: item;
}

.md ol > li::before {
  content: counter(item) ".";
}

.md code {
  padding: 0.05em 0.4em;
  border-radius: 3px;
  background: var(--code-bg);
  font: inherit;
  font-size: 0.93em;
  overflow-wrap: anywhere;
}

.md a code {
  color: inherit;
}

.md blockquote code {
  background: none;
  padding: 0;
}

.md td code {
  overflow-wrap: normal;
}

.md pre.code,
.md pre.frontmatter {
  position: relative;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--code-bg);
  font: inherit;
  font-size: 0.87rem;
  line-height: 1.55;
}

.md pre.code code {
  padding: 0;
  background: none;
  font-size: inherit;
  overflow-wrap: normal;
}

.md pre.code::before {
  content: "```" attr(data-lang);
  display: block;
  margin-bottom: 0.35rem;
  color: var(--faint);
}

.md pre.code::after {
  content: "```";
  display: block;
  margin-top: 0.35rem;
  color: var(--faint);
}

.md pre.frontmatter {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--dim);
}

.md blockquote {
  padding: 0.85rem 1rem 0.85rem 4ch;
  position: relative;
  border: 1px solid var(--paid-border);
  border-radius: 4px;
  background: var(--paid-bg);
  color: var(--paid-fg);
}

.md blockquote::before {
  content: ">";
  position: absolute;
  left: 1.5ch;
  opacity: 0.6;
}

.md blockquote p:last-child {
  margin-bottom: 0;
}

.md strong {
  font-weight: 700;
}

/* --- cost tags, methods ---------------------------------------------------------- */

.md code.tag {
  padding: 0.05em 0.75ch;
  border: 1px solid;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.md code.tag.paid {
  background: var(--paid-bg);
  border-color: var(--paid-border);
  color: var(--paid-fg);
}

.md code.tag.paid::before {
  content: "$ ";
}

.md code.tag.free {
  background: var(--free-bg);
  border-color: var(--free-border);
  color: var(--free-fg);
}

.md code.ep {
  padding: 0;
  background: none;
  font-size: inherit;
}

.md .method {
  font-weight: 700;
  color: var(--get);
}

.md .method.post {
  color: var(--post);
}

.md blockquote .method {
  color: inherit;
}

.md p.cost {
  color: var(--dim);
}

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

.md .table-wrap {
  overflow-x: auto;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.md th,
.md td {
  padding: 0.45rem 1.5ch 0.45rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.md th {
  border-bottom-color: var(--faint);
  color: var(--dim);
  font-weight: 400;
  white-space: nowrap;
}

.md td:first-child {
  white-space: nowrap;
}

/* --- contents -------------------------------------------------------------------- */

.toc {
  margin-bottom: 2rem;
  font-size: 0.93rem;
}

.toc .toc-title {
  margin-bottom: 0.35rem;
}

.md .toc li {
  margin-bottom: 0.1rem;
}

.md .toc li.d3 {
  margin-left: 3ch;
}

.toc a {
  color: inherit;
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.toc code.tag {
  display: none;
}

.js .file[data-view="rendered"] .raw,
.js .file[data-view="raw"] .md {
  display: none;
}

@media (max-width: 40rem) {
  body {
    font-size: 14px;
  }

  /* Tables stack: one block per row, one `label: value` line per cell. */
  .md table,
  .md tbody,
  .md tr,
  .md td {
    display: block;
  }

  .md thead,
  .md td:empty {
    display: none;
  }

  .md tr {
    padding-block: 0.6rem;
    border-bottom: 1px solid var(--border);
  }

  .md td,
  .md td:first-child {
    padding: 0.1rem 0;
    border: 0;
    white-space: normal;
  }

  .md td::before {
    content: attr(data-label) ": ";
    color: var(--faint);
  }
}

@media print {
  .file-actions,
  .raw {
    display: none;
  }

  .file-head {
    position: static;
  }
}
