/* MAIN */

html, body {
  height: 100%;
}

body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

main {
  flex-grow: 1;
  flex-basis: 0;
  position: relative;
}

/* CANVAS */

#canvas-wrapper {
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: var(--bg-1);
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  filter: blur(2px);
}

@keyframes fade-in {
  to {
    opacity: 1;
    filter: none;
  }
}

#pixel-info {
  position: absolute;
  bottom: 5px;
  left: 8px;
  color: #888;
  font-size: 12px;
  pointer-events: none;
}

@media (max-width: 300px) {
  #pixel-info {
    display: none;
  }
}

/* COLOR PALETTE */

#color-buttons {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 5px;
  flex-direction: column;
  justify-content: center;
  padding: 8px; /* 10px including border width */
  border: 2px solid transparent;
  color: var(--selected-color, var(--text-default));
  border-radius: 25px;
  background: var(--bg-0);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: border-color 0.3s ease-out -0.2s,
              height 0.4s var(--bounce-out),
              translate 0.4s var(--ease-out);
}

@media (max-height: 620px) {
  #color-buttons {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    align-content: center;
    grid-auto-flow: column;
  }
}

#color-buttons.hidden {
  translate: calc(100% + 20px) 0;
  pointer-events: none;
}

#color-buttons.closed {
  height: 50px !important;
  border-color: var(--selected-color, transparent);
  transition: border-color 0.15s 0.3s,
              height 0.4s var(--bounce-in),
              translate 0.4s var(--bounce-in);
}

#color-buttons.cooldown {
  cursor: not-allowed;
}

.color-button {
  width: 30px;
  height: 30px;
  border-radius: 100px;
  background: var(--color);
  position: relative;
  transition: scale 0.1s, opacity 0.3s;
}

#color-buttons.closed .color-button {
  opacity: 0;
  transition: scale 0.1s, opacity 0.23s 0.15s;
}

:root:not(#dark) .color-button.white {
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.color-button:focus-visible {
  outline: 2px solid var(--color);
  outline-offset: 2px;
}

:root:not(#dark) .color-button.white:focus-visible {
  outline-color: #b1b1b1;
}

.color-button:hover {
  scale: 1.05;
}

.color-button:active {
  scale: 0.95;
}

#exit-place-mode {
  padding: 0;
  border-radius: 100px;
  inset: auto 0;
  aspect-ratio: 1;
  border: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0s 0.2s;
}

#color-buttons.closed #exit-place-mode {
  transition: opacity 0.2s 0.2s, visibility 0s 0.2s;
  opacity: 1;
  visibility: visible;
}

#exit-place-mode i {
  font-size: 30px
}

/* COOLDOWN PROGRESS BAR */

#cooldown {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 2;
  height: 100%;
  background: var(--button-active);
  opacity: 0;
  transition: opacity 0.25s;
  visibility: hidden;
  pointer-events: none;
}

#color-buttons.cooldown .color-button {
  pointer-events: none;
  opacity: 0;
}

#color-buttons.cooldown #cooldown {
  visibility: visible;
  animation: cooldown 6s linear forwards;
  opacity: 100%;
}

@keyframes cooldown {
  to { height: 0; }
}

/* THEME SELECTOR */

#logo {
  pointer-events: none;
}

#theme-selector-title {
  margin-top: 10px;
  margin-bottom: 5px;
}

#theme-selector {
  display: flex;
  gap: 5px;
  width: 100%;
}

#theme-selector button {
  padding: 5px;
  /* height: 40px; */
  flex-basis: 100%;
  flex-shrink: 1;
}

#theme-selector button[data-theme="auto"].selected i {
  transform: scaleX(-1);
}

/* ACCOUNTS */

#account-wrapper {
  position: absolute;
  top: 5px;
  right: 5px;
  filter: drop-shadow(0 1px 6px transparent);
  display: flex;
  gap: 10px;
  z-index: 10;
  transition: filter 0.2s linear;
  padding: 5px;
  border-radius: 25px;
}

#account-wrapper.signed-in #sign-in {
  display: none;
}

#context-menu-button, #profile-button {
  position: relative;
  background: var(--bg-1);
}

#context-menu-button::after, #profile-button::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
}

#context-menu-button:is(:hover, :focus-visible)::after, #profile-button:is(:hover, :focus-visible)::after {
  background: var(--button-hover);
}

#context-menu-button:active::after, #profile-button:active::after {
  background: var(--button-active);
}

#context-menu-button.selected::after, #profile-button.selected::after {
  background: var(--button-selected);
  border-color: transparent;
}

#sign-in {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

#profile-button {
  overflow: hidden;
  width: 40px;
  height: 40px;
  border-radius: 100px;
  padding: 0;
}

#account-wrapper:not(.signed-in) #profile-button-wrapper {
  display: none;
}

#profile-button > img {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 3;
}

#context-button-wrapper,
#profile-button-wrapper {
  position: relative;
}

.menu {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, opacity 0.1s linear;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg-0);
  border-radius: 10px;
  opacity: 0;
  min-width: 190px;
  pointer-events: none;
  z-index: 100;
  transform: translateY(-8px);
}

.menu.shown {
  transform: none;
  opacity: 1;
  pointer-events: all;
}

#account-menu {
  padding: 10px;
}

#account-email {
  opacity: 0.5;
}

#sign-in {
  padding: 10px 17px 10px 15px;
}

#sign-out {
  padding: 5px 10px;
  margin-top: 10px;
  width: 100%;
}

#context-menu {
  gap: 5px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 5px;
}

#context-menu > button {
  padding: 5px 15px 5px 5px;
  border: none;
  justify-content: start;
  white-space: nowrap;
  border-radius: 5px;
}

#context-menu i {
  width: 1.25rem;
  height: 1.25rem;
}

#context-menu-button {
  height: 40px;
  width: 40px;
  padding: 0;
}

#terms-link {
  display: block;
  margin-top: 10px;
  color: var(--text-default);
  opacity: 0.3;
  font-size: 80%;
  text-align: right;
}

/* TOAST (so yummy) */

#toast {
  visibility: hidden;
  position: absolute;
  top: 10px;
  left: 50%;
  translate: -50% 0;
  pointer-events: none;
  z-index: 80;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(calc(-100% - 20px));
  transition: visibility 0s 0.5s, transform 0.5s var(--bounce-in);
  border-radius: 8px;
  overflow: hidden;
  color: var(--text-success);
  background: var(--bg-0);
  padding: 10.5px 12px;
  max-width: clamp(300px, 50%, 600px);
}

#toast.shown {
  visibility: visible;
  transform: translateY(0);
  transition: transform 0.6s linear(0, 0.009 1.2%, 0.035 2.4%, 0.078 3.7%, 0.139 5.1%, 0.273 7.6%, 0.698 14.7%, 0.817 17%, 0.91 19.1%, 0.987 21.2%, 1.05 23.4%, 1.095 25.6%, 1.125 27.8%, 1.143 31.1%, 1.137 34.8%, 1.018 50.2%, 0.996 54.6%, 0.983 59.2%, 0.98 65.9%, 1 85.2%, 1);
  pointer-events: all;
}

#toast.error {
  color: var(--text-error);
}
