* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 0;
  font-family: sans-serif;
}

main {
  flex: 1;
  margin: 0 1rem;
}

h1.page {
  margin-top: 0;
}

.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.top h1 {
  margin-right: 0.8rem;
  margin-bottom: 0.8rem;
}

.top a {
  margin-left: auto;
  white-space: nowrap;
  margin-bottom: 0.8rem;
}


/* Base */

a {
  color: mediumblue;
  text-decoration: none;
}

img {
  display: block;
}

p {
  margin: 0;
}

nav {
  display: flex;
  white-space: nowrap;
}

nav .right {
  margin-left: auto;
}

nav .right > * {
  margin-left: 1em;
}

[data-js-fullscreen]:not([data-js-fullscreen="enabled"]) {
  display: none;
}

label, input {
  display: block;
}

label.checkbox, input[type=checkbox] {
  display: inline;
}

input {
  margin-bottom: 0.8rem;
}

.videomarker {
  z-index: 1;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10%;
  min-width: 64px;
  max-height: 90%;
}


/* Navbar and footer */
nav, footer {
  padding: 0.8rem;
  background-color: gainsboro;
}

nav strong {
  font-weight: bold;
}

footer {
  font-size: 0.8rem;
}


/* Flashes */

.flashes {
  margin: 0 0.8rem 0.8rem 0.8rem;
}

.flash {
  padding: 0.8rem;
  border: 1px solid;
}

.flash:not(:last-child) {
  margin-bottom: 0.8rem;
}

.flash.error { background-color: mistyrose; }
.flash.warning { background-color: antiquewhite; }
.flash.success { background-color: honeydew; }
.flash.info { background-color: azure; }


/* Share */

.share {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}


/* Album list */

.albums {
  margin-bottom: 1.6rem;
  flex-grow: 1;
}

.albums ol {
  list-style: none;
  padding-left: 0;
}

.albums ol li {
  margin-bottom: 0.8rem;
  padding-left: 1.6rem;
}

.albums ol li:first-child:not(:only-child) {
  display: none;
}

.albums ol li.group {
  background-color: gainsboro;
  padding: 0.4rem;
}

.albums small {
  font-size: 0.7rem;
}

.albums .source, .albums .path {
  display: none;
}

@media (width < 640px) {
  .albums .source {
    display: inline;
  }
}

@media (width >= 640px) {
  .albums .path {
    display: inline;
  }
}


/* Grid */

.grid {
  display: grid;
  gap: 1rem;

  /* 154px = 2 columns on a lot of phones */
  grid-template-columns: repeat(auto-fit, 154px);
}

.grid .item {
  position: relative;
}

.grid img.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1/1;
  background-color: gainsboro;

  /* Alt text styles */
  color: gray;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


/* Gallery */

.gallery body {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.gallery .items {
  height: 100%;
  width: 100%;
  font-size: 0;
  overflow-x: scroll;
  scroll-snap-type: inline mandatory;
  white-space: nowrap;
}

.gallery .item {
  flex-shrink: 0;
  height: 100%;
  width: 100%;
  display: inline-flex;
  flex-direction: column;
  font-size: 1rem;
  white-space: wrap;
  scroll-snap-align: center;
  position: relative;
  vertical-align: top;
}

.gallery .item.loading {
  scroll-snap-align: none;
}

.gallery .fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.gallery nav {
  display: flex;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  background: rgba(220, 220, 220, 0.9);
  transition: transform 0.15s;
}

.gallery nav.collapsed {
  transform: translateY(-100%);
}

.gallery strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery .count {
  margin: 0 0.8rem;
}

.gallery img:not(.videomarker) {
  height: 100%;
  min-width: 0;
  margin: auto 0;
  object-fit: contain;

  /* Alt text styles */
  color: gray;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Can't vertically center alt text in Chrome so move it from under the navbar */
.gallery img:not(.videomarker):before {
  margin-top: 3.6rem;
  content: "";
}

.gallery .content {
  flex: 1;
  min-height: 0;
  position: relative;
  background-color: white;  /* for fullscreen */
}

.gallery div.content {
  display: flex;
  justify-content: center;
  align-items: center;
  color: gray;
}

.gallery .nav {
  position: absolute;
  top: 0;
  width: 30%;
  height: 100%;

  color: inherit;
  background-color: white;
  font-size: 8rem;
  display: flex;
  justify-content: center;
  align-items: center;

  opacity: 0;
}

@keyframes pulse {
  from { opacity: 0.8; }
  to { opacity: 0; }
}

@keyframes jiggle {
  0% { transform: translateX(0) }
  33% { transform: translateX(2%) }
  67% { transform: translateX(-2%) }
  100% { transform: translateX(0) }
}

/* Mouse */
@media (pointer: fine) {
  .gallery .nav {
    animation: 0.5s pulse;
  }
}

/* Touch */
@media (pointer: coarse) {
  .gallery .items {
    animation: 1s jiggle 0.5s;
  }
}
