/* Our additions to Apache Answer's CSS (public/static/answer/, unmodified) for the qa "answer" skin
   (src/archetypes/qa/skins/answer/Layout.astro). Light mode only. */

/* The shared components' tokens (public/static/components/components.css), in Answer's (Bootstrap's) colours. */
:root {
    --c-border: var(--bs-border-color);
    --c-surface: var(--bs-gray-100);
    --c-card: var(--bs-body-bg);
    --c-muted: var(--bs-secondary-color);
    --c-accent: var(--bs-primary);
    --c-on-accent: #fff;
    --c-title-bar: var(--bs-gray-200);
    --c-group-bar: var(--bs-gray-100);
    --c-new-link: var(--bs-danger);
    --c-warning: var(--bs-danger);
    --c-input-border: var(--bs-border-color);
    --c-space: 1rem;
    --c-inset: 0.75rem;
    --c-measure: none;
    --c-radius: var(--bs-border-radius);
    --c-radius-large: var(--bs-border-radius-lg);
    --c-label-weight: 600;
    --c-small: 0.875em;
    /* Q&A components: Bootstrap's success green, Answer's grey tags, square-ish avatars. */
    --c-success: var(--bs-success);
    --c-on-success: #fff;
    --c-success-soft: var(--bs-success-bg-subtle);
    --c-tag: var(--qa-tag-bg);
    --c-tag-text: var(--qa-tag-text);
    --c-heading: var(--bs-body-color);
    --c-avatar-radius: var(--bs-border-radius);
    --c-anchor-offset: 76px;
    /* Content blocks: callouts as Bootstrap alerts (each type's subtle background and border, its emphasis
       colour for the icon), steps in Answer's blue, a list-group's border for the checklist's boxes. */
    --c-callout-warning: var(--bs-warning-text-emphasis);
    --c-callout-warning-soft: var(--bs-warning-bg-subtle);
    --c-callout-warning-edge: var(--bs-warning-border-subtle);
    --c-callout-tip: var(--bs-success-text-emphasis);
    --c-callout-tip-soft: var(--bs-success-bg-subtle);
    --c-callout-tip-edge: var(--bs-success-border-subtle);
    --c-callout-note: var(--bs-primary-text-emphasis);
    --c-callout-note-soft: var(--bs-primary-bg-subtle);
    --c-callout-note-edge: var(--bs-primary-border-subtle);
    --c-step-badge: var(--bs-primary);
    --c-on-step-badge: #fff;
    --c-checkbox: var(--bs-secondary-color);
    --c-timeline-dot: var(--bs-primary);
}

/* Answer's header is 62-64px tall: anchors (#answer-2 …) land below it. */
html { scroll-padding-top: 76px; }

.qa-skip:focus { position: absolute; z-index: 1100; top: 0.5rem; left: 0.5rem; padding: 0.5rem 1rem; background: var(--bs-body-bg); }

/* The brand: the site's logo and name together (Answer shows one or the other). */
#header .navbar-brand { min-width: 0; color: #fff; font-weight: 500; }
#header .navbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#header .qa-ask { flex: none; }

/* The header's row lines up with the page under it (Answer's runs edge to edge with 16px each side): on
   wide screens the logo sits over the side navigation's icons and "Ask a question" ends where the main
   column (its right-hand cards) ends; below that the row's ends match the content's (12px on phones, 36px
   from 768px). The main column (sideNavLayout.css .main-mx-with, 1072px at most) is centred in what the
   264px side navigation leaves (240px upstream, widened below), less 24px each side (px-md-4), so its right
   edge is 50% + 668px. */
#header .qa-header-row { --qa-header-pad: 12px; padding-left: 16px; padding-right: var(--qa-header-pad); }
#header .qa-phone-search.qa-header-row { padding-left: var(--qa-header-pad); }
#header .qa-phone-search .search-wrap { left: var(--qa-header-pad); }
@media (min-width: 768px) { #header .qa-header-row { --qa-header-pad: 36px; } }
@media (min-width: 992px) { #header .qa-header-row { padding-left: 32px; } }
@media (min-width: 1200px) { #header .qa-header-row { padding-right: max(24px, calc(50% - 668px)); } }

/* Topics card: tags with their question counts. */
.qa-topics { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.qa-topic { white-space: nowrap; }

.qa-welcome > :last-child { margin-bottom: 1rem; }

/* Answer's tags are 14px; related questions in a card sit flush. */
.qa-tag { font-size: 14px; }
.qa-related .qa-questions { margin: -0.5rem 0; }

/* Content from the shared Markdown pipeline inside Answer's .fmt: MediaWiki-style headings, references, tables. */
.fmt .mw-editsection { display: none; }
.fmt table { display: block; max-width: 100%; overflow-x: auto; margin-bottom: 1rem; }
.fmt th, .fmt td { border: 1px solid var(--bs-border-color); padding: 0.375rem 0.625rem; vertical-align: top; }
.fmt th { background: var(--bs-gray-100); }
.fmt sup.reference { font-size: 0.75em; }
.fmt ol.references { font-size: 0.875rem; }
.fmt a.new { color: var(--bs-danger); }

/* The contact and question forms ({{contact form}}, {{question form}}, src/lib/templates.ts) in Bootstrap's form style. */
.wiki-contact-form { display: grid; gap: 0.375rem; max-width: 36rem; margin-bottom: 1.5rem; }
.wiki-contact-form label { font-weight: 500; margin-top: 0.5rem; }
.wiki-contact-form input:not([type="hidden"], [type="checkbox"]), .wiki-contact-form select, .wiki-contact-form textarea {
    display: block; width: 100%; padding: 0.375rem 0.75rem; font: inherit; color: var(--bs-body-color); background-color: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color); border-radius: var(--bs-border-radius);
}
.wiki-contact-form input:focus, .wiki-contact-form select:focus, .wiki-contact-form textarea:focus { border-color: var(--qa-focus-border); outline: 0; box-shadow: 0 0 0 0.25rem var(--qa-focus-ring); }
.wiki-contact-submit { justify-self: start; margin-top: 0.75rem; padding: 0.375rem 0.75rem; font: inherit; color: #fff; background: var(--bs-primary); border: 1px solid var(--bs-primary); border-radius: var(--bs-border-radius); cursor: pointer; }
.wiki-contact-submit:hover { background: var(--qa-primary-hover); }
.wiki-contact-optional, .wiki-contact-note { color: var(--bs-secondary-color); font-size: 0.875rem; font-weight: 400; }
.wiki-contact-sent { padding: 0.75rem 1rem; color: var(--bs-success-text-emphasis); background: var(--bs-success-bg-subtle); border: 1px solid var(--bs-success-border-subtle); border-radius: var(--bs-border-radius); }
.wiki-contact-form [hidden] { display: none !important; }
.wiki-contact-hint { margin: 0; color: var(--bs-secondary-color); font-size: 0.875rem; }
.wiki-contact-form label.wiki-contact-check { display: flex; align-items: flex-start; gap: 0.5rem; margin-top: 0.75rem; font-weight: 400; }
.wiki-contact-check input { flex: none; width: 1rem; height: 1rem; margin-top: 0.25rem; accent-color: var(--bs-primary); }
.error { color: var(--bs-danger); }

/* Footer: wraps on phones. */
footer > div { row-gap: 0.25rem; }

/* The drawer's copy of the side navigation (Answer renders the same #sideNav there; an id can't repeat, so
   the drawer's is #mobileNav and gets SideNav.css's rules here, all but its focus rule: see below). */
#mobileNav { max-width: 208px; }
#mobileNav .nav-link { color: var(--an-side-nav-link); }
#mobileNav .nav-link:hover { color: var(--an-side-nav-link-hover-color); background-color: var(--bs-gray-100); }
#mobileNav .nav-link.active { color: var(--an-side-nav-link-hover-color); background-color: var(--bs-gray-200); }

/* A visible focus ring on the side navigation's links. SideNav.css (vendored, unmodified) removes Bootstrap's
   (.nav-link:focus-visible { box-shadow: none }, after Bootstrap's outline: 0), which leaves keyboard users
   with none; this puts back Bootstrap's own ring, inset so the column doesn't clip it. */
/* A 2px gap between neighbouring items' backgrounds (the current one and a hovered one), taken from their
   padding so the rows keep their rhythm. */
#sideNav .nav-link, #mobileNav .nav-link { padding-top: calc(var(--bs-nav-link-padding-y) - 1px); padding-bottom: calc(var(--bs-nav-link-padding-y) - 1px); margin-bottom: 2px; }
/* A label too long for the column wraps under its own first line, not under the icon: the icon keeps a fixed
   column and the label is the flex item beside it (Answer's sizes are kept: 16px text, 8px/16px padding,
   a 16px icon and 8px gap). */
#sideNav .nav-link, #mobileNav .nav-link { display: flex; align-items: flex-start; }
#sideNav .nav-link > .icon, #mobileNav .nav-link > .icon { flex: none; height: 1lh; }
#sideNav .nav-link > span, #mobileNav .nav-link > span { min-width: 0; overflow-wrap: anywhere; }
#sideNav .nav-link:focus-visible, #mobileNav .nav-link:focus-visible { outline: 0; box-shadow: inset 0 0 0 0.2rem var(--qa-focus-ring-strong); }

/* No rule between the side navigation and the content: the column's spacing separates them. */
#pcSideNav.border-end { border-right: 0 !important; }

/* The question list (questionList: cards) lines up with the heading above it: the item's text starts at the
   column's edge, and the rules between items still run its full width. */
.qa-questions-cards .qa-question { padding-left: 0; padding-right: 0; }

/* The menu button is a link (to #mobileSideNav, so the drawer opens without JavaScript, by :target). */
#header .answer-navBar { display: inline-flex; align-items: center; }
#mobileSideNav:target { visibility: visible; transform: none; }
.qa-drawer-close { display: none; }
@media (max-width: 991.9px) { #mobileSideNav:target:not(.show) ~ .qa-drawer-close { display: block; opacity: 0.5; } }

/* Search suggestions (src/scripts/typeahead.ts, data-typeahead-class="qa-typeahead") as a Bootstrap dropdown.
   They open inside the header, which is data-bs-theme="dark": the menu takes back Bootstrap's light values. */
.qa-typeahead {
    --bs-body-color: #212529; --bs-body-bg: #fff; --bs-secondary-color: rgba(33, 37, 41, 0.75);
    --bs-border-color: #dee2e6; --bs-border-color-translucent: rgba(0, 0, 0, 0.175);
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050; margin-top: 4px; max-height: 70vh; overflow-y: auto;
    padding: 0.25rem 0; text-align: left; color: var(--bs-body-color); background: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color-translucent); border-radius: var(--bs-border-radius); box-shadow: var(--bs-box-shadow);
}
.qa-phone-search .qa-typeahead { left: 1rem; right: 1rem; }
.qa-typeahead__item { display: block; padding: 0.375rem 1rem; color: var(--bs-body-color); text-decoration: none; line-height: 1.4; }
.qa-typeahead__item:hover, .qa-typeahead__item.is-active { color: var(--bs-body-color); background: var(--bs-gray-100); }
.qa-typeahead__title { display: block; }
.qa-typeahead mark { padding: 0; color: inherit; background: none; font-weight: 600; }
.qa-typeahead__via, .qa-typeahead__desc { display: block; color: var(--bs-secondary-color); font-size: 0.875rem; }
.qa-typeahead__via { font-style: italic; }
.qa-typeahead__desc { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qa-typeahead__heading { margin-top: 0.25rem; padding: 0.5rem 1rem 0.125rem; color: var(--bs-secondary-color); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; border-top: var(--bs-border-width) solid var(--bs-border-color); }
.qa-typeahead__footer { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; border-top: var(--bs-border-width) solid var(--bs-border-color); color: var(--bs-primary); }
.qa-typeahead__footer:hover, .qa-typeahead__footer.is-active { color: var(--bs-primary); }

/* Phones: the header's search box on its own row (the search icon opens it). */
#header .qa-phone-search .search-wrap { top: 0.5rem; }

/* The search page (src/components/search.ts renderFoundSearch). Its field is the header's (#header
   .placeholder-search, a Bootstrap .form-control with the search icon inside on the left), larger: 1px border in
   the cards' colour, Bootstrap's radius, a normal-weight placeholder in the muted colour. Enter searches; the
   submit button is for the other skins. The results are the question list (cards) and keep its styles. */
.qa-search-page { position: relative; display: flex; margin-bottom: 1rem; }
.qa-search-page::before { content: "\F52A"; position: absolute; top: 50%; left: 1rem; transform: translateY(-50%); color: var(--bs-secondary-color); font-family: "bootstrap-icons"; font-size: 1.25rem; line-height: 1; pointer-events: none; }
.qa-search-page .qa-search-icon, .qa-search-page .qa-search-submit { display: none; }
.qa-search-page input { flex: 1; min-width: 0; height: calc(1.5em + 1rem + 2px); padding: 0.5rem 1rem 0.5rem 3rem; font: inherit; font-size: 1.25rem; font-weight: 400; line-height: 1.5; color: var(--bs-body-color); background: var(--bs-body-bg); border: var(--bs-border-width) solid var(--bs-border-color); border-radius: var(--bs-border-radius); }
.qa-search-page input::placeholder { color: var(--bs-secondary-color); opacity: 1; }
.qa-search-page input:focus { border-color: var(--qa-focus-border); outline: 0; box-shadow: 0 0 0 0.25rem var(--qa-focus-ring); }
.qa-search-status { margin: 0 0 0.5rem; color: var(--bs-secondary-color); font-size: 0.875rem; }
.qa-search-status:empty { display: none; }
.qa-search-more button { padding: 0.375rem 0.75rem; color: var(--bs-primary); background: none; border: var(--bs-border-width) solid var(--bs-primary); border-radius: var(--bs-border-radius); font: inherit; }
.qa-search-more button:hover { color: #fff; background: var(--bs-primary); }
.qa-found-list mark { padding: 0; color: inherit; background: none; font-weight: 600; }

/* Colours a site can change (in its public/static/sites/<id>/site.css, after this file). Bootstrap's root
   variables (--bs-primary, --bs-link-color, --bs-success, --bs-body-bg, --bs-gray-100 …) are variables already;
   these are the colours Bootstrap and Answer compile into their rules, given back as variables with the same
   values, so a site that sets --bs-primary can set these to match. */
:root {
    --qa-primary-hover: rgb(0, 43, 217);
    --qa-primary-active: rgb(0, 41, 204);
    --qa-focus-border: hsl(228, 100%, 75%);
    --qa-focus-ring: rgba(0, 51, 255, 0.25);
    --qa-focus-ring-strong: rgba(0, 51, 255, 0.5);
    --qa-header-search-bg: hsla(0, 0%, 100%, 0.2);
    --qa-header-search-border: hsla(0, 0%, 100%, 0.2);
    --qa-header-search-placeholder: hsla(0, 0%, 100%, 0.75);
    /* The header's own controls (the menu and search icons, the brand): their colour, on hover, and the
       focus outline, all light on the dark bar. */
    --qa-header-fg: #fff;
    --qa-header-fg-hover: hsla(0, 0%, 100%, 0.75);
    --qa-header-focus: hsla(0, 0%, 100%, 0.85);
    --qa-tag-bg: #e9ecef;
    --qa-tag-text: #495057;
}
.btn-primary {
    --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--qa-primary-hover); --bs-btn-hover-border-color: var(--qa-primary-hover);
    --bs-btn-active-bg: var(--qa-primary-active); --bs-btn-active-border-color: var(--qa-primary-active);
    --bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn-outline-primary {
    --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.form-control:focus, .form-select:focus { border-color: var(--qa-focus-border); box-shadow: 0 0 0 0.25rem var(--qa-focus-ring); }
.nav-link:focus-visible { box-shadow: 0 0 0 0.25rem var(--qa-focus-ring); }
#header.theme-dark .placeholder-search { background-color: var(--qa-header-search-bg); border-color: var(--qa-header-search-border); }
#header.theme-dark .placeholder-search:focus { border-color: #dee2e6; }
#header.theme-dark .placeholder-search::placeholder { color: var(--qa-header-search-placeholder); }
/* The header's icon controls take its foreground colour, not Bootstrap's dark-theme link blue (the search
   icon is a .nav-link outside a .navbar-nav) or the toggler's 55% white; the menu icon (inline SVG) is
   drawn in the same colour. Focus: an outline in the header's focus colour on every link and control. */
#header .nav-link, #header .navbar-toggler { color: var(--qa-header-fg); }
#header .nav-link:hover, #header .nav-link:focus, #header .navbar-toggler:hover { color: var(--qa-header-fg-hover); }
#header .qa-menu-icon { display: block; width: 1.5em; height: 1.5em; }
#header :is(a, button):not(.btn):focus-visible { outline: 2px solid var(--qa-header-focus); outline-offset: 2px; box-shadow: none; }
.badge-tag { color: var(--qa-tag-text); background: var(--qa-tag-bg); }

/* The answers' heading scale (components.css: title > h3 > h4): Answer's `.fmt h2/h3/h4` force 1.5rem,
   1.25rem and 1rem with !important, so the same sizes are set here with it. */
.fmt .qa-answer .qa-answer-title { font-size: var(--c-qa-title-size) !important; }
.fmt .qa-answer .qa-answer-body h3 { font-size: var(--c-qa-h3-size) !important; }
.fmt .qa-answer .qa-answer-body h4 { font-size: var(--c-qa-h4-size) !important; }
/* …but a folded reference list's heading is its small summary (components.css .mw-references-details). */
.fmt .qa-answer .qa-answer-body .mw-references-details > summary > :is(h2, h3, h4) { font-size: var(--c-small) !important; margin: 0; }
/* Answer spaces `.fmt` headings 2rem above and 0.5rem below; the answers' headings take a fifth less. */
.fmt .qa-answer { --c-qa-heading-above: 1.6rem; --c-qa-heading-below: 0.4rem; }
/* A question's right-hand column: "Answers on this page" (and related questions under it) stays in view on
   wide screens, where the column sits beside the answers, below the sticky header (64px). */
@media (min-width: 1200px) {
    /* Answer's main area is overflow-x: hidden, which would make it the sticky box's scroll container (so it
       never sticks); clip hides the same overflow without that. */
    .qa-view-question .flex-fill.overflow-x-hidden { overflow-x: clip !important; }
    .qa-side-sticky { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow-y: auto; }
}
/* The answer being read (set by the skin's script). */
.qa-onpage .list-group-item:has(a[aria-current]) { background: var(--bs-tertiary-bg); }
.qa-onpage a[aria-current] { font-weight: 600; }
/* Phones: the page's h1 (a question, a topic, "All questions", a site page) is the most prominent text, well
   above the answers' titles; Answer sizes its h1s with !important utilities (.fs-5, QuestionDetail's h1.h3). */
@media (max-width: 767.98px) {
    #content h1 { font-size: 1.75rem !important; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
}

/* Icons: inline SVG from this skin's icon pack (Remix Icon; src/components/icon.ts, src/archetypes/qa/skins/icons.ts),
   1em in the text's colour, sitting on the text as Bootstrap Icons' font did. */
.icon { flex: none; vertical-align: -0.125em; }
#header .search-wrap .search-icon { display: block; }
.qa-heading-icon { color: var(--bs-primary); vertical-align: -0.1em; }
.qa-typeahead__icon { display: inline-flex; }

/* A folded reference list's chevron (components.css draws it with borders): the skin's icon pack's chevron-down
   (Remix Icon arrow-down-s-line, as in src/components/icons/remix.ts), as a mask in the text's colour, pointing right when closed. */
.mw-references-details > summary::before { width: 0.9em; height: 0.9em; border: 0; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 13.17l4.95-4.95 1.41 1.41L12 16 5.64 9.64l1.41-1.41L12 13.17z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 13.17l4.95-4.95 1.41 1.41L12 16 5.64 9.64l1.41-1.41L12 13.17z'/%3E%3C/svg%3E") center / contain no-repeat; transform: rotate(-90deg); }
.mw-references-details[open] > summary::before { transform: none; }

/* The side navigation a little wider than Answer's (264px, not 240px) with slightly smaller (15.5px), tighter items, so
   longer topic names fit on one line. */
@media (min-width: 992px) { #pcSideNav { width: 264px; } }
#sideNav { max-width: 232px; }
#sideNav .nav-link, #mobileNav .nav-link { font-size: 0.96875rem; line-height: 1.4; padding-top: 5px; padding-bottom: 5px; }
