/* Plain on purpose: black on white, one font, thin grey lines, standard links. */
:root {
  color-scheme: light;
  font: 14px/1.4 Arial, Helvetica, sans-serif;
  color: #000;
  background: #fff;
  /* the space around everything: at the left and right of the header, and around home, help,
     the contents and the item, the header's line included, so that every page starts as far below it */
  --pad: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
a { color: #00c; }
a:visited { color: #00c; }
button, select, input { font: inherit; color: #000; }
button, select, input[type="search"] {
  border: 1px solid #767676;
  border-radius: 0;
  background: #fff;
  padding: 2px 6px;
}
button { cursor: pointer; }
h1 { font-size: 15px; margin: 0; }
h2 { font-size: 14px; margin: 16px 0 6px; }

/* ---------- header: one line of the same height on every page */
.bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0 20px;
  height: 36px;
  padding: 0 var(--pad);
  border-bottom: 1px solid #ccc;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.bar::-webkit-scrollbar { display: none; }
.bar > * { flex: none; }
/* "WDS BMW E87, E90, E89": the part that gives way when the line is short */
.bar > .title { flex: 0 1 auto; min-width: 12em; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
/* home and help: "WDS" alone, the languages right after it */
.bar:not(.on-model) > .title { flex: none; min-width: 0; }
.bar.compact > .title { min-width: 4em; }
.title a, .title a:visited { color: #000; text-decoration: none; }
.title a:hover { text-decoration: underline; }
.bar > .spacer { flex: 1 1 0; min-width: 0; }
.offline { display: flex; align-items: center; gap: 6px; }
.offline:empty { display: none; }
.bar > .break { display: none; }
.help-link[aria-current] { font-weight: bold; color: #000; text-decoration: none; }
.toc { display: none; }

/* language links: the current one is plain bold text, missing ones struck through */
.choices { display: flex; gap: 0 8px; margin: 0; }
.choices .current { font-weight: bold; }
/* where the header's links do not fit (narrow screens, many languages) they are lists */
.bar .choices select { display: none; field-sizing: content; max-width: 6em; padding: 1px 2px; }
.bar.compact .choices > :not(select) { display: none; }
.bar.compact .choices select { display: inline-block; }
.bar.compact { gap: 0 10px; }
.choices .missing { color: #777; text-decoration: line-through; }

/* ---------- home */
.home { padding: var(--pad) var(--pad) 32px; overflow: auto; flex: 1; }
.home > * { max-width: 60rem; }
/* the contents keep room for their scrollbar, so opening a folder does not change their width;
   home and help do not, so that their right edge is as far in as their left */
.tree, .hits { scrollbar-gutter: stable; }
.home h1 { font-size: 18px; margin-bottom: 12px; }
/* the box and its button on one line, on any screen, as wide as the page */
.search { display: flex; gap: 6px; max-width: none; margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; }
.models, .saved { list-style: none; padding: 0; margin: 0; }
/* Columns of a fixed width: the list is as wide as a whole number of columns and the gaps between
   them, so the columns do not slide while the window is resized (stretched ones would), until one more fits. */
.models { columns: 10rem; column-gap: 1rem; width: max(10rem, round(down, 100% + 1rem, 11rem) - 1rem); }
.models li, .saved li { padding: 1px 0; }
.results { list-style: none; padding: 0; margin: 6px 0 16px; }
.results li { margin: 0 0 6px; }
.results small, .note { color: #555; }
.error { color: #c00; }

/* ---------- help */
.help h2 { font-size: 15px; margin: 20px 0 8px; }
.legend { border-collapse: collapse; margin: 0 0 8px; }
.legend td { padding: 3px 12px 3px 0; vertical-align: middle; }
.legend.symbols td { padding-bottom: 10px; }
.legend img, .help .figure { display: block; }
.legend.colours td:nth-child(2) { font-weight: bold; }
.parts { margin: 0; padding-left: 2em; }
.parts li { padding: 2px 0; }
.uses dt { font-weight: bold; margin-top: 8px; }
.uses dd { margin: 2px 0 0; }
kbd { font: 13px/1 Consolas, "Courier New", monospace; border: 1px solid #999; padding: 1px 4px; }

/* ---------- contents and item */
.work { display: flex; flex: 1; min-height: 0; }
.side {
  display: flex;
  flex-direction: column;
  /* one width on every screen: the item beside it does not slide while the window is resized */
  width: 22rem;
  flex: none;
  min-height: 0;
  border-right: 1px solid #ccc;
}
.side input { margin: var(--pad); }
.tree, .hits { flex: 1; overflow: auto; padding: 0 var(--pad) 16px; }
/* folders and leaves keep 2px inside their highlight: their arrows and icons line up with the rest */
.tree { padding-left: calc(var(--pad) - 2px); }

.tree ul { list-style: none; margin: 0; padding: 0 0 0 16px; }
.tree > ul { padding-left: 0; }
.tree summary { cursor: pointer; padding: 1px 2px; }
.tree summary:hover, .tree .leaf:hover { text-decoration: underline; }
.leaf { display: block; position: relative; padding: 1px 2px 1px 20px; color: #000; text-decoration: none; }
.leaf:visited { color: #000; }
.tree .sel { background: #ddd; }
.tree .found { background: #ff0; }

/* the kind of a leaf: the icons of WDS (see the help page) */
.leaf::before, .hits .leaf span::before {
  content: "";
  position: absolute;
  left: 2px;
  top: calc(.7em - 7px);
  width: 15px;
  height: 15px;
  background: var(--icon) no-repeat;
}
.i-schem { --icon: url("/icons/icon_schem.gif"); }
.i-comploc { --icon: url("/icons/icon_comploc.gif"); }
.i-connector { --icon: url("/icons/icon_connector.gif"); }
.i-pin { --icon: url("/icons/icon_pin.gif"); }
.i-specval { --icon: url("/icons/icon_specval.gif"); }
.i-help { --icon: url("/icons/icon_help.gif"); }
.i-check { --icon: url("/icons/icon_check.gif"); }
.i-document { --icon: url("/icons/icon_document.gif"); }
.i-measure { --icon: url("/icons/icon_measure.gif"); }

/* filter results */
.hits { list-style: none; margin: 0; }
.hits li { margin: 0 0 4px; }
.hits a { display: block; color: #000; text-decoration: none; }
.hits a:hover span { text-decoration: underline; }
.hits .leaf { padding-left: 0; }
.hits .leaf::before { content: none; }
.hits .leaf span { position: relative; padding-left: 20px; display: block; }
.hits .folder span { font-weight: bold; display: block; }
.hits small { display: block; color: #555; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* cut the path at its start: the nearest folders say the most */
.hits small { direction: rtl; text-align: left; }
.hits small bdi { direction: ltr; }
.hits .leaf small { padding-left: 20px; }
.hits .none { color: #555; }
.hits .all a { color: #00c; text-decoration: underline; }


.item { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; position: relative; background: #fff; }
.item-head { padding: var(--pad); border-bottom: 1px solid #ccc; }
/* the item's folders, and at the right the release it comes from: the folders give way first */
.item-line { display: flex; gap: 12px; color: #555; font-size: 12px; }
.crumbs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.release { flex: none; white-space: nowrap; }
.crumbs span + span::before { content: " › "; }
.item h1:empty { display: none; }
/* the item's tools float over the bottom right corner of the item */
.view-tools { position: absolute; right: var(--pad); bottom: var(--pad); display: flex; gap: 4px; }
.view-tools button { padding: 7px; background: #fff; line-height: 0; }
.view-tools img { display: block; }
/* Full screen turns into its way out */
#full .leave, #item:fullscreen #full .enter { display: none; }
#item:fullscreen #full .leave { display: block; }
.view { flex: 1; min-height: 0; }

.toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #000;
  padding: 6px 12px;
}

/* ---------- narrow screens: the contents are a page of their own */
@media (max-width: 760px) {
  .toc { display: inline-block; }
  .side { display: none; width: auto; flex: 1; border-right: 0; }
  .toc-open .side { display: flex; }
  .toc-open .item { display: none; }
  /* On a model's pages the header takes three rows:
       WDS BMW E87, E90, E89                    Help
       DE RU US   12.0 12.3 15.0
       Contents                       Save offline
     The first is the row of every other page and width: as tall, WDS and Help where they are
     there. Home and help keep that one row as it is, so crossing 760 px moves nothing there. */
  .bar.on-model { height: auto; flex-wrap: wrap; gap: 0 12px; overflow: visible; }
  /* the title is the row's height (the wide row's 35 px inside its line), its text centred in it */
  .bar.on-model > .title { order: 1; flex: 1 1 0; min-width: 0; padding-block: calc((35px - 1lh) / 2); }
  .bar.on-model > .help-link { order: 2; }
  .bar.on-model::before { content: ""; order: 3; flex-basis: 100%; }
  .bar.on-model > #langs { order: 4; }
  .bar.on-model > .break { order: 6; display: block; flex-basis: 100%; height: 0; }
  .bar.on-model > .toc { order: 7; }
  .bar.on-model > .offline { order: 8; margin-left: auto; }
  .bar.on-model > .spacer { display: none; }
  .bar.on-model > :is(.choices, .toc, .offline) { margin-bottom: 6px; }
  .bar.on-model > .choices { flex: 0 1 auto; flex-wrap: wrap; min-width: 0; }
}

/* ---------- printing: the item and where it comes from */
.print-head { display: none; }
.print-head {
  grid-template-columns: max-content 1fr;
  gap: 0 12px;
  margin: 0 0 8px;
  padding: 8px var(--pad);
  border-bottom: 1px solid #999;
  font-size: 13px;
}
.print-head:empty { display: none !important; }
.print-head dt { color: #555; }
.print-head dd { margin: 0; overflow-wrap: anywhere; }

@media print {
  /* an info page flows over as many pages as it takes */
  body { display: block; height: auto; }
  .bar, .side, .item-head, .view-tools, .toast { display: none !important; }
  .work, .item { display: block; }
  .print-head { display: grid; padding: 0 0 6px; font-size: 9pt; }
  /* a schematic is one page */
  body.svg-item { display: flex; flex-direction: column; height: 100vh; }
  body.svg-item .work, body.svg-item .item { display: flex; flex-direction: column; flex: 1; min-height: 0; }
}
