/* SPDX-License-Identifier: GPL-3.0-or-later */

* { box-sizing: border-box; }

html {
  --fg: #222;
  --bg: #fff;
  --muted: #6b6b6b;
  --line: #ddd;
  --soft: #f4f4f4;
  --accent: #0b62c4;
  --bad: #b3261e;
  --warn: #c99700;
  --manifest: darkgreen;
  /* Spacing: --step between blocks, --half between lines of one block,
     --side between columns and inside boxes. */
  --step: 0.8rem;
  --half: 0.4rem;
  --side: 1rem;
  font-family: "Courier New", Courier, monospace;
  /* 1rem from a 444px viewport, 0.8rem at 355px and below. */
  font-size: clamp(0.8rem, 3.6vw, 1rem);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  color-scheme: light;
}

/* Dark: the system preference unless "light" was chosen, or the choice
   "dark". The two blocks hold the same values. */
@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --fg: #dadada;
    --bg: #1c1c1e;
    --muted: #9a9a9a;
    --line: #3a3a3c;
    --soft: #2a2a2c;
    --accent: #7ab4f5;
    --bad: #f2877f;
    --warn: #e6c34a;
    --manifest: #6fbf73;
    color-scheme: dark;
  }
}
html.dark {
  --fg: #dadada;
  --bg: #1c1c1e;
  --muted: #9a9a9a;
  --line: #3a3a3c;
  --soft: #2a2a2c;
  --accent: #7ab4f5;
  --bad: #f2877f;
  --warn: #e6c34a;
  --manifest: #6fbf73;
  color-scheme: dark;
}

body {
  min-width: 375px;
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem var(--side) 3rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--half) var(--side);
  padding-bottom: var(--step);
  border-bottom: 1px solid var(--line);
}

/* One size and one weight; only titles are larger. */
h1 { font-size: 1.5rem; line-height: 1.3; }
h2 { line-height: 1.3; }
h1, h2 { font-weight: normal; }

h1, h2, p, ul { margin: 0; }
ul { padding-left: 1.3rem; }
li + li { margin-top: var(--half); }

/* Blocks of a container are one step apart. */
section > * + *,
form > * + *,
.result > * + * { margin-top: var(--step); }

form { margin-top: calc(2 * var(--step)); }
section { margin-top: calc(3 * var(--step)); }
#outcome:empty { display: none; }

a, button.link { color: var(--accent); text-decoration: none; }
a:hover, button.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

button.link {
  padding: 0;
  border: 0;
  font: inherit;
  background: none;
  text-align: left;
  cursor: pointer;
}

label { display: block; }
/* The note of a fast path, until go.js submits the form. */
.notice {
  padding: var(--half) var(--side);
  background: color-mix(in srgb, var(--warn) 20%, var(--bg));
  overflow-wrap: anywhere;
}
.notice[hidden] + * { margin-top: 0; }
.query { display: flex; gap: var(--half); }
.query input, .query button {
  padding: var(--half) var(--side);
  border: 1px solid var(--line);
  border-radius: 0;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
}
.query input { flex: 1; min-width: 0; }
.query button { cursor: pointer; }
.query button:hover { border-color: var(--accent); background: var(--soft); }

/* The prompt added by file.js, the menu of a result added by
   search-client/result.js. */
.dim { opacity: 50%; }

.status { color: var(--muted); }
.status.error { color: var(--bad); }

/* A result, its record included, is at 80% of the page size. */
.result {
  padding-top: var(--step);
  border-top: 1px solid var(--line);
  font-size: 80%;
}
/* The name of a manifest, not a link: view and raw follow it. */
.manifest { color: var(--manifest); }
.where small { display: block; font-size: inherit; color: var(--muted); }
/* The links, then the place of the record: each kept whole, on two
   lines where one is too narrow. */
.where small span { display: inline-block; }

/* A record line is up to 110 columns: the record scrolls sideways
   inside its box instead of widening the page. Its scroll bars are
   thin, in the colour of the border at 10% opacity, on no track. */
.box { border: 1px solid var(--line); }
.record {
  margin: 0;
  padding: var(--half) var(--half);
  font: inherit;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--line) 10%, transparent) transparent;
}
/* Expanded by result.js into the records around it: a box of a set
   height that scrolls both ways, the record of the result on its own
   background, as wide as its longest line. */
.box.expanded .record { overflow: auto; }
.matched {
  display: block;
  width: max-content;
  min-width: 100%;
  background: color-mix(in srgb, var(--warn) 12.5%, var(--bg));
}
mark { color: inherit; background: color-mix(in srgb, var(--warn) 40%, var(--bg)); }
/* The text of an r2value standing for a query read as bytes. */
mark.hexadecimal { background: color-mix(in srgb, #c300c3 40%, var(--bg)); }
mark.base64 { background: color-mix(in srgb, #00a3a3 40%, var(--bg)); }

footer {
  margin-top: calc(3 * var(--step));
  padding-top: var(--step);
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}
