/*
 * saggar book theme — the chrome layer over alabaster.
 *
 * theme.conf carries the dark values (the product's default mode) and
 * the pygments style; this file adds the app shell — the fixed rail,
 * the brand block, the nav — and restyles the content components to
 * the UI's vocabulary: wells for code, tags for inline code, the
 * .note pattern for admonitions, the app's table treatment.
 *
 * Every value comes from saggar-ui/app/assets/css/main.css (:root,
 * the dark token set). The book ships dark-only: alabaster generates
 * one static stylesheet from theme.conf and Sphinx one pygments
 * stylesheet per build, so a light mode would need a drifting
 * override layer or a stylesheet switch the theme cannot carry.
 */

:root {
  color-scheme: dark;

  /* ground / surfaces */
  --ground: #141312;
  --surface: #1d1c1b;
  --elevated: #252422;
  --sunken: #0f0e0d;
  --border: #302e2c;
  --border-strong: #46433f;

  /* text */
  --text: #f3f2f2;
  --text-2: #c1bdb9;
  --text-3: #9c958b;

  /* brand */
  --patina: #2f8074;
  --patina-text: #4fa595;
  --ember-text: #f0774a;

  /* status tones admonitions borrow */
  --st-warn: #e0a33e;
  --st-fail: #ff7073;

  --radius: 8px;
  --radius-sm: 5px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar: 224px;
}

/* ---------- shell: rail + content, like .app/.sidebar/.page ---------- */

div.document {
  width: auto;
  margin: 0;
}

div.sphinxsidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar);
  max-height: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 10;
}

div.sphinxsidebarwrapper {
  padding: 14px 12px;
  font-size: 13.5px;
  line-height: 1.5;
}

div.bodywrapper {
  margin-left: var(--sidebar);
}

div.body {
  max-width: 47rem;
  padding: 2.4rem 2.8rem 4rem;
  box-sizing: border-box;
  color: var(--text-2);
  line-height: 1.65;
}

div.footer {
  width: auto;
  margin: 0 0 0 var(--sidebar);
  padding: 1rem 2.8rem 2rem;
  text-align: left;
  color: var(--text-3);
  font-size: 0.8rem;
}

div.footer a {
  color: var(--text-3);
  text-decoration: none;
  border-bottom: none;
}

div.footer a:hover {
  color: var(--text-2);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--patina);
  outline-offset: -2px;
}

/* ---------- brand block: the app's .brand ---------- */

.saggar-brand {
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--border);
}

.saggar-brand-link {
  display: flex;
  align-items: center;
  gap: 9px;
}

.saggar-mark {
  display: block;
  flex: none;
}

.saggar-wordmark {
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.02em;
  color: var(--text);
}

.saggar-tagline {
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
}

/* alabaster colors every sidebar p at (0,1,2); out-rank it */
div.sphinxsidebarwrapper .saggar-tagline {
  color: var(--text-3);
}

/* Interface chrome does not paint itself in the anchor color. The
   selectors carry div.sphinxsidebar because alabaster colors sidebar
   anchors at that specificity. */
div.sphinxsidebar .saggar-brand-link,
div.sphinxsidebar .saggar-brand-link:hover {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
  opacity: 1;
}

div.sphinxsidebar .saggar-brand-link:hover {
  opacity: 0.85;
}

/* ---------- sidebar sections: the app's .nav-cat ---------- */

div.sphinxsidebar h3 {
  margin: 14px 0 4px;
  padding: 0 9px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

div.sphinxsidebar h3 a {
  color: inherit;
  border-bottom: none;
}

/* toctree captions — the same quiet category label */
div.sphinxsidebarwrapper p.caption,
div.toctree-wrapper p.caption {
  margin: 14px 0 4px;
  padding: 0 9px;
  line-height: 1.5;
}

div.sphinxsidebarwrapper p.caption span.caption-text,
div.toctree-wrapper p.caption span.caption-text {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

/* ---------- sidebar nav: the app's .nav a ---------- */

div.sphinxsidebar ul {
  margin: 0;
  padding: 0;
}

div.sphinxsidebar ul li {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* alabaster sizes these at 120%/110% with a higher-specificity
   selector (div.sphinxsidebar ul li.toctree-l1 > a); match it to win */
div.sphinxsidebar ul li.toctree-l1 > a {
  display: block;
  margin: 1px 0;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border-bottom: none;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  text-decoration: none;
}

div.sphinxsidebar li.toctree-l1 > a:hover,
div.sphinxsidebar li.toctree-l1.current > a {
  background: var(--elevated);
  color: var(--text);
  text-decoration: none;
  border-bottom: none;
}

div.sphinxsidebar ul li.toctree-l1.current > a {
  font-weight: 600;
}

div.sphinxsidebar ul li.toctree-l2 > a {
  padding-left: 22px;
  font-size: 12.5px;
}

/* relations: prev/next under the nav, quieter */
div.relations {
  margin-top: 14px;
}

div.relations ul ul {
  margin: 4px 0 0;
}

div.relations li {
  margin: 1px 0;
}

div.relations a {
  display: block;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border-bottom: none;
  color: var(--text-3);
  font-size: 12.5px;
  text-decoration: none;
}

div.relations a:hover {
  background: var(--elevated);
  color: var(--text);
  text-decoration: none;
}

/* ---------- search: the app's input treatment ---------- */

/* the selectors carry div.sphinxsidebar because basic.css sizes the
   same inputs at that specificity; anything shorter loses the cascade */
div.sphinxsidebar #searchbox {
  margin: 4px 0 12px;
}

div.sphinxsidebar #searchbox form.search {
  overflow: hidden;
}

div.sphinxsidebar #searchbox input[type="text"] {
  float: none;
  width: 100%;
  padding: 7px 10px;
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--text);
  font-family: var(--font);
  font-size: 12.5px;
}

div.sphinxsidebar #searchbox input[type="text"]:focus {
  outline: none;
  border-color: var(--patina);
}

/* the field submits on Enter; the app has no button beside its inputs */
div.sphinxsidebar #searchbox input[type="submit"] {
  display: none;
}

/* ---------- body typography: the app's heading treatment ---------- */

div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
  color: var(--text);
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

div.body h1 {
  margin-top: 0;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
  font-size: 1.5em;
}

div.body h2 {
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  font-size: 1.25em;
}

div.body h3 {
  font-size: 1.05em;
}

div.body h4,
div.body h5,
div.body h6 {
  font-size: 0.95em;
}

/* weight 600 is the app's emphasis; bold copy must not vanish against
   --text-2 body copy */
div.body strong {
  color: var(--text);
}

/* alabaster pins p/li/dd line-height at 1.4em; restore the app's 1.5
   reading rhythm on the same selector */
div.body p,
div.body li,
div.body dd {
  line-height: 1.65;
  hyphens: auto;
}

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

/* ---------- links: the app's treatment — patina, underline on hover */

a {
  color: var(--patina-text);
}

a:hover {
  color: var(--patina-text);
  text-decoration: underline;
}

/* alabaster draws dotted reference borders; the app never does */
a.reference,
a.reference:hover,
a.reference.internal,
a.reference.external {
  border-bottom: none;
  text-decoration: none;
}

a.reference:hover,
a.reference.internal:hover,
a.reference.external:hover {
  text-decoration: underline;
}

a.headerlink {
  color: var(--border-strong);
}

a.headerlink:hover {
  color: var(--text-3);
  background: none;
}

/* ---------- code: the CommandBlock well and the .tag inline chip --- */

div.body pre {
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.55;
  overflow-x: auto;
  color: var(--text-2);
}

dl pre,
blockquote pre,
li pre {
  padding-left: 12px;
}

.highlight {
  background: none;
}

/* pygments.css hardcodes the style's own match highlight (#ffffcc for
   one-dark); key it to the app's border-strong instead */
.highlight .hll {
  background-color: var(--border-strong);
}

/* the outer .notranslate wrapper carries the block's breathing room;
   the inner pre is tightened by basic.css */
div.body div.notranslate {
  margin: 15px 0;
}

/* the console prompt: ember heat, never copied with the text
   (basic.css already strips it from selection) */
.highlight-console .gp,
.highlight-shell-session .gp {
  color: var(--ember-text);
  font-weight: 640;
}

/* output lines stay quiet next to typed commands */
.highlight-console .go,
.highlight-shell-session .go {
  color: var(--text-3);
}

/* inline code: the app's .tag — sunken chip with a hair border */
div.body tt,
div.body code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--text-2);
  font-size: 0.78em;
}

/* a code chip has no business inside a well */
div.body pre tt,
div.body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

div.body tt.xref,
div.body code.xref,
div.body a tt,
div.body a code {
  border-bottom: none;
}

/* a cross-reference chip reads in patina, like the link it is */
div.body a code,
div.body a tt {
  color: var(--patina-text);
}

/* the endpoint the browser jumped to, tinted like the app's .note */
div.body dt:target {
  background: color-mix(in srgb, var(--patina) 10%, var(--surface));
}

/* ---------- tables: the app's card-table treatment ----------------- */

div.body table.docutils {
  width: 100%;
  border: 1px solid var(--border);
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: none;
  font-size: 0.85em;
}

div.body table.docutils th,
div.body table.docutils td {
  border: none;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

div.body table.docutils thead th {
  padding: 9px 15px;
  background: var(--surface);
  color: var(--text-3);
  text-align: left;
  font-size: 0.8em;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

div.body table.docutils td {
  padding: 10px 15px;
}

div.body table.docutils tbody tr:last-child td {
  border-bottom: none;
}

div.body table.docutils td > p,
div.body table.docutils th > p {
  margin: 0;
}

/* definition lists carry the CLI/API reference: the term is the app's
   .strong, the description keeps body voice */
div.body dt {
  margin-top: 0.8em;
  color: var(--text);
  font-weight: 600;
}

div.body dl > dt:first-child {
  margin-top: 0;
}

div.body dd {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--border);
}

/* ---------- admonitions: the app's .note, tone on the left border -- */

div.admonition {
  margin: 15px 0;
  padding: 10px 13px;
  border: none;
  border-left: 3px solid var(--patina);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: color-mix(in srgb, var(--patina) 7%, var(--surface));
  color: var(--text-2);
}

div.admonition p.admonition-title {
  margin: 0 0 4px;
  font-size: 0.78em;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--patina-text);
}

div.admonition.warning,
div.admonition.caution,
div.admonition.attention,
div.admonition.warn {
  border-left-color: var(--st-warn);
  background: color-mix(in srgb, var(--st-warn) 7%, var(--surface));
}

div.admonition.warning p.admonition-title,
div.admonition.caution p.admonition-title,
div.admonition.attention p.admonition-title,
div.admonition.warn p.admonition-title {
  color: var(--st-warn);
}

div.admonition.danger,
div.admonition.error {
  border-left-color: var(--st-fail);
  background: color-mix(in srgb, var(--st-fail) 7%, var(--surface));
}

div.admonition.danger p.admonition-title,
div.admonition.error p.admonition-title {
  color: var(--st-fail);
}

div.topic {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- the in-body toctree: nav rows, not bullets -------------- */

div.toctree-wrapper ul {
  margin: 8px 0 16px;
  padding: 0;
}

div.toctree-wrapper ul li {
  margin: 0;
  padding: 0;
  list-style: none;
}

div.toctree-wrapper li.toctree-l1 > a {
  display: block;
  margin: 1px 0;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
}

div.toctree-wrapper li.toctree-l1 > a:hover {
  background: var(--elevated);
  color: var(--text);
  text-decoration: none;
}

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

ul.search li a {
  color: var(--patina-text);
}

ul.search li p.context {
  color: var(--text-3);
}

.highlighted {
  background: var(--elevated);
  color: var(--text);
  padding: 0 2px;
  border-radius: 3px;
}

/* ---------- narrow screens: the rail folds into a top block --------- */

@media screen and (max-width: 1100px) {
  div.sphinxsidebar {
    position: static;
    width: auto;
    max-height: none;
    margin: -20px -30px 20px -30px;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }

  div.sphinxsidebarwrapper {
    padding: 14px 12px 12px;
  }

  /* alabaster recolors these to base_bg for its dark narrow sidebar;
     on our dark ground that is dark-on-dark, so re-key them */
  div.sphinxsidebar h3,
  div.sphinxsidebar h3 a,
  div.sphinxsidebar p,
  div.sphinxsidebar p.caption span.caption-text {
    color: var(--text-3);
  }

  div.sphinxsidebar li.toctree-l1 > a {
    color: var(--text-2);
  }

  div.body {
    max-width: none;
    padding: 0 0 3rem;
  }

  div.footer {
    display: none;
  }
}
