/* Loading Screen Styles - Hourglass Loader */
.loader {
    --dur: 2s;
    --hue: 223;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #0f0f17;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader .loader-svg {
    --dur: 2s;
    display: block;
    margin: auto;
    width: 14em;
    height: auto;
}

.loader__glare-top,
.loader__glare-bottom,
.loader__model,
.loader__motion-thick,
.loader__motion-medium,
.loader__motion-thin,
.loader__sand-drop,
.loader__sand-fill,
.loader__sand-grain-left,
.loader__sand-grain-right,
.loader__sand-line-left,
.loader__sand-line-right,
.loader__sand-mound-top,
.loader__sand-mound-bottom {
    animation-duration: var(--dur);
    animation-timing-function: cubic-bezier(0.83, 0, 0.17, 1);
    animation-iteration-count: infinite;
}

.loader__glare-top {
    animation-name: glare-top;
}

.loader__glare-bottom {
    animation-name: glare-bottom;
}

.loader__model {
    animation-name: loader-flip;
    transform-origin: 12.25px 16.75px;
}

.loader__motion-thick,
.loader__motion-medium,
.loader__motion-thin {
    transform-origin: 26px 26px;
}

.loader__motion-thick {
    animation-name: motion-thick;
}

.loader__motion-medium {
    animation-name: motion-medium;
}

.loader__motion-thin {
    animation-name: motion-thin;
}

.loader__sand-drop {
    animation-name: sand-drop;
}

.loader__sand-fill {
    animation-name: sand-fill;
}

.loader__sand-grain-left {
    animation-name: sand-grain-left;
}

.loader__sand-grain-right {
    animation-name: sand-grain-right;
}

.loader__sand-line-left {
    animation-name: sand-line-left;
}

.loader__sand-line-right {
    animation-name: sand-line-right;
}

.loader__sand-mound-top {
    animation-name: sand-mound-top;
}

.loader__sand-mound-bottom {
    animation-name: sand-mound-bottom;
    transform-origin: 12.25px 31.5px;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: hsl(var(--hue), 90%, 10%);
        --fg: hsl(var(--hue), 90%, 90%);
    }
}

/* Animation */
@keyframes loader-flip {
    from {
        transform: translate(13.75px, 9.25px) rotate(-180deg);
    }
    24%,
    to {
        transform: translate(13.75px, 9.25px) rotate(0);
    }
}

@keyframes glare-top {
    from {
        stroke: rgba(255, 255, 255, 0);
    }
    24%,
    to {
        stroke: white;
    }
}

@keyframes glare-bottom {
    from {
        stroke: white;
    }
    24%,
    to {
        stroke: rgba(255, 255, 255, 0);
    }
}

@keyframes motion-thick {
    from {
        animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(0.67turn);
    }
    20% {
        animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
        stroke: rgb(32, 32, 32);
        stroke-dashoffset: 141.11;
        transform: rotate(1turn);
    }
    40%,
    to {
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(1.33turn);
    }
}

@keyframes motion-medium {
    from,
    8% {
        animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(0.5turn);
    }
    20% {
        animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
        stroke: white;
        stroke-dashoffset: 147.53;
        transform: rotate(0.83turn);
    }
    32%,
    to {
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(1.17turn);
    }
}

@keyframes motion-thin {
    from,
    4% {
        animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(0.33turn);
    }
    24% {
        animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
        stroke: rgb(53, 53, 53);
        stroke-dashoffset: 134.7;
        transform: rotate(0.67turn);
    }
    44%,
    to {
        stroke: rgba(255, 255, 255, 0);
        stroke-dashoffset: 153.94;
        transform: rotate(1turn);
    }
}

@keyframes sand-drop {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 1;
    }
    70%,
    to {
        stroke-dashoffset: -107;
    }
}

@keyframes sand-fill {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 55;
    }
    70%,
    to {
        stroke-dashoffset: -54;
    }
}

@keyframes sand-grain-left {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 29;
    }
    70%,
    to {
        stroke-dashoffset: -22;
    }
}

@keyframes sand-grain-right {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 27;
    }
    70%,
    to {
        stroke-dashoffset: -24;
    }
}

@keyframes sand-line-left {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 53;
    }
    70%,
    to {
        stroke-dashoffset: -55;
    }
}

@keyframes sand-line-right {
    from,
    10% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        stroke-dashoffset: 14;
    }
    70%,
    to {
        stroke-dashoffset: -24.5;
    }
}

@keyframes sand-mound-top {
    from,
    10% {
        animation-timing-function: linear;
        transform: translate(0, 0);
    }
    15% {
        animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
        transform: translate(0, 1.5px);
    }
    51%,
    to {
        transform: translate(0, 13px);
    }
}

@keyframes sand-mound-bottom {
    from,
    31% {
        animation-timing-function: cubic-bezier(0.61, 1, 0.88, 1);
        transform: scale(1, 0);
    }
    56%,
    to {
        transform: scale(1, 1);
    }
}

.loader span {
    display: block;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 20px;
    text-align: center;
    color: white;
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Hide loader when content is loaded */
.loader.loaded {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

/* Flashcards Loading Screen */
.flashcards-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.flashcards-loader.show {
    opacity: 1;
    visibility: visible;
}

.flashcards-loader .loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin-top: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.pencil {
    display: block;
    width: 10em;
    height: 10em;
}

.pencil__body1,
.pencil__body2,
.pencil__body3,
.pencil__eraser,
.pencil__eraser-skew,
.pencil__point,
.pencil__rotate,
.pencil__stroke {
    animation-duration: 3s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.pencil__body1,
.pencil__body2,
.pencil__body3 {
    transform: rotate(-90deg);
}

.pencil__body1 {
    animation-name: pencilBody1;
}

.pencil__body2 {
    animation-name: pencilBody2;
}

.pencil__body3 {
    animation-name: pencilBody3;
}

.pencil__eraser {
    animation-name: pencilEraser;
    transform: rotate(-90deg) translate(49px,0);
}

.pencil__eraser-skew {
    animation-name: pencilEraserSkew;
    animation-timing-function: ease-in-out;
}

.pencil__point {
    animation-name: pencilPoint;
    transform: rotate(-90deg) translate(49px,-30px);
}

.pencil__rotate {
    animation-name: pencilRotate;
}

.pencil__stroke {
    animation-name: pencilStroke;
    transform: translate(100px,100px) rotate(-113deg);
}

/* Pencil Animations */
@keyframes pencilBody1 {
    from,
    to {
        stroke-dashoffset: 351.86;
        transform: rotate(-90deg);
    }

    50% {
        stroke-dashoffset: 150.8;
        transform: rotate(-225deg);
    }
}

@keyframes pencilBody2 {
    from,
    to {
        stroke-dashoffset: 406.84;
        transform: rotate(-90deg);
    }

    50% {
        stroke-dashoffset: 174.36;
        transform: rotate(-225deg);
    }
}

@keyframes pencilBody3 {
    from,
    to {
        stroke-dashoffset: 296.88;
        transform: rotate(-90deg);
    }

    50% {
        stroke-dashoffset: 127.23;
        transform: rotate(-225deg);
    }
}

@keyframes pencilEraser {
    from,
    to {
        transform: rotate(-45deg) translate(49px,0);
    }

    50% {
        transform: rotate(0deg) translate(49px,0);
    }
}

@keyframes pencilEraserSkew {
    from,
    32.5%,
    67.5%,
    to {
        transform: skewX(0);
    }

    35%,
    65% {
        transform: skewX(-4deg);
    }

    37.5%, 
    62.5% {
        transform: skewX(8deg);
    }

    40%,
    45%,
    50%,
    55%,
    60% {
        transform: skewX(-15deg);
    }

    42.5%,
    47.5%,
    52.5%,
    57.5% {
        transform: skewX(15deg);
    }
}

@keyframes pencilPoint {
    from,
    to {
        transform: rotate(-90deg) translate(49px,-30px);
    }

    50% {
        transform: rotate(-225deg) translate(49px,-30px);
    }
}

@keyframes pencilRotate {
    from {
        transform: translate(100px,100px) rotate(0);
    }

    to {
        transform: translate(100px,100px) rotate(720deg);
    }
}

@keyframes pencilStroke {
    from {
        stroke-dashoffset: 439.82;
        transform: translate(100px,100px) rotate(-113deg);
    }

    50% {
        stroke-dashoffset: 164.93;
        transform: translate(100px,100px) rotate(-113deg);
    }

    75%,
    to {
        stroke-dashoffset: 439.82;
        transform: translate(100px,100px) rotate(112deg);
    }
}

/* Progress Loading Screen */
.progress-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.progress-loader.show {
    opacity: 1;
    visibility: visible;
}

.progress-loader .loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin-top: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.loading-wave {
    width: 300px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.loading-bar {
    width: 20px;
    height: 10px;
    margin: 0 5px;
    background-color: #3498db;
    border-radius: 5px;
    animation: loading-wave-animation 1s ease-in-out infinite;
}

.loading-bar:nth-child(1) {
    background-color: #ff69b4; /* Pink */
    animation-delay: 0s;
}

.loading-bar:nth-child(2) {
    background-color: #ffd700; /* Golden */
    animation-delay: 0.1s;
}

.loading-bar:nth-child(3) {
    background-color: #3498db; /* Blue */
    animation-delay: 0.2s;
}

.loading-bar:nth-child(4) {
    background-color: #3498db; /* Blue */
    animation-delay: 0.3s;
}

@keyframes loading-wave-animation {
    0% {
        height: 10px;
    }

    50% {
        height: 50px;
    }

    100% {
        height: 10px;
    }
}

/* Checklist Loading Screen */
.checklist-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.checklist-loader.show {
    opacity: 1;
    visibility: visible;
}

.checklist-loader .loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin-top: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Book Animation Styles */
.book,
.book__pg-shadow,
.book__pg {
  animation: cover 5s ease-in-out infinite;
}
.book {
  background-color: hsl(220, 90%, 65%);
  border-radius: 0.25em;
  box-shadow:
    0 0.25em 0.5em hsla(0, 0%, 0%, 0.3),
    0 0 0 0.25em hsl(210, 100%, 57%) inset;
  padding: 0.25em;
  perspective: 37.5em;
  position: relative;
  width: 8em;
  height: 6em;
  transform: translate3d(0, 0, 0);
  transform-style: preserve-3d;
}
.book__pg-shadow,
.book__pg {
  position: absolute;
  left: 0.25em;
  width: calc(50% - 0.25em);
}
.book__pg-shadow {
  animation-name: shadow;
  background-image: linear-gradient(
    -45deg,
    hsla(0, 0%, 0%, 0) 50%,
    hsla(0, 0%, 0%, 0.3) 50%
  );
  filter: blur(0.25em);
  top: calc(100% - 0.25em);
  height: 3.75em;
  transform: scaleY(0);
  transform-origin: 100% 0%;
}
.book__pg {
  animation-name: pg1;
  background-color: hsl(223, 10%, 100%);
  background-image: linear-gradient(
    90deg,
    hsla(223, 10%, 90%, 0) 87.5%,
    hsl(223, 10%, 90%)
  );
  height: calc(100% - 0.5em);
  transform-origin: 100% 50%;
}
.book__pg--2,
.book__pg--3,
.book__pg--4 {
  background-image: repeating-linear-gradient(
      hsl(223, 10%, 10%) 0 0.125em,
      hsla(223, 10%, 10%, 0) 0.125em 0.5em
    ),
    linear-gradient(90deg, hsla(223, 10%, 90%, 0) 87.5%, hsl(223, 10%, 90%));
  background-repeat: no-repeat;
  background-position: center;
  background-size:
    2.5em 4.125em,
    100% 100%;
}
.book__pg--2 {
  animation-name: pg2;
}
.book__pg--3 {
  animation-name: pg3;
}
.book__pg--4 {
  animation-name: pg4;
}
.book__pg--5 {
  animation-name: pg5;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(223, 10%, 30%);
    --fg: hsl(223, 10%, 90%);
  }
}

/* Book Animations */
@keyframes cover {
  from,
  5%,
  45%,
  55%,
  95%,
  to {
    animation-timing-function: ease-out;
    background-color: hsl(220, 84%, 67%);
  }
  10%,
  40%,
  60%,
  90% {
    animation-timing-function: ease-in;
    background-color: hsl(210, 90%, 45%);
  }
}
@keyframes shadow {
  from,
  10.01%,
  20.01%,
  30.01%,
  40.01% {
    animation-timing-function: ease-in;
    transform: translate3d(0, 0, 1px) scaleY(0) rotateY(0);
  }
  5%,
  15%,
  25%,
  35%,
  45%,
  55%,
  65%,
  75%,
  85%,
  95% {
    animation-timing-function: ease-out;
    transform: translate3d(0, 0, 1px) scaleY(0.2) rotateY(90deg);
  }
  10%,
  20%,
  30%,
  40%,
  50%,
  to {
    animation-timing-function: ease-out;
    transform: translate3d(0, 0, 1px) scaleY(0) rotateY(180deg);
  }
  50.01%,
  60.01%,
  70.01%,
  80.01%,
  90.01% {
    animation-timing-function: ease-in;
    transform: translate3d(0, 0, 1px) scaleY(0) rotateY(180deg);
  }
  60%,
  70%,
  80%,
  90%,
  to {
    animation-timing-function: ease-out;
    transform: translate3d(0, 0, 1px) scaleY(0) rotateY(0);
  }
}
@keyframes pg1 {
  from,
  to {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.4deg);
  }
  10%,
  15% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(180deg);
  }
  20%,
  80% {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(180deg);
  }
  85%,
  90% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(180deg);
  }
}
@keyframes pg2 {
  from,
  to {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(0.3deg);
  }
  5%,
  10% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.3deg);
  }
  20%,
  25% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.9deg);
  }
  30%,
  70% {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(179.9deg);
  }
  75%,
  80% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.9deg);
  }
  90%,
  95% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.3deg);
  }
}
@keyframes pg3 {
  from,
  10%,
  90%,
  to {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(0.2deg);
  }
  15%,
  20% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.2deg);
  }
  30%,
  35% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.8deg);
  }
  40%,
  60% {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(179.8deg);
  }
  65%,
  70% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.8deg);
  }
  80%,
  85% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.2deg);
  }
}
@keyframes pg4 {
  from,
  20%,
  80%,
  to {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(0.1deg);
  }
  25%,
  30% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.1deg);
  }
  40%,
  45% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.7deg);
  }
  50% {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(179.7deg);
  }
  55%,
  60% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.7deg);
  }
  70%,
  75% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0.1deg);
  }
}
@keyframes pg5 {
  from,
  30%,
  70%,
  to {
    animation-timing-function: ease-in;
    background-color: hsl(223, 10%, 45%);
    transform: translate3d(0, 0, 1px) rotateY(0);
  }
  35%,
  40% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0deg);
  }
  50% {
    animation-timing-function: ease-in-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(179.6deg);
  }
  60%,
  65% {
    animation-timing-function: ease-out;
    background-color: hsl(223, 10%, 100%);
    transform: translate3d(0, 0, 1px) rotateY(0);
  }
}
