/* ---------- Design tokens (brand palette) ---------- */
:root {
  --fq-navy: #003858;
  --fq-steel: #487088;
  --fq-orange: #f06818;
  --fq-steel-reversed: #7fa0b4;

  --fq-header-h: 75px;
  --fq-sidebar-w: 300px;
  --fq-pagetoc-w: 300px;
  --fq-radius: 10px;
  --fq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fq-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Light theme (default) */
html[data-theme="light"] {
  color-scheme: light;
  --fq-bg: #ffffff;
  --fq-bg-soft: #eef1f3;
  --fq-bg-code: #f4f6f7;
  --fq-fg: #1c2b34;
  --fq-fg-muted: #5b6b76;
  --fq-border: #dbe2e7;
  --fq-link: var(--fq-navy);
  --fq-accent: var(--fq-orange);
  --fq-header-bg: #ffffff;
  --fq-logo-light: block;
  --fq-logo-dark: none;
}

/* Dark theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --fq-bg: #0d1b24;
  --fq-bg-soft: #12242f;
  --fq-bg-code: #0a151c;
  --fq-fg: #e6eef3;
  --fq-fg-muted: #9fb4c1;
  --fq-border: #1f3745;
  --fq-link: var(--fq-steel-reversed);
  --fq-accent: var(--fq-orange);
  --fq-header-bg: #0a151c;
  --fq-logo-light: none;
  --fq-logo-dark: block;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--fq-header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--fq-font);
  background: var(--fq-bg);
  color: var(--fq-fg);
  line-height: 1.65;
}
a { color: var(--fq-link); text-decoration: none; }
a:hover { text-decoration: underline; }

.fq-skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--fq-navy); color: #fff; padding: 8px 14px;
}
.fq-skip:focus { left: 8px; top: 8px; }

/* ---------- Header ---------- */
.fq-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--fq-header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--fq-header-bg);
  border-bottom: 1px solid var(--fq-border);
}
.fq-brand { display: flex; align-items: center; gap: 10px; }
.fq-brand:hover { text-decoration: none; }
.fq-logo { height: 34px; width: auto; }
.fq-brand .fq-logo { height: 60px; width: auto; }
.fq-logo--light { display: var(--fq-logo-light); }
.fq-logo--dark  { display: var(--fq-logo-dark); }
.fq-brand-name {
  font-weight: 700; font-size: 1.05rem; color: var(--fq-navy);
  letter-spacing: .01em;
}
html[data-theme="dark"] .fq-brand-name { color: var(--fq-fg); }

.fq-header-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.fq-header-link {
  font-size: .9rem; font-weight: 600; color: var(--fq-fg-muted);
  padding: 6px 10px; border-radius: var(--fq-radius);
}
.fq-header-link:hover { color: var(--fq-accent); text-decoration: none; }

.fq-icon-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: transparent;
  color: var(--fq-fg-muted); border-radius: var(--fq-radius); cursor: pointer;
}
.fq-icon-link:hover { color: var(--fq-accent); background: var(--fq-bg-soft); }

.fq-theme-toggle .fq-icon-moon { display: none; }
html[data-theme="dark"] .fq-theme-toggle .fq-icon-sun { display: none; }
html[data-theme="dark"] .fq-theme-toggle .fq-icon-moon { display: block; }

/* Version switcher */
.fq-version-switcher { position: relative; }
.fq-version-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--fq-fg-muted); background: var(--fq-bg-soft);
  border: 1px solid var(--fq-border); border-radius: var(--fq-radius); cursor: pointer;
}
.fq-version-btn:hover { color: var(--fq-accent); border-color: var(--fq-accent); }
.fq-version-caret { transition: transform .15s ease; }
.fq-version-btn[aria-expanded="true"] .fq-version-caret { transform: rotate(180deg); }
.fq-version-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  min-width: 170px; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none;
  background: var(--fq-bg); border: 1px solid var(--fq-border);
  border-radius: var(--fq-radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.fq-version-menu[hidden] { display: none; }
.fq-version-menu li { margin: 0; }
.fq-version-menu a {
  display: block; padding: 7px 10px; border-radius: 7px;
  font-size: .85rem; color: var(--fq-fg); text-decoration: none;
}
.fq-version-menu a:hover { background: var(--fq-bg-soft); color: var(--fq-accent); text-decoration: none; }
.fq-version-menu .fq-version-active a { color: var(--fq-accent); font-weight: 700; }

.fq-nav-toggle {
  display: none; flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px;
}
.fq-nav-toggle span { width: 22px; height: 2px; background: var(--fq-fg); }

/* ---------- Layout shell ---------- */
.fq-shell {
  display: grid;
  grid-template-columns: var(--fq-sidebar-w) minmax(0, 1fr) var(--fq-pagetoc-w);
  max-width: 1500px; margin: 0 auto;
}

/* ---------- Sidebars ---------- */
.fq-sidebar, .fq-pagetoc {
  position: sticky; top: var(--fq-header-h);
  height: calc(100vh - var(--fq-header-h));
  overflow-y: auto;
}
.fq-sidebar { border-right: 1px solid var(--fq-border); }
.fq-sidebar-inner { padding: 22px 16px; }
.fq-package-logo .fq-logo {
  height: auto; width: 80%; max-width: 80%; margin: auto; margin-bottom: 30px; margin-top: 30px;
}
.fq-sidebar-repo {
  display: inline-block; font-size: .82rem; font-weight: 600;
  color: var(--fq-fg-muted); margin-bottom: 14px;
}
.fq-toctree ul { list-style: none; margin: 0; padding-left: 12px; }
.fq-toctree > ul { padding-left: 0; }
.fq-toctree li { margin: 2px 0; }
.fq-toctree a {
  display: block; padding: 4px 10px; border-radius: 7px;
  color: var(--fq-fg-muted); font-size: .9rem;
  overflow-wrap: anywhere;
}
.fq-toctree a:hover { background: var(--fq-bg-soft); color: var(--fq-fg); text-decoration: none; }
.fq-toctree .current > a {
  color: var(--fq-accent); font-weight: 600;
  border-left: 2px solid var(--fq-accent); padding-left: 8px;
}
.fq-toctree .caption {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--fq-fg-muted); margin: 16px 0 6px; font-weight: 700;
}

/* Collapsible sections. Sub-lists are hidden once JS marks their parent as
   having children, so without JS the full tree stays visible (graceful). */
.fq-toctree li { position: relative; }
.fq-toctree li.fq-has-children > ul { display: none; }
.fq-toctree li.fq-has-children.fq-expanded > ul { display: block; }
.fq-toctree li.fq-has-children > a { padding-right: 30px; }
.fq-toc-toggle {
  position: absolute; top: 2px; right: 2px;
  width: 24px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; cursor: pointer;
  color: var(--fq-fg-muted); border-radius: 6px;
}
.fq-toc-toggle:hover { background: var(--fq-bg-soft); color: var(--fq-accent); }
.fq-toc-toggle:focus-visible { outline: 2px solid var(--fq-accent); outline-offset: 1px; }
.fq-toc-toggle::before {
  content: ""; width: 6px; height: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s ease;
}
.fq-toctree li.fq-expanded > .fq-toc-toggle::before { transform: rotate(45deg); }

.fq-pagetoc-inner { padding: 22px 16px; }
.fq-pagetoc-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--fq-fg-muted); font-weight: 700; margin: 0 0 8px;
}
.fq-pagetoc ul { list-style: none; margin: 0; padding-left: 12px; }
.fq-pagetoc > .fq-pagetoc-inner > ul { padding-left: 0; }
.fq-pagetoc a { color: var(--fq-fg-muted); font-size: .85rem; display: block; padding: 3px 0; overflow-wrap: anywhere; }
.fq-pagetoc a:hover { color: var(--fq-accent); text-decoration: none; }
.fq-pagetoc a.fq-active { color: var(--fq-accent); font-weight: 600; }

/* ---------- Content ---------- */
.fq-content { min-width: 0; padding: 36px 44px 60px; }
.fq-article { max-width: 820px; }
.fq-article h1, .fq-article h2, .fq-article h3,
.fq-article h4 { color: var(--fq-navy); line-height: 1.25; }
html[data-theme="dark"] .fq-article h1,
html[data-theme="dark"] .fq-article h2,
html[data-theme="dark"] .fq-article h3,
html[data-theme="dark"] .fq-article h4 { color: var(--fq-fg); }
.fq-article h1 { border-bottom: 2px solid var(--fq-border); padding-bottom: .3em; }

/* Code */
code, pre { font-family: var(--fq-mono); }
code.literal, .fq-article :not(pre) > code {
  background: var(--fq-bg-code); padding: .15em .4em;
  border-radius: 5px; font-size: .88em; color: var(--fq-navy);
}
html[data-theme="dark"] .fq-article :not(pre) > code { color: var(--fq-steel-reversed); }
div.highlight, pre {
  background: var(--fq-bg-code); border: 1px solid var(--fq-border);
  border-radius: var(--fq-radius); padding: 14px 16px; overflow-x: auto;
}

/* Admonitions */
.admonition {
  border: 1px solid var(--fq-border); border-left: 4px solid var(--fq-steel);
  border-radius: var(--fq-radius); padding: 12px 16px; margin: 18px 0;
  background: var(--fq-bg-soft);
}
.admonition.warning, .admonition.caution { border-left-color: var(--fq-orange); }
.admonition-title { font-weight: 700; margin: 0 0 6px; }

/* Tables */
table.docutils {
  border-collapse: collapse; width: 100%; margin: 18px 0;
}
table.docutils th, table.docutils td {
  border: 1px solid var(--fq-border); padding: 8px 12px; text-align: left;
}
table.docutils th { background: var(--fq-bg-soft); }

/* ---------- Footer ---------- */
.fq-footer {
  margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--fq-border);
  font-size: .82rem; color: var(--fq-fg-muted);
}
.fq-footer-flaqship-logo {
  margin-bottom: 30px;
}
.fq-footer-flaqship-logo .fq-logo {
  height: 180px; width: auto;
}
.fq-footer-links { display: flex; gap: 18px; margin-bottom: 8px; }
.fq-footer-meta { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Search ---------- */
.fq-search { display: flex; gap: 8px; margin: 20px 0; }
.fq-search input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--fq-border);
  border-radius: var(--fq-radius); background: var(--fq-bg); color: var(--fq-fg);
}
.fq-search button {
  padding: 10px 18px; border: none; border-radius: var(--fq-radius);
  background: var(--fq-orange); color: #fff; font-weight: 600; cursor: pointer;
}

/* ---------- Responsive ---------- */
.fq-sidebar-backdrop { display: none; }

@media (max-width: 1200px) {
  .fq-shell { grid-template-columns: var(--fq-sidebar-w) minmax(0, 1fr); }
  .fq-pagetoc { display: none; }
}
@media (max-width: 900px) {
  .fq-shell { grid-template-columns: minmax(0, 1fr); }
  .fq-nav-toggle { display: flex; }
  .fq-sidebar {
    position: fixed; top: var(--fq-header-h); left: 0; z-index: 45;
    width: var(--fq-sidebar-w); background: var(--fq-bg);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .fq-sidebar.fq-open { transform: translateX(0); }
  .fq-sidebar-backdrop.fq-open {
    display: block; position: fixed; inset: var(--fq-header-h) 0 0 0;
    background: rgba(0,0,0,.4); z-index: 44;
  }
  .fq-content { padding: 24px 20px 48px; }
}

/* Dark-mode syntax highlight tweaks (Pygments 'friendly' is light-oriented) */
html[data-theme="dark"] .highlight { color: #e6eef3; }
html[data-theme="dark"] .highlight .k,
html[data-theme="dark"] .highlight .kn,
html[data-theme="dark"] .highlight .kd { color: #7fa0b4; }
html[data-theme="dark"] .highlight .s,
html[data-theme="dark"] .highlight .s1,
html[data-theme="dark"] .highlight .s2 { color: #f0a878; }
html[data-theme="dark"] .highlight .c,
html[data-theme="dark"] .highlight .c1 { color: #607785; font-style: italic; }
html[data-theme="dark"] .highlight .nf,
html[data-theme="dark"] .highlight .nc { color: #d8e4ec; }
html[data-theme="dark"] .highlight .mi,
html[data-theme="dark"] .highlight .mf { color: #f06818; }

/* ---------- API reference (Python domain) ---------- */
dl.py { margin: 0 0 26px; }

/* Signature line — a class / method / function / attribute / property definition.
   Styled as a prominent header band so each API object reads like a section title. */
dl.py > dt.sig {
  font-family: var(--fq-mono);
  font-size: .95rem;
  line-height: 1.5;
  color: var(--fq-fg);
  background: var(--fq-bg-code);
  border: 1px solid var(--fq-border);
  border-left: 4px solid var(--fq-accent);
  border-radius: var(--fq-radius);
  padding: 13px 16px;
  overflow-x: auto;
  scroll-margin-top: calc(var(--fq-header-h) + 12px);
}

/* Nested members (methods/properties inside a class) — steel accent, softer bg */
dl.py dl.py > dt.sig {
  border-left-color: var(--fq-steel);
  background: var(--fq-bg-soft);
}

/* The object's own name — sized and weighted like a heading so it stands out */
dl.py > dt.sig .sig-name.descname {
  color: var(--fq-navy);
  font-weight: 700;
  font-size: 1.22em;
  letter-spacing: -.01em;
}
html[data-theme="dark"] dl.py > dt.sig .sig-name.descname { color: var(--fq-steel-reversed); }
/* Nested members read a touch smaller than the top-level class header */
dl.py dl.py > dt.sig .sig-name.descname { font-size: 1.1em; }

/* Dotted qualifier prefix (module.Class.) — muted */
dl.py > dt.sig .sig-prename.descclassname {
  color: var(--fq-fg-muted);
  font-weight: 400;
}

/* Leading keyword (class / property / classmethod / static / async) — accent */
dl.py > dt.sig .property { color: var(--fq-fg-muted); font-style: normal; font-weight: 400; }
dl.py > dt.sig .property .k { color: var(--fq-accent); font-weight: 600; }

/* Parameters (Sphinx italicises them by default) and their default values */
dl.py > dt.sig .sig-param { font-style: normal; }
dl.py > dt.sig .default_value { color: var(--fq-steel); }
html[data-theme="dark"] dl.py > dt.sig .default_value { color: #f0a878; }
dl.py > dt.sig .sig-paren,
dl.py > dt.sig .o,
dl.py > dt.sig .p { color: var(--fq-fg-muted); }

/* [source] link */
dl.py > dt.sig .viewcode-link { font-size: .78rem; font-weight: 600; color: var(--fq-fg-muted); }

/* Permalink ¶ — reveal on hover */
dl.py > dt.sig .headerlink {
  visibility: hidden; margin-left: 8px;
  color: var(--fq-accent); text-decoration: none;
}
dl.py > dt.sig:hover .headerlink { visibility: visible; }

/* Description body + nested members, indented under the signature */
dl.py > dd {
  margin: 0 0 0 3px;
  padding: 12px 0 2px 18px;
  border-left: 1px solid var(--fq-border);
}

/* Field lists — Parameters / Returns / Return type / Raises */
dl.field-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 18px;
  margin: 16px 0;
}
dl.field-list > dt {
  grid-column: 1; margin: 0;
  font-weight: 700; color: var(--fq-navy);
}
html[data-theme="dark"] dl.field-list > dt { color: var(--fq-steel-reversed); }
dl.field-list > dd { grid-column: 2; margin: 0; padding: 0; }
dl.field-list > dd > ul { margin: 0; padding-left: 18px; }
dl.field-list > dd p { margin: 0 0 6px; }
dl.field-list dd strong { color: var(--fq-fg); font-weight: 600; }

/* API entries in the nav sidebars are rendered as inline code (class/method
   names). Let them inherit the link colour instead of the dark code colour,
   and drop the code-box so they read like normal navigation text. */
.fq-toctree a code,
.fq-pagetoc a code,
.fq-toctree code.literal,
.fq-pagetoc code.literal {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: .92em;
}
