/* DomUI palette.
 *
 * Every colour here comes out of the DomUI logo. Its three interlocking blobs
 * are amber, ember and violet, and each one is given exactly one job on the
 * page, so a colour always means the same thing:
 *
 *   amber   headings - the structure of a document
 *   ember   "you are here" - the current breadcrumb, hovers, the code rule
 *   violet  links - somewhere else to go
 *
 * The ground stays a cool graphite so the three warm marks have something
 * neutral to sit on (the way the logo needs a plain background), and so it
 * sits comfortably next to the Dracula code blocks, which are #282a36.
 */

:root {
    /** Brand: the three blobs of the logo, lifted where a dark ground needs it */
    --clr-amber-a0: #f09000;
    --clr-amber-a10: #f7a72e;
    --clr-amber-a20: #fbbf63;
    --clr-ember-a0: #e44818;
    --clr-ember-a10: #f26a3c;
    --clr-violet-a0: #602478;
    --clr-violet-a10: #a26bc4;
    --clr-violet-a20: #c9a0e0;

    /** Text: the wordmark's warm neutral, at reading contrast */
    --clr-text: #e6ddd5;
    --clr-text-dim: #a99e94;

    /** Primary ramp (heading colour and its tints) */
    --clr-primary-a0: #f09000;
    --clr-primary-a10: #f39c1c;
    --clr-primary-a20: #f7a72e;
    --clr-primary-a30: #f9b449;
    --clr-primary-a40: #fbbf63;
    --clr-primary-a50: #e6ddd5;

    /** Surfaces: cool graphite, tuned to sit beside the Dracula code theme */
    --clr-surface-a0: #16161f;
    --clr-surface-a10: #24242f;
    --clr-surface-a20: #32323f;
    --clr-surface-a30: #43434f;
    --clr-surface-a40: #5c5c68;
    --clr-surface-a50: #8a8a95;

    /** Tonal surfaces: the same graphite warmed a few degrees toward the brand */
    --clr-surface-tonal-a0: #1e1c26;
    --clr-surface-tonal-a10: #2d2a35;
    --clr-surface-tonal-a20: #3d3944;
    --clr-surface-tonal-a30: #4e4954;
    --clr-surface-tonal-a40: #6a6470;
    --clr-surface-tonal-a50: #948d99;

    /** Breadcrumb **/
    --bc-bg: var(--clr-surface-tonal-a20);
    --bc-fg: var(--clr-text);
    --bc-bg-last: var(--clr-surface-tonal-a30);
    --bc-border: var(--clr-surface-tonal-a0);
    --bc-hover: var(--clr-amber-a0);
}

::selection {
    background: var(--clr-amber-a0);
    color: var(--clr-surface-a0);
}

a:focus-visible,
.ui-nav-item:focus-visible {
    outline: 2px solid var(--clr-amber-a0);
    outline-offset: 2px;
    border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *:before, *:after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

html {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    height: 100%;
    padding: 0;
    margin: 0;
}

body {
    height: 100%;
    font: 400 1em / 1.714 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Ubuntu, system-ui, "Helvetica Neue", sans-serif;
    color: var(--clr-text);
    background-color: var(--clr-surface-a10);

    display: flex;
    flex-direction: column;
    overflow: hidden;                       /* The page itself never scrolls, only the middle row's columns do */
    padding: 0;
    margin: 0;
}

.ui-tbl {
    border-collapse: collapse;
    background-color: var(--clr-surface-tonal-a10);
}
.ui-tbl thead {
	background-color: var(--clr-surface-tonal-a0);
}

.ui-tbl th {
	padding: 3px 10px;
	border-left: 1px solid #aaaaaa;
	text-align: left;
	white-space: nowrap;
    font-weight: bold;
}
.ui-tbl th:last-child {
	border-right: 1px solid #aaaaaa;
}
.ui-tbl td {
	padding: 1px 10px;
	border-left: 1px solid #aaaaaa;
	vertical-align: top;
}
.ui-tbl tr:nth-child(even) {
	background-color: var(--clr-surface-tonal-a20);
}
.ui-tbl td:last-child {
	border-right: 1px solid #aaaaaa;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--clr-primary-a30);
}
a, a:visited {
    color: var(--clr-violet-a20);
    text-decoration: none;
}
a:hover {
    color: var(--clr-ember-a10);
    text-decoration: underline;
}

/** Main layout **/
/** Main layout: three rows - the top and the bottom row take the room they
 * need, the middle row gets whatever is left. That middle row holds two
 * columns, the menu and the page content, each scrolling on its own.
 **/
.ui-page-top {
    flex: 0 0 auto;
}
.ui-page-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 20px 22px;
    background-color: var(--clr-surface-tonal-a10);
    background-image: linear-gradient(to right,
        var(--clr-amber-a0) 0 33.34%,
        var(--clr-ember-a0) 33.34% 66.67%,
        var(--clr-violet-a10) 66.67% 100%);
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: 100% 4px;
}
.ui-page-header img {
    height: 72px;
    width: auto;
}

.ui-page-bottom {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ui-page-copyright {
    font-size: xx-small;
    color: #777;
}
.ui-page-meta-date {
    font-size: xx-small;
    color: var(--clr-text-dim);
}
.ui-page-middle {
    flex: 1 1 auto;
    min-height: 0;                          /* Without this the row grows to fit its content instead of scrolling */
    overflow: hidden;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
}
.ui-page-menu {
    /* As wide as the menu needs, but never below 300 nor over 400 pixels */
    flex: 0 0 auto;
    width: max-content;
    min-width: 300px;
    max-width: 400px;
    min-height: 0;
    overflow: auto;
}
.ui-page-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: row;
    justify-content: center;
}

.ui-flex-content {
    box-sizing: border-box;
    width: 1024px;
    max-width: 100%;
    padding: 0 16px;
}

/* Imported screenshots run wider than the column; keep them inside it. */
.ui-flex-content img {
    max-width: 100%;
    height: auto;
}

.ui-page-nav {
    display: flex;
    justify-content: space-between;
    margin: 20px 10px;
}
.ui-page-nav-end {

}
.ui-nav-item {
    display: flex;
    padding: 0.75em 1.25em;
    outline: none;
    position: relative;
    text-decoration: none;
    border-radius: 0.3rem;
    border: 1px solid var(--clr-surface-tonal-a30);
    background-color: var(--clr-surface-tonal-a10);
}
.ui-page-nav-end a.ui-nav-item, .ui-page-nav-end a.ui-nav-item:visited {
    color: var(--clr-text);
}
.ui-nav-item:hover {
    border-color: var(--clr-amber-a0);
    color: var(--clr-amber-a10);
    text-decoration: none;
}
.ui-page-bc-cont {
/*    width: 700px; */
}

/** Breadcrumb **/
.ui-page-breadcrumb {
    flex-direction: row;
    border: 1px solid var(--bc-border);
    border-radius: 0.3rem;
    display: inline-flex;
    overflow: hidden;
    /* margin: 20px 10px; */
}

.ui-bc-item {
    background: var(--bc-bg);
    color: var(--bc-fg);
    outline: none;
    padding: 0.75em 0.75em 0.75em 1.25em;
    position: relative;
    text-decoration: none;
    transition: background 0.2s linear;
}
.ui-page-breadcrumb a, .ui-page-breadcrumb a:visited {
    color: var(--bc-fg);
}

.ui-bc-item:hover:after,
.ui-bc-item:hover {
    background: var(--bc-hover);
}
.ui-page-breadcrumb a.ui-bc-item:hover {
    color: var(--clr-surface-a0);
}

.ui-bc-item:focus:after,
.ui-bc-item:focus,
.ui-bc-item.is-active:focus {
    background: var(--clr-surface-tonal-a30);
    color: var(--clr-text);
}
.ui-bc-item:focus-visible {
    outline: 2px solid var(--clr-amber-a0);
    outline-offset: -2px;
}

.ui-bc-item:after,
.ui-bc-item:before {
    background: var(--bc-bg);
    bottom: 0;
    clip-path: polygon(50% 50%, -50% -50%, 0 100%);
    content: "";
    left: 100%;
    position: absolute;
    top: 0;
    transition: background 0.2s linear;
    width: 1em;
    z-index: 1;
}

.ui-bc-item:before {
    background: var(--clr-surface-tonal-a0);
    margin-left: 1px;
}

.ui-bc-last {
    border-right: none;
}

.ui-bc-item.ui-bc-last {
    background: var(--bc-bg-last);
    color: var(--clr-amber-a20);
    font-weight: 600;
}

/** Menu.
 * Deliberately not styled like the page text: its own darker surface, dimmed
 * text and denser type, so it reads as navigation. Colour is kept for state
 * only, following the palette: amber marks the path you came down, ember marks
 * where you are and what you are pointing at.
 **/
.ui-page-menu {
    background: var(--clr-surface-a0);
    border-right: 1px solid var(--clr-surface-a20);
}
.ui-menu {
    font-size: 0.8125em;
    line-height: 1.4;
    padding: 10px 6px 20px 6px;
}
.ui-menu-level {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ui-menu-level-0 {
    padding-left: 0;
}
.ui-menu-item {
    margin: 1px 0;
}
.ui-menu-item .ui-menu-level {
    padding-left: 12px;
    border-left: 1px solid var(--clr-surface-a10);
    margin-left: 6px;
}
.ui-menu-item > a {
    display: block;
    padding: 3px 8px;
    border-radius: 3px;
    color: var(--clr-text-dim);
    text-decoration: none;
}
.ui-menu-level-0 > .ui-menu-item > a {
    font-weight: 600;
    letter-spacing: 0.02em;
}
.ui-menu-item > a:hover {
    background: var(--clr-surface-a10);
    color: var(--clr-ember-a10);
}
.ui-menu-open > a {
    color: var(--clr-amber-a20);
}
.ui-menu-current > a {
    background: var(--clr-surface-tonal-a10);
    color: var(--clr-ember-a10);
    font-weight: 600;
}

/** code **/

/* The box belongs to the pre, not to the code inside it: styling "code" itself
   turns every inline `code` span in running text into a block, which chops the
   sentence around it into pieces. */
pre {
    background: var(--clr-surface-a0);
    border-left: 3px solid var(--clr-ember-a0);
    color: var(--clr-text);
    page-break-inside: avoid;
    font-family: monospace;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 1.6em;
    max-width: 100%;
    overflow: auto;
    padding: 0.8em 1.2em;
    display: block;
}

/* Inside a pre the code tag is just the text: the pre draws the box, and
   highlight.js adds its own padding on .hljs which we do not want on top. */
pre code, pre code.hljs {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    overflow: visible;
    word-wrap: break-word;
}

/* Inline code in running text: marked, but still part of the sentence. */
code {
    background: var(--clr-surface-a0);
    color: var(--clr-text);
    font-family: monospace;
    font-size: 0.92em;
    padding: 0.1em 0.35em;
    border-radius: 3px;
    word-wrap: break-word;
}

/*--- Embedded live application pages (the !demo() tag) ------------------*/

/* The frame keeps the size the tag asked for; the box around it scrolls when
   the screen is narrower than that, because scaling an application down makes
   it unreadable and squashing it changes the layout being demonstrated. */
.ui-demo {
	margin: 1.5em 0;
	max-width: 100%;
	overflow-x: auto;
	background: var(--clr-surface-a10);
	border: 1px solid var(--clr-surface-a30);
	border-radius: 4px;
	padding: 8px;
}
.ui-demo-frame {
	display: block;
	border: 0;
	background: #fff;
}

/* A generated PlantUML diagram: black line art, so it gets its own light card */
.ui-uml {
	margin: 1.5em 0;
	max-width: 100%;
	overflow-x: auto;
	background: #fff;
	border: 1px solid var(--clr-surface-a30);
	border-radius: 4px;
	padding: 8px;
}
.ui-uml img {
	display: block;
	max-width: 100%;
	height: auto;
}

.ui-not {
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	align-items: center;
	padding: 0 20px;
}
.ui-not-icon {
	width: 32px;
	height: 32px;
	flex-shrink: 0;						/* Or the text beside it squeezes the icon and clips it in half */
	background-repeat: no-repeat;
	background-position: center;
}
.ui-not-cnt {
	padding: 0 20px;
}

.ui-not-warning .ui-not-icon {
	background-image: url(../img/notif-icon-warning.png);
}
.ui-not-error .ui-not-icon {
	background-image: url(../img/notif-icon-error.png);
}
.ui-not-success .ui-not-icon {
	background-image: url(../img/notif-icon-success.png);
}
.ui-not-info .ui-not-icon {
	background-image: url(../img/notif-icon-info.png);
}


.ui-not-warning {
	border-left: 5px solid #E7B600;
}
.ui-not-error {
	border-left: 5px solid #C20000;
}
.ui-not-success {
	border-left: 5px solid #A4B123;
}
.ui-not-info {
	border-left: 5px solid rgb(102, 209, 255);
}

/** Blog **/
.blg-date {
    color: var(--clr-surface-a50);
    font-size: 0.9em;
    margin-right: 0.5em;
}

.ui-blog-nav {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
    width: 1024px;
    max-width: 100%;
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--clr-surface-tonal-a20);
    font-size: medium;
}

.ui-blog-nav-prev,
.ui-blog-nav-next {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    color: var(--clr-primary-a30);
    text-decoration: none;
}

.ui-blog-nav-prev:hover,
.ui-blog-nav-next:hover {
    color: var(--clr-primary-a0);
    text-decoration: underline;
}

.ui-blog-nav-next {
    margin-left: auto;
    text-align: right;
}

.ui-blog-nav-icon {
    font-size: 1.2em;
    line-height: 1;
}

/** Printing.
 * The screen layout is a full-height flexbox with the content in a scrolling
 * container of a fixed 1024px width. On paper that prints as a single clipped
 * page, so undo all of it: no viewport-height boxes, no internal scrolling, no
 * fixed widths, and dark-on-light instead of light-on-dark.
 */
@media print {
    @page {
        margin: 15mm;
    }

    html, body {
        height: auto;
        display: block;
        overflow: visible;
        color: #000;
        background: #fff;
        background-image: none;
        font-size: 11pt;
    }

    .ui-page-middle, .ui-page-content, .ui-page-top, .ui-page-bottom {
        display: block;
        overflow: visible;
        height: auto;
    }

    .ui-flex-content {
        width: auto;
        max-width: 100%;
    }

    /* Screen-only navigation: useless on paper */
    .ui-page-nav-end, .ui-page-menu, .ui-blog-nav {
        display: none;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #000;
        break-after: avoid;
        page-break-after: avoid;
    }

    a, a:visited,
    .ui-page-breadcrumb a, .ui-page-breadcrumb a:visited {
        color: #000;
        text-decoration: none;
    }

    img {
        max-width: 100%;
        height: auto;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Code blocks: light background, wrap instead of scroll, allow page breaks */
    pre {
        background: #fff;
        color: #000;
        border-left: 3px solid #888;
        overflow: visible;
        font-size: 8pt;
        line-height: 1.35;
        white-space: pre-wrap;
        word-wrap: break-word;
        break-inside: auto;
        page-break-inside: auto;
    }

    /* Inline code keeps flowing with its sentence, without the block's border */
    code {
        background: #fff;
        color: #000;
        border: 0;
        padding: 0;
        word-wrap: break-word;
    }

    /* Dracula highlighting is unreadable on white */
    .hljs, .hljs * {
        color: #000 !important;
        background: transparent !important;
    }

    /* Breadcrumb as plain text instead of dark arrow tabs */
    .ui-page-breadcrumb {
        display: block;
        border: none;
        overflow: visible;
    }
    .ui-bc-item {
        display: inline;
        background: none;
        color: #000;
        padding: 0;
    }
    .ui-bc-item:before {
        display: none;
    }
    .ui-bc-item:after {
        content: " \203A ";
        position: static;
        background: none;
        clip-path: none;
        width: auto;
    }
    .ui-bc-item.ui-bc-last {
        background: none;
    }
    .ui-bc-item.ui-bc-last:after {
        content: "";
    }

    .ui-page-copyright, .ui-page-meta-date {
        color: #555;
    }
}

