* {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
  user-select: none;
  &:focus {outline: none;}
}

:root {
  --bgColor: light-dark(white, black) ;
  --baseColor: black;
  --bracketColor: black;

  --card: #F5F5F5;
  --alpha: 0.3;
  
  --lightestShade: hsl(50, 18%, 95%);
  --lighterShade: hsl(50, 25%, 92%);
  --darkShade: hsl(50, 20%, 50%);
  --darkerShade: hsl(50, 18%, 35%);
  --darkestShade: hsl(50, 18%, 25%);

  --focusColor: hsl(50, 37%, 86%);
  --emphasisColor: hsl(50, 37%, 45%);
  --correctColor: hsl(130, 35%, 35%);

  --hueShiftIcons: unset;

  --dialogWidth: min(80vw, 500px);

  color-scheme: light;
  color: black;


  *::before, *::after {color: black;}

  &.dark *, &.dark *::before, &.dark *::after {
    box-shadow: none !important;
  }
}

#tab_catch, #backtab_catch {
  position: fixed; top: 0; pointer-events: none;
}

.notransitions * {
  transition: none !important;
  animation-duration: 0 !important;
}

/*  Prevent mismatch between viewport and body dimensions */
html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  perspective: 900px;
}
body, .page {
  overflow: hidden;
  background-color: var(--bgColor);
}


.page.level.slideout {
  opacity: 0;
  translate: 0 100vh;
}
.page.home.slideout:has(~ .level) {
  opacity: 0;
  translate: 0 -100vh;
}

.page.home.slideout:has(~ .home) {
  opacity: 0;
  translate: 0;
}


.page.level.slideout:has(~ .level) {
  opacity: 0;
  translate: -100vw 0;
}

.level:has(~ .page.level.slidein) {
  opacity: 0;
  translate: 100vw 0;
}

.page {
  width: 100%;
  height: 100%;
  position: absolute;

  opacity: 1;
  translate: 0px;
  transition: opacity 0.4s, translate 0.4s;

  will-change: opacity, translate;

  &:not(:is(.home, .level)) { transition: none; }

  &:not(:has(~ .page)), .home ~ .home {
    @starting-style {
      opacity: 0;
      left: 0;
      bottom: 0;
    }
  }

  

  &.home ~ .level {
    @starting-style {
      opacity: 0;
      translate: 0 100vh;
    }
  }

  &.level ~ .home {
    @starting-style {
      opacity: 0;
      translate: 0 -100vh;
    }
  }

  &.level.slideout ~ .level {
    @starting-style {
      opacity: 0;
      translate: 100vw 0;
    }
  }
  &.level ~ .level.slidein {
    @starting-style {
      opacity: 0;
      translate: -100vw 0;
    }
  }
  
}
.nudged, .nudged::after {
  transform: scale(0.95);
}

.dialog_button {
  border: 0;
  outline: 0;

  margin: 0;

  cursor: pointer;

  z-index: 1;

  opacity: 1;
  transition: opacity 0.05s, transform 0.1s;
  background-repeat: no-repeat;

  filter: var(--hueShiftIcons);
}

@media(hover: hover) and (pointer: fine) {
  .dialog_button:hover { opacity: 0.65; }
}

.dialog_button:focus {
  opacity: 0.65;
}


.close {
  position: absolute;
  right: 20px;
  top: 18px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  border-radius: 5px;
  cursor: pointer
}

.close:hover:before, .close:hover:after {
  opacity: 0.75;
}
.close:before, .close:after {
  border-radius: 10px;
  left: 15px;
  content: ' ';
  height: 28px;
  width: 1px;
  background-color: var(--bracketColor);
  position: absolute;
  
}
.close:before {
  transform: rotate(45deg);
}
.close:after {
  transform: rotate(-45deg);
}





#overlay {
  position: fixed; 
  display: block; 
  width: 100%; 
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;

  z-index: 100;
  pointer-events: none;

  background-color: rgba(0,0,0,var(--alpha));
  opacity: 0;
  transition: opacity .25s cubic-bezier(0.39, 0.58, 0.57, 1);
}

html:has(dialog[open]) #overlay {
  opacity: 0.5;
}
html:has(dialog.hide) #overlay {
  transition: opacity .1s cubic-bezier(0.39, 0.58, 0.57, 1);
  opacity: 0 !important;
}


dialog {
  outline: 0;
  
  position: fixed;
  
  margin: auto;
  display: block;
  background-color: var(--bgColor);
  font-family: "source serif 4";
  width: min(80vw, 500px);
  height: min-content;
  visibility: hidden;
  opacity: 0;
  overflow: clip;

  color: var(--baseColor);


  border-radius: 12px;

  scrollbar-width: none;
  scrollbar-color: transparent transparent;
  
  transition: opacity 0.3s, transform cubic-bezier(.25,1,.25,1) 0.3s;
  transform: scale(0);
}

dialog::backdrop {
  opacity: 0;
}

dialog[open] {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  border: 1px solid light-dark(transparent, var(--darkestShade));

  box-shadow: 0 0 5px rgb(0,0,0,0.05), 0 0 8px rgba(0, 0, 0, 0.075),
  0 0 30px rgb(0,0,0,0.075);
}

:root.dark dialog[open] {
  filter: drop-shadow(0 0 5px black);
}


dialog.hide {
  transition: transform ease-in 0.1s, opacity ease-in 0.1s;
  transform: scale(75%);
  opacity: 0;
}


dialog {
  h1 {
    margin-top:-8px;
    margin-bottom: 15px;
    font-size: 1.95rem;
    font-weight: 800;
    text-align: center;

  }
}



#settings_dialog {
  max-width: 400px;
  height: min-content;
  max-height: 80vh;
  padding-bottom: 10px;
}

#configs {
  margin-left: 1rem;
  margin-right: 1rem;
  font-size: 1.4rem;
  font-weight: 400;
  display:flex;
  align-items: flex-end;
  justify-content: left;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 60vh;
  overflow-y: scroll;
  padding-bottom: 10px;
  box-sizing: border-box;

  #wrap_theme {
    width: 100%;
    display: flex;
    label:first-child {margin-right: 10px;}

    input {
      position: absolute; opacity: 0;
    }
  }
  .theme {
    display:block;
    margin: 0;
    margin-bottom: 2px;
    appearance: none;
    height: 30px;
    width: 50px;
    background-color: #C0C0C0;
    position: relative;
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.1s ease;
    margin-right: 4px;
    box-sizing: border-box;
    
    &::after {
      content: "";
      position: absolute;
      width: 50%;
      height: 50%;
      top: 25%;
      left: 25%;
      border-radius: 19px;

    }

  }

  input:checked + .theme {
    border: 3px solid var(--emphasisColor) !important;
  }

  #frostdark {
    margin-right: auto;
  }

  #litlight, #frostlight {
    background-color: #DDD;
  }
  #litdark, #frostdark {
    background-color: #222;
  }

  #litlight::after, #litdark::after {
    background-color: hsl(50, 37%, 45%);
  }

  #frostlight::after, #frostdark::after {
    background-color: hsl(200, 37%, 45%);
  }
  .toggle {
    margin: 0;
    margin-bottom: 2px;
    appearance: none;
    height: 26px;
    width: 60px;
    background-color: #C0C0C0;
    position: relative;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.15s, filter 0.15s;
  }

  .toggle::before {
    content: '';
    display: block;
    height: 18px;
    width: 21px;
    transform: translate(-50%, -50%);
    position: absolute;
    top: 50%;
    left: 16px;
    background-color: #3f3f3f;
    border-radius: 18px;
    transition: background 0.15s ease, left 0.15s;
    
  }

  .tristate {
    width: 70px;
    
  }
  .tristate::before {
    font-family: "Source Serif 4";
    color: #EEE;
    text-align: center;
  }

  @media (hover: hover) and (pointer: fine) {
    input:hover, .theme:hover {
      filter: brightness(90%);
    }
  }
  input:focus, label:focus .theme {
    outline: 0;
    filter: brightness(85%);
  }

  .toggle:checked {
    background-color: hsl(113, 21%, 69%);
  }

  .toggle:checked::before {
    background-color: hsl(113, 21%, 30%);
    left: calc(100% - 16px);
  }

  .toggle.tristate:not(.top):checked {
    background-color: hsl(80, 25%, 69%);
  }
  .toggle.tristate:not(.top):checked::before {
    background-color: hsl(80, 25%, 30%);
    content: "I";
    left: calc(50%);
  }
  .toggle.tristate:checked::before {
    background-color: hsl(113, 21%, 30%);
    content: "II";
    left: calc(100% - 16px);
  }

  .toggle:not(:checked) + p {
    opacity: 0.5;
  }

  p {
    margin: 0;
    margin-top: -5px;
    font-style: italic;
    font-weight: 350;
    font-size: 1rem;
    flex-basis:100%;
    text-align: left;
  }

  #hideMatrixTools {
    display: none;
    &:checked ~ * {
      display: none;
    }
  }

}
