/* ----------------------------------------------------------------------------
   DSPX documentation: the stylesheet of every page.

   Our own design: one centered column of text, generous line height, system
   fonts (no web fonts, no CDN: the documentation works offline), pictures
   the width of the column and never wrapped by text. A light theme, a dark
   one that follows the system (prefers-color-scheme), and a print layout.

   doc/tools/dscdoc.py generates the pages; doc/tools/template.html shows
   every element this file styles.
   ---------------------------------------------------------------------------- */

:root
{
   --bg: #fbfbfa;
   --surface: #f2f4f7;
   --text: #1d2229;
   --text-dim: #5a6472;
   --rule: #dde2e8;
   --accent: #2160c4;
   --accent-soft: #e6eefb;
   --tip: #1f7a4d;
   --tip-soft: #e5f4ec;
   --warn: #9a5b00;
   --warn-soft: #fbf1e0;
   --code-bg: #eef1f5;
   --banner-from: #0d1526;
   --banner-to: #1d3a6e;
   --banner-text: #f4f7fc;
   --shadow: 0 1px 2px rgba( 15, 23, 42, 0.06 ), 0 4px 16px rgba( 15, 23, 42, 0.06 );

   --font: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, "Noto Sans", Ubuntu, Cantarell,
           "Helvetica Neue", Arial, sans-serif;
   --mono: "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
   --column: 860px;
   color-scheme: light dark;
}

@media ( prefers-color-scheme: dark )
{
   :root
   {
      --bg: #12161d;
      --surface: #1a2029;
      --text: #dfe5ee;
      --text-dim: #9aa6b6;
      --rule: #2b3340;
      --accent: #7fb2ff;
      --accent-soft: #1b2a44;
      --tip: #6fd3a0;
      --tip-soft: #15291f;
      --warn: #f0b860;
      --warn-soft: #2e2414;
      --code-bg: #1f2632;
      --shadow: 0 1px 2px rgba( 0, 0, 0, 0.4 ), 0 4px 16px rgba( 0, 0, 0, 0.3 );
   }
}

/* ----- the page ------------------------------------------------------------ */

*,
*::before,
*::after
{
   box-sizing: border-box;
}

html
{
   background: var( --bg );
   scroll-behavior: smooth;
   -webkit-text-size-adjust: 100%;
}

body
{
   margin: 0;
   padding: 0 16px 64px;
   background: var( --bg );
   color: var( --text );
   font-family: var( --font );
   font-size: 16.5px;
   line-height: 1.65;
   text-rendering: optimizeLegibility;
}

.page
{
   max-width: var( --column );
   margin: 0 auto;
}

/* Where we are: DSPX > Processes > the page. */
.crumbs
{
   margin: 20px 0 14px;
   font-size: 14px;
   color: var( --text-dim );
}

.crumbs a
{
   color: var( --text-dim );
}

.crumbs span + span::before
{
   content: "\203A";
   margin: 0 8px;
   opacity: 0.7;
}

/* ----- the banner ---------------------------------------------------------- */

.banner
{
   position: relative;
   display: flex;
   align-items: center;
   gap: 22px;
   min-height: 168px;
   padding: 28px 32px;
   border-radius: 0;
   overflow: hidden;
   color: var( --banner-text );
   background: linear-gradient( 120deg, var( --banner-from ), var( --banner-to ) );
   background-size: cover;
   background-position: center;
   box-shadow: var( --shadow );
}

/* A picture behind the banner, darkened on the left so the title reads. */
.banner.picture::before
{
   content: "";
   position: absolute;
   inset: 0;
   background: linear-gradient( 90deg, rgba( 6, 10, 20, 0.86 ) 0%, rgba( 6, 10, 20, 0.62 ) 45%, rgba( 6, 10, 20, 0.15 ) 100% );
}

.banner > *
{
   position: relative;
}

.banner .icon
{
   flex: none;
   width: 76px;
   height: 76px;
   padding: 10px;
   border-radius: 0;
   background: rgba( 255, 255, 255, 0.10 );
   border: 1px solid rgba( 255, 255, 255, 0.18 );
}

.banner h1
{
   margin: 0;
   font-size: 40px;
   font-weight: 300;
   line-height: 1.1;
   letter-spacing: 0.2px;
}

.banner .tagline
{
   margin: 8px 0 0;
   font-size: 17px;
   font-weight: 400;
   opacity: 0.88;
}

.banner .kind
{
   display: block;
   margin-bottom: 6px;
   font-size: 12px;
   font-weight: 600;
   letter-spacing: 1.4px;
   text-transform: uppercase;
   opacity: 0.7;
}

/* ----- the description, categories and keywords --------------------------- */

.summary
{
   margin: 28px 0 10px;
   font-size: 18px;
   line-height: 1.6;
}

.meta
{
   display: grid;
   grid-template-columns: max-content 1fr;
   gap: 6px 14px;
   margin: 14px 0 0;
   font-size: 14px;
   color: var( --text-dim );
}

.meta dt
{
   font-weight: 600;
}

.meta dd
{
   margin: 0;
}

.tags
{
   display: flex;
   flex-wrap: wrap;
   gap: 6px;
   margin: 0;
   padding: 0;
   list-style: none;
}

.tags li
{
   padding: 1px 10px;
   border-radius: 2px;
   background: var( --surface );
   border: 1px solid var( --rule );
   color: var( --text );
   font-size: 13px;
}

/* ----- the table of contents ----------------------------------------------- */

.toc
{
   margin: 32px 0 8px;
   padding: 18px 24px 16px;
   border: 1px solid var( --rule );
   border-radius: 0;
   background: var( --surface );
}

.toc h2
{
   margin: 0 0 8px;
   padding: 0;
   border: 0;
   font-size: 13px;
   font-weight: 600;
   letter-spacing: 1.4px;
   text-transform: uppercase;
   color: var( --text-dim );
}

.toc ol
{
   margin: 0;
   padding: 0;
   list-style: none;
}

.toc > ol
{
   columns: 2 300px;
   column-gap: 32px;
}

.toc > ol > li
{
   break-inside: avoid;
   padding: 3px 0;
}

.toc ol ol
{
   padding-left: 26px;
   font-size: 15px;
}

.toc a
{
   color: var( --text );
   text-decoration: none;
}

.toc a:hover
{
   color: var( --accent );
   text-decoration: underline;
}

.toc .num,
h2 .num,
h3 .num
{
   display: inline-block;
   min-width: 1.8em;
   margin-right: 6px;
   color: var( --text-dim );
   font-variant-numeric: tabular-nums;
   font-weight: 400;
}

.toc ol ol .num
{
   min-width: 2.4em;
}

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

h2,
h3,
h4
{
   line-height: 1.3;
   scroll-margin-top: 16px;
}

h2
{
   margin: 56px 0 14px;
   padding-top: 22px;
   border-top: 1px solid var( --rule );
   font-size: 27px;
   font-weight: 600;
}

h3
{
   margin: 36px 0 10px;
   font-size: 20px;
   font-weight: 600;
}

h4
{
   margin: 26px 0 6px;
   font-size: 16.5px;
   font-weight: 600;
}

p,
ul,
ol,
dl,
table
{
   margin: 0 0 14px;
}

ul,
ol
{
   padding-left: 24px;
}

/* Square bullets: the documentation has no round shapes (corners are sharp, or 2px at most). */
ul
{
   list-style: square;
}

li
{
   margin: 4px 0;
}

li > ul,
li > ol
{
   margin: 4px 0 0;
}

a
{
   color: var( --accent );
   text-decoration-thickness: 1px;
   text-underline-offset: 2px;
}

strong,
b
{
   font-weight: 600;
}

code,
kbd,
samp
{
   font-family: var( --mono );
   font-size: 0.88em;
}

code
{
   padding: 1px 5px;
   border-radius: 2px;
   background: var( --code-bg );
}

kbd
{
   padding: 1px 6px;
   border: 1px solid var( --rule );
   border-bottom-width: 2px;
   border-radius: 2px;
   background: var( --surface );
   white-space: nowrap;
}

pre
{
   margin: 0 0 16px;
   padding: 12px 16px;
   overflow-x: auto;
   border-radius: 0;
   background: var( --code-bg );
   line-height: 1.5;
}

pre code
{
   padding: 0;
   background: none;
}

/* A menu path: Process > Masks > DeepStarMask. */
.menu
{
   font-weight: 600;
   white-space: nowrap;
}

/* ----- parameters ---------------------------------------------------------- */

/* One parameter: <p class="param"><b>Name:</b> what it does.</p>. Its values,
   when they need a line each, follow in <ul class="values">. */
.param
{
   margin: 0 0 12px;
   padding: 2px 0 2px 14px;
   border-left: 3px solid var( --accent-soft );
}

.param > b:first-child
{
   color: var( --text );
}

.values
{
   margin: -6px 0 14px 17px;
   padding-left: 20px;
}

.values li
{
   margin: 3px 0;
}

/* ----- pictures ------------------------------------------------------------ */

/* Every picture takes the whole width of the column; text never flows
   around it. */
figure
{
   margin: 22px 0 26px;
   padding: 0;
   clear: both;
}

figure img,
img.full
{
   display: block;
   width: 100%;
   height: auto;
   border-radius: 0;
   box-shadow: var( --shadow );
}

/* A panel's picture keeps its own size: a panel stretched to the column
   would read as a different interface. It is centered on the row. */
figure.panel img
{
   width: auto;
   max-width: 100%;
   margin: 0 auto;
}

/* A tall picture (a long panel) is kept narrow: at the column's width it would fill several screens. */
figure.tall img
{
   width: auto;
   max-width: min( 100%, 400px );
   margin: 0 auto;
}

figcaption
{
   margin-top: 10px;
   font-size: 14.5px;
   line-height: 1.5;
   color: var( --text-dim );
}

figcaption b
{
   color: var( --text );
}

/* A before and after slider (figure.compare; doc/compare.js makes it work). Without the script
   the two pictures simply follow each other, the first one being the "before". The bar and the
   labels sit on the picture, so their colors do not follow the theme: they must show on any image. */
/* A slider of pictures that are small or that are shown at a chosen width (max-width on the figure): centered on the column. */
figure.compare.sized
{
   margin-left: auto;
   margin-right: auto;
}

figure.compare:not( .ready ) img + img
{
   margin-top: 10px;
}

.cmp
{
   position: relative;
   overflow: hidden;
   box-shadow: var( --shadow );
   line-height: 0;
   cursor: ew-resize;
   touch-action: pan-y;
   user-select: none;
   -webkit-user-select: none;
   --p: 50%;
}

.cmp img
{
   display: block;
   width: 100%;
   height: auto;
   box-shadow: none;
   -webkit-user-drag: none;
   pointer-events: none;
}

.cmp img.before
{
   position: absolute;
   top: 0;
   left: 0;
   clip-path: inset( 0 calc( 100% - var( --p ) ) 0 0 );
}

.cmp .bar
{
   position: absolute;
   top: 0;
   bottom: 0;
   left: var( --p );
   width: 2px;
   margin-left: -1px;
   background: #ffffff;
   box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.5 );
   outline: none;
}

.cmp .bar::before
{
   content: "";
   position: absolute;
   top: 50%;
   left: 50%;
   width: 30px;
   height: 46px;
   margin: -23px 0 0 -15px;
   background: #ffffff url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 46'%3E%3Cpath d='M12 17 5 23 12 29ZM18 17 25 23 18 29Z' fill='%231d2229'/%3E%3C/svg%3E" ) center / 30px 46px no-repeat;
   border: 1px solid rgba( 0, 0, 0, 0.6 );
   border-radius: 2px;
}

.cmp .bar:focus-visible::before
{
   outline: 3px solid var( --accent );
   outline-offset: 2px;
}

.cmp .tag
{
   position: absolute;
   bottom: 10px;
   padding: 3px 8px;
   font-size: 13px;
   line-height: 1.3;
   color: #ffffff;
   background: rgba( 0, 0, 0, 0.55 );
   border-radius: 2px;
}

.cmp .tag.l
{
   left: 10px;
}

.cmp .tag.r
{
   right: 10px;
}

/* ----- notes --------------------------------------------------------------- */

.note,
.tip,
.caution
{
   margin: 18px 0;
   padding: 12px 16px;
   border-radius: 0;
   border-left: 4px solid var( --accent );
   background: var( --accent-soft );
}

.tip
{
   border-left-color: var( --tip );
   background: var( --tip-soft );
}

.caution
{
   border-left-color: var( --warn );
   background: var( --warn-soft );
}

.note > :last-child,
.tip > :last-child,
.caution > :last-child
{
   margin-bottom: 0;
}

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

table
{
   width: 100%;
   border-collapse: collapse;
   font-size: 15px;
}

th,
td
{
   padding: 7px 10px;
   border-bottom: 1px solid var( --rule );
   text-align: left;
   vertical-align: top;
}

th
{
   font-weight: 600;
   color: var( --text-dim );
}

/* ----- steps (Quick Start) ------------------------------------------------- */

ol.steps
{
   counter-reset: step;
   list-style: none;
   padding-left: 0;
}

ol.steps > li
{
   position: relative;
   margin: 0 0 12px;
   padding-left: 40px;
}

ol.steps > li::before
{
   counter-increment: step;
   content: counter( step );
   position: absolute;
   left: 0;
   top: 1px;
   width: 26px;
   height: 26px;
   border-radius: 0;
   background: var( --accent );
   color: var( --bg );
   font-size: 14px;
   font-weight: 600;
   line-height: 26px;
   text-align: center;
}

/* ----- the end of the page ------------------------------------------------- */

footer
{
   margin-top: 64px;
   padding-top: 16px;
   border-top: 1px solid var( --rule );
   font-size: 13px;
   color: var( --text-dim );
}

footer p
{
   margin: 0 0 4px;
}

/* A draft: what is not written yet (the main page while its contents are
   reviewed). */
.draft
{
   color: var( --text-dim );
   font-style: italic;
}

/* ----- narrow windows ------------------------------------------------------ */

@media ( max-width: 640px )
{
   body
   {
      font-size: 16px;
   }

   .banner
   {
      flex-direction: column;
      align-items: flex-start;
      padding: 22px;
   }

   .banner h1
   {
      font-size: 32px;
   }

   .meta
   {
      grid-template-columns: 1fr;
   }
}

/* ----- the main documentation ---------------------------------------------- */

/* A control's name: Apply, Reset Page. */
.ui
{
   font-weight: 600;
}

/* The search box and its results. */
.search
{
   margin: 18px 0 0;
}

.search input
{
   width: 100%;
   padding: 9px 12px;
   border: 1px solid var( --rule );
   border-radius: 2px;
   background: var( --surface );
   color: var( --text );
   font: inherit;
   font-size: 15px;
}

.results
{
   margin: 6px 0 0;
   padding: 0;
   list-style: none;
   font-size: 15px;
}

.results li
{
   margin: 0;
   padding: 5px 2px;
   border-bottom: 1px solid var( --rule );
}

.results li span
{
   color: var( --text-dim );
}

/* Previous and next chapter, at the end of a chapter. */
.pager
{
   display: grid;
   grid-template-columns: 1fr 1fr 1fr;
   gap: 10px;
   margin: 56px 0 0;
}

.pager a
{
   display: block;
   padding: 10px 14px;
   border: 1px solid var( --rule );
   background: var( --surface );
   color: var( --text );
   text-decoration: none;
   font-size: 15px;
}

.pager a:hover
{
   border-color: var( --accent );
}

.pager a span
{
   display: block;
   font-size: 12px;
   letter-spacing: 1.2px;
   text-transform: uppercase;
   color: var( --text-dim );
}

.pager a[rel="next"]
{
   text-align: right;
}

/* The glossary and the index. */
dl.glossary dt
{
   margin: 14px 0 2px;
   font-weight: 600;
}

dl.glossary dd
{
   margin: 0 0 0 18px;
}

.letters a
{
   margin-right: 8px;
   font-weight: 600;
}

ul.index
{
   columns: 2 300px;
   column-gap: 32px;
   list-style: none;
   padding-left: 0;
}

ul.index li
{
   break-inside: avoid;
   margin: 2px 0;
}

h4[id^="ix-"]
{
   margin-top: 22px;
   padding-bottom: 2px;
   border-bottom: 1px solid var( --rule );
}

/* A place the writer has not filled: counted by the checker. */
.todo
{
   padding: 6px 12px;
   border-left: 3px solid var( --warn );
   background: var( --warn-soft );
   color: var( --warn );
}

table.pages td:first-child
{
   white-space: nowrap;
}

/* A flow drawn inline in a chapter (SVG with sharp corners). */
figure svg
{
   display: block;
   width: 100%;
   height: auto;
}

@media ( max-width: 640px )
{
   .pager
   {
      grid-template-columns: 1fr;
   }
}

/* ----- print --------------------------------------------------------------- */

@media print
{
   .search,
   .results,
   .pager
   {
      display: none;
   }

   :root
   {
      --bg: #ffffff;
      --surface: #ffffff;
      --text: #000000;
      --text-dim: #444444;
      --rule: #bbbbbb;
      --accent: #000000;
      --accent-soft: #eeeeee;
      --tip-soft: #ffffff;
      --warn-soft: #ffffff;
      --code-bg: #f3f3f3;
      --shadow: none;
   }

   body
   {
      padding: 0;
      font-size: 11pt;
      line-height: 1.5;
   }

   .page
   {
      max-width: none;
   }

   .crumbs
   {
      display: none;
   }

   .banner
   {
      min-height: 0;
      padding: 0 0 12px;
      border-radius: 0;
      border-bottom: 2px solid #000;
      background: none !important;
      color: #000;
   }

   .banner.picture::before
   {
      display: none;
   }

   .banner .icon
   {
      background: none;
      border: 0;
   }

   .toc > ol
   {
      columns: 1;
   }

   h2
   {
      break-before: auto;
      break-after: avoid;
   }

   h3,
   h4
   {
      break-after: avoid;
   }

   figure,
   .param,
   .note,
   .tip,
   .caution,
   tr
   {
      break-inside: avoid;
   }

   a
   {
      color: inherit;
      text-decoration: none;
   }

   /* A before and after slider prints as its two pictures, one above the other. */
   .cmp img.before
   {
      position: static;
      clip-path: none;
      margin-bottom: 8px;
   }

   .cmp .bar,
   .cmp .tag
   {
      display: none;
   }
}
