
#main-header {
  width: fit-content;

  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 9px;

  margin: 0;
  cursor: pointer;

  color: var(--baseColor);
  
  font-family: computer modern serif;
  font-weight: bolder;
  font-size: 3.1rem;
}


.page.home {
  align-content: center;
}
html:has(#wrap_cards:hover) {
  overscroll-behavior-x: none;
}
.dialog_button.home {

  position: absolute;
  top: clamp(1rem, 2vmin, 1.75rem); 
  height: 38px;
  width: 38px;
}

#settings.home {
  background: url("../assets/SETTINGS.svg");
  right: clamp(0.5rem, 2.75vmin, 1.5rem); 
}

#about {

  background: url("../assets/INFO.svg");
  left: clamp(0.5rem, 2.75vmin, 1.5rem);
}
:root.dark #mcgill { filter: invert(0.9); }

#about_dialog {
  padding-bottom: 41px;

  #github {
    background: url("../assets/INVERTOCAT.svg");
    background-size: 100%;
    background-repeat: no-repeat;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: hsl(200, 15%, 55%);
    position: absolute;
    left: 20px;
    top: 18px;
    text-align: center;
    filter: var(--hueShiftIcons);
  }

  #sources {
    display: flex;
    width: 100%;
    margin-top: 15px;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    
    #mcgill {
      background: url("../assets/MCGILL.svg");
      background-size: 100%;
      background-repeat: no-repeat;
      width: calc(300px / 4);
      height: calc(76px / 4);
      display: block;
    }


    #wikipedia {
      background: url("../assets/WIKI.svg");
      background-size: 100%;
      background-repeat: no-repeat;
      width: calc(103px / 2);
      height: calc(94px / 2);
      display: block;
    }

    #textbook {
      background: url("../assets/TEXTBOOK.jpg");
      background-size: 100%;
      background-repeat: no-repeat;
      width: calc(67px / 2);
      height: calc(80px / 2);
      display: block;
    }
  }

  
  #privacy {
    display: flex;
    margin-top: 16px;
    margin-bottom: -25px;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 300;
    p {margin: 0;}
    
  }
  @media (hover: hover) and (pointer: fine) {
    #github:hover { opacity: 0.75; }
  }

  #precis {
    margin-left: 2vw;
    margin-right: 2vw;
    display:flex;
    align-items: flex-end;
    justify-content: left;
    flex-wrap: wrap;
    gap: 10px;

    h2 {
      font-size: 1.3rem;
      font-weight: 400;

      margin: 0;
      text-align: center;
    }

    a {
      cursor: pointer;
      text-decoration: underline;
      color: hsl(120 20% 60%);
      
      transition: color 0.07s;
    }

    @media (hover: hover) and (pointer: fine) {
      a:hover {
        color: hsl(120 20% 40%);
      }
    }

    hr { width: 100%;}

    p {
      font-size: 1.1rem;
      font-weight: 400;
      width: 100%;
      font-style: italic;
      margin:0;
      text-align: center;
    }

  }

}

#wrap_cards {
  width: 94vw;
  /* For box-shadow */
  padding-left: 4px;
  padding-right: 4px;

  box-sizing: border-box;

  display: flex;
  flex-direction: row;
  gap: 15px;
  justify-content: flex-start;
  align-items: center;

  
  scrollbar-width: none;
}

#wrap_cards.noswipe {
  &, * {
    touch-action: none;
  }
}

#wrap_cards > :first-child {
  margin-left: auto;
}
#wrap_cards > :last-child {
  margin-right: auto;
}

@media (height > 640px) {
  .card { height: 453px; }
}

@media (height <= 640px) {
  .card { height: max(100px, calc(453px - (640px - 100vh))); }
}

:root.dark .card {
  filter: drop-shadow(0px 2px 7px #000);
}
.card {
  min-width: 295px;
  max-width: 295px;
  padding: 15px;

  /* Also modified for mobile view below!! */
  transition: rotate 0.15s ease-out, transform .1s ease-out, filter .1s ease-out, opacity .1s ease-out;

  &:is(#training) {
    /* Add max-height */
    transition: rotate 0.15s ease-out, transform .1s ease-out, filter .1s ease-out, opacity .1s ease-out, max-height 0.15s;
  }

  background-color: var(--card);
  border: light-dark(#DADADA, #333) 1px solid;
  border-radius: 5px;
  box-shadow: 0 0 4px #EAEAEA, 0 0px 2px  #C0C0C0, 0 7px 8px -8px #D0D0D0;

  font-family: "Source Serif 4";

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  overflow-y: hidden;

  h2 {
    font-family: "Source Serif 4";
    font-size: 1.85rem;
    font-weight: 700;
    margin-top: -10px;
    margin-bottom: 8px;
    color: var(--baseColor);
  }
}

#wrap_levelselect {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: min(1.5vh, 30px);
}
#navbar {display: none;}

@media (width < 1450px) {
  #wrap_levelselect {
    margin-top: 26px;
  }

  #navbar {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    
    width: clamp(130px, 60vw, 400px);

    span {
      height: 12px;
      width: 12px;
      border-radius: 100%;
      background-color: transparent;
      box-shadow: inset 0 0 0 2px transparent;
      border: 1.5px solid light-dark(#555, #888);
      filter: drop-shadow(0 1px 1px light-dark(#e7e7e7, #000));
      
      transition: scale 0.1s ease-out, opacity 0.1s;
      cursor: pointer;
      &::before {
        content: "";
        position: relative;
        display: block;
        bottom: 0;
        height: 10px;
        width: 10px;
        scale: 3;
        cursor: pointer;
      }

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

    button {
      content: "";
      height: 22px;
      width: 22px;
      background: none;
      border: none;
      padding: 0;

      cursor: pointer;

      border-bottom: 7px solid light-dark(#555, #888);
      border-right: 7px solid light-dark(#555, #888);
      border-radius: 4px;

      &::before {
        content: "";
        position: relative;
        display: block;
        bottom: 0;
        height: 22px;
        width: 22px;
        scale: 1.8;
        cursor: pointer;
      }

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

    #leftnav {
      left: -12px;
      rotate: 135deg;
      filter: drop-shadow(2px -2px 1px light-dark(#eaeaea, #000));
    }
    #rightnav {
      right: -12px;
      rotate: -45deg;
      filter: drop-shadow(-2px 2px 1px light-dark(#eaeaea, #000));
    }
    
  }

  
  #wrap_cards:has(#training.upcard) ~ #navbar #nav1,
  #wrap_cards:has(#normal.upcard) ~ #navbar #nav2,
  #wrap_cards:has(#difficult.upcard) ~ #navbar #nav3,
  #wrap_cards:has(#extreme.upcard) ~ #navbar #nav4
  {
    
    background-color: light-dark(#555, #888);
    &:hover {
      opacity: 1;
    }
  }

  
  #wrap_cards.grabbing {
    cursor: grabbing;
    .card, .campaignlist, #wrap_stages {
      cursor: grabbing;
      .level-button, .trainstage {
        cursor: grabbing;
      }
    }
  }

  .upcard {     cursor: grab;
    .campaignlist, #wrap_stages {
      cursor: default;
  }}
  .card:not(.upcard) {
    cursor: pointer;
    
    .level-button, .trainstage {
      pointer-events: none;
    }
  }
}

@media (width < 1450px) and (width > 600px) {
  .card {
    --offset: clamp(140px, calc((1450px - 100vw) / 2.8), 290px);
    position: relative;
    bottom: 0;
    margin-left: calc(-1 * var(--offset));
    backface-visibility: hidden;
    will-change: rotate;
  }
  

  .upcard {
    clip-path: none;
    box-shadow: 0 0 4px #EAEAEA, 0 0px 2px  #C0C0C0, 0 7px 8px -8px #D0D0D0, 18px 0 20px -10px rgba(0,0,0,0.3), -18px 0 20px -10px rgba(0,0,0,0.3);

    #wrap_cards.grabbing & {

      cursor: grabbing;
      .level-button, .trainstage {
        cursor: grabbing;
      }
    }
    
    
    &:first-child.card {
      box-shadow: 0 0 4px #EAEAEA, 0 0px 2px  #C0C0C0, 0 7px 8px -8px #D0D0D0, 18px 0 20px -10px rgba(0,0,0,0.3);
    }
    &:last-child.card {
      box-shadow: 0 0 4px #EAEAEA, 0 0px 2px  #C0C0C0, 0 7px 8px -8px #D0D0D0, -18px 0 20px -10px rgba(0,0,0,0.3);
    }
  }
  
  .card:has(~ .upcard) {
    clip-path: inset(0 0 0 -30px);
    box-shadow: -18px 0 20px -10px rgba(0,0,0,0.25);

    &:first-child {clip-path: none; box-shadow: none;}
    
    &.hover {  rotate: -4deg; }
  }
  .upcard ~ .card {
    clip-path: inset(0 -30px 0 0);
    box-shadow: 18px 0 20px -10px rgba(0,0,0,0.25);

    &:last-child {clip-path: none; box-shadow: none;}

    &.hover {  rotate: 4deg; }  }

  #wrap_cards.grabbing .card {
    &.hover { rotate: unset; }
  }
  #wrap_levelselect * {
    touch-action: none;
  }
}




@media (width <= 600px ) {
  .card:first-child {
    margin-left: calc(0.5 * (100% - 326px)) !important;
  }
  #wrap_cards {
    overflow-x: auto;
    gap: 20px;
    width: 100vw;
    mask-image: linear-gradient(to right, transparent 0px, black 40px, black calc(100% - 50px), transparent 100%);
  }
  .card:last-child {
    margin-right: calc(0.5 * (100% - 326px)) !important;
  }

  .card {
    scroll-snap-align: center;
    transition: rotate 0.15s ease-out, transform .1s ease-out, filter .1s ease-out, box-shadow 0.2s, opacity .2s ease-out;

    &:is(#training) {
      /* Add max-height */
      transition: rotate 0.15s ease-out, transform .1s ease-out, filter .1s ease-out, box-shadow 0.2s, opacity .2s ease-out, max-height 0.15s;
    }
  }

  .card:not(.upcard) {
    opacity: 0.6;
    cursor: pointer;
    opacity: 0.5;
    box-shadow: 0 0 4px transparent, 0 0px 2px transparent, 0 7px 8px -8px transparent;
  }
}




.level-button {
  height: 54px;
  width: 54px;
  margin-bottom: 0;
  box-sizing: border-box;
  
  font-size: 1.75rem;
  font-weight: 315;
  
  border: 1px solid light-dark(#888, #000);
  color: var(--baseColor);
  border-radius: 3px;
  
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;

  transition: transform 0.1s ease-out, opacity 0.1s, background 0.1s, border 0.1s, font-weight 0.12s;
}


.level-button.solved {
  filter: saturate(1.75) brightness(0.935);
  &::after {
    content: "";
    background-image: url("../assets/MEDAL.svg");
    background-repeat: no-repeat;
    background-size: 100%;
    position: absolute;
    top: 1.5px;
    right: 1.5px;
    opacity: 0.3;
    filter: var(--hueShiftIcons);
    width: 13px;
    height: 13px;
    pointer-events: none;
  }
}


:root.dark .level-button.solved {
  filter: saturate(2);
  &::after {
    top: 1px;
    right: 1px;
    height: 12px;
    width: 12px;
  }
}

:root.dark {
  #training .level-button {
    border: 2px solid hsl(120 18% 25%);
  }

  #training .trainstage:not(.dropped) {
    box-sizing: border-box;
    width: 100%;
    border: 2px solid hsl(120 18% 22%);
  }
  
  #training .trainstage.dropped {
    box-sizing: border-box;
    width: 100%;
    border: 2px solid hsl(120 18% 15%);
  }

  #normal .level-button {
    border: 2px solid hsl(55 18% 25%);

  }
  #difficult .level-button {
    border: 2px solid hsl(0 18% 28%);

  }
  #extreme .level-button {
    border: 2px solid hsl(300 18% 28%);
  }
  
}

.level-button:focus {
  border: 1px solid light-dark(#555, #000);
}

.level-button.locked.nudged {
  transform: scale(0.97) !important;
  transition: transform 0.03s;
}
.level-button.nudged {
  transform: scale(0.95) !important;
  transition: transform 0.08s;
}

#normal {
  li {
    box-shadow: 0 2px 3px hsl(55 8% 86% / 1), 0 0 2px hsl(55 8% 91% / 1);
    background: light-dark(hsl(55 20% 85%), hsl(55 20 15%));
    
    &:focus {
      background: light-dark(hsl(55 25% 80%), hsl(55 20% 13%));
      box-shadow: 0 2px 3px hsl(55 8% 85% / 1), 0 0 2px hsl(55 8% 90% / 1);
    }
    
  }
}

#difficult {
  li {
    box-shadow: 0 2px 3px hsl(0 8% 86% / 1), 0 0 2px hsl(0 8% 91% / 1);
    background: light-dark(hsl(0 20% 85%), hsl(0 20% 15%));


    &:focus {
      background: light-dark(hsl(0 25% 80%), hsl(0 20% 13%));
      box-shadow: 0 2px 3px hsl(0 8% 85% / 1), 0 0 2px hsl(0 8% 90% / 1);
    }
  }
}

#extreme {
  li {
    box-shadow: 0 2px 3px hsl(300 8% 86% / 1), 0 0 2px hsl(300 8% 91% / 1);
    background: light-dark(hsl(300 20% 85%), hsl(300 20% 15%));

    &:focus {
      background: light-dark(hsl(300 25% 80%), hsl(300 20% 13%));
      box-shadow: 0 2px 3px hsl(300 8% 85% / 1), 0 0 2px hsl(300 8% 90% / 1);
    }
  }
}

.card:not(#training) .level-button.locked {
  opacity: 0.4;
}

#training {
  max-height: 453px;
  overflow: visible;
  &:not(:has(.dropped)) {
    max-height: 326px;
  }
  
  .trainstage, .level-button {
    box-shadow: 0 2px 3px hsl(120 8% 86% / 1), 0 0 2px hsl(120 8% 91% / 1);
    background: light-dark(hsl(120 20% 85%), hsl(120 20% 15%));
  }

  .trainstage:focus, .level-button:focus {
    background: light-dark(hsl(120 20% 80%), hsl(120 20% 13%));
    box-shadow: 0 2px 3px hsl(120 8% 85% / 1), 0 0 2px hsl(120 8% 90% / 1);
  }

  .trainstage.dropped {
    box-shadow: 0 2px 3px hsl(120 8% 86% / 1), 0 0 2px hsl(120 8% 91% / 1);
    background: light-dark(hsl(120 25% 80%), hsl(120 28% 9%));
    border: 1px solid light-dark(#888, #000);

    & + * > .level-button.locked {
      opacity: 0.3;
    }
  }
}

.trainstage {
  width: calc(100% - 11px - 2px); /* Align edge with droplist */
  min-height: 48px;
  max-height: 48px;
  padding-left: 11px;
  margin-bottom: 10px;
  
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;

  font-size: 1.45rem;
  font-weight: 435;
  color: var(--baseColor);

  border: 1px solid light-dark(#AAA, #000);
  border-radius: 2px;
  box-shadow: 0 2px 3px #DFDFDF, 0 0 2px #EEE;

  list-style-type: none;
  cursor: pointer;

  transition: background .1s, box-shadow .15s ease-out, top .3s ease-out, margin-bottom 0.1s, border .1s;

  &:last-of-type { margin-bottom: 0px; }
}


@media (hover: hover) and (pointer: fine) {
  .trainstage:hover {
    border: 1px solid light-dark(#888, #000);
  }

  .level-button:hover {
    border: 1px solid light-dark(#555, #000);
  }

  #training .trainstage:not(.dropped):hover, #training .level-button:hover {
    background: light-dark(hsl(120 20% 80%), hsl(120 20% 13%));
    box-shadow: 0 2px 3px hsl(120 8% 85% / 1), 0 0 2px hsl(120 8% 90% / 1);
  }

  #normal .level-button:hover {
    background: light-dark(hsl(55 20% 80%), hsl(55 20% 13%));
    box-shadow: 0 2px 3px hsl(55 8% 85% / 1), 0 0 2px hsl(55 8% 90% / 1);
  }

  #difficult .level-button:hover {
    background: light-dark(hsl(0 20% 80%), hsl(0 20% 13%));
    box-shadow: 0 2px 3px hsl(0 8% 85% / 1), 0 0 2px hsl(0 8% 90% / 1);
  }

  #extreme .level-button:hover {
    background: light-dark(hsl(300 20% 80%), hsl(300 20% 13%));
    box-shadow: 0 2px 3px hsl(300 8% 85% / 1), 0 0 2px hsl(300 8% 90% / 1);
  }

  :root.dark {
    #training .trainstage:not(.dropped):hover {
      border: 2px solid hsl(120 18% 19%);
    }
    #training .level-button:hover {
      border: 2px solid hsl(120 18% 19%);
    }
    #normal .level-button:hover {
      border: 2px solid hsl(55 18% 19%);
    }
    #difficult .level-button:hover {
      border: 2px solid hsl(0 18% 19%);
    }
    #extreme .level-button:hover {
      border: 2px solid hsl(300 18% 19%);
    }
  }
}




.dropdown_chevron {
  position: relative;
  right: 15px;
  bottom: 3px;
  margin-left: auto;
  transition: top 0.12s cubic-bezier(0.77,0.2,0.05,1.0);
}

.dropdown_chevron:before {
  content: "";

  display: inline-block;
  height: 12px;
  width: 12px;

  border-bottom: 2px solid var(--baseColor);
  border-right: 2px solid var(--baseColor);
  border-radius: 0px;

  rotate: 45deg;
  transition: transform 0.12s cubic-bezier(0.77,0.2,0.05,1.0);
}

.trainstage.dropped .dropdown_chevron:before {
  transform: rotate(180deg);
}
.trainstage.dropped .dropdown_chevron {
  /* Counteract apparent upwards-shift caused by rotating chevron */
  top: 4px;
}

.droplist, .campaignlist {
  padding: 0;
  
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;

  list-style-type: none;
}

.campaignlist, #wrap_stages {
  overflow: auto;
  scrollbar-width: none;
}

#wrap_stages {
  max-height: min-content;
  width: 100%;
  padding: 0;
  overscroll-behavior-x: none;
}

.droplist {
  margin-bottom: 0;
  max-height: 0;
  transition: max-height 0.1s linear, margin-bottom .1s linear;
  position: relative;
  .level-button {
    transform: translateY(-15px);
    opacity: 0;
  }
}

.trainstage:last-of-type.dropped {
  margin-bottom: 10px;

  + .droplist {
    margin-bottom: 0px;
  }
}

.trainstage.dropped + .droplist {
  max-height: 200px;
  margin-bottom: 10px;

  .level-button {
    position: relative;
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
  }
}

.trainstage:not(.dropped) + .droplist .level-button {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
}

#training:has(#s5.dropped) {
}
