html {
  -webkit-text-size-adjust: 100%;
}

body, h1, p, input, figure, figcaption {
  margin: 0;
  padding: 0;
  text-align: center;
  font: normal 16px/1 'Libre Baskerville', serif;
}

body {
  background-color: #f9f9f9;
}

h1 {
  margin: 1.25em 20px 0.75em;
  line-height: 1.25;
  font-size: 1.75em;
}

p {
  max-width: 550px;
  margin: 1.25em auto 2.5em;
  padding: 0 20px;
  line-height: 1.5;
}

a {
  border-bottom: 1px solid gray;
  text-decoration: none;
  color: black;
}

main {
  max-width: calc(250px * 5 + 20px * 6); /* See comment on breakpoints. */
  margin: auto;
}

div#gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 10px;
  margin: 10px;
}

div#gallery img {
  width: 100%;
  margin-bottom: 0.4em;
  border-radius: 5px;
  cursor: pointer;
}

figcaption {
  margin-bottom: 0.75em;
  line-height: 1.1;
}

figcaption span { /* Latin names. */
  font-size: 0.75em;
  font-style: italic;
}

footer {
  margin: 2.5em 20px 3.5em;
  line-height: 1.5;
  font-size: 0.75em;
}

/* FILTERS */

button#toggle-filters {
  display: none; /* Currently only for larger screens. */
  position: absolute;
  top: 1.25em;   /* Match h1 margin-top. */
  right: 1.25em; /* Match h1 margin-top. */
  width: 1em;
  height: 1em;
  background: center / contain no-repeat url('filter.svg');
  border: none;
  font-size: 1.75em; /* Match h1. */
  cursor: pointer;
}

div#filters {
  display: none;
  max-width: 400px;
  margin: 1.25em auto 2.5em;
}

input#filter-name {
  width: 100%;
  padding: 7px;
  text-align: left;
}

/* PROJECTOR */

div#projector {
  display: none;
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  background: black;
  cursor: pointer;
}

div#projector figure {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95%;
  max-width: 500px;
  color: white;
}

div#projector img {
  width: 100%;
  margin-bottom: 1em;
}

/* Breakpoints are set such that images can reach up to 250px in width. The calculation is:
   250px * numberOfColumns + widthOfGap * numberOfGaps + 1px
   In this case "gaps" includes the left and right margins of the gallery itself, which are
   the same width as the gaps within the grid. */

@media screen and (min-width: calc(250px * 2 + 10px * 3 + 1px)) {
  h1, button#toggle-filters {
    font-size: 2em;
  }
  div#gallery {
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 15px;
    margin: 15px;
  }
}

@media screen and (min-width: calc(250px * 3 + 15px * 4 + 1px)) {
  h1, button#toggle-filters {
    font-size: 2.25em;
  }
  button#toggle-filters {
    display: block;
  }
  div#gallery {
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 20px;
    margin: 20px;
  }
}

@media screen and (min-width: calc(250px * 4 + 20px * 5 + 1px)) {
  div#gallery {
    grid-template-columns: repeat(5, 1fr);
  }
}