/*
  CSDGN site styles.

  All the colors are defined once, right here: first for light mode, then for
  dark mode (used automatically when the visitor's computer is set to dark).
*/
:root {
  color-scheme: light dark;

  --page: #ececf1;        /* background behind the article */
  --card: #ffffff;        /* the article itself */
  --text: #2a2a33;
  --muted: #6a6a7c;       /* dates, footer */
  --heading: #3a3a50;
  --line: #dcdce5;        /* borders and dividers */
  --brand: #555566;       /* the header bar: CSDGN's classic slate */
  --brand-text: #ffffff;
  --link: #3f3fa6;
  --link-hover: #28287a;
  --code-bg: #f5f5f9;
  --note-bg: #f3f3f9;     /* > quoted / callout boxes */
  --note-edge: #8888aa;
  --red: #b3261e;
  --green: #1b7a2e;

  /* Code colors (same idea as the old site: green comments, purple
     declarations, blue keywords, orange numbers) */
  --code-comment: #2f7d32;
  --code-keyword: #1f4fbf;
  --code-declare: #8a2c8a;
  --code-number: #b35c00;
  --code-string: #a3292b;
  --code-name: #6b4f00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #121218;
    --card: #1c1c24;
    --text: #dcdce6;
    --muted: #9a9aae;
    --heading: #ececf6;
    --line: #30303e;
    --brand: #3b3b4d;
    --link: #a6a6ff;
    --link-hover: #cacaff;
    --code-bg: #15151c;
    --note-bg: #23232e;
    --note-edge: #6c6c92;
    --red: #ff8a80;
    --green: #7ddc8b;

    --code-comment: #7fc98a;
    --code-keyword: #8fb3ff;
    --code-declare: #d9a3ff;
    --code-number: #f0b460;
    --code-string: #f09a9a;
    --code-name: #e6d38a;
  }
}

/* ---- Page layout ------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 1.0625rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 52rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.site-header {
  background: var(--brand);
  color: var(--brand-text);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.site-name {
  color: inherit;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-left: auto;
}

.site-header nav a {
  color: inherit;
  opacity: 0.85;
  text-decoration: none;
  text-underline-offset: 0.4em;
  text-decoration-thickness: 2px;
}

.site-header nav a:hover,
.site-header nav a.current {
  opacity: 1;
  text-decoration-line: underline;
}

main {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 2rem 2rem;
}

/* Keep floated pictures inside the article. */
article::after {
  content: "";
  display: table;
  clear: both;
}

.site-footer {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0 1rem 2rem;
}

/* Phones: let the article use the whole width. */
@media (max-width: 40rem) {
  main.wrap {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }
  article {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: 0.25rem 1rem 1.5rem;
  }
}

/* ---- Text -------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  color: var(--heading);
  line-height: 1.25;
  margin: 1.8em 0 0.6em;
}

h1 {
  font-size: 2.1rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--line);
}

h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.published {
  color: var(--muted);
  margin-top: 0;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

/* The "#" that appears when you point at a heading, for linking to it. */
.headerlink {
  color: var(--muted);
  font-weight: normal;
  margin-left: 0.4em;
  text-decoration: none;
  opacity: 0;
}

:hover > .headerlink,
.headerlink:focus {
  opacity: 1;
}

ul, ol {
  padding-left: 1.6rem;
}

li + li {
  margin-top: 0.2rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.1rem;
  background: var(--note-bg);
  border-left: 4px solid var(--note-edge);
  border-radius: 0 8px 8px 0;
}

blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }

abbr[title] {
  cursor: help;
}

hr {
  border: 0;
  border-top: 2px solid var(--line);
  margin: 2rem 0;
}

/* Handy classes for Markdown, e.g.  ![logo](logo.png){.right}  */
.right {
  float: right;
  margin: 0.25rem 0 1rem 1.5rem;
}

.left {
  float: left;
  margin: 0.25rem 1.5rem 1rem 0;
}

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 40rem) {
  .right, .left {
    float: none;
    display: block;
    margin: 1rem auto;
  }
}

.red { color: var(--red); }
.green { color: var(--green); }

/* ---- Pictures and tables ----------------------------------------------- */

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

table {
  display: block;       /* lets wide tables scroll sideways on phones */
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.25rem 0;
}

th, td {
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  border-bottom-width: 2px;
}

table.compare td {
  vertical-align: top;
}

table.compare pre {
  margin: 0;
}

/* ---- Code -------------------------------------------------------------- */

code, pre {
  font-family: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  font-size: 0.875em;
}

:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  line-height: 1.5;
  overflow-x: auto;
  tab-size: 4;
}

pre code {
  font-size: inherit;
}

.highlight :is(.c, .ch, .cm, .c1, .cs, .cp, .cpf) { color: var(--code-comment); }
.highlight :is(.k, .kc, .kn, .kp, .kr, .ow) { color: var(--code-keyword); font-weight: 600; }
.highlight :is(.kd, .kt) { color: var(--code-declare); font-weight: 600; }
.highlight :is(.m, .mb, .mf, .mh, .mi, .mo, .il) { color: var(--code-number); }
.highlight :is(.s, .sa, .sb, .sc, .dl, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss) { color: var(--code-string); }
.highlight :is(.nf, .fm, .nc, .nd) { color: var(--code-name); }

/* ---- Article lists (the Articles and Projects pages) ------------------- */

.page-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.page-list li {
  margin: 0;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.page-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.page-list a {
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
  margin-right: 0.75rem;
}

.page-list a:hover {
  text-decoration: underline;
}

.page-list time {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.page-list p {
  margin: 0.3rem 0 0;
}

/* ---- Printing ---------------------------------------------------------- */

@media print {
  body {
    background: #fff;
    color: #000;
  }
  .site-header {
    background: none;
    color: #000;
  }
  .site-header nav, .headerlink {
    display: none;
  }
  article {
    border: 0;
    padding: 0;
  }
  a {
    color: inherit;
  }
  pre {
    white-space: pre-wrap;
  }
}
