/* Gallery page */
body{
  min-height: 100vh;
  height: auto;
  
  header{
    position: sticky;
    top:0;
    z-index: 11;
    .templates-container{
      /* fix cause in gallery, new btn is on the left side */
      left: calc(100% - 2rem);
      align-items: start;
    }
  }
}

main.gallery {
  flex-grow: 1;
  background: var(--bright);
  color: var(--dark);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-content: flex-start;
  gap: 20px;
  padding: 20px 20px 20px;
  position: relative;
}

.gallery-item {
  margin-bottom: var(--p);
  position: relative;
  a:hover {
    background: none;
  }
  iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    border: 0;
    background: white;
    z-index: 3;
    transition: opacity 250ms;
  }
  nav {
    display: flex;
    margin-bottom: var(--p);
    align-items: center;
    justify-content: space-between;
    gap: var(--p);
  }
  article {
    aspect-ratio: 16 / 9;
    position: relative;
    box-shadow: 0 0 4px var(--almostdark);
    &:before {
      display: block;
      content: "preview";
      font-family: monospace;
      pointer-events: none;
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      background: white;
      display: grid;
      place-content: center;
      z-index: 1;
      aspect-ratio: 16 / 9;
    }
    img {
      position: absolute;
      width: 100%;
      height: 100%;
      object-fit: cover;
      z-index: 2;
    }
    &:hover img {
      opacity: 0;
      pointer-events: none;
    }
  }
  .title {
    display: inline-block;
    font-size: 1.5em;
    line-height: 1.5em;
    position: relative;
    padding-inline: 1.5em;
    /*! flex: 1; */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 10px;
    background: unset;
    width: 100%;
    &:before {
      content: "";
      width: 16px;
      height: 16px;
      left: 0.2em;
      top: 0.5em;
      position: absolute;
      background: var(--dark);
      border-radius: 100%;
    }
  }
  .rm-btn {
    display: none;
    font-size: 2em;
    /*! line-height: .5; */
    /*! margin-left: 5px; */
  }
  &.local-stem-item .publish-local-btn {
    display: none;
    /*! margin-left: 5px; */
  }
}
#localStemsContainer {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  padding-bottom: 1em;
  margin-bottom: 1em;
  position: relative;
  margin: -20px -20px 0;
  background: var(--darker);
  box-shadow: inset 0px 0px 5px var(--dark);
  background: radial-gradient(var(--almostdark) 15%, transparent 16%) 0 0;
  background-size: 8px 8px;
  padding: 20px;
  details {
    grid-column: 1 / -1;
    margin-bottom: calc(var(--p) * 4);
    p {
      background: var(--brighter);
      margin-top: calc(var(--p) * 2);
      padding: var(--p);
    }
  }
  h2 {
    display: inline;
  }
}
details > summary {
  list-style: none;
  &::-webkit-details-marker {
    display: none;
  }
}
.gallery .button {
  background: var(--brighter);
  border: 1px solid var(--almostdark);
  :hover{
    background: color-mix(in hsl, var(--brighter), white);
  }
}

body[data-cansave="1"] .gallery-item:hover .rm-btn,
body[data-cansave="1"] .gallery-item:has(*:focus) .rm-btn,
.gallery-item.local-stem-item:hover .rm-btn,
.gallery-item.local-stem-item:has(*:focus) .rm-btn {
  display: block;
}

body[data-cansave="1"] .gallery-item.local-stem-item:hover .publish-local-btn,
body[data-cansave="1"] .gallery-item.local-stem-item:has(*:focus) .publish-local-btn {
  display: inline-block;
}

.line {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  transform: translateY(calc(.22em + var(--p))) rotate(var(--rotate, 0deg));
}

.line path {
  fill: var(--dark);
  stroke: var(--dark);
  stroke-width: 3px;
  stroke-linecap: round;
  opacity: 0.5;
  /* stroke-dasharray: 1em var(--p); */
  /* filter:blur(4px); */
  /* filter: url("../img/noise.svg#noise") */
}

/* filters on gallery */
#filter-form{
  display: flex;
  gap: var(--p);
}
.buttons-group label, .filter span{
  align-self: center;
}

/*foldout menu */
.filtering .filter, .filter:has(.filter-active){
  display: flex;
}
.filter-btn::after{
  content: "…";
}
.filtering .filter-btn::after{
  content: ":";
}
.group:has(>.filter-btn):has(.filter-active), .filtering .group:has(>.filter-btn){
  outline: var(--bright) 1px solid;
  border-radius: 10px;
}
/* display reset btn only when a value is selected */
select.query-input:has(option[value=""]:checked) + input[type="reset"],
input.query-input:placeholder-shown + input[type="reset"]{
  display: none;
}
select.query-input:has(option:not([value=""]):checked){
  padding-right: 0;
}
select.query-input:has(option[value=""]:checked){
  border-radius: 10px;
  padding-right: 2rem;
}
/* a filter hidden in the menu, visible only when activated by another way */
#filter-lineage{
  display: none;
  &:has(input){
    display: flex;
  }
}

/* input for text */
input.query-input{
  width: 8rem;
}
input.query-input + input[type="reset"]{
  border: none;
  margin-left: -1rem;
}
/* display label only when a value is selected/filter is active */
.filter{
  display: none;
  label, .label{
    display: none;
  }
  &:has(.filter-active) label,
  &:has(.filter-active) .label{
    display: inline ;
  }
}

/* multi-selection element (maybe for tags)*/
.multi-selection{
  input[type="checkbox"]{
    display: none;
  }
    label::after{
    content: " ✕";
    position: relative;
    top: .1em;
  }
}
/* a way to show which stem is focused by lineage filter */
.gallery-item[data-lineage="0"] .title{
  background-color: yellow;
}
