:root {
  --text: #222;

  --header-text: black;
  --header-shadow: rgba(0, 0, 0, .6);
  --subheader-text: #555;

  --a-normal-text: #0773ca;
  --a-normal-underline: #aaa;
  --a-visited-text: #033b68;
  --a-visited-underline: #ccc;
  --a-hover-text: #000;
  --a-hover-underline: #000;
  --a-active-text: #cc211b;
  --a-active-underline: transparent;

  --toc-text: #555;

  --search-bg: #eee;
  --search-shadow: rgba(0, 0, 0, 0.75);
  --search-sub-text: #555;
  --search-a-focus-text: white;
  --search-a-focus-bg: var(--whatwg-green);
  --search-a-focus-sub-text: rgba(255, 255, 255, .7);

  --note-bg: #f7f7f7;
  --note-pre-bg: #fff;
  --example-text: #555;
  --xxx-bg: #fceaea;
  --warning-bg: #f6bfbd;
  --warning-border: #cc211b;

  --pre-css-text: #757575;
  --pre-border: #eee;

  --table-border: #acc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ddd;

    --header-text: white;
    --header-shadow: rgba(255, 255, 255, .6);
    --subheader-text: #bbb;

    --a-normal-text: #5ab2ff;
    --a-normal-underline: #555;
    --a-visited-text: #8f7ce3;
    --a-visited-underline: #444;
    --a-hover-text: #fff;
    --a-hover-underline: #fff;
    --a-active-text: #cc211b;
    --a-active-underline: transparent;

    --toc-text: #aaa;

    --search-bg: #111;
    --search-shadow: rgba(255, 255, 255, 0.75);
    --search-sub-text: #aaa;
    --search-a-focus-text: black;
    --search-a-focus-bg: var(--whatwg-green);
    --search-a-focus-sub-text: rgba(0, 0, 0, .7);

    --note-bg: #222;
    --note-pre-bg: black;
    --example-text: #aaa;
    --xxx-bg: #310c0c;
    --warning-bg: #310c0c;
    --warning-border: #cc211b;

    --pre-text: #ccc;
    --pre-css-text: #aaa;
    --pre-border: #222;

    --table-border: #444;
  }
}

@font-face {
  font-family: "M+2pheavy";
  src: url("mplus-2p-heavy.woff");
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: "Droid Serif";
  font-style: normal;
  font-weight: 400;
  src: local("Droid Serif"), local("DroidSerif"), url("./droidserif.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215;
}

@font-face {
  font-family: "Droid Serif";
  font-style: normal;
  font-weight: 700;
  src: local("Droid Serif Bold"), local("DroidSerif-Bold"), url("./droidserif-bold.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215;
}

@font-face {
  font-family: "Droid Serif";
  font-style: italic;
  font-weight: 400;
  src: local("Droid Serif Italic"), local("DroidSerif-Italic"), url("./droidserif-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215;
}

@font-face {
  font-family: "Droid Serif";
  font-style: italic;
  font-weight: 700;
  src: local("Droid Serif Bold Italic"), local("DroidSerif-BoldItalic"), url("./droidserif-bolditalic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215;
}

/* GENERAL ELEMENTS */

/* Resets */
body, h1, h2, h3, h4, h5, h6, p, a, ul, ol, dl, dt, dd, table, caption, th, td, fieldset, legend, blockquote {
  font-weight: normal;
  margin: 0;
  padding: 0;
  color: inherit;
  box-sizing: border-box;
}

a img, form, legend {
  border: 0;
}

fieldset, abbr {
  border: none;
}

/* Basics */

body {
  font-size: 14px;
  line-height: 1.45em;
  font-family: "Droid Serif", Georgia, serif;
  max-width: 760px;
  margin: 4em auto;
  padding: 0 1em;
}

/* Headings */

h1 {
  font-size: 300%;
}

h2:not(#about-dev-edition) {
  font-size: 160%;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  line-height: 1.5em;
  font-family: "M+2pheavy", "Helvetica Neue", Arial, Helvetica, sans-serif;
  margin: 2em 0;
}

h2 .secno {
  position: absolute;
  display: block;
  left: -2em;
  text-align: right;
}

h3 .secno, h4 .secno, h5 .secno, h6 .secno {
  display: none;
}

h3 {
  font-size: 140%;
}

h4, h5 {
  font-size: 120%;
}

h6 {
  font-size: 100%;
}

h5, h6 {
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
}

h2, h3, h4, h5, h6 {
  position: relative;
}

h3, h4, h5, h6 {
  margin: 3em 0 1em 0;
}

h4, h6 {
  font-weight: bold;
}

h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn {
  font-style: normal;
}

h2 > a.self-link {
  left: -4em;
}

/* Links */

a:link, a:visited {
  text-decoration: none;
}

a:link {
  color: var(--a-normal-text);
  border-bottom: 1px solid var(--a-normal-underline);
}

a:visited {
  color: var(--a-visited-text);
  border-bottom: 1px solid var(--a-visited-underline);
}

a:hover {
  color: var(--a-hover-text);
  border-bottom: 1px solid var(--a-hover-underline);
}

a:active {
  color: var(--a-active-text);
  border-bottom: 1px solid var(--a-active-underline);
}

/* Paragraphs and lists */

p {
  line-height: 1.7em;
}

p, ul, ol, dl {
  margin-bottom: 1em;
  max-width: 520px;
}

hr {
  display: block;
  background: none;
  border: none;
  padding: 0;
  margin: 3em 0;
  height: auto;
}

ul li ul {
  margin: 0;
}

li li {
  margin-left: 1.2em;
}

dt {
  font-weight: bold;
}

dd {
  margin-bottom: 0.5em;
}

ul.domTree li {
  margin-bottom: 0;
  list-style: none;
}

/* Tables */

table {
  border: 0;
}

table th, table td {
  border: 0;
  border-bottom: 1px solid var(--table-border);
  padding: 4px;
  vertical-align: top;
}

table th li, table td li {
  margin: 0 0 0 1.5em;
}

table caption, table th {
  text-align: left;
}

table th {
  font-weight: bold;
}

table td {
  vertical-align: top;
  padding: 0.25em 1.25em 0.25em 0em;
}

table tr, table tbody {
  border: 0px;
}

/* Code */

code, pre {
  font-family: "DejaVu Sans Mono", Inconsolata, Consolas, "Lucida Console", monospace;
  display: inline-block;
  font-style: normal;
}

pre {
  display: block;
  padding: 0.25em 0.3em;
  margin: 1em 0em 1em -2.6em;
  border: 1px solid var(--pre-border);
  white-space: pre-wrap;
}

/* Variables */

var sub {
  vertical-align: bottom;
  font-size: smaller;
  top: 0.1em;
}

var > var::before {
  content: "⟨";
  font-style: normal;
}

var > var::after {
  content: "⟩";
  font-style: normal;
}

/*
  Typographic conventions
  (https://developers.whatwg.org/introduction.html#typographic-conventions)
*/
.note, .example, .XXX, .warning, pre {
  max-width: 580px;
}

.note {
  padding: 3px;
  background-color: var(--note-bg);
}

.note pre {
  background-color: var(--note-pre-bg);
}

.example {
  color: var(--example-text);
  font-style: italic;
}

.XXX {
  background-color: var(--xxx-bg);
  padding: 0.5em;
}

.warning {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  padding: 0.5em;
}

.css::before {
  content: "CSS:";
  color: var(--pre-css-text);
  font-size: 1em;
  display: block;
  background: transparent;
}

/* Caniuse boxes */

.status {
  right: auto;
  left: calc(50% + 586px / 2 - 9em / 2);
}

/* SPECIFIC ELEMENTS */
/* Header */

header#head {
  display: flex;
  --logo-width: 100px;
  --logo-margin: 20px;
  margin-left: calc(-1 * (var(--logo-width) + var(--logo-margin)));
}

header#head hgroup {
  flex: 1;
}

header#head h1 {
  line-height: 1em;
  font-family: "M+2pheavy", "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-weight: bold;
  color: var(--header-text);
}

header#head a.logo, header#head a.logo:visited,
header#head hgroup a:link, header#head hgroup a:visited {
  border-bottom: 0;
}

header#head a {
  color: inherit;
}

header#head h1 a:hover {
  text-shadow: 0 0 5px var(--header-shadow);
}

header#head hgroup p {
  font-size: 12px;
  margin-bottom: 0.5em;
  font-family: "Droid Serif", Georgia, serif;
  font-style: italic;
  font-weight: normal;
  color: var(--subheader-text);
}

header#head .logo {
  margin-right: var(--logo-margin);
}

/* Search bar */

#search, #search input {
  width: 150px;
}

#search ol {
  z-index: 1;
  position: absolute;
  width: 25em;
  list-style: none;
  background-color: var(--search-bg);
  border-radius: 0.2em;
  box-shadow: 0 0 1em var(--search-shadow);
}

#search ol li {
  text-align: left;
}

#search ol li:first-of-type a:focus {
  border-top-left-radius: 0.2em;
  border-top-right-radius: 0.2em;
}

#search ol li:last-of-type a:focus {
  border-bottom-left-radius: 0.2em;
  border-bottom-right-radius: 0.2em;
}

#search ol li a {
  display: block;
  padding: 0.2em 0.4em;
  color: var(--text);
}

#search ol li a span {
  display: block;
  color: var(--search-sub-text);
  font-size: 0.7em;
  font-style: italic;
}

#search ol li a:focus {
  color: var(--search-a-focus-text);
  background-color: var(--search-a-focus-bg);
}

#search ol li a:focus span {
  color: var(--search-a-focus-sub-text);
}

/* Nav and table of contents */

body > nav {
  margin: 2em 0;
}

ol.toc li {
  list-style: none;
}

ol.toc .secno {
  color: var(--toc-text);
}

html.index ol.toc li {
  position: relative;
}

html.index ol.toc li .secno {
  position: absolute;
  left: -1.7em;
}

html.index ol.toc li li {
  margin-left: 1.6em;
}

html.index ol.toc li li .secno {
  left: -1.7em;
}

html.index ol.toc li li a {
  margin-left: 1em;
}

html.index ol.toc li ol ol {
  display: none;
}

html:not(.index) ol.toc li {
  margin-bottom: 0.2em;
}
html:not(.index) ol.toc ol {
  margin: 0;
}

/* About */

#about-dev-edition {
  margin: 1.5em 0 1em 0;
  font-size: 34px;
}

/* RESPONSIVE STYLES */

@media screen and (max-width: 1000px) {
  header#head {
    margin-left: 0;
  }
}

@media screen and (max-width: 767px) {
  body {
    font-size: 110%;
    line-height: 1.6em;
    max-width: 580px;
    margin: 1em auto;
    padding: 0 2em;
  }

  header#head {
    text-align: center;
    display: block;
  }

  header#head .logo {
    width: 60px;
    position: static;
    left: 0;
  }

  img {
    max-width: 100%;
    height: auto;
  }

  h2 {
    font-size: 18px;
  }

  .note, .example, .XXX, .warning, pre {
    max-width: 560px;
  }

  pre {
    margin-left: -0.6em;
    word-wrap: break-word;
  }

  h2 .secno {
    position: static;
    display: inline;
  }

 .status {
    position: static;
    margin: 0;
  }

  /* Search */
  #search {
    position: relative;
    display: block;
    width: 100%;
  }

  #search input,
  #search ol {
    margin: 0 auto;
    width: 90%;
  }

  #search ol {
    position: relative;
    box-shadow: none;
  }
}
