/* GLOBAL VARIABLES */

:root {
  /* Light Mode Colors */
  @media (prefers-color-scheme: light) {
    --c-bg: #e9f0f9;
    --c-fg: #1b1a1f;
    --c-outline: rgba(193, 210, 231, 0.25);
    --c-hover: #34f;
  }

  /* Dark Mode Colors */
  @media (prefers-color-scheme: dark) {
    --c-bg: #1b1c1f;
    --c-fg: #e9f0f9;
    --c-outline: rgba(193, 210, 231, 0.15);
    --c-hover: #68f;
  }
}

/* MAIN LAYOUT */

* {
  box-sizing: border-box;
}

*:focus {
  outline: none;
}

html {
  display: flex;
  justify-content: center;
  color: var(--c-fg);
  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-kerning: normal;
  line-height: normal;
}

body {
  position: relative;

  display: grid;
  align-items: start;
  width: clamp(360px, 100%, 1680px);
  height: 100%;

  padding: 4rem;
  background: var(--c-bg);
  overflow-x: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  padding-block: clamp(1rem, 15vh, 4rem) 6rem;
  line-height: 1.6;

  & a {
    align-self: flex-end;
    font-size: 0.9rem;
  }
}

/* COMPONENT STYLING */

h2 {
  margin-top: 0;
}

a {
  color: var(--c-fg);

  &:hover {
    color: var(--c-hover);
  }
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;

  & img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;

    border: solid thin var(--c-outline);
    -webkit-box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0);
    -moz-box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0);
    box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0);

    transition: all 300ms;
  }
  & img:hover {
    scale: 1.025;
    border: solid thin rgba(255, 255, 255, 0.75);
    -webkit-box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0.25);
    -moz-box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0.25);
    box-shadow: 0px 19px 39px -7px rgba(0, 0, 0, 0.25);
    cursor: pointer;
  }
}

dialog {
  border: none;
  padding: 0.5rem;
  max-width: 75vw;
  max-height: 75vh;
  transition: all 300ms;

  &[open] {
    position: fixed;
    inset: 0 0 0 0;
    margin: auto;
  }

  &::backdrop {
    background: var(--c-bg);
    opacity: 0.9;
  }

  & img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
  }
}

dialog button {
  position: absolute;
  top: 1rem;
  left: 1rem;

  width: 1.5rem;
  height: 1.5rem;

  background: rgba(0, 0, 0, 0.3);
  border-radius: 5rem;

  color: white;
  line-height: 1;
  font-size: 1rem;

  transition: all 250ms;
  cursor: pointer;

  &:hover {
    background: rgba(0, 0, 0, 0.8);
  }
}

/* RESPONSIVE */
@media screen and (max-width: 900px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 580px) {
  body {
    padding-inline: 2rem;
  }

  header {
    flex-direction: column;
    padding-block: 0 4rem;

    & a {
      align-self: flex-start;
      margin-top: 1em;
    }
  }

  .gallery {
    grid-template-columns: 1fr;
    & img:hover {
      scale: 1;
      border: solid thin var(--c-outline);
    }
  }
}
