*{
  margin: 0; 
  box-sizing: border-box; 
}

:root{
  --gap-width: 5px;
  --gap-width-smallscreen: 3px;
  --body-background-color: black; 
  --h1-font-color: white; 
  --title-font-color: black; 
  --title-background-color: white; 
  --title-top-offset: 8px; 
  --title-left-offset: 8px; 
  --title-padding: 1rem;
  --title-opacity: .85;
  --gallery-figure-height: 250px; 
  --gallery-figure-hight-smallscreen: 80px;
  --container-width: 1260px; 
  --container-padding: 1.5rem;
  --arrow-size: 2rem; 
/*  --smallscreen-width-cutoff: 500px; <- doesn't work!!! */
}

body{
  background-color: var(--body-background-color); 
  font: 1rem/1.6 sans-serif; 
}

h1{
  color: var(--h1-font-color); 
}

.flex-container{
  display: flex; 
  flex-wrap: wrap;
}

.popup-flex{
  display: flex; 
  align-items: center;
  justify-content: center;
}

#gallery{
  max-width: var(--container-width);
  margin-right: auto; 
  margin-left: auto; 
  padding: var(--container-padding); 
}

#gallery-figures{
  gap: var(--gap-width); 
  figure{
    flex: auto; 
    position: relative; 
    height: var(--gallery-figure-height); 
    /*transition: transform 0.3s ease; */
    img{
      height: 100%;
      width: 100%;
      object-fit: cover; 
    }
    figcaption{
      position: absolute; 
      inset: auto auto 0 0; 
      color: var(--title-font-color); 
      background-color: var(--title-background-color); 
      width: 100%; 
      opacity: var(--title-opacity); 
      text-align: center; 
      p{
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-left: 6px; 
        padding-right: 6px; 
        display: none; 
      }
    }
    &:hover{
      transform: scale(1.05); 
      z-index: 1;
      transition: transform 0.3s ease; 
      p{
        display: revert;
      }
    } 
  }
  &::after {
    content: "";
    flex-grow: 999;
    flex-shrink: 1;
    flex-basis: auto;
  }
}

#link-container{
  top: 1rem;
  position: fixed;
  z-index: 2; 
  left: 50%;
  translate: -50%;
}

.link-container-flex{
  display: flex;
  gap: 4px;
}

.link{
  color: red;
  border-radius: 2px;
  background-color: white;
  text-align: center;
  width: 2rem;
  opacity: .5;
  &:hover{
    transform: scale(1.25);
    transition: transform 0.3s ease;
    cursor: pointer;
    opacity: 1;
  }
}

#linkyap{
  position: fixed;
  top: 4rem;
  left: 50%; 
  translate: -50%;
  background-color: white;
  padding: 0 6px 0 6px;
  border-radius: 2px;
  color: red;
  text-align: center; 
}


figure#popup-figure{
  position: fixed; 
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  z-index: 1; 

  img{
    max-width: 100vw;
    max-height: 100vh;
    display: block; /*so caption stops at img base*/
  }
  figcaption{
    z-index: 1;
    border-radius: 5px 5px 0 0;
    box-shadow: 6px 5px 2px 0px black;
    position: absolute; 
    bottom: 0; 
    color: var(--title-font-color); 
    background-color: var(--title-background-color); 
    width: auto; 
    max-width: 80%; 
    max-height: 100%;
    overflow-y: auto; 
    opacity: var(--title-opacity);
    padding: var(--title-padding);
    p {
      white-space-collapse: preserve; 

      &.title{
        text-align: center;
        font-size: 1.5rem; 
      }
      &.caption{
        text-align: left; 
      }
    }
  }
}

#instructions{
  position: fixed;
  top: 50%;
  left: 50%;
  padding-right: 1rem;
  z-index: 2;
  background-color: white;
  width: auto;
  color: black;
  transform: translate(-50%, -50%);
  padding-top: 1rem;
  padding-bottom: 1rem;
  opacity: .90;
  border-radius: 15px;
  box-shadow: 6px 5px 9px 2px black;
  h2 {
    text-align: center; 
    text-decoration: underline; 
  }
  h3 {
    padding-top: 1rem; 
    padding-left: 1rem;
  }
  p {
    padding-left: 2rem; 
  }
  span.strong-red {
    color: red;
    font-size: 1.5rem;
    font-weight: 600;
  }
}

.no-display{
  display: none; 
}

.blur-me {
  filter: blur(4px); 
  opacity: .25;
  transition: .5s; 
}

.arrow{
  width: 0; 
  height: 0; 
  border-style: solid;
  z-index: 1; 
  opacity: 0.65;
  position: fixed;
  transition: opacity 0.3s ease;
  top: 50%;
  transform: translateY(-50%);
  color: black;
  background-color: white; 
  &:hover {
    cursor: pointer;
    opacity: 1; 
  }
}
#left{
  left: 0;
  border-width: 3rem 3rem 3rem .1rem;
  border-color: transparent black transparent transparent;
}
#right{
  right: 0;
  border-width: 3rem .1rem 3rem 3rem; 
  border-color: transparent transparent transparent black;
}

/*@media (max-width: var(--smallscreen-width-cutoff)){
  (why doesn't the above work?)*/
@media (max-width: 500px) or (max-height: 425px){
  #instructions {
    width: 100%;
  }
  #gallery-figures{
    gap: var(--gap-width-smallscreen);
      & figure{
      height: var(--gallery-figure-hight-smallscreen); 
      &:hover{
        transform: none; 
        p{
          display: none; 
        }
      }
    }
  }

  .link{
    &:hover{
      transform: none;
      opacity: 0.5; 
    }
  }
  
  .arrow{
    &:hover {
      opacity: .65; 
    }
  }
  
  #left{
    border-width: 3rem 1.5rem 3rem .1rem; 
  }
  #right{
    border-width: 3rem .1rem 3rem 1.5rem;
  }
}
