/* The shared component stylesheet (docs/architecture.md, rule 9): every variant of every component in
   src/components/, as every skin draws it. Every wiki and docs skin loads it. qa's plain layout
   doesn't: its few components (questions, redirect, not-found) are styled by public/static/basic/basic.css.

   Tokens only. A colour, font or size that differs between skins is a custom property (--c-…), listed
   with its default below; each skin sets its own in its extras (public/static/wiki.css for the two
   wiki skins, pydocs-extra/ and furo-extra/ for the docs skins). The defaults are the python docs
   skin's light theme. Upstream theme CSS stays as it is: the wiki skins draw the infobox's and navbox's
   own box with Wikipedia's CSS, and the docs skins with public/static/docs/sphinx.css; this file draws
   what each variant adds.

   Some tokens are optional, with a default worked out from others where they are used
   (var(--c-crumbs-color, var(--c-muted))): a skin that sets its colours on <body> (Furo) then needs to set
   only the main ones. They are: --c-border-subtle, --c-crumbs-color, --c-crumbs-link,
   --c-infobox-title-padding, --c-card-title-padding, --c-card-padding, --c-card-row-border,
   --c-card-row-background and --c-card-label-color.

   Variants: src/components/registry.ts. A variant is a class or its own markup (the infobox). */
:root {
    /* Colours */
    --c-border: #ccc;               /* box and card borders, rules between rows */
    --c-surface: #f8f8f8;           /* box backgrounds */
    --c-card: #fff;                 /* a card inside a box, a navbox column */
    --c-muted: #555;                /* secondary text: descriptions, review line, breadcrumbs */
    --c-accent: #0072aa;            /* step badges, the "Start here" bar, hover borders */
    --c-on-accent: #fff;            /* text on the accent */
    --c-title-bar: #cee0f2;         /* Wikipedia's title bars: series sidebar, main page boxes */
    --c-group-bar: #e6e6ff;         /* Wikipedia's navbox group headings (navbox: columns) */
    --c-new-link: #ba0000;          /* links to pages not written yet */
    --c-warning: #b32424;
    --c-input-border: #a2a9b1;
    /* Spacing and shape */
    --c-space: 16px;                /* gaps between blocks */
    --c-inset: 13px;                /* padding inside a block */
    --c-measure: 35rem;             /* the widest a component gets, to match the skin's text (none: no cap) */
    --c-radius: 3px;
    --c-radius-large: 6px;          /* cards */
    /* Type */
    --c-label-weight: 600;          /* labels: infobox labels, card titles */
    --c-small: 0.9em;               /* the review line */
    /* Breadcrumbs: their size and colour where the skin has not already set them (the wiki's #contentSub has) */
    --c-crumbs-size: 0.875em;
    /* Infobox */
    --c-infobox-row-gap: 6px;       /* padding above and below a row's text */
    --c-infobox-line-size: 1em;     /* infobox: line */
    /* infobox: card. The docs draw it as a grid of tiles, label small above value; the wiki as one list of
       rows, label beside value, in Wikipedia's box. */
    --c-card-box-padding: 0;        /* inside the box, around the title and the list */
    --c-card-columns: repeat(auto-fill, minmax(12rem, 1fr));
    --c-card-gap: 8px;
    --c-card-row: 1fr;              /* a row's columns: 1fr = label above value */
    --c-card-row-padding: 8px 10px;
    --c-card-label-size: 0.8em;
    --c-card-label-case: uppercase;
    --c-card-label-spacing: 0.02em;
    --c-card-label-gap: 2px;
    /* infobox: the title bar's colour by page type (the class infobox-<type>). Only the wiki gives an
       infobox a type; transparent leaves the skin's own title bar. */
    --c-infobox-procedure: transparent;
    --c-infobox-test: transparent;
    --c-infobox-condition: transparent;
    --c-infobox-law: transparent;
    --c-infobox-organisation: transparent;
    --c-infobox-location: transparent;
    --c-infobox-comparison: transparent;
    --c-infobox-guide: transparent;
    /* Wikipedia's Main Page palette (mainpage: portal, twocol) */
    --c-mp-start: #eaf3ff;
    --c-mp-heading: #000;
    --c-mp-green: #f5fffa;
    --c-mp-green-bar: #cef2e0;
    --c-mp-green-edge: #a3bfb1;
    --c-mp-blue: #f5faff;
    --c-mp-blue-bar: #cedff2;
    --c-mp-blue-edge: #a3b0bf;
    --c-mp-purple: #faf5ff;
    --c-mp-purple-bar: #ddcef2;
    --c-mp-purple-edge: #afa3bf;
}

/* ---- Infobox (src/components/infobox.ts) ------------------------------------------------------------ */
/* The title bar coloured by page type, in the spirit of Wikipedia's infobox families */
.infobox-procedure .infobox-above { background-color: var(--c-infobox-procedure); color: inherit; }
.infobox-test .infobox-above { background-color: var(--c-infobox-test); color: inherit; }
.infobox-condition .infobox-above { background-color: var(--c-infobox-condition); color: inherit; }
.infobox-law .infobox-above { background-color: var(--c-infobox-law); color: inherit; }
.infobox-organisation .infobox-above { background-color: var(--c-infobox-organisation); color: inherit; }
.infobox-location .infobox-above { background-color: var(--c-infobox-location); color: inherit; }
.infobox-comparison .infobox-above { background-color: var(--c-infobox-comparison); color: inherit; }
.infobox-guide .infobox-above { background-color: var(--c-infobox-guide); color: inherit; }
.infobox-subheader {
    text-align: center;
    font-style: italic;
}

/* stacked: each label on its own row above its value, a rule between facts */
table.infobox-stacked th.infobox-label {
    padding-top: var(--c-infobox-row-gap);
    padding-bottom: 0;
}
table.infobox-stacked td.infobox-data {
    padding-top: 0;
    padding-bottom: var(--c-infobox-row-gap);
}
table.infobox-stacked tr:has(> .infobox-data) + tr:has(> .infobox-label) > * {
    border-top: 1px solid var(--c-border-subtle, var(--c-border));
}

/* card: a definition list instead of a table */
.infobox-card {
    box-sizing: border-box;
    padding: var(--c-card-box-padding);
}
.infobox-card .infobox-above {
    display: block;
    padding: var(--c-card-title-padding, var(--c-infobox-title-padding, 8px var(--c-inset)));
}
.infobox-card .infobox-list {
    display: grid;
    grid-template-columns: var(--c-card-columns);
    gap: var(--c-card-gap);
    margin: 0;
    padding: var(--c-card-padding, var(--c-inset));
}
.infobox-card .infobox-row {
    display: grid;
    grid-template-columns: var(--c-card-row);
    column-gap: 0.5em;
    padding: var(--c-card-row-padding);
    border: var(--c-card-row-border, 1px solid var(--c-border));
    border-radius: var(--c-radius);
    background: var(--c-card-row-background, var(--c-card));
}
.infobox-card .infobox-label {
    margin: 0 0 var(--c-card-label-gap);
    font-size: var(--c-card-label-size);
    font-weight: var(--c-label-weight);
    letter-spacing: var(--c-card-label-spacing);
    text-transform: var(--c-card-label-case);
    color: var(--c-card-label-color, var(--c-muted));
}
.infobox-card .infobox-data {
    margin: 0;
}
/* The wiki's rows that docs pages leave out. */
.infobox-card .infobox-subheader {
    padding: 0.2em 0.4em;
}
.infobox-card .infobox-image {
    margin: 0.3em 0;
    text-align: center;
}
.infobox-card .infobox-header,
.infobox-card .infobox-full-data {
    padding: 0.2em;
    text-align: center;
    font-weight: bold;
}
.infobox-card .infobox-full-data {
    font-weight: normal;
}

/* line: one compact line of "label: value" pairs under the title, no box. The title is for screen readers;
   header rows, full-width values and the image are left out. */
.infobox.infobox-line {
    float: none;
    clear: none;
    width: auto;
    max-width: none;
    margin: 0 0 var(--c-space);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    font-size: var(--c-infobox-line-size);
    color: var(--c-muted);
}
.infobox-line .infobox-above {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.infobox-line .infobox-subheader,
.infobox-line .infobox-image,
.infobox-line .infobox-header,
.infobox-line .infobox-full-data {
    display: none;
}
.infobox-line .infobox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 0;
    margin: 0;
}
.infobox-line .infobox-row,
.infobox-line .infobox-label,
.infobox-line .infobox-data {
    display: inline;
    margin: 0;
    vertical-align: baseline;
    line-height: inherit;
}
.infobox-line .infobox-label {
    font-weight: var(--c-label-weight);
}
.infobox-line .infobox-label::after {
    content: ": ";
}
.infobox-line .infobox-row:not(:last-child)::after {
    content: "·";
    margin: 0 0.6em;
}

/* ---- Navbox (src/components/navbox.ts): the variants beyond Module:Navbox's own box ----------------- */
/* columns: {{Navbox with columns}} */
.navbox-columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13em, 1fr));
    gap: 2px;
}
.navbox-column {
    background: var(--c-card);
}
.navbox-column-heading {
    padding: 0.25em 0.5em;
    text-align: center;
    font-weight: bold;
    background: var(--c-group-bar);
}
.navbox-column ul {
    list-style: none;
    margin: 0.3em 0.6em 0.5em;
    padding: 0;
    text-align: left;
}
.navbox-column li,
.navbox-column li a {
    margin: 0;
    padding: 0.1em 0;
    white-space: normal;
}
/* related: a plain "related articles" section */
.related-articles {
    clear: both;
    margin-top: 1.5em;
}
.related-articles-group h3 {
    margin: 0.6em 0 0.1em;
    font-size: 100%;
}
.related-articles-group .hlist {
    font-size: 95%;
}
/* Navboxes stack on narrow screens instead of overflowing */
@media (max-width: 720px) {
    .navbox-inner,
    .navbox-inner > tbody,
    .navbox-inner tr {
        display: block;
        width: 100% !important;
    }
    .navbox-inner th.navbox-group,
    .navbox-inner td.navbox-list {
        display: block;
        width: auto !important;
        text-align: left;
        white-space: normal;
    }
    .navbox-title > div {
        margin: 0 !important;
    }
}

/* ---- Series sidebar (src/components/series.ts): {{Sidebar}} ------------------------------------------ */
table.sidebar {
    float: right;
    clear: right;
    width: 22em;
    margin: 0.5em 0 1em 1em;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    padding: 0.2em;
    border-spacing: 0;
    font-size: 88%;
    line-height: 1.4em;
    text-align: center;
}
.sidebar-pretitle {
    padding: 0.4em 0.4em 0;
}
.sidebar-title {
    font-size: 125%;
    padding: 0.2em 0.4em 0.4em;
    background: var(--c-title-bar);
}
.sidebar-content {
    padding: 0 0.4em 0.4em;
}
.sidebar-heading {
    font-weight: bold;
    padding-top: 0.4em;
}
.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sidebar-list li {
    display: inline;
}
.sidebar-list li:not(:last-child)::after {
    content: " · ";
    font-weight: bold;
}
/* A long title (an Act's name) would otherwise stretch the box past its 22em. */
.sidebar-list a {
    white-space: normal;
}
@media (max-width: 640px) {
    table.sidebar {
        float: none;
        width: 100%;
        margin: 0.5em 0;
    }
}

/* ---- Breadcrumbs (src/components/breadcrumbs.ts) ------------------------------------------------------
   Where the skin places them is the skin's own CSS; this is their look.
   subpages: MediaWiki's "< Parent" line. trail: the whole trail on wide screens, "‹ Parent" on narrow ones;
   the switch is at the python skin's mobile width (1023px; a custom property can't be used in a media
   query), and furo-extra repeats it at Furo's 63em. */
.subpages,
nav.breadcrumbs {
    font-size: var(--c-crumbs-size);
    color: var(--c-crumbs-color, var(--c-muted));
}
nav.breadcrumbs a {
    color: var(--c-crumbs-link, var(--c-muted));
}
nav.breadcrumbs .crumbs-up {
    display: none;
}
@media (max-width: 1023px) {
    nav.breadcrumbs .crumbs-full {
        display: none;
    }
    nav.breadcrumbs .crumbs-up,
    nav.breadcrumbs .crumbs-here {
        display: inline-block;
        padding: 4px 0;
        text-decoration: none;
    }
}

/* ---- Review line under the title (src/components/review.ts): subtitle, title ------------------------- */
.mw-reviewed-line,
.doc-review-line {
    font-size: var(--c-small);
    color: var(--c-muted);
}
.doc-review-line {
    margin: 0 0 var(--c-space);
}

/* ---- Steps: <section class="step" data-step="n"><h2 data-step="n"><span class="step-label">Step n: </span>…
   list: the heading as written. cards / timeline: the number as a badge drawn before the heading (its
   ::before, sized in the heading's own em so it scales with h2 or h3 in any skin, centred on the line);
   the "Step n:" words stay for screen readers, at font-size 0. */
.steps-cards .step-label,
.steps-timeline .step-label {
    font-size: 0;
}
.steps-cards section.step > :is(h2, h3),
.steps-timeline section.step > :is(h2, h3) {
    display: flex;
    align-items: center;
}
.steps-cards section.step > :is(h2, h3)::before,
.steps-timeline section.step > :is(h2, h3)::before {
    content: attr(data-step);
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Half the heading's size for the number; the circle is 1.1 times the heading's size. */
    font-size: 0.5em;
    width: 2.2em;
    height: 2.2em;
    margin-right: 1.1em;
    border-radius: 50%;
    background: var(--c-accent);
    color: var(--c-on-accent);
    font-weight: 700;
    line-height: 1;
}

/* cards: each step in its own box */
.steps-cards section.step {
    box-sizing: border-box;
    max-width: var(--c-measure);
    margin: var(--c-space) 0;
    padding: 0 var(--c-inset) 2px;
    border: 1px solid var(--c-border);
    border-radius: var(--c-radius-large);
}
.steps-cards section.step > :is(h2, h3) {
    margin-top: var(--c-inset);
}

/* timeline: badges in a gutter on the left, joined by a line */
.steps-timeline section.step {
    position: relative;
    padding: 0 0 var(--c-space) 3rem;
}
.steps-timeline section.step > :is(h2, h3) {
    margin-top: var(--c-space);
}
.steps-timeline section.step > :is(h2, h3)::before {
    /* A fixed 2rem badge in the 3rem gutter, centred on the line (1rem in): the badge plus the gap fill
       the gutter, so the title starts where the step's text does. */
    font-size: 0.9rem;
    width: 2rem;
    height: 2rem;
    margin-left: -3rem;
    margin-right: 1rem;
    position: relative;
    z-index: 1;
}
.steps-timeline section.step::after {
    content: "";
    position: absolute;
    left: calc(1rem - 1px);
    top: var(--c-space);
    bottom: 0;
    width: 2px;
    background: var(--c-border);
}
.steps-timeline section.step:not(:has(+ section.step))::after {
    display: none;
}

/* ---- Page lists (src/components/page-list.ts): cards for sections (sections: cards) and the home page (home: cards) */
.doc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--c-inset);
    margin: var(--c-space) 0;
}
.doc-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--c-inset);
    border: 1px solid var(--c-border);
    border-radius: var(--c-radius-large);
    background: var(--c-card);
}
.doc-card-title {
    font-weight: var(--c-label-weight);
    font-size: 1.05em;
}
/* Links in cards and the section list are underlined on hover only: a card full of underlines is heavy. */
.doc-card a,
.doc-section-list a,
.doc-start a {
    text-decoration: none;
}
.doc-card a:hover,
.doc-section-list a:hover,
.doc-start a:hover {
    text-decoration: underline;
}
.doc-card p {
    margin: 0;
}
.doc-card-description,
.doc-card-count {
    font-size: 0.9em;
    color: var(--c-muted);
}
.doc-card-pages {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.9em;
}
.doc-card-pages li {
    margin: 0 0 4px;
}
.doc-card-more {
    margin-top: auto;
    font-size: 0.9em;
}

/* home: intro: "Start here", then the sections with their descriptions */
.doc-start {
    box-sizing: border-box;
    max-width: var(--c-measure);
    margin: var(--c-space) 0;
    padding: var(--c-inset);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-accent);
    border-radius: var(--c-radius);
    background: var(--c-surface);
}
.doc-start p {
    margin: 0;
}
.doc-start-label {
    font-size: 0.8em;
    font-weight: var(--c-label-weight);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--c-muted);
}
.doc-start-link {
    display: inline-block;
    margin: 4px 0;
    font-size: 1.15em;
    font-weight: var(--c-label-weight);
}
.doc-section-list {
    max-width: var(--c-measure);
    margin: var(--c-space) 0;
}
.doc-section-list dt {
    font-weight: var(--c-label-weight);
}
.doc-section-list dd {
    margin: 2px 0 var(--c-inset);
    color: var(--c-muted);
}

/* related: the same section's other pages after the content (list | cards) */
.doc-related {
    clear: both;
    max-width: var(--c-measure);
    margin: calc(var(--c-space) * 2) 0 var(--c-space);
    padding-top: var(--c-space);
    border-top: 1px solid var(--c-border);
}
.doc-related-title {
    margin: 0 0 8px;
    font-weight: var(--c-label-weight);
}
.doc-related ul {
    margin: 0;
    padding-left: 1.2em;
}
.doc-related li {
    margin: 0 0 4px;
}

/* ---- Previous / next cards after the content (src/components/prev-next.ts, prevNext: buttons) --------- */
.doc-prevnext {
    clear: both;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--c-inset);
    max-width: var(--c-measure);
    margin: calc(var(--c-space) * 2) 0 var(--c-space);
}
.doc-prevnext a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--c-inset);
    border: 1px solid var(--c-border);
    border-radius: var(--c-radius-large);
    text-decoration: none;
}
.doc-prevnext a:hover {
    border-color: var(--c-accent);
}
.doc-prevnext-next {
    grid-column: 2;
    text-align: right;
}
.doc-prevnext-label {
    font-size: 0.85em;
    color: var(--c-muted);
}
.doc-prevnext-title {
    font-weight: var(--c-label-weight);
}

/* ---- Main page (the wiki's mainpage component) ------------------------------------------------------- */
/* portal: a grid of topic boxes */
.mp-columns {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
}
.mp-box {
    flex: 1 1 22em;
    border: 1px solid var(--c-border-subtle, var(--c-border));
    margin-bottom: 1em;
}
.mp-box > h2 {
    margin: 0;
    padding: 0.2em 0.5em;
    font-family: sans-serif;
    font-size: 1em;
    font-weight: bold;
    border: 0;
    background: var(--c-title-bar);
}
.mp-box.mp-box-b > h2 {
    background: var(--c-mp-green-bar);
}
.mp-box > div {
    padding: 0.3em 0.8em 0.6em;
}
.mp-start {
    margin: 0 0 1em;
    padding: 0.2em 0.9em 0.6em;
    border: 1px solid var(--c-border-subtle, var(--c-border));
    background: var(--c-mp-start);
}
.mp-start h2 {
    border: 0;
    margin: 0.3em 0 0.2em;
    font-family: sans-serif;
    font-size: 1em;
    font-weight: bold;
}
.mp-start p {
    margin: 0;
}
.mp-portal .mp-box {
    flex: 1 1 18em;
}
.mp-portal .mp-box ul {
    margin-top: 0.2em;
}
.mp-lead {
    margin: 0.3em 0 0.2em;
}
.mp-outer > div p {
    margin: 0.4em 0;
}
.mp-browse {
    text-align: center;
    margin-top: 1em;
}
/* twocol: Wikipedia's Main Page boxes, with its colours */
.mp-banner {
    text-align: center;
    background: var(--c-surface);
}
.mp-upper {
    display: flex;
    gap: 1em;
    margin: 0 0 1em;
}
.mp-upper > div {
    flex: 1 1 50%;
    min-width: 0;
    border: 1px solid;
    padding-bottom: 0.4em;
}
.mp-left {
    background: var(--c-mp-green);
    border-color: var(--c-mp-green-bar) !important;
}
.mp-right {
    background: var(--c-mp-blue);
    border-color: var(--c-mp-blue-bar) !important;
}
.mp-section .mp-h2 {
    margin: 0.5em;
    padding: 0.2em 0.4em;
    font-family: sans-serif;
    font-size: 120%;
    font-weight: bold;
    color: var(--c-mp-heading);
    border: 1px solid;
}
.mp-left .mp-h2 {
    background: var(--c-mp-green-bar);
    border-color: var(--c-mp-green-edge);
}
.mp-right .mp-h2 {
    background: var(--c-mp-blue-bar);
    border-color: var(--c-mp-blue-edge);
}
.mp-section-body {
    padding: 0.1em 0.6em;
}
.mp-section-body p {
    margin: 0.3em 0;
}
.mp-lower {
    background: var(--c-mp-purple);
    border: 1px solid var(--c-mp-purple-bar);
    padding-bottom: 0.4em;
    margin-bottom: 1em;
}
.mp-lower .mp-h2 {
    background: var(--c-mp-purple-bar);
    border-color: var(--c-mp-purple-edge);
}
.mp-lower-group {
    margin: 0.4em 0;
}
@media (max-width: 720px) {
    .mp-upper {
        flex-direction: column;
    }
}
/* contents: Wikipedia's Contents pages */
.mp-contents-bar {
    text-align: center;
    border: 1px solid var(--c-border-subtle, var(--c-border));
    background: var(--c-surface);
    padding: 0.4em 0.8em;
    margin: 0 0 1em;
}
.mp-contents-lead {
    margin: 0.4em 0 0.2em;
}
.mp-contents-list {
    margin-bottom: 0.6em;
}
.mp-contents-outer dt {
    font-weight: bold;
    margin-top: 0.6em;
}
.mp-contents-outer dd {
    margin: 0 0 0.2em;
}
