/*
 * The Knowledge Base stylesheet for the dirks theme.
 *
 * Written against the kb- class contract. Delivered by the publisher to
 * assets/kb.css on every run.
 *
 * The first self-contained theme. A dirks library names no stylesheet of its
 * own, so this is the only stylesheet the page loads, and it carries
 * everything: the tokens, the faces, the element rules, the page column, the
 * kb- classes, and the dirks- classes in the library's navigation markup.
 *
 * The palette and the faces are copied from DI_CO 0.3.3 MF Brand Development,
 * in the Dirks Instruments project, which is the original for every value in
 * section 1. PS3 3.2.2 Knowledge Base Specification, The Dirks Theme, is the
 * original for every rule below it. A change to a value is made there first.
 */

/*
 * HOW THIS FILE IS BUILT
 *
 * Four palette tokens and no tints. Every colour in the file is one of them,
 * and no rule names a palette token or a colour: each rule reads a role token,
 * and the role tokens are the only place a palette token is read.
 *
 * Every face is a static latin woff2 file under /brand/fonts/ on the library's
 * own origin, which the client host policy already admits as 'self'. Nothing
 * here imports a file or names another origin.
 *
 * A selector names an element, a class the renderer emits, or a class under
 * the dirks- prefix, and nothing else.
 */


/* ------------------------------------------------------------------------
   1. Tokens
   The palette, the roles that read it, the faces, the scale, and the
   column. The scale is written against the body size, so the one change
   below 600 pixels moves every size with it.
   ------------------------------------------------------------------------ */

:root {
    /* The palette. */
    --dirks-orange: #FF7000;
    --dirks-mid-gray: #585858;
    --dirks-green: #22664E;
    --dirks-white: #FFFFFF;

    /* The roles. White is the ground. Mid Gray is the text, every heading,
       and every rule and border. Green is the link. Orange is the accent, on
       the rule above the H1 and on the call to action and nowhere else. */
    --dirks-ground: var(--dirks-white);
    --dirks-text: var(--dirks-mid-gray);
    --dirks-heading: var(--dirks-mid-gray);
    --dirks-rule: var(--dirks-mid-gray);
    --dirks-link: var(--dirks-green);
    --dirks-link-hover: var(--dirks-mid-gray);
    --dirks-focus: var(--dirks-green);
    --dirks-accent: var(--dirks-orange);
    --dirks-takeaway-edge: var(--dirks-green);
    --dirks-header-ground: var(--dirks-white);
    --dirks-footer-ground: var(--dirks-mid-gray);
    --dirks-footer-text: var(--dirks-white);

    /* Green does not carry on the Mid Gray band, so a footer link is White,
       always underlined, and ringed in White on keyboard focus. */
    --dirks-footer-link: var(--dirks-white);
    --dirks-footer-focus: var(--dirks-white);

    /* The call to action is outlined. White or Mid Gray text on a solid
       Orange block fails AA, at 2.77 and 2.56 to 1, so Orange is the border
       and never the ground. */
    --dirks-action-ground: var(--dirks-white);
    --dirks-action-border: var(--dirks-orange);
    --dirks-action-text: var(--dirks-mid-gray);
    --dirks-action-hover-ground: var(--dirks-mid-gray);
    --dirks-action-hover-text: var(--dirks-white);

    /* The faces. */
    --dirks-font-display: "Raleway", "Trebuchet MS", Helvetica, sans-serif;
    --dirks-font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
    --dirks-font-data: "JetBrains Mono", Consolas, Menlo, monospace;

    /* The scale. */
    --dirks-size-body: 18px;
    --dirks-leading-body: 1.55;
    --dirks-leading-heading: 1.2;
    --dirks-size-h1: calc(var(--dirks-size-body) * 2.5);
    --dirks-size-h2: calc(var(--dirks-size-body) * 1.75);
    --dirks-size-h3: calc(var(--dirks-size-body) * 1.35);
    --dirks-size-h4: calc(var(--dirks-size-body) * 1.05);
    --dirks-size-lead: calc(var(--dirks-size-body) * 1.2);
    --dirks-size-meta: calc(var(--dirks-size-body) * 0.9);
    --dirks-size-data: calc(var(--dirks-size-body) * 0.95);

    /* The column, and the gutter either side of it. */
    --dirks-column: 720px;
    --dirks-gutter: 24px;
    --dirks-card-padding: 24px;

    /* The logo. The specification leaves its height open. */
    --dirks-logo-height: 40px;
}


/* ------------------------------------------------------------------------
   2. The faces
   Six static files, one per weight, each with swap so the text is read in
   the fallback while the face arrives.
   ------------------------------------------------------------------------ */

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/brand/fonts/raleway-600.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/brand/fonts/raleway-700.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/brand/fonts/inter-400.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/brand/fonts/inter-500.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/brand/fonts/inter-600.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/brand/fonts/jetbrains-mono-400.woff2") format("woff2");
}


/* ------------------------------------------------------------------------
   3. Elements
   There is no parent stylesheet underneath this one, so the page and every
   element a cleaned body can hold are set here.
   ------------------------------------------------------------------------ */

html {
    background: var(--dirks-ground);
}

body {
    margin: 0;
    background: var(--dirks-ground);
    color: var(--dirks-text);
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-body);
    font-weight: 400;
    line-height: var(--dirks-leading-body);
}

/* Every heading is Mid Gray and sentence case, with more space above it than
   below, so it belongs to the text that follows it. */
h1,
h2,
h3,
h4 {
    color: var(--dirks-heading);
    line-height: var(--dirks-leading-heading);
    text-transform: none;
}

h1 {
    margin: 0 0 0.4em;
    font-family: var(--dirks-font-display);
    font-size: var(--dirks-size-h1);
    font-weight: 700;
}

h2 {
    margin: 1.6em 0 0.5em;
    font-family: var(--dirks-font-display);
    font-size: var(--dirks-size-h2);
    font-weight: 700;
}

h3 {
    margin: 1.5em 0 0.45em;
    font-family: var(--dirks-font-display);
    font-size: var(--dirks-size-h3);
    font-weight: 600;
}

h4 {
    margin: 1.4em 0 0.4em;
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-h4);
    font-weight: 600;
}

p,
ul,
ol,
blockquote,
pre {
    margin: 0 0 1em;
}

ul,
ol {
    padding-left: 1.5em;
}

li {
    margin: 0 0 0.35em;
}

/* Green and Mid Gray are close in brightness, so the underline is what tells
   a link from the text around it. It is never taken away. */
a {
    color: var(--dirks-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--dirks-link-hover);
}

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

blockquote {
    padding-left: 1em;
    border-left: 1px solid var(--dirks-rule);
}

code,
pre {
    font-family: var(--dirks-font-data);
    font-size: var(--dirks-size-data);
}

pre {
    padding: 1em;
    border: 1px solid var(--dirks-rule);
    overflow-x: auto;
}

/* A block inside a block does not take the step down twice. */
pre code {
    font-size: inherit;
}

img {
    max-width: 100%;
}


/* ------------------------------------------------------------------------
   4. The navigation
   The library's own markup, under the dirks- prefix. A White header with a
   Mid Gray rule beneath it, running the full width, with its content on the
   same column as the page. The padding is the gutter until the viewport
   passes the column, and the centring half of the difference after that, so
   no inner wrapper is needed.
   ------------------------------------------------------------------------ */

.dirks-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding-top: 16px;
    padding-bottom: 16px;
    padding-left: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    padding-right: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    border-bottom: 1px solid var(--dirks-rule);
    background: var(--dirks-header-ground);
}

.dirks-brand {
    display: inline-block;
}

.dirks-brand img {
    display: block;
    width: auto;
    height: var(--dirks-logo-height);
}

.dirks-nav a {
    font-weight: 500;
}

/* The hub navigation, which the renderer emits below the header on every
   page of a library with a Live hub. A White band,
   its content on the header's column, by the header's own
   padding. The links run in one row that wraps, 16 pixels apart, in Inter
   500 at the metadata size. Each is Green and always underlined, turns Mid
   Gray on hover, and takes the 2 pixel Green focus ring 2 pixels off the
   link. The current hub's link is Inter 600 in Mid Gray and keeps its
   underline, so it is marked by weight as well as colour. */
.kb-hub-nav {
    padding-top: 12px;
    padding-bottom: 12px;
    padding-left: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    padding-right: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    background: var(--dirks-ground);
}

.kb-hub-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.kb-hub-nav li {
    margin: 0;
}

.kb-hub-nav a {
    color: var(--dirks-link);
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-meta);
    font-weight: 500;
    text-decoration: underline;
}

.kb-hub-nav a:hover {
    color: var(--dirks-link-hover);
}

.kb-hub-nav a:focus-visible {
    outline: 2px solid var(--dirks-focus);
    outline-offset: 2px;
}

.kb-hub-nav .kb-hub-nav-current {
    color: var(--dirks-text);
    font-weight: 600;
}


/* ------------------------------------------------------------------------
   5. The page column
   One centred reading column, 720 pixels at its widest, with a 24 pixel
   gutter either side.
   ------------------------------------------------------------------------ */

.kb-main {
    box-sizing: content-box;
    max-width: var(--dirks-column);
    margin: 0 auto;
    padding: 40px var(--dirks-gutter) 64px;
}


/* ------------------------------------------------------------------------
   6. The title block
   A short Orange rule above the H1. The question one step under it, and the
   credit line, the role line, and the dates in the metadata size.

   The hub headline and the source description are the lead of their own
   pages. The specification names their classes and not their treatment, and
   they take the lead size here, as the takeaway does, without its edge.
   ------------------------------------------------------------------------ */

.kb-main h1::before {
    content: "";
    display: block;
    width: 64px;
    height: 4px;
    margin-bottom: 20px;
    background: var(--dirks-accent);
}

.kb-question {
    font-size: var(--dirks-size-lead);
    font-weight: 500;
    line-height: var(--dirks-leading-heading);
}

.kb-credit-line,
.kb-author-role,
.kb-dates {
    margin-bottom: 0.5em;
    font-size: var(--dirks-size-meta);
    font-weight: 400;
}

.kb-dates {
    margin-bottom: 1.5em;
}

.kb-date-modified {
    margin-left: 1em;
}

.kb-headline,
.kb-description {
    font-size: var(--dirks-size-lead);
}


/* ------------------------------------------------------------------------
   7. The content
   The takeaway carries a Green edge. An address shown as text, the link out
   and the citation alike, is set in the data face.
   ------------------------------------------------------------------------ */

.kb-takeaway {
    margin: 0 0 1.5em;
    padding-left: 16px;
    border-left: 4px solid var(--dirks-takeaway-edge);
    font-size: var(--dirks-size-lead);
}

.kb-takeaway p {
    margin: 0;
}

.kb-link-out {
    font-family: var(--dirks-font-data);
    font-size: var(--dirks-size-data);
    overflow-wrap: anywhere;
}


/* ------------------------------------------------------------------------
   8. The call to action
   An Orange rule across the top of the block. The heading takes the H3
   treatment. The action is outlined: a White ground, a 2 pixel Orange
   border, and a Mid Gray label with no underline, which turns White on a Mid
   Gray ground on hover.
   ------------------------------------------------------------------------ */

.kb-cta {
    margin: 48px 0 0;
    padding-top: 20px;
    border-top: 4px solid var(--dirks-accent);
}

.kb-cta h2 {
    margin-top: 0;
    font-family: var(--dirks-font-display);
    font-size: var(--dirks-size-h3);
    font-weight: 600;
}

.kb-cta-action {
    display: inline-block;
    padding: 10px 24px;
    border: 2px solid var(--dirks-action-border);
    background: var(--dirks-action-ground);
    color: var(--dirks-action-text);
    font-family: var(--dirks-font-body);
    font-weight: 600;
    text-decoration: none;
}

.kb-cta-action:hover {
    background: var(--dirks-action-hover-ground);
    color: var(--dirks-action-hover-text);
}


/* ------------------------------------------------------------------------
   9. The credit block
   A Mid Gray rule above it. The heading names the block rather than opening
   a section of the article, so it takes the H4 treatment rather than the H2.
   ------------------------------------------------------------------------ */

.kb-credit {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--dirks-rule);
}

.kb-credit h2 {
    margin-top: 0;
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-h4);
    font-weight: 600;
}

.kb-credit-sources,
.kb-credit-authors {
    padding-left: 0;
    list-style: none;
}

.kb-citation {
    font-family: var(--dirks-font-data);
    font-size: var(--dirks-size-data);
    overflow-wrap: anywhere;
}


/* ------------------------------------------------------------------------
   10. The way back to the hub
   The generated left arrow, as the mpx theme carries it. The renderer emits
   the hub's name alone, and the arrow says what the link is for.
   ------------------------------------------------------------------------ */

.kb-hub-link {
    margin: 40px 0 0;
}

.kb-hub-link a::before {
    content: "\2190\00a0";
}


/* ------------------------------------------------------------------------
   11. The roll up and the home page lists
   Items separated by a Mid Gray rule. The title takes the H3 treatment and
   is a link. The source line is in the metadata size.
   ------------------------------------------------------------------------ */

.kb-rollup {
    margin: 32px 0 0;
    padding-left: 0;
    list-style: none;
    border-top: 1px solid var(--dirks-rule);
}

.kb-rollup-item {
    margin: 0;
    padding: 20px 0;
    border-bottom: 1px solid var(--dirks-rule);
}

.kb-rollup-title {
    margin: 0 0 0.35em;
}

.kb-rollup-summary {
    margin: 0 0 0.35em;
}

.kb-rollup-source {
    margin: 0;
    font-size: var(--dirks-size-meta);
}

.kb-lists {
    margin-top: 40px;
}

/* A hub block is a card. The border replaces the two rules the roll-up
   draws on the other pages, so the hub heading and its articles read as one
   unit. Nothing here clips overflow, so the focus outline is never cut. */
.kb-list {
    margin: 0 0 40px;
    padding: var(--dirks-card-padding);
    border: 1px solid var(--dirks-rule);
    background: var(--dirks-ground);
}

.kb-list h2 {
    margin-top: 0;
}

.kb-list .kb-rollup {
    margin-top: 16px;
    border-top: 0;
}

.kb-list .kb-rollup-item {
    border-bottom: 0;
}

.kb-list .kb-rollup-item + .kb-rollup-item {
    border-top: 1px solid var(--dirks-rule);
}

.kb-list .kb-rollup-item:first-child {
    padding-top: 0;
}

.kb-list .kb-rollup-item:last-child {
    padding-bottom: 0;
}


/* ------------------------------------------------------------------------
   12. The footer band
   Mid Gray with White text, full width, its content on the page column.
   The site title and the tagline share the first line. The standing page
   links sit in one row below them, which wraps, and the copyright line sits
   below the row. Both are Inter 400 at 0.9 times body. Each link is White
   and always underlined, because Green does not carry on the Mid Gray band,
   and on keyboard focus it carries a 2 pixel White outline set 2 pixels off
   the link.
   ------------------------------------------------------------------------ */

.kb-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
    margin-top: 64px;
    padding-top: 24px;
    padding-bottom: 24px;
    padding-left: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    padding-right: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    background: var(--dirks-footer-ground);
    color: var(--dirks-footer-text);
    font-size: var(--dirks-size-meta);
}

.kb-footer-title,
.kb-footer-tagline,
.kb-footer-links,
.kb-footer-copyright {
    margin: 0;
}

.kb-footer-title {
    font-weight: 600;
}

.kb-footer-links {
    display: flex;
    flex-wrap: wrap;
    flex-basis: 100%;
    gap: 8px 24px;
    padding-left: 0;
    list-style: none;
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-meta);
    font-weight: 400;
}

.kb-footer-links li {
    margin: 0;
}

.kb-footer-links a,
.kb-footer-links a:hover {
    color: var(--dirks-footer-link);
    text-decoration: underline;
}

.kb-footer-links a:focus-visible {
    outline: 2px solid var(--dirks-footer-focus);
    outline-offset: 2px;
}

.kb-footer-copyright {
    flex-basis: 100%;
    font-family: var(--dirks-font-body);
    font-size: var(--dirks-size-meta);
    font-weight: 400;
}


/* ------------------------------------------------------------------------
   13. The renderer's own header
   Emitted only where the library authors no navigation of its own. A dirks
   library authors its own, so this renders only if that is cleared, and it
   then takes the shape the dirks header has.
   ------------------------------------------------------------------------ */

.kb-header {
    padding-top: 16px;
    padding-bottom: 16px;
    padding-left: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    padding-right: max(var(--dirks-gutter), calc((100% - var(--dirks-column)) / 2));
    border-bottom: 1px solid var(--dirks-rule);
    background: var(--dirks-header-ground);
}

.kb-logo {
    display: inline-block;
}

.kb-logo img {
    display: block;
    width: auto;
    height: var(--dirks-logo-height);
}


/* ------------------------------------------------------------------------
   14. Narrow screens
   Below 600 pixels the body steps down to 16 pixels, which moves every size
   written against it, and the logo steps down to 32 pixels. The gutter
   holds at 24.
   ------------------------------------------------------------------------ */

@media (max-width: 599px) {

    :root {
        --dirks-size-body: 16px;
        --dirks-logo-height: 32px;
        --dirks-card-padding: 16px;
    }
}
