*,
*::before,
*::after {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* CSS variables */
:root {
  --background: #09122c;
  --foreground: #fffefe;
  --primary: #e17564;
  --primary-darker: #be3144;

  --container-width: 1100px;
}

/* General element styles */

body {
  display: flow-root; /* Fix escaping margins >:( */
  margin: 0;
  color-scheme: dark;
  background-color: var(--background);
  color: var(--foreground);
  font-family: system-ui, sans-serif;
  line-height: 1.8;
}

figure {
  margin: 0;
}

a {
  color: var(--primary);
  &:visited {
    color: var(--primary);
  }
}

button {
  font: inherit;
  color: inherit;
  line-height: 1.2;
  padding: 0.5rem 0.75rem;
}

/* Layout styles */

footer {
  display: flex;
  justify-content: space-between;
  font-size: 14px;

  > * {
    margin: 0;
  }

  > ul {
    display: contents;
    list-style: none;
  }
}

.container {
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: 1rem;
}

/* Specific Styles */

.image-list {
  list-style: none;
  padding-inline-start: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;

  img {
    display: block;
    max-width: 100%;
    height: auto;
  }

  /* Change caption text to be screen reader only */
  figcaption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
}

.image-dialog {
  padding: 0;
  border: unset;

  /* Inner element is used so the dialog element is only composed of the backdrop */
  .dialog-inner {
    padding: 1rem;
    border: 2px solid var(--foreground);
  }

  .dialog-image {
    display: block;
    margin-inline: auto;
  }

  .dialog-close {
    display: block;
    margin-left: auto;
  }

  &::backdrop {
    background-image: linear-gradient(45deg, var(--primary), var(--primary-darker));
    opacity: 0.75;
  }
}
