@import url("https://fonts.googleapis.com/css2?family=Nixie+One&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "open sans", sans-serif;
  font-size: 12px;
}

body {
  background: #f6f2e9;
}

header {
  display: none;
  flex-direction: column;

  &.visible {
    display: flex;
  }
}

h1 {
  font-family: "Nixie One", sans-serif;
  font-size: 6em;
  color: #ff7c53;
  font-weight: bold;
}

h2 {
  font-size: 1em;
}

a {
  font: inherit;
  color: inherit;
}

a:hover {
  color: #cd6509;
}

body {
  padding: 20px;
}

header {
  margin-bottom: 20px;
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
}

.panel {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;

  .buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
  }
}

#switching,
.btn {
  border-radius: 6px;
  padding: 10px 20px;
  text-decoration: none;
  color: white;
  background: #3e3e3e;
  position: relative;
  display: inline-block;
  border: 1px solid #555;
  transition: background-color 100ms ease-in-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;

  svg {
    height: 16px;
  }
}

#switching {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 300ms ease-out;
}

#switching.hidden {
  opacity: 0;
}

.btn:hover {
  color: white;
  background: #5a5a5a;
}

.btn:active {
  background: #888;
  border-color: #888;
}

.btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

canvas {
  position: absolute;
  inset: 0;
}

#gallery {
  display: none;
  position: relative;

  &.visible {
    display: flex;
  }

  .gallery-container {
    display: flex;
    flex-direction: column;
    position: absolute;

    border-radius: 6px;
    padding: 10px 20px;
    color: white;
    background: #3e3e3e88;

    a {
      text-decoration: none;
    }

    a:hover {
      color: white;
      font-weight: bold;
    }
  }
}

@media (min-width: 950px) {
  #gui-container {
    position: fixed;
    top: 10px;
    right: 10px;
    /* Bounded, and scrolling. Without a bottom the column simply grew past the window, and
       since the panels each carry their own scroller there was nothing left to scroll the
       stack of them — two open panels just ran off the screen. */
    bottom: 10px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  #gui-container::-webkit-scrollbar {
    display: none;
  }

  /* Panels keep their natural height inside that column rather than being squeezed to fit. */
  #gui-container > .gui {
    flex: 0 0 auto;
  }
}

@media (max-width: 1120px) {
  header {
    .btn span {
      display: none;
    }
  }
}

@media (max-width: 950px) {
  header {
    align-items: center;
    right: 20px;
    h1 {
      font-size: 42px;
    }
    .btn {
      padding: 10px;
    }
    .btn span {
      display: none;
    }
  }

  .gallery-container {
    width: 100%;
  }
  #gui-container {
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 10px;
    /* Anchored to the bottom, so the bound is a max-height rather than a top. dvh, because
       the mobile address bar makes vh taller than what you can actually see. */
    max-height: calc(100dvh - 20px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }

    > .gui {
      flex: 0 0 auto;
    }

    /* Each panel still caps its own list, so one long panel cannot push the other off the
       bottom — but the column above scrolls when both together are too tall. */
    .gui-scroller {
      max-height: 40vh;
    }
  }
}

/* Keep the Rendering panel below the sketch's own. */
#gui-container > .gui-rendering {
  order: 1;
}
