/* fp.mojo documentation theme: one stylesheet, two colour schemes. */

/* ---------------------------------------------------------------- tokens */

:root, :root.light {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --fg: #262a3d;
  --fg-muted: #626a85;
  --border: #e3e6ef;
  --accent: #4655d4;
  --accent-soft: #eceeff;
  --header-bg: rgba(255, 255, 255, .88);
  --code-bg: #f8f8fc;
  --inline-bg: #f0f1f7;
  --inline-fg: #343a5c;
  --shadow: 0 1px 2px rgba(30, 35, 60, .06), 0 6px 24px rgba(30, 35, 60, .06);

  /* Syntax: Catppuccin Latte hues, deepened for contrast on a light page. */
  --syn-keyword: #8839ef;
  --syn-type: #b45f06;
  --syn-function: #1e66f5;
  --syn-module: #0e8a8a;
  --syn-string: #2e8b1e;
  --syn-docstring: #4f8a3c;
  --syn-number: #e14d00;
  --syn-constant: #e14d00;
  --syn-decorator: #d02f8f;
  --syn-self: #d20f39;
  --syn-operator: #0a7fb5;
  --syn-comment: #8c8fa1;
  --syn-punctuation: #6c6f85;
}

:root.dark {
  color-scheme: dark;
  --bg: #14161f;
  --bg-soft: #1a1d29;
  --fg: #e2e5f0;
  --fg-muted: #9aa2bc;
  --border: #2a2f41;
  --accent: #8d9cff;
  --accent-soft: #232945;
  --header-bg: rgba(20, 22, 31, .88);
  --code-bg: #0f1118;
  --inline-bg: #232838;
  --inline-fg: #dfe3f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);

  /* Syntax: Catppuccin Mocha. */
  --syn-keyword: #cba6f7;
  --syn-type: #f9e2af;
  --syn-function: #89b4fa;
  --syn-module: #94e2d5;
  --syn-string: #a6e3a1;
  --syn-docstring: #8fcf8a;
  --syn-number: #fab387;
  --syn-constant: #fab387;
  --syn-decorator: #f5c2e7;
  --syn-self: #f38ba8;
  --syn-operator: #89dceb;
  --syn-comment: #7f849c;
  --syn-punctuation: #9399b2;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15.5px/1.7 'Open Sans', system-ui, sans-serif; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: var(--bg); padding: 12px; }
.skip-link:focus { top: 8px; }

/* ---------------------------------------------------------------- header */

.menu-bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 28px; background: var(--header-bg); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.menu-bar .brand { color: var(--fg); font: 700 22px 'Source Code Pro', monospace; letter-spacing: -.6px; text-decoration: none; }
.brand-dot { color: var(--accent); }
.version {
  font: 600 12px 'Source Code Pro', monospace; color: var(--accent); background: var(--accent-soft);
  padding: 2px 9px; border-radius: 999px; text-decoration: none;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search-link { color: var(--fg-muted); font-size: 14px; text-decoration: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; margin-right: 8px; }
.search-link:hover { color: var(--fg); border-color: var(--accent); }
kbd { font: 11px 'Source Code Pro', monospace; border: 1px solid var(--border); padding: 0 5px; border-radius: 4px; margin-left: 6px; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px;
  border: 0; border-radius: 8px; background: transparent; color: var(--fg-muted); cursor: pointer; font-size: 20px;
}
.icon-button:hover { color: var(--fg); background: var(--bg-soft); }

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

.site-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr) 220px; max-width: 1560px; margin: 0 auto; }
.content { min-width: 0; }
.content main { padding: 44px 56px 64px; max-width: 980px; }

/* ---------------------------------------------------------------- sidebar */

.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 28px 18px 28px 28px; }
.sidebar details { margin: 18px 0 6px; }
.sidebar summary {
  list-style: none; cursor: pointer; padding: 4px 8px; color: var(--fg-muted);
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: '›'; float: right; transition: transform .15s; }
.sidebar details[open] summary::after { transform: rotate(90deg); }
.sidebar ul { list-style: none; margin: 4px 0 0; padding: 0; }
.sidebar a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--fg); font-size: 13.5px; line-height: 1.45; text-decoration: none; }
.sidebar a:hover { background: var(--bg-soft); }
.sidebar a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sidebar .top-link { font-weight: 600; }
.sidebar .nav-note { border-top: 1px solid var(--border); margin-top: 28px; padding: 18px 10px 0; font-size: 11.5px; color: var(--fg-muted); }

/* ---------------------------------------------------------------- page table of contents */

.page-toc { position: sticky; top: 84px; height: fit-content; max-height: calc(100vh - 108px); overflow-y: auto; padding: 0 20px 0 8px; margin-top: 44px; font-size: 12px; }
.page-toc strong { display: block; margin-bottom: 8px; color: var(--fg-muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.page-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.page-toc ul ul { border-left: 0; padding-left: 10px; }
.page-toc a { display: block; padding: 4px 12px; color: var(--fg-muted); text-decoration: none; }
.page-toc a:hover { color: var(--accent); }
.page-toc ul ul a { padding: 2px 12px; font-family: 'Source Code Pro', monospace; }

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

.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 700; margin-bottom: 14px; }
h1 { font-size: 36px; line-height: 1.2; letter-spacing: -.8px; font-weight: 700; margin: 0 0 18px; }
h2 { font-size: 24px; line-height: 1.35; letter-spacing: -.3px; font-weight: 700; margin: 2.2em 0 .7em; }
h3 { font-size: 18px; font-weight: 700; margin: 1.8em 0 .6em; }
h4 { font-size: 15.5px; font-weight: 700; }
/* Prose keeps a comfortable line length; code and tables use the full column. */
main > p, main > ul, main > ol, main > dl, main > h2, main > h3, main > h4, main > blockquote { max-width: 74ch; }
p, li { overflow-wrap: anywhere; }
.headerlink { margin-left: .4em; opacity: 0; color: var(--fg-muted); text-decoration: none; }
*:hover > .headerlink, .headerlink:focus { opacity: .7; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }

/* ---------------------------------------------------------------- inline code */

code { font-family: 'Source Code Pro', monospace; font-size: .86em; }
:not(pre) > code { background: var(--inline-bg); color: var(--inline-fg); padding: .12em .38em; border-radius: 5px; }
a > code { color: inherit; }
td a { text-decoration: none; }
td a > code { background: transparent; padding: 0; font-weight: 600; color: var(--accent); }

/* ---------------------------------------------------------------- code blocks */

pre { margin: 0; overflow-x: auto; }
.codehilite { margin: 20px 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; }
.codehilite pre { padding: 18px 20px; line-height: 1.65; font-size: 13px; }
.codehilite pre code { font-size: 13px; }
.code-container { position: relative; }
.copy-code {
  position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg-muted); padding: 3px 9px;
  border-radius: 6px; font-size: 11px; cursor: pointer;
}
.code-container:hover .copy-code, .copy-code:focus { opacity: 1; }

/* A complete example: file bar, code, run command and output form one unit. */
.example { margin: 24px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); box-shadow: var(--shadow); }
.example .codehilite { margin: 0; border: 0; border-radius: 0; }
.example-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 8px 18px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.example-file { font: 600 12.5px 'Source Code Pro', monospace; color: var(--fg-muted); }
.example-file::before { content: '●  ●  ●'; margin-right: 14px; letter-spacing: -1px; color: var(--border); }
.example-download { font-size: 12.5px; font-weight: 600; text-decoration: none; padding: 3px 10px; border-radius: 6px; }
.example-download:hover { background: var(--accent-soft); }
.example-run, .example-output { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 10px 18px; font-size: 13px; }
.example-run p { margin: 0; }
.example-run code { background: transparent; padding: 0; }
.example-label { display: inline-block; margin-right: 10px; color: var(--fg-muted); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.example-output .codehilite { background: transparent; }
.example-output > p { margin: 0; }
.example-output .codehilite pre { padding: 0 0 2px; }

/* ---------------------------------------------------------------- syntax highlighting (Pygments classes) */

.codehilite { color: var(--fg); }
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kr, .codehilite .ow { color: var(--syn-keyword); font-weight: 600; }
.codehilite .kc { color: var(--syn-constant); font-weight: 600; }
.codehilite .kt, .codehilite .nb, .codehilite .nc { color: var(--syn-type); }
.codehilite .nf, .codehilite .fm { color: var(--syn-function); }
.codehilite .nn { color: var(--syn-module); }
.codehilite .nd { color: var(--syn-decorator); }
.codehilite .bp { color: var(--syn-self); font-style: italic; }
.codehilite .ne { color: var(--syn-self); }
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sa, .codehilite .sb, .codehilite .sc, .codehilite .sh, .codehilite .sx { color: var(--syn-string); }
.codehilite .sd { color: var(--syn-docstring); font-style: italic; }
.codehilite .se, .codehilite .si { color: var(--syn-number); }
.codehilite .m, .codehilite .mi, .codehilite .mf, .codehilite .mh, .codehilite .mo, .codehilite .il { color: var(--syn-number); }
.codehilite .o { color: var(--syn-operator); }
.codehilite .p { color: var(--syn-punctuation); }
.codehilite .c, .codehilite .c1, .codehilite .ch, .codehilite .cm, .codehilite .cs, .codehilite .cp { color: var(--syn-comment); font-style: italic; }
.codehilite .err { color: inherit; border: 0; background: none; }
.codehilite .gp { color: var(--syn-comment); user-select: none; }

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

table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 20px 0; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { color: var(--fg-muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-bottom-width: 2px; }
tbody tr:hover { background: var(--bg-soft); }

/* ---------------------------------------------------------------- admonitions and API entries */

.admonition { margin: 24px 0; padding: 12px 18px; border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 8px; }
.admonition-title { font-weight: 700; margin: 0 0 4px; }
.admonition > p:last-child { margin-bottom: 0; }
.api-name { font-family: 'Source Code Pro', monospace; font-weight: 700; letter-spacing: 0; }
h3.api-name { font-size: 19px; margin-top: 2.6em; padding-top: 1.3em; border-top: 1px solid var(--border); }
h4.api-name { font-size: 15.5px; margin-top: 2.2em; }
.api-signature .codehilite { border-left: 4px solid var(--accent); }
.api-signature pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.api-overloads { margin: 0 0 24px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; }
.api-overloads summary { cursor: pointer; font-weight: 600; color: var(--fg-muted); }
.api-overloads pre { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; padding: 10px 12px; background: var(--code-bg); border-radius: 6px; font: 12.5px/1.6 'Source Code Pro', monospace; }
.api-overloads p { margin: 12px 0 0; }

/* ---------------------------------------------------------------- landing page */

.hero { margin: 8px 0 36px; }
.hero > p { font-size: 18px; line-height: 1.65; color: var(--fg-muted); max-width: 68ch; }
.hero .codehilite { display: inline-block; margin: 6px 0 22px; max-width: 100%; }
.hero .codehilite pre { padding: 12px 18px; font-size: 14px; }
.hero-actions, .hero-actions p { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.button {
  display: inline-block; padding: 9px 18px; border: 1px solid var(--border); border-radius: 9px;
  color: var(--fg); font-weight: 600; font-size: 14.5px; text-decoration: none; background: var(--bg);
}
.button:hover { border-color: var(--accent); color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root.dark .button.primary { color: #12142a; }
.button.primary:hover { filter: brightness(1.08); color: #fff; }
:root.dark .button.primary:hover { color: #12142a; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 8px 0 40px; }
.card { position: relative; padding: 18px 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card p { margin: 0; font-size: 14px; color: var(--fg-muted); }
.card p:first-child { margin-bottom: 6px; font-size: 16px; color: var(--fg); }
.card a { text-decoration: none; color: var(--fg); font-weight: 700; }
.card a::after { content: ''; position: absolute; inset: 0; }  /* the whole card is the link */

/* ---------------------------------------------------------------- page footer */

.page-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; }
.page-nav a { flex: 0 1 48%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-weight: 600; text-decoration: none; }
.page-nav a:hover { border-color: var(--accent); }
.page-nav a:last-child { text-align: right; }
.page-nav small { display: block; color: var(--fg-muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--fg-muted); font-size: 12px; }

/* ---------------------------------------------------------------- search page */

#search-query { width: 100%; padding: 12px 16px; margin: 8px 0 16px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 10px; }
#search-query:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
#search-results article { border-bottom: 1px solid var(--border); padding: 10px 0; }
#search-results h2 { font-size: 17px; margin: 0 0 4px; }

/* ---------------------------------------------------------------- responsive and print */

.mobile-only { display: none; }
@media (max-width: 1200px) {
  .site-layout { grid-template-columns: 248px minmax(0, 1fr); }
  .page-toc { display: none; }
  .content main { padding: 40px 36px 56px; }
}
@media (max-width: 900px) { .cards { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .menu-bar { padding: 0 10px; gap: 8px; }
  .version, .search-link kbd { display: none; }
  .search-link { margin-right: 0; }
  .site-layout { display: block; }
  .sidebar { display: none; }
  .nav-open .sidebar { display: block; position: fixed; top: 60px; left: 0; width: min(320px, 88vw); z-index: 9; background: var(--bg); box-shadow: 0 0 0 100vmax #0006; }
  .content main { padding: 26px 18px 40px; }
  h1 { font-size: 28px; } h2 { font-size: 21px; }
  .hero .codehilite { min-width: 0; display: block; }
  .page-nav { flex-direction: column; } .page-nav a { flex-basis: auto; }
}
@media print {
  .menu-bar, .sidebar, .page-toc, .page-nav, .copy-code, .example-download { display: none; }
  .site-layout { display: block; } .content main { padding: 0; max-width: none; }
  pre { white-space: pre-wrap; } .example { box-shadow: none; }
}
