/* The shared base of every page on the site: the front page, the docs and
   the API index. It holds the fonts, the design tokens and the site header
   (theme/header.hbs). `site build` copies it to build/assets/site.css, and
   each page links it before its own styles.

   The theme is the `data-theme` attribute on <html>, "light" or "dark".
   head.hbs and the front page set it before the page renders.

   Every colour on the site is a token here. Page styles use the tokens and
   define no colours of their own. */

/* -- Fonts ------------------------------------------------------------------ */

@font-face {
    font-family: Space;
    src: url("fonts/space-grotesk.ttf") format("truetype");
    font-weight: 300 700;
    font-display: swap;
}
@font-face {
    font-family: Plex;
    src: url("fonts/ibm-plex-mono.ttf") format("truetype");
    font-display: swap;
}

/* -- Tokens ----------------------------------------------------------------- */

:root, :root[data-theme="dark"] {
    --bg: #111113;
    --panel: #19181d;
    --fg: #eeebf2;
    --body: #ddd;
    --muted: #b9b6c2;
    --quiet: #aaa5b4;
    --line: #2c2933;
    --accent: #ff8f8a;
    --accent-solid: #ff7a73;
    --accent-text: #1a0f0f;
    --subtle: #2e1f1f;
    --green: #b2d99c;
    --yellow: #d7ac55;
    --blue: #6aaeff;
    --header: rgba(17, 17, 19, .94);
    --logo-tile: #232127;
    /* Code: One Dark, with its lighter comment grey (mono-2). */
    --code-bg: #282c34;
    --code-fg: #abb2bf;
    --code-bright: #d7dae0;
    --code-muted: #9da5b4;
    --code-line: #3e4451;
    --code-comment: #828997;
    --code-keyword: #c678dd;
    --code-string: #98c379;
    --code-number: #d19a66;
    --code-type: #e5c07b;
    --code-function: #61afef;
    --code-macro: #56b6c2;
    --code-variable: #e06c75;
    color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #fff;
    --panel: #f6f6f8;
    --fg: #111827;
    --body: #374151;
    --muted: #4b5563;
    --quiet: #626977;
    --line: #dedbe3;
    --accent: #d0342c;
    --accent-solid: #d0342c;
    --accent-text: #fff;
    --subtle: #fae8e6;
    --green: #497343;
    --yellow: #8a6116;
    --blue: #246bc2;
    --header: rgba(255, 255, 255, .95);
    --logo-tile: #fbeceb;
    /* Code: One Light. The comment grey is its mono-2, and green, blue,
       cyan and red are darkened to 4.5:1 on the background. Orange and
       yellow are shifted apart in hue as well, since darkened they look
       alike. */
    --code-bg: #fafafa;
    --code-fg: #383a42;
    --code-bright: #202227;
    --code-muted: #696c77;
    --code-line: #e5e5e6;
    --code-comment: #696c77;
    --code-keyword: #a626a4;
    --code-string: #40803f;
    --code-number: #c05000;
    --code-type: #8a6a00;
    --code-function: #2d6af1;
    --code-macro: #017baf;
    --code-variable: #da3020;
    color-scheme: light;
}
:root {
    --display: Space, Arial, sans-serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: Plex, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --shadow: rgba(0, 0, 0, .33);
    --scrim: rgba(0, 0, 0, .45);
    /* The front page's dark red bands, the same in both themes. */
    --band-bg: #3b1d20;
    --band-panel: #2d1517;
    --band-fg: #f8f1f0;
    --band-muted: #cbbcba;
    --band-line: #5c3a3d;
    --band-accent: #ffb0ab;
    --band-accent-solid: #ff8f8a;
    --band-accent-text: #1a0f0f;
    --band-subtle: #4a2629;
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --header-height: 60px;
    --layout-max: 1328px;
    --layout-pad: 56px;
    scroll-padding-top: calc(var(--header-height) + 20px);
}
@media (max-width: 1150px) { :root { --layout-pad: 32px; } }
@media (max-width: 720px) { :root { --layout-pad: 20px; } }

::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* -- Header ----------------------------------------------------------------- */

.site-header {
    position: sticky; top: 0; z-index: 120;
    background: var(--header); backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    font-family: var(--display); font-size: 15px; line-height: 1.6;
}
.site-header a { color: inherit; text-decoration: none; transition: color .18s, background .18s, border-color .18s; }
.site-header a:hover { color: var(--accent); }
.site-header button, .site-header summary { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.site-header .nav-inner {
    width: calc(100% - 2 * var(--layout-pad)); max-width: var(--layout-max); margin: auto;
    height: var(--header-height); display: flex; align-items: center; gap: 36px;
}

/* The logo is inline SVG in the theme's colours: a tile, a dot and two pairs of waves. */
.site-header .wordmark { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; font-size: 22px; font-weight: 600; letter-spacing: -.04em; color: var(--fg); }
.site-header .wordmark:hover { color: var(--fg); }
.site-header .wordmark em { font-style: normal; color: var(--accent); }
.site-logo { display: block; width: 32px; height: 32px; color: var(--accent); }
.site-logo .tile { fill: var(--logo-tile); }

/* The tabs: one link per section. `site build` marks the current one. */
.site-header .site-tabs { display: flex; align-self: stretch; gap: 26px; font-size: 14px; color: var(--muted); }
.site-header .site-tabs .tab { display: flex; align-items: center; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.site-header .site-tabs .tab[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

.site-header .nav-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.site-header .icon-button { padding: 5px; display: flex; align-items: center; justify-content: center; min-width: 28px; height: 32px; color: var(--muted); }
.site-header .icon-button:hover { color: var(--accent); }
.site-header .nav-cta {
    display: inline-flex; align-items: center; margin-left: 6px; padding: 7px 14px;
    border: 1px solid var(--fg); border-radius: var(--radius); background: var(--fg); color: var(--bg);
    font-size: 12px; line-height: 1.5; white-space: nowrap;
}
.site-header .nav-cta:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.site-header .theme-toggle > span { line-height: 0; }
.site-header .theme-light { display: none; }
[data-theme="light"] .site-header .theme-dark { display: none; }
[data-theme="light"] .site-header .theme-light { display: inline; }

.site-header .search-trigger {
    display: flex; align-items: center; gap: 10px; width: 240px; margin-right: 6px;
    padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--panel); color: var(--quiet); font-family: var(--sans); font-size: 13px; text-align: left;
}
.site-header .search-trigger:hover { border-color: var(--accent); color: var(--fg); }
.site-header .search-trigger kbd { margin-left: auto; padding: 0 5px; border: 1px solid var(--line); border-radius: 3px; background: none; box-shadow: none; color: inherit; font: 11px var(--mono); }

.site-header .docs-menu, .site-header .mobile-nav { display: none; }
.site-header details { position: relative; }
.site-header summary { list-style: none; }
.site-header summary::-webkit-details-marker { display: none; }
.site-header .nav-menu {
    position: absolute; top: calc(100% + 12px); right: 0; min-width: 200px; padding: 8px;
    display: flex; flex-direction: column;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 12px 40px var(--shadow);
}
.site-header .nav-menu a { padding: 9px 12px; font-size: 14px; }
.site-header .nav-menu a:hover { background: var(--subtle); }
.site-header .nav-menu a[aria-current="page"] { color: var(--accent); }

@media (max-width: 1150px) {
    .site-header .nav-inner { gap: 24px; }
    .site-header .search-trigger { width: 180px; }
}
@media (max-width: 1079px) {
    .site-header .docs-menu { display: flex; }
}
@media (max-width: 820px) {
    .site-header .nav-inner { gap: 14px; }
    .site-header .site-tabs, .site-header .github-link { display: none; }
    .site-header .mobile-nav { display: block; }
    .site-header .search-trigger { width: auto; margin: 0; padding: 6px; border: 0; background: none; }
    .site-header .search-trigger span, .site-header .search-trigger kbd { display: none; }
    .site-header .nav-actions { gap: 4px; }
}
@media (max-width: 420px) {
    .site-header .nav-cta { display: none; }
}
@media print {
    .site-header { display: none; }
}

/* -- Syntax ----------------------------------------------------------------- */

/* `site build` highlights every code block and gives each token one of
   these classes (see tool/src/highlight.rs). */
.sx-comment { color: var(--code-comment); font-style: italic; }
.sx-keyword { color: var(--code-keyword); }
.sx-string { color: var(--code-string); }
.sx-number { color: var(--code-number); }
.sx-type { color: var(--code-type); }
.sx-function { color: var(--code-function); }
.sx-macro { color: var(--code-macro); }
.sx-property { color: var(--code-variable); }
