html {
  --textsize: 16px;
  --textcolor: #482f68;
  --textbgcolor: #8f3a35;
  --bartextcolor1: #b53636;  
  --bartextcolor2: #cf4141;  
  --bartextcolor3: #5c3c85;
  --bartextcolor4: #634190;
  --bordercolor: #482f68;
  --backcolor: #fff;
  --barcolor: #dcdae4;

  --bg-image: url('_assets/bg.webp');

  --margin: calc(0.8em + 1vw);
  --thumbsize: 156px; /* size M */
  --slide-transition: auto;
}

* {
  margin: 0;
  padding: 0;
}

@font-face {
	font-family: 'Alef';
	src: url('_assets/alef-reg.ttf') format("truetype"); 
}

@font-face {
	font-family: 'Alef'; font-weight:bold;
	src: url('_assets/alef-bold.ttf') format("truetype");
}

@font-face {
	font-family: 'DejaVu Serif'; font-weight:bold;
	src: url('_assets/dejavuserif-bold.ttf') format("truetype");
}

html,body {
  height: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font: var(--textsize) / 1.4 'Alef';
  color: var(--textcolor);
  background: var(--bg-image);
  background-repeat: repeat;
  background-size: 1600px;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  body {
    background-size: 336% auto;
    background-position: center;
  }
}

.flex-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding-bottom: 4.4em;
}

.header-row {
  color: var(--bartextcolor3);
  background-color: var(--barcolor);
  padding: 0.2em;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px dashed var(--bordercolor);
}

footer {
  margin-top: auto;
}

.footer-row {
  color: var(--bartextcolor3);
  background-color: var(--barcolor);
  padding: 0.2em;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  border-top: 2px dashed var(--bordercolor);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.footer-row .footer-middle {
  display: flex;
  align-items: center;
  gap: 0.8em;
}

.footer-row .footer-index {
  color: var(--bartextcolor);
  text-decoration: none;
}

.footer-row .footer-index:hover {
  color:var(--bartextcolor4);
  outline: 2px solid;
  border-radius: 3px;
}

.footer-row .footer-prev,.footer-next {
  color: var(--bartextcolor4);
  text-decoration: none;
}

.footer-row .footer-prev {
  padding-left: 0.3em;
}

.footer-row .footer-next {
  padding-right: 0.7em;
}

.footer-row .footer-prev:hover,.footer-next:hover {
  color:var(--bartextcolor1);
}

.footer-row .currentitem {
  color: var(--bartextcolor1);
}


h1 {
  color: var(--bartextcolor2);
  font-size: 1em;
  text-shadow: 0.7px 0.7px #000000;
  display: inline-block;
}

h1 span {
  font-weight: normal;
  display: inline-block;
}

a {
  color: currentColor;
}

frame {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
}

/* -- Image grid -- */

.grid {
  clear: both;
  display: grid;
  grid-auto-flow: dense;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumbsize), 1fr));
  grid-gap: calc(var(--margin) * 1.33) var(--margin);
  padding-top: calc(var(--margin) * 1.5);
}

.grid figure {  
  position: relative;
}

.grid a {
  display: block;
  position: relative;
  scroll-margin: 20vh 0;
}

.grid a img {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.grid a::before {
  content: "";
  display: block;
  padding-top: 100%;
}

.grid figcaption {
  font-size: 0.85em;
  text-align: center;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
  background-color: var(--textbgcolor);
  color: var(--backcolor);
  margin-top: calc(var(--margin) / 2.3);
  padding: 0.4em 0.5em;
  border-radius: 1px;
  width: fit-content;
  max-width: 13.6em;
  margin-left: auto;
  margin-right: auto;
}

.grid figure a:focus {
  outline: 0 none;
  border-radius: 1px;
  box-shadow: 0 0 0 4px;
  background: currentColor;
}

.grid figure a:target {
  outline: 1px solid;
  border-radius: 4px;
}

.grid figure a:hover + figcaption,
.grid figure a:focus + figcaption {
  background-color: var(--textcolor);
}

/* Thumbnail size switcher */
input {
  appearance: none;
  -webkit-appearance: none;
  width: 0;
  height: 0;
  overflow: hidden;
  direction: rtl;
}

label {
  text-shadow: 0.7px 0.9px #000000;
  user-select: none;
  cursor: pointer;
  opacity: 0.5;
  padding: 0.05em 0.45em;
  margin-top: -0.05em;
  float: right;
  display: none;
}

label:hover,
input:focus + label {
  opacity: 1;
  color:var(--bartextcolor4);
  outline: 2px solid;
  border-radius: 3px;
}

input:focus + label,
input:checked + label:hover {
color: var(--bartextcolor3);
outline: none;
border-radius: none;
}

input:checked + label {
  opacity: 1;
  font-weight: bold;
}

/* Responsive: mobile */
@media only screen and (max-width: 800px) {
  .grid figcaption {
    border-radius: 4px;
    max-width: 12em;
  }
}

/* Responsive: bigger screens */
@media (min-width: 820px) {
  label {
    display: inline-block;
  }
  h1 {
    float: left;
    width: calc(100% - 20ch);
  }
}

/* -- Lightbox -- */
.lightbox {
  display:none;
}

.fixed .lightbox {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  z-index: 5;
}

.lightbox:hover {
  scroll-behavior: var(--slide-transition);
}

.lightbox figure {
  display: flex;
  flex: none;
  background: var(--bg-image);
  background-repeat: repeat;
  background-size: 1600px;
  overscroll-behavior: contain;
  position: relative;
  scroll-snap-align: center;
  width: 100vw;
  align-items: center;
  justify-content: center;
  
}

/* Fix for #permalinks to work */
.lightbox:not(:focus-within) figure:target {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
}

.lightbox figure:focus {
  outline: none;
}

.lightbox figure a.iframe iframe {
  width: 85vw;
  height: 87vh;
  max-width: 100%;
  max-height: calc(100vh - 4em);
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.lightbox:focus-within figure a.iframe iframe,
.lightbox:not(:focus-within) figure:target a.iframe iframe {
  opacity: 1;
  transition: 0.35s opacity ease-out;
}

/* -- Prev / Next Scroll -- */
.lightbox figure a.iframe::before {
  left: -33vw;
}

.lightbox figure a.iframe::after {
  right: -33vw;
}

.lightbox figure:first-of-type a.iframe::before,
.lightbox figure:last-of-type a.iframe::after {
  display: none;
}