/* singular-lang.dev
 *
 * Colors come from the banner: its near-black background (#03020a) and the
 * purple of its light trails. Dark is the default, and a light theme follows
 * the reader's system setting. There is no JavaScript.
 */

:root {
  --background: #03020a;
  --surface: #0c0a17;
  --surface-strong: #15112a;
  --border: #251f3d;
  --text: #e9e6f3;
  --text-muted: #a39db8;
  --accent: #a990ff;
  --accent-strong: #c7b6ff;
  --button-background: #6f52d9;
  --button-text: #ffffff;

  /* Code */
  --code-text: #e4e0f2;
  --code-keyword: #b99dff;
  --code-access: #ff8fcf;
  --code-failure: #ffae6b;
  --code-literal: #f2c27b;
  --code-type: #79d3e6;
  --code-function: #9bb6ff;
  --code-string: #a6dd9b;
  --code-interpolation: #f2c27b;
  --code-number: #f2c27b;
  --code-comment: #7a7492;
  --code-doc: #938bb5;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-code: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --header-height: 60px;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --background: #fbfaff;
    --surface: #f3f0fb;
    --surface-strong: #e9e4f7;
    --border: #ddd6ef;
    --text: #17141f;
    --text-muted: #5a556c;
    --accent: #5a3ec8;
    --accent-strong: #3f2899;
    --button-background: #5a3ec8;
    --button-text: #ffffff;

    --code-text: #1f1b2b;
    --code-keyword: #6a3fd1;
    --code-access: #b8226f;
    --code-failure: #a8500c;
    --code-literal: #8f5a00;
    --code-type: #0b6f82;
    --code-function: #2d4fb0;
    --code-string: #2b7a2f;
    --code-interpolation: #8f5a00;
    --code-number: #8f5a00;
    --code-comment: #767088;
    --code-doc: #655d85;

    color-scheme: light;
  }
}

/* ---- Base ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}

[id] {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
  margin: 2.2em 0 0.6em;
}

h1 {
  font-size: 2.2rem;
  margin-top: 0.6em;
}

h2 {
  font-size: 1.6rem;
}

h3 {
  font-size: 1.25rem;
}

p,
ul,
ol {
  margin: 0 0 1em;
}

ul,
ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.3em;
}

li > ul,
li > ol {
  margin: 0.3em 0 0;
}

li > p {
  margin-bottom: 0.5em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3em 0;
}

strong {
  font-weight: 650;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 16px;
  top: 12px;
  z-index: 20;
  padding: 6px 12px;
  background: var(--surface-strong);
}

/* ---- Header and footer --------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  min-height: var(--header-height);
  padding: 10px max(16px, calc((100% - 1160px) / 2));
  background: var(--background);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand img {
  border-radius: 7px;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 0.95rem;
}

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

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

.site-header nav a[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--accent);
}

main {
  padding: 0 16px 64px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  max-width: 720px;
  margin: 0 auto;
}

/* ---- Prose --------------------------------------------------------------- */

.prose {
  max-width: 760px;
  margin: 0 auto;
}

.prose > h2:first-child {
  margin-top: 2.4em;
}

/* Ligatures are off, so `->` and `*=` look exactly as they are typed. */
code {
  font-family: var(--font-code);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  font-size: 0.88em;
  background: var(--surface-strong);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  overflow-wrap: break-word;
}

pre.code {
  margin: 0 0 1.2em;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
  tab-size: 4;
}

pre.code code {
  display: block;
  width: max-content;
  min-width: 100%;
  padding: 0;
  background: none;
  border-radius: 0;
  color: var(--code-text);
  font-size: 14.5px;
  overflow-wrap: normal;
}

.table-wrap {
  margin: 0 0 1.2em;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.5;
}

th,
td {
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface);
  font-weight: 650;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td code,
th code {
  white-space: nowrap;
}

/* Highlighted Singular code. Classes come from highlight_sing() in build.py. */
.code .keyword { color: var(--code-keyword); }
.code .access { color: var(--code-access); font-weight: 650; }
.code .failure { color: var(--code-failure); font-weight: 650; }
.code .literal { color: var(--code-literal); }
.code .type { color: var(--code-type); }
.code .function { color: var(--code-function); }
.code .string,
.code .char { color: var(--code-string); }
.code .interpolation { color: var(--code-interpolation); }
.code .number { color: var(--code-number); }
.code .comment { color: var(--code-comment); font-style: italic; }
.code .doc { color: var(--code-doc); font-style: italic; }

/* ---- Home ---------------------------------------------------------------- */

.hero {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 28px;
  text-align: center;
}

.banner {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.tagline {
  margin: 1em 0 0.4em;
  font-size: clamp(1.7rem, 5.2vw, 2.7rem);
  letter-spacing: -0.01em;
}

.intro {
  max-width: 640px;
  margin: 0 auto 1.6em;
  color: var(--text-muted);
  font-size: 1.12rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.button {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
}

.button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.button.primary {
  background: var(--button-background);
  border-color: var(--button-background);
  color: var(--button-text);
}

.button.primary:hover {
  color: var(--button-text);
  filter: brightness(1.1);
}

.caption {
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

.status li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.status li + li {
  margin-top: 0;
}

.badge {
  display: inline-block;
  min-width: 92px;
  margin-right: 8px;
  padding: 1px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.badge.done {
  color: var(--code-string);
  border-color: currentColor;
}

.badge.active {
  color: var(--accent);
  border-color: currentColor;
}

/* ---- Examples ------------------------------------------------------------ */

.page-intro {
  padding-top: 8px;
}

.example-list {
  padding-left: 0;
  list-style: none;
  columns: 2 300px;
  column-gap: 32px;
  font-size: 0.95rem;
}

.example-list li {
  break-inside: avoid;
  margin: 0 0 10px;
  line-height: 1.4;
}

.example-list a {
  display: block;
  font-weight: 600;
  text-decoration: none;
}

.example-list .number {
  color: var(--text-muted);
  font-family: var(--font-code);
  font-weight: 400;
}

.example-list .summary {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.examples {
  max-width: 860px;
  margin: 0 auto;
}

.example {
  margin-top: 56px;
}

.example h2 {
  margin: 0 0 14px;
  font-size: 1.45rem;
}

h2 .number,
h3 .number {
  color: var(--text-muted);
  font-family: var(--font-code);
  font-weight: 500;
  text-decoration: none;
}

h2 .number:hover,
h3 .number:hover {
  color: var(--accent);
}

.file {
  margin: 0 0 14px;
}

.file figcaption {
  display: inline-block;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface-strong);
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: 0.8rem;
}

.file pre.code {
  margin: 0;
  border-top-left-radius: 0;
}

.file.output pre.code {
  background: var(--background);
  border-style: dashed;
}

/* ---- Spec ---------------------------------------------------------------- */

.spec-layout {
  max-width: 1160px;
  margin: 0 auto;
}

.spec h1 {
  margin-top: 0.8em;
}

.toc-note {
  margin: 0 0 8px;
  color: var(--text-muted);
}

.toc-top .toc-note {
  margin-top: 8px;
}

.toc {
  font-size: 0.9rem;
  line-height: 1.4;
}

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

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 3px 0;
  color: var(--text-muted);
  text-decoration: none;
}

.toc-list a:hover {
  color: var(--text);
}

.toc-list .level-2 {
  margin-top: 8px;
}

.toc-list .level-2 > a {
  color: var(--text);
  font-weight: 600;
}

.toc-list .level-3 {
  padding-left: 1.6em;
}

.toc-list .number {
  font-family: var(--font-code);
  font-size: 0.85em;
  color: var(--text-muted);
}

.toc-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.toc-top {
  margin: 1.4em 0;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.toc-top summary {
  cursor: pointer;
  font-weight: 650;
}

.toc-top .toc-list {
  margin-top: 8px;
}

.toc-side {
  display: none;
}

@media (min-width: 1000px) {
  .spec-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 48px;
  }

  .toc-side {
    display: block;
    position: sticky;
    top: calc(var(--header-height) + 16px);
    align-self: start;
    max-height: calc(100vh - var(--header-height) - 32px);
    overflow-y: auto;
    padding: 24px 8px 24px 0;
  }

  .toc-top {
    display: none;
  }

  .spec {
    margin: 0;
  }
}

/* ---- Small screens ------------------------------------------------------- */

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .site-header nav {
    gap: 4px 16px;
  }

  pre.code {
    padding: 12px 14px;
  }

  pre.code code {
    font-size: 13px;
  }

  th,
  td {
    padding: 8px 10px;
  }

  .badge {
    min-width: 0;
  }
}
