src/ui/styles.scss
@use "../../node_modules/normalize.css/normalize.css";

:root {
  // Constant variables
  --radius-standard: 999px;
  --blue: #1cb0f6;
  --bluish-white: #d4f1ff;

  // Theme-dependent variables
  --bg-color: white;
  --border-color: #e5e5e5;
  --highlight-color: #ffffba;
  --no-results-color: #d5d5d5;
  --primary-text-color: #3c3c3c;
  --secondary-text-color: #888;
  --sidebar-hover-color: var(--bluish-white);

  // @media-dependent variables
  --padding-standard: 30px;
  --logo-font-size: 35px;
  --logo-margin: -1px;
  --search-box-height: 50px;
  --search-box-padding-left: calc(var(--padding-standard) - 3px);
  --placeholder-opacity: 1;
  --sorter-display: initial;
  --sidebar-width: 250px;
  --engine-padding-left: 12px;
  --toggler-display: initial;
  --footer-display: initial;
}

@media (max-height: 700px), (max-width: 700px) {
  :root {
    --padding-standard: 5px;
    --logo-font-size: 31px;
    --logo-margin: -2px;
    --search-box-height: 40px;
    --search-box-padding-left: 15px;
    --placeholder-opacity: 0;
    --sorter-display: none;
    --sidebar-width: 180px;
    --toggler-display: none;
    --footer-display: none;
  }
}

.dark {
  --bg-color: #151c24;
  --border-color: #374251;
  --highlight-color: var(--border-color);
  --no-results-color: var(--border-color);
  --primary-text-color: var(--bluish-white);
  --secondary-text-color: #7f91aa;
  --sidebar-hover-color: var(--border-color);
}

@font-face {
  font-display: swap;
  font-family: Metasearch;
  font-style: normal;
  font-weight: 500;
  src: url(/normal.woff2) format("woff2");
}
@font-face {
  font-display: swap;
  font-family: Metasearch;
  font-style: normal;
  font-weight: 700;
  src: url(/bold.woff2) format("woff2");
}

*,
*::before,
*::after {
  box-sizing: inherit;
  // Metasearch is mostly developed and tested using the proprietary font FF Din
  // Rounded. We specify Arial instead of (the typographically superior?)
  // Helvetica as the fallback because Din's height is closer to Arial's than to
  // Helvetica's. More consistent behavior across OSes is a secondary reason for
  // using web-safe Arial.
  font-family: Metasearch, Arial, sans-serif;
  outline: none;
  transition:
    background-color 0.4s,
    color 0.4s;
}

::placeholder {
  color: var(--secondary-text-color);
  opacity: var(--placeholder-opacity);
}

html {
  box-sizing: border-box;
  font-size: 15px;
}

hr {
  border: 1px solid var(--border-color);
}

ul {
  list-style: none;
  padding: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

mark {
  background: var(--highlight-color);
  border-radius: 3px;
  color: inherit;
  font-family: inherit;
}

.theme {
  background: var(--bg-color);
  color: var(--primary-text-color);
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr auto;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

.logo {
  font-size: var(--logo-font-size);
  grid-area: 1 / 1 / 2 / 2;
  letter-spacing: -0.03em;
  margin-top: var(--logo-margin);
  padding: var(--padding-standard) var(--padding-standard)
    calc(var(--padding-standard) / 2) calc(var(--padding-standard) + 9px);
  text-transform: lowercase;
  user-select: none;
}

.header {
  grid-area: 1 / 2 / 2 / 3;
  padding: var(--padding-standard) var(--padding-standard)
    calc(var(--padding-standard) / 2) 0;
  white-space: nowrap;
}

.search-box {
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-standard) 0 0 var(--radius-standard);
  border-right: 0;
  color: inherit;
  font-size: 1.2rem;
  height: var(--search-box-height);
  max-width: 600px;
  min-width: 120px;
  padding: 0 0 0 var(--search-box-padding-left);
  vertical-align: top;
  width: calc(100% - var(--search-box-height));
}

.submit {
  background: url(/favicon.png) no-repeat 10px center;
  background-size: 20px;
  border: 2px solid var(--border-color);
  border-left: 0;
  border-radius: 0 var(--radius-standard) var(--radius-standard) 0;
  cursor: pointer;
  height: var(--search-box-height);
  padding: 0;
  vertical-align: top;
  width: var(--search-box-height);
}

.sorter {
  display: var(--sorter-display);
  grid-area: 1 / 3 / 2 / 4;
  padding: calc(var(--padding-standard) + 17px) var(--padding-standard)
    var(--padding-standard) 0;

  img {
    height: 18px;
  }

  & > * {
    vertical-align: top;

    &::after {
      content: "";
      margin: 7px;
    }

    &:last-child::after {
      display: none;
    }
  }
}

.sidebar {
  grid-area: 2 / 1 / 3 / 2;
  overflow-y: auto;
  padding: 0 var(--padding-standard);
  user-select: none;

  ul {
    display: flex;
    flex-direction: column;
    height: calc(100% - 30px);
  }

  li {
    color: var(--secondary-text-color);
    flex-grow: 1;
    max-height: 37px;
    min-height: 24px;
    padding: 0 8px 0 var(--engine-padding-left);
    transition: initial;
  }

  .engine-wrap {
    position: relative;
    top: 50%;
    transform: translateY(-50%);
  }

  .has-results {
    border-radius: var(--radius-standard);
    color: inherit;
    cursor: pointer;
    font-weight: bold;

    &:hover {
      background: var(--sidebar-hover-color);
    }

    span {
      background: var(--blue);
    }
  }

  span {
    background: var(--no-results-color);
    border-radius: 15px;
    color: var(--bg-color);
    float: right;
    font-size: 0.9rem;
    font-weight: bold;
    margin-top: -2px;
    padding: 3px 7px;
  }
}

.results {
  grid-area: 2 / 2 / 4 / 4;
  overflow-wrap: anywhere;
  overflow-y: auto;
  padding: 0 calc(2 * var(--padding-standard)) 0 var(--padding-standard);
  position: relative; // Simplifies programmatic adjustment of scroll position
  scrollbar-color: var(--border-color) transparent;
}

.result-group {
  border-bottom: 2px solid var(--border-color);
  margin-bottom: calc(var(--padding-standard) / 2);
  padding-bottom: calc(var(--padding-standard) / 2);
}

.result-group:last-child {
  border-bottom: 0;
}

h2 {
  cursor: pointer;
  display: inline-block;
  user-select: none;

  svg {
    color: #d5d5d5;
    display: var(--toggler-display);
    margin-left: -25px;
    margin-top: 2px;
    position: absolute;
    transition: transform 0.2s;
    width: 20px;
  }

  &.hide-results svg {
    transform: rotate(-90deg);
  }
}

.stats {
  color: var(--secondary-text-color);
  margin-left: 15px;
}

.result {
  margin-bottom: var(--padding-standard);
}

.title {
  font-weight: bold;
}

.modified {
  color: var(--secondary-text-color);

  &::before {
    content: "-";
    margin: 7px;
  }
}

.snippet {
  color: var(--secondary-text-color);

  img {
    // Show checkered background for partially transparent images
    background-blend-mode: normal, difference, normal;
    background-image: linear-gradient(
        to right,
        rgba(224, 224, 224, 0.9),
        rgba(224, 224, 224, 0.9)
      ),
      linear-gradient(to right, black 50%, white 50%),
      linear-gradient(to bottom, black 50%, white 50%);
    background-size: 20px 20px;

    margin: 5px 10px 0 0;
    max-height: 100px;
  }

  pre {
    white-space: pre-wrap;
  }
}

.footer {
  color: var(--secondary-text-color);
  display: var(--footer-display);
  grid-area: 3 / 1 / 4 / 2;
  padding: var(--padding-standard)
    calc(var(--padding-standard) + var(--engine-padding-left));
}
