*,
*::before,
*::after {
  border: 0;
  box-sizing: border-box;
  font: inherit;
  font-size: 100%;
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}

:root {
  height: 100%;
  min-width: 280px;

  --font-family-text: 'Open Sans', 'Arial', 'Helvetica', sans-serif;
  --font-family-stylized: 'Roboto Mono', 'DejaVu Sans Mono', 'Consolas',
    monospace;

  --color-twitter: rgb(29, 161, 242);
  --color-twitter-hover: rgba(29, 161, 242, 0.8);
  --side-offset: 6rem;
  --border-radius-small: 3px;
  --border-radius-large: 6px;

  /* Dark mode colors and assets */
  --dm-asset-svg-copy: url(./assets/copy-white.svg);
  --dm-asset-svg-copied: url(./assets/check-white.svg);
  --dm-asset-svg-external-link: url(./assets/external-link-white.svg);
  --dm-asset-svg-legal: url(./assets/legal-white.svg);
  --dm-color-background: rgb(34, 34, 34);
  --dm-color-background-transparent: rgba(20, 20, 20, 0.7);
  --dm-color-background-card: rgb(20, 20, 20);
  --dm-color-text-default: rgb(236, 236, 236);
  --dm-color-text-light: rgb(170, 170, 170);
  --dm-color-svg-default: rgb(246, 246, 246);
  --dm-color-button-border: rgb(186, 186, 186);
  --dm-color-button-hover: rgb(212, 212, 212);
  --dm-color-button-active: rgb(212, 212, 212);
  --dm-color-button-text-hover: rgb(0, 0, 0);
  --dm-color-disabled: rgb(170, 170, 170);
  --dm-color-grid-item-divider: rgb(64, 64, 64);
  --dm-color-shadow: rgba(215, 215, 215, 0.95);
  --dm-color-link: rgb(0, 100, 238);
  --dm-color-link-hover: rgb(0, 72, 238);
  --dm-color-link-visited: rgb(169, 144, 189);

  /* Light mode colors and assets */
  --lm-asset-svg-copy: url(./assets/copy.svg);
  --lm-asset-svg-copied: url(./assets/check.svg);
  --lm-asset-svg-external-link: url(./assets/external-link.svg);
  --lm-asset-svg-legal: url(./assets/legal.svg);
  --lm-color-background: rgb(252, 252, 252);
  --lm-color-background-transparent: rgba(255, 255, 255, 0.7);
  --lm-color-background-card: rgb(255, 255, 255);
  --lm-color-text-default: rgb(0, 0, 0);
  --lm-color-text-light: rgb(102, 102, 102);
  --lm-color-svg-default: rgb(0, 0, 0);
  --lm-color-button-border: rgb(51, 51, 51);
  --lm-color-button-hover: rgb(51, 51, 51);
  --lm-color-button-active: rgb(51, 51, 51);
  --lm-color-button-text-hover: rgb(255, 255, 255);
  --lm-color-disabled: rgb(170, 170, 170);
  --lm-color-grid-item-divider: rgb(204, 204, 204);
  --lm-color-shadow: rgba(0, 0, 0, 0.5);
  --lm-color-link: rgb(0, 0, 238);
  --lm-color-link-hover: rgb(52, 52, 238);
  --lm-color-link-visited: rgb(85, 26, 139);

  --grid-width: 13.5rem;
  --grid-gap: 0.75rem;
}
@media (max-width: 1280px) {
  :root {
    --side-offset: 3rem;
  }
}
@media (max-width: 860px) {
  :root {
    --side-offset: 1.5rem;
  }
}
@media (max-width: 640px) {
  :root {
    font-size: 130%;
  }
}

/* Color schemes */

:root {
  --asset-svg-copy: var(--lm-asset-svg-copy);
  --asset-svg-copied: var(--lm-asset-svg-copied);
  --asset-svg-external-link: var(--lm-asset-svg-external-link);
  --asset-svg-legal: var(--lm-asset-svg-legal);
  --color-background: var(--lm-color-background);
  --color-background-transparent: var(--lm-color-background-transparent);
  --color-background-card: var(--lm-color-background-card);
  --color-text-default: var(--lm-color-text-default);
  --color-text-light: var(--lm-color-text-light);
  --color-svg-default: var(--lm-color-svg-default);
  --color-button-border: var(--lm-color-button-border);
  --color-button-hover: var(--lm-color-button-hover);
  --color-button-active: var(--lm-color-button-active);
  --color-button-text-hover: var(--lm-color-button-text-hover);
  --color-disabled: var(--lm-color-disabled);
  --color-grid-item-divider: var(--lm-color-grid-item-divider);
  --color-shadows: var(--lm-color-shadow);
  --color-link: var(--lm-color-link);
  --color-link-hover: var(--lm-color-link-hover);
  --color-link-visited: var(--lm-color-link-visited);
}

body.dark {
  --asset-svg-copy: var(--dm-asset-svg-copy);
  --asset-svg-copied: var(--dm-asset-svg-copied);
  --asset-svg-external-link: var(--dm-asset-svg-external-link);
  --asset-svg-legal: var(--dm-asset-svg-legal);
  --color-background: var(--dm-color-background);
  --color-background-transparent: var(--dm-color-background-transparent);
  --color-background-card: var(--dm-color-background-card);
  --color-text-default: var(--dm-color-text-default);
  --color-text-light: var(--dm-color-text-light);
  --color-svg-default: var(--dm-color-svg-default);
  --color-button-border: var(--dm-color-button-border);
  --color-button-hover: var(--dm-color-button-hover);
  --color-button-active: var(--dm-color-button-active);
  --color-button-text-hover: var(--dm-color-button-text-hover);
  --color-disabled: var(--dm-color-disabled);
  --color-grid-item-divider: var(--dm-color-grid-item-divider);
  --color-shadows: var(--dm-color-shadow);
  --color-link: var(--dm-color-link);
  --color-link-hover: var(--dm-color-link-hover);
  --color-link-visited: var(--dm-color-link-visited);
}
body.light {
  --asset-svg-copy: var(--lm-asset-svg-copy);
  --asset-svg-copied: var(--lm-asset-svg-copied);
  --asset-svg-external-link: var(--lm-asset-svg-external-link);
  --asset-svg-legal: var(--lm-asset-svg-legal);
  --color-background: var(--lm-color-background);
  --color-background-transparent: var(--lm-color-background-transparent);
  --color-background-card: var(--lm-color-background-card);
  --color-text-default: var(--lm-color-text-default);
  --color-text-light: var(--lm-color-text-light);
  --color-svg-default: var(--lm-color-svg-default);
  --color-button-border: var(--lm-color-button-border);
  --color-button-hover: var(--lm-color-button-hover);
  --color-button-active: var(--lm-color-button-active);
  --color-button-text-hover: var(--lm-color-button-text-hover);
  --color-disabled: var(--lm-color-disabled);
  --color-grid-item-divider: var(--lm-color-grid-item-divider);
  --color-shadows: var(--lm-color-shadow);
  --color-link: var(--lm-color-link);
  --color-link-hover: var(--lm-color-link-hover);
  --color-link-visited: var(--lm-color-link-visited);
}

body.dark .icon-preview {
  filter: invert(1);
}

/* General */

body {
  background-color: var(--color-background);
  color: var(--color-text-default);
  display: flex;
  flex-direction: column;
  line-height: 1.4;
  min-height: 100vh;
}

button {
  background: none;
  cursor: pointer;
  outline: none;
}

ol,
ul {
  list-style: none;
}

a {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

/* Header */

.header {
  background-color: var(--color-background);
  padding: 5rem var(--side-offset);
  z-index: 10;
}
@media (max-width: 860px) {
  .header {
    padding-top: 2rem;
  }
}
@media (max-width: 640px) {
  .header {
    background-color: var(--color-background);
    padding-top: 1rem;
  }
}

.header__title {
  font-family: var(--font-family-stylized);
  font-size: 1.7rem;
  font-weight: 600;
  flex-basis: 40%;
  margin: 0 0 0.5rem;
}

.header__description {
  font-family: var(--font-family-stylized);
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.header__list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  float: right;
  justify-content: flex-end;
  margin: 0.2rem 0 0;
}
@media (max-width: 640px) {
  .header__list {
    float: none;
    justify-content: space-around;
    margin: 0 0 1rem;
  }
}

.header__list-item {
  height: 55px;
  width: 55px;
  background-color: var(--color-background);
  fill: var(--color-button-active);
}

.header__list-icon:hover,
.header__list-icon:focus {
  cursor: pointer;
  fill: var(--color-background);
  background-color: var(--color-button-active);
  border-radius: var(--border-radius-large);
}

.header__list-icon {
  padding: 10px;
  height: 100%;
  width: 100%;
  outline: none;
  display: inline-block;
  fill: var(--color-button-active);
}

/* Main */

.main {
  background-color: var(--color-background);
  flex-grow: 2;
  padding: 0 var(--side-offset) 2rem;
}

/* Control */

.sticky-header-shadow {
  box-shadow: 0 4px 1px 0 var(--color-shadows);
  height: 1px;
  position: sticky;
  width: 100%;
  top: 3.75rem;
  z-index: 9;
}
@media (max-width: 640px) {
  .sticky-header-shadow {
    display: none;
  }
}

.control {
  background-color: var(--color-background);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap-reverse;
  margin: 0 calc(-1 * var(--side-offset)) 1.2rem;
  padding: 0.8rem var(--side-offset) 1rem;
  position: sticky;
  top: -1.9rem;
  z-index: 10;
}
@media (max-width: 640px) {
  .control {
    background-color: var(--color-background);
    box-shadow: none;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
    position: relative;
  }
}

.control-field {
  display: flex;
  flex-direction: column;
  margin-right: 1rem;
}
.control-field:first-of-type {
  flex-basis: 25%;
  min-width: 260px;
}
@media (max-width: 640px) {
  .control-field {
    margin: 0.5rem 0 0.5rem 1rem;
  }
  .control-field:first-of-type {
    flex-basis: 70%;
    flex-grow: 1;
    margin: 0.5rem 0;
  }
}

.control-field__title {
  font-family: var(--font-family-stylized);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1rem;
  margin-bottom: 0.7rem;
  position: relative;
}
body.no-js .control-field__title {
  color: var(--color-disabled);
}

.control-field__row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.control__button,
.control__input {
  background-color: transparent;
  color: var(--color-text-default);
  height: 2.4rem;
  padding: 0.4rem;
}

.control__input {
  border: 0.1rem solid var(--color-button-border);
  border-radius: var(--border-radius-small);
  font-family: var(--font-family-stylized);
  outline: none;
  padding: 0.4rem 2rem 0.4rem 0.8rem;
  width: 100%;
}
.control__input:focus {
  box-shadow: 0 0 3px 0 var(--color-shadows);
}
@media (max-width: 640px) {
  .control__input {
    font-size: 1.1rem;
  }
}

.control__button {
  border: 0.1rem solid var(--color-button-border);
  border-left-width: 0;
  cursor: default; /* Button should not work when JS is disabled */
  fill: var(--color-button-hover);
  width: 2.4rem;
}

.first__button {
  border-left-width: 0.1rem;
  border-top-left-radius: var(--border-radius-small);
  border-bottom-left-radius: var(--border-radius-small);
}

.last__button {
  border-top-right-radius: var(--border-radius-small);
  border-bottom-right-radius: var(--border-radius-small);
}

.control__button:not(:disabled):focus,
.control__button:not(:disabled):hover {
  box-shadow: 0 0 3px 0 var(--color-shadows);
  cursor: pointer;
}

/* Control - disabled */

.control__input:disabled {
  border-color: var(--color-disabled);
}

.control__button:disabled {
  border-color: var(--color-disabled) !important;
  fill: var(--color-disabled);
}

/* Control - search */

.search__wrapper {
  position: relative;
}

.search-input {
  padding-right: 20px;
}

.search #search-clear {
  cursor: pointer;
  display: inline;
  font-family: var(--font-family-stylized);
  font-size: 1.5rem;
  line-height: 2.3rem;
  padding: 0 12px;
  position: absolute;
  right: 0;
  top: 0;
}
.search #search-clear::selection {
  background-color: transparent;
}

input[type='search']::-webkit-search-decoration,
input[type='search']::-webkit-search-cancel-button,
input[type='search']::-webkit-search-results-button,
input[type='search']::-webkit-search-results-decoration {
  -webkit-appearance: none;
}
input[type='search']::-ms-clear,
input[type='search']::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

/* Control - order */

body.order-alphabetically #order-alpha,
body.order-by-color #order-color,
body.order-by-relevance #order-relevance {
  background-color: var(--color-button-active);
  border-color: var(--color-button-active);
  color: var(--color-background);
  cursor: default;
  fill: var(--color-background);
}

/* Control - copy */

.copy-control-active {
  background-color: var(--color-button-active);
  border-color: var(--color-button-active);
  color: var(--color-background);
  cursor: default !important;
  fill: var(--color-background);
}

/* Control - noscript */

.control noscript {
  position: absolute;
  font-family: var(--font-family-stylized);
  font-style: italic;
  top: -2rem;
}

/* Grid */

.grid-rows-container {
  .grid {
    margin: 0 0 var(--grid-gap);
  }
}

.grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-width), 1fr));
  margin: 0 0 1.5rem;
}

.grid-item--if-empty {
  display: flex;
  grid-column: 1 / span 2;
  margin: 0 0.4rem;
}
.grid-item--if-empty p {
  font-family: var(--font-family-stylized);
  font-size: 0.9rem;
}
.grid-item--if-empty a {
  color: var(--color-link);
}
.grid-item--if-empty a:focus,
.grid-item--if-empty a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}
.grid-item--if-empty a:visited {
  color: var(--color-link-visited);
}

.grid-item {
  background-color: var(--color-background-card);
  border-radius: var(--border-radius-large);
  box-shadow: 0px 0px 3px 0px var(--color-shadows);
  contain-intrinsic-size: 0 11.25rem;
  content-visibility: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grid-item__row {
  padding: 0 1rem;
  width: 100%;
}

.grid-item__preview {
  cursor: default;
  display: block;
  margin: 1.5rem auto 1rem;
  position: relative;
}

.icon-preview {
  width: 100%;
  height: auto;
}

.grid-item__title {
  font-family: var(--font-family-text);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.5rem;
  margin: 0.4rem 0;
  padding-right: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-svg::before {
  background-color: var(--color-background-transparent);
  background-size: 1.7rem 1.7rem;

  /* Make this element behave as text when JS is disabled */
  cursor: default;
}
.copy-color::before {
  background-size: 1.2rem 1.2rem;
  background-color: inherit;

  /* Make this element behave as text when JS is disabled */
  cursor: text;
  user-select: text;
}

.grid-item__link {
  align-items: center;
  color: var(--color-text-default);
  display: flex;
  flex-direction: row;
  font-family: var(--font-family-stylized);
  font-size: 0.8rem;
  line-height: 1rem;
  margin: 0.3rem 0;
  opacity: 0.6;
  outline: none;
}
.grid-item__link:focus {
  opacity: 1;
  text-decoration: underline;
}
@media (hover: hover) {
  .grid-item__link:hover {
    opacity: 1;
    text-decoration: underline;
  }
}

.grid-item__footer {
  align-items: stretch;
  align-self: stretch;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-top: 0.4rem;
}

.grid-item__color {
  border-top: 1px solid var(--color-grid-item-divider);
  border-right: 1px solid var(--color-grid-item-divider);
  color: var(--color-button-active);
  background-color: var(--color-background);
  flex-grow: 1;
  font-family: var(--font-family-stylized);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1rem;
  padding: 8px;
  position: relative;
}
.grid-item__color.contrast-light {
  color: #fff;
}
.grid-item__footer > :last-child {
  border-right: none;
}

.grid-item__button {
  border-top: 1px solid var(--color-grid-item-divider);
  background-color: var(--color-background);
  color: var(--color-button-active);
  flex-grow: 1;
  font-family: var(--font-family-stylized);
  font-size: 0.75rem;
  font-weight: 600;
  outline: none;
  padding: 8px;
  text-align: center;
}
.grid-item__button:focus,
.grid-item__button:hover {
  background: var(--color-button-hover);
  color: var(--color-button-text-hover);
}

/* Footer */

.footer {
  align-items: center;
  background-color: var(--color-background);
  display: flex;
  font-family: var(--font-family-stylized);
  font-size: 0.9rem;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 1rem var(--side-offset) 2rem;
}

.footer-description {
  margin: 1rem;
  margin-left: 0;
}

.footer-description a {
  font-weight: 600;
}
.footer-description a:focus,
.footer-description a:hover {
  color: var(--color-button-hover);
  text-decoration: underline;
}

.footer .footer-share {
  align-items: center;
  background-color: var(--color-twitter);
  border-radius: 4px;
  color: #fff;
  display: flex;
  font-weight: normal;
  padding: 0.75rem 1.25rem;
  text-align: center;
}
@media (max-width: 640px) {
  .footer .footer-share {
    flex-grow: 1;
    justify-content: center;
  }
}
.footer .footer-share:focus,
.footer .footer-share:hover {
  background-color: var(--color-twitter-hover);
}

.footer-share--icon {
  fill: #fff;
  height: 1rem;
  margin-right: 0.75rem;
}

/* .copy-button */

.copy-button::before {
  content: '';
  background-image: var(--asset-svg-copy);
  background-position: 50% 50%;
  background-repeat: no-repeat;
  display: none;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}
.copy-button.contrast-dark::before {
  background-image: var(--lm-asset-svg-copy);
}
.copy-button.contrast-light::before {
  background-image: var(--dm-asset-svg-copy);
}
.copy-button.copied::before {
  background-image: var(--asset-svg-copied);
}
.copy-button.copied.contrast-dark::before {
  background-image: var(--lm-asset-svg-copied);
}
.copy-button.copied.contrast-light::before {
  background-image: var(--dm-asset-svg-copied);
}
.copy-button:not(:disabled).copied::before,
.copy-button:not(:disabled):focus::before {
  display: block;
  z-index: 1;
}
@media (hover: hover) {
  .copy-button:not(:disabled):hover::before {
    cursor: pointer;
    display: block;
    z-index: 1;
  }
}

/* .link-button */

.link-button::before {
  content: '';
  background-image: var(--asset-svg-external-link);
  background-size: cover;
  background-position: 50% 50%;
  height: 0.85rem;
  margin: 0.05rem 0.2rem 0.05rem 0;
  width: 0.9rem;
}
.link-button.icon-legal::before {
  background-image: var(--asset-svg-legal);
}

/* Utility */

.fg-2 {
  flex-grow: 2;
}

.hidden {
  display: none !important;
}

#copy-input.hidden {
  display: block !important;
  height: 0;
  width: 0;
}

#loader {
  display: flex;

  img {
    margin: 30px auto;
  }
}
