* {
  box-sizing: border-box;
}

:root {
  --bg-color: #fcfcfc;
  --text-main: #111;
  --text-muted: #666;
  --text-faint: #999;
  --text-ref: black;
  --link-color: #0000EE;
  --border-main: #111;
  --accent-dot: #c9bc38;
  --accent-close: #c99;
  --icon-fill: #aaa;
  --focus-ring: #0b57d0;
  --error-text: #b3261e;
  --shadow-tag: 0 1px 2px rgba(0, 0, 0, 0.16);
  --shadow-input: 0 1px 2px rgba(0, 0, 0, 0.07);
  --scrollbar-thumb: #c9c9c9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #222;
    --text-main: #ddd;
    --text-muted: #aaa;
    --text-faint: #777;
    --text-ref: #ddd;
    --link-color: #8ab4f8;
    --border-main: #ddd;
    --accent-dot: #e6db74;
    --accent-close: #e06c75;
    --icon-fill: #777;
    --focus-ring: #8ab4f8;
    --error-text: #f2b8b5;
    --shadow-tag: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-input: 0 1px 2px rgba(0, 0, 0, 0.35);
    --scrollbar-thumb: #555;
  }
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font: 12pt/14pt "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 1em 5%;
  max-width: 1600px;
}

a:link,
a:visited,
a:active {
  text-decoration: none;
  background-color: transparent;
  color: var(--link-color);
}

#container {
  display: flex;
  flex-direction: row;
  height: 100%;
  position: relative;
}

#selector {
  width: 280px;
  margin-top: 1.5em;
  padding: 10px;
  line-height: 1.55em;
  overflow-y: visible;
  border-right: 1px solid var(--bg-color);
  /* Matches background to prevent visible border by default */
}

.search-field {
  position: relative;
  display: block;
}

.noresults #selector {
  margin: 50px auto;
  width: 90%;
}

.noresults #form form {
  margin: 0 auto;
  width: 90%;
  max-width: 600px;
}

.noresults input#search {
  display: block;
  width: 100%;
}

.start {
  margin: 3em 15%;
  width: 70%;
  text-align: center;
  color: var(--text-muted);
}

.results .start {
  display: none;
}

#main {
  flex: 1;
  margin: 1.5em 1em 0 20px;
  padding: 0;
}

#count {
  color: var(--text-muted);
  font-size: 75%;
}

#rfc-list {
  padding-bottom: 6em;
}

ul {
  padding-left: 0.75em;
  list-style-type: none;
}

li {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  column-gap: 0.6em;
  line-height: 1.55em;
}

#rfc-list > li {
  margin-bottom: 0.25em;
}

li .reference {
  text-align: right;
}

li ul {
  margin: 0.25em 0 0;
  padding-left: 0;
}

li ul li {
  grid-template-columns: 4.5em 1fr;
  margin-bottom: 0.25em;
}

.noresults #main {
  display: none;
  flex: 0;
}

/* Tag clouds: flex-wrap gives even horizontal + vertical spacing and centers
   any lone wrapped tag so it doesn't read as a stray orphan. */
div.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em 0.5em;
  margin: 0.35em 0 1.1em;
}

.noresults #facets {
  max-width: 40em;
  margin: 0 auto;
}

.noresults h2.tags {
  text-align: center;
  margin: 1.5em 0 0.4em;
}

.noresults div.tags {
  justify-content: center;
  margin-bottom: 1.4em;
}

@media all and (max-width: 800px) {

  .results #facets {
    display: none;
  }

  .results #filterToggle {
    display: block;
    width: 100%;
    margin: 0.5em 0 0;
    padding: 12px;
    text-align: center;
    font: inherit;
    color: var(--link-color);
    background: none;
    border: 1px solid var(--text-faint);
    border-radius: 5px;
    cursor: pointer;
  }

  .results.filters-open #facets {
    display: block;
    margin-top: 0.75em;
  }

  .results .start em,
  .results .start em+p {
    display: none !important;
  }
}

input#search {
  width: 100%;
  font-size: 18px;
  background-color: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  box-shadow: var(--shadow-input);
  padding: 8px 32px 8px 12px;
}

input#search::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

input#search:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: var(--shadow-input), 0 0 0 1px var(--focus-ring);
}

.control {
  font-size: 85%;
}

.noresults .control {
  display: none;
}

#filterToggle {
  display: none;
}

.tag,
.tag-active {
  display: inline;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  padding: .12em .6em;
  font-size: 75%;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border: 1px solid transparent;
  border-radius: 6px;
  box-shadow: var(--shadow-tag);
  user-select: none;
  cursor: pointer;
  filter: none;
  transition: filter 0.12s ease;
}

.tag-active {
  border: 1px solid var(--border-main);
}

@media (hover: hover) {
  button.tag:hover {
    filter: brightness(0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tag {
    transition: none;
  }
}

li .tag {
  margin: 0 0 0 .75em;
  padding-top: 0.08em;
  padding-bottom: 0.08em;
  line-height: 1.2;
  vertical-align: middle;
}

h1 {
  width: 100%;
  font-size: 300%;
  text-align: center;
  margin: 0 0 1em 0;
  line-height: 1.2em;
  padding-top: 5px;
  cursor: pointer;
  user-select: none;
}

h1 .dot {
  color: var(--accent-dot);
}

h1 .fyi {
  color: var(--text-faint);
}

h2 {
  font-size: 14pt;
}

.mobile-hidden {
  display: none !important;
}

#clearSearch {
  position: absolute;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  z-index: 100;
  cursor: pointer;
  user-select: none;
  color: var(--accent-close);
  padding: 4px 8px;
}

.noresults #clearSearch {
  display: none;
}

.footer {
  width: 100%;
  margin-top: 2.5em;
  padding: 3px;
  text-align: center;
}

.octicon {
  fill: var(--icon-fill);
}

.reference {
  color: var(--text-ref);
  font-weight: 600;
}

.status-obsoleted .reference,
.level-historic .reference {
  text-decoration: line-through;
}

.refcountlink {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 75%;
  margin-left: 1em;
  white-space: nowrap;
  color: var(--link-color);
  cursor: pointer;
}

.refcountlink:hover {
  text-decoration: underline;
}

.sortlink {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--link-color);
  cursor: pointer;
}

.sortlink:hover {
  text-decoration: underline;
}

.sort-active {
  font-weight: bold;
  color: var(--text-main);
  text-decoration: none;
  cursor: default;
}

.linklike {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--link-color);
  text-decoration: underline;
  cursor: pointer;
}

.empty-state {
  margin: 2em 0;
  color: var(--text-muted);
  max-width: 55ch;
}

.error {
  color: var(--error-text);
  font-weight: 500;
}

/* Touch devices: enlarge tap targets without affecting mouse density */
@media (pointer: coarse) {
  button.tag {
    display: inline-block;
    padding: .3em .7em;
    margin-bottom: .35em;
  }

  #clearSearch {
    padding: 10px 12px;
  }

  .sortlink {
    display: inline-block;
    padding: 8px 6px;
  }
}

@media all and (max-width: 800px) {
  #container {
    flex-direction: column;
  }

  #main {
    margin: 1em 0;
  }

  #selector,
  .noresults #selector {
    width: 100%;
  }

  .start {
    margin: 2em 0;
    width: 100%;
  }

  .noresults .tags {
    width: 100%;
  }

  .results .start em,
  .results .start em+p,
  .results p.start {
    display: none !important;
  }

  .noresults #form form {
    width: 100%;
  }

  .noresults input#search {
    display: block;
    width: 100%;
  }

  #sort {
    text-align: center;
  }

  .noresults #clearSearch {
    display: none;
  }

  .results .footer {
    display: none;
  }
}

@media all and (min-width: 800px) {
  #selector {
    position: fixed;
    overflow-y: auto;
    height: 100%;
    border-right: none;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }

  #selector::-webkit-scrollbar {
    width: 10px;
  }

  #selector::-webkit-scrollbar-track {
    background: transparent;
  }

  #selector::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 10px;
    /* Transparent border + padding-box clip insets the thumb so it sits with
       breathing room from the sidebar edge rather than flush against it. */
    border: 3px solid transparent;
    background-clip: padding-box;
  }

  #shadow {
    width: 280px;
    margin-top: 1.5em;
    padding: 0;
  }
}
/* Full-text mode: the matched passages under each RFC. These are what the
   feature buys over title search, so they need to read as evidence rather
   than decoration. */
.hint {
  opacity: 0.7;
  font-size: 0.85em;
}

ul.sections {
  margin: 0.25em 0 0 0;
  padding-left: 1em;
  list-style: none;
  font-size: 0.9em;
}

ul.sections li {
  margin: 0;
  opacity: 0.85;
}

ul.sections li::before {
  content: "↳ ";
  opacity: 0.5;
}

/* Not .control: that class is hidden on the front page, which is exactly
   where the model download starts, so the progress it reports was rendered
   into a hidden element for the whole of the first use. */
#ftStatus {
  font-size: 85%;
  font-style: italic;
  opacity: 0.8;
  /* Sits under #mode, which is centred; left-justified it read as misaligned. */
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.5em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s }
}

/* The checkboxes under the search field are one group, not separate
   paragraphs. Default <p> margins put a full line between them. */
/* `.control` is on the label, not the paragraph, so target the paragraph. */
#form form > p {
  margin: 0.4em 0 0 0;
}

#form form > p:first-of-type {
  margin-top: 0.6em;
}

/* The mode selector stays on the front page, unlike the other controls.
   It is how people discover full-text search exists, and selecting it is
   what starts the model downloading -- both of which have to be possible
   before anyone has typed anything. */
.noresults #mode {
  display: block;
}

#mode {
  text-align: center;
}
