/* Styles for the ReST roles registered by pyTooling.Documentation.Sphinx. */

/* Previously injected into every document by a 'raw:: html' block in each project's doc/prolog.inc. */

/* Every value a project might want to change is a custom property, so it can be overridden without replacing
   this file. Put a stylesheet of your own after this one - 'html_css_files' in conf.py is appended in order -
   and redefine what you need:

     :root {
       --pyTooling-color-red: #b00020;
     }

   A property is only read where it is used below, so redefining one changes exactly the role that uses it. */
:root {
  --pyTooling-color-red:    #c00;
  --pyTooling-color-green:  #093;
  --pyTooling-color-blue:   #06f;
  --pyTooling-color-purple: #90c;

  --pyTooling-xlarge-size:  x-large;

  --pyTooling-table-cell-vertical-align: top;
  --pyTooling-table-list-margin:         0;
  --pyTooling-table-min-width:           50%;

  --pyTooling-tree-row-height:     1.6em;
  --pyTooling-tree-indentation:    1.4em;
  --pyTooling-tree-expander-width: 1em;
  --pyTooling-tree-icon-gap:       0.3em;
  --pyTooling-tree-line:           1px solid #999;
  --pyTooling-tree-margin-bottom:  24px;
}

span.bolditalic {
  font-weight: bold;
  font-style: italic;
}

span.underline {
  text-decoration: underline;
}

span.strike {
  text-decoration: line-through;
}

span.xlarge {
  font-size: var(--pyTooling-xlarge-size);
}

span.colorred {
  color: var(--pyTooling-color-red);
}

span.colorgreen {
  color: var(--pyTooling-color-green);
}

span.colorblue {
  color: var(--pyTooling-color-blue);
}

span.colorpurple {
  color: var(--pyTooling-color-purple);
}


/* Styles for the tables built by pyTooling.Documentation.Sphinx.

   The class is put on the table by the directive, so these rules reach only a table this package generated and
   never a table a document wrote by hand.

   Every declaration here is '!important', which is not laziness: it has to outrank a theme's own table rules, and
   a theme is chosen by the project rather than by this package, so its selectors can't be predicted. sphinx_rtd_
   theme's '.rst-content table.docutils td' is two classes and two elements, which beats anything this file can
   write without naming that theme. The values stay overridable regardless, because a project redefines the
   custom property rather than the declaration - and a custom property has no specificity to lose. */

/* A row is as tall as its tallest cell, and in a dependency table that is the cell holding a dependency tree.
   Centring the other three vertically pushes a package's name into the middle of an otherwise empty column, far
   away from the row it belongs to. */
table.dependency-table td,
table.dependency-table th {
  vertical-align: var(--pyTooling-table-cell-vertical-align) !important;
}

/* A list inside a cell is the cell's whole content, so the margin a theme puts below it for running text is a gap
   between the last bullet and the cell's border with nothing in it. */
table.dependency-table td > ul,
table.dependency-table td ul,
table.dependency-table td li > p,
table.dependency-table td li > ul,
table.dependency-table td > p {
  margin-bottom: var(--pyTooling-table-list-margin) !important;
}

/* Without a floor, every table is as wide as its widest row, so a table of one short dependency and a table of a
   four-level tree sit beside each other at wildly different widths and the page reads as ragged. */
table.dependency-table {
  min-width: var(--pyTooling-table-min-width);
}


/* Styles for the trees drawn by the 'tree' directive.

   A tree is a nested bullet list, so a theme's list styles - bullets, margins, paddings - reach it too. They are
   reset here with '!important', for the reason given at the tables above. */
ul.pytooling-tree,
ul.pytooling-tree ul,
ul.pytooling-tree li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

ul.pytooling-tree {
  margin-bottom: var(--pyTooling-tree-margin-bottom) !important;
}

/* The lines are drawn at half a row's height, so the row's height has to be the one they are computed from. */
ul.pytooling-tree,
ul.pytooling-tree ul,
ul.pytooling-tree li {
  line-height: var(--pyTooling-tree-row-height) !important;
}

/* A theme may space the blocks in a list item - sphinx_rtd_theme puts 12px above and below each. Below an entry's
   '<details>', that space ends up between the entry and its next sibling, outside both of their lines: a gap in the
   vertical line. Only vertical margins are reset, as an icon keeps its gap to the text. */
ul.pytooling-tree li > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* A level's lines start below the centre of its parent's expander. */
ul.pytooling-tree ul {
  margin-left: calc(var(--pyTooling-tree-expander-width) / 2) !important;
}

ul.pytooling-tree ul > li {
  position: relative;
  padding-left: var(--pyTooling-tree-indentation) !important;
}

/* The line from the parent down to this entry, and across to its text: '└'. */
ul.pytooling-tree ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--pyTooling-tree-indentation) - 0.2em);
  height: calc(var(--pyTooling-tree-row-height) / 2);
  border-left: var(--pyTooling-tree-line);
  border-bottom: var(--pyTooling-tree-line);
}

/* An entry without children has an empty expander, which the line crosses: '└── text'. */
ul.pytooling-tree ul > li:not(.tree-expandable)::before {
  width: calc(var(--pyTooling-tree-indentation) + var(--pyTooling-tree-expander-width) - 0.2em);
}

/* The line on to the next sibling, past this entry's children; with the one above, it makes '├'. */
ul.pytooling-tree ul > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: var(--pyTooling-tree-line);
}

/* The expander icons replace the browser's disclosure triangle. */
ul.pytooling-tree summary {
  display: block;
  list-style: none;
  cursor: pointer;
}

ul.pytooling-tree summary::-webkit-details-marker {
  display: none;
}

ul.pytooling-tree span.tree-expander {
  display: inline-block;
  width: var(--pyTooling-tree-expander-width);
  text-align: center;
}

ul.pytooling-tree span.tree-icon {
  margin-right: var(--pyTooling-tree-icon-gap);
}

/* Both expander icons are written; which one shows depends on whether the entry is expanded. */
ul.pytooling-tree details > summary > span.tree-collapsed,
ul.pytooling-tree details:not([open]) > summary > span.tree-expanded {
  display: none;
}

ul.pytooling-tree details:not([open]) > summary > span.tree-collapsed {
  display: inline-block;
}
