* {
  box-sizing: border-box;
}

:root {
  --transition-duration: 200ms;
  --seed: 280;

  --light-primary: hsl(var(--seed) 50% 70%);
  --light-background: hsl(var(--seed) 10% 95%);
  --light-surface: hsl(var(--seed) 10% 90%);
  --light-foreground: hsl(var(--seed) 10% 20%);

  --dark-primary: hsl(var(--seed) 50% 80%);
  --dark-background: hsl(var(--seed) 10% 5%);
  --dark-surface: hsl(var(--seed) 10% 13%);
  --dark-foreground: hsl(var(--seed) 10% 95%);

  --primary: light-dark(var(--light-primary), var(--dark-primary));
  --background: light-dark(var(--light-background), var(--dark-background));
  --surface: light-dark(var(--light-surface), var(--dark-surface));
  --foreground: light-dark(var(--light-foreground), var(--dark-foreground));
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary-filter: brightness(0) saturate(100%) invert(97%) sepia(4%)
      saturate(4271%) hue-rotate(192deg) brightness(93%) contrast(104%);
    --background-filter: brightness(0) saturate(100%) invert(4%) sepia(10%)
      saturate(778%) hue-rotate(236deg) brightness(102%) contrast(100%);
  }
}

html,
body {
  padding: 0;
  margin: 0;
}

html {
  color-scheme: light dark;
  background: var(--background);
  color: var(--foreground);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 90vh;

  #brand {
    font-size: 3.9rem;
    margin-bottom: 0.5rem;
    font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif;
    color: var(--primary);
    font-weight: bold;
    font-style: italic;
  }

  #random {
    margin-top: 0.3rem;
  }
}

button {
  cursor: pointer;
}

hr {
  border-color: var(--surface);
  background-color: var(--surface);
  color: var(--surface);
}

a {
  color: var(--primary);
  text-decoration: none;
  border-radius: 0.2rem;
  transition: all ease-in-out var(--transition-duration);
  padding: 0.1rem 0.2rem;
}

a.link:hover {
  background: var(--primary);
  color: var(--background);
}

button, .button {
  background: var(--primary);
  color: var(--background);
  padding: 0.5rem 1rem;
  border-radius: 0.7rem;
  display: flex;
  gap: 0.5rem;

  img {
    height: 1.2rem;
  }

  &:hover {
    cursor: pointer;
    filter: brightness(1.1);
  }
}

.floating-button {
  aspect-ratio: 1/1;
  border-radius: 1rem;
  border: none;
  background: var(--surface);
  align-content: center;

  img {
    height: 1.5rem;
    filter: var(--primary-filter);
  }
}

#search-container {
  width: 100%;
  display: flex;
  padding: 1rem 0.5rem;
  justify-content: center;

  #searchbar {
    --radius: 1rem;

    display: flex;
    padding-left: 0.9rem;
    border-radius: var(--radius);
    width: min-content;
    background: var(--surface);

    input[type="text"],
    button[type="submit"] {
      outline: none;
      background: none;
      border: none;
    }

    input[type="text"] {
      font-size: 1.1rem;
      width: min(30rem, 70vw);
    }

    button[type="submit"] {
      border-radius: var(--radius);
      padding: 0.4rem 0.9rem;
      transition: background ease-in-out var(--transition-duration);

      img {
        filter: var(--primary-filter);
        transition: filter ease-in-out var(--transition-duration);
      }
    }

    button[type="submit"]:hover {
      background: var(--primary);

      img {
        filter: var(--background-filter);
      }
    }
  }
}

#results-container {
  display: flex;
  flex-direction: column;
  margin-inline: 1rem;
  gap: 1rem;

  .result {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 0.7rem;
    background: var(--surface);

    .result-aside a {
      font-size: 1.2rem;
      font-weight: bold;
    }

    .result-thumbnail {
      max-width: 30%;
      border-radius: 0.2rem;
    }
  }
}

/* table of contents */
#toc {
	margin: 1rem 2rem;

  #toc-toggle {
    position: fixed;
    bottom: 1rem;
    right: 2rem;
  }
	
	#toc-contents:popover-open {
	  position: fixed;
	  inset: initial;
	  right: 2rem;
	  bottom: 5rem;
	  border: none;
	  border-radius: 0.5rem;
	  padding: 0.5rem 1rem;

	  h4 {
	    margin: 0.3rem 0 0.7rem 0;
	  }

  	div {
  			margin: 0.2rem 0;  	
  	}

    details {
      &[open]::details-content {
        margin: 0.3rem 1.5rem;
      }

      summary::marker {
        color: var(--primary);
      }
    }
  }
}

#article {
  margin: 0rem auto;
  padding: 0rem 1rem;
  max-width: 1400px;

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    & > a {
      color: var(--foreground);
    }
  }

  a {
    padding: 0;
  }

  img {
    display: block;
    max-width: 100%;
    border-radius: 1rem;
    max-height: 60vh;
    margin: 1rem auto;
  }

  table {
    background: var(--surface);
    /* START - add rounded corners to the table */
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0.5rem;
    border: 1.5px solid var(--foreground);

    td, th {
      border-left: 1.5px solid var(--foreground);
      border-top: 1.5px solid var(--foreground);
      padding: 0.5rem;
    }

    tr:first-child > td, tr:first-child > th {
      border-top: none;
    }

    td:first-child, th:first-child {
       border-left: none;
    }
    /* END - add rounded corners to the table */
  }

  dl {
    dt {
      font-weight: bold;
      text-decoration: underline;
    }

    dd {
      padding: 0.5em 0;
    }
  }

  figure {
    figcaption {
      text-align: center;
    }
  }

  .gallery {
    display: flex;
    max-width: 100%;
    overflow-x: scroll;
    align-items: center;

    figure {
      margin: 1rem;
    }
  }

  table.infobox {
    th:first-child, td:first-child {
      font-weight: bold;
    }

    img {
      max-width: 40vw;
    }

    ul, ol {
      margin: 0;
      padding-inline: 1.2rem;
    }
  }
}

footer {
  padding-bottom: 10px;

  #footer-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 0.2rem;

    .footer-info {
      font-size: 0.8rem;
    }
  }
}
