* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Space Grotesk", sans-serif;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  flex-direction: column;
}
header {
  width: 100%;
  height: 10rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
header > img {
  height: 3rem;
}
.title {
  text-align: center;
  font-size: 1.5rem;
}
main {
  width: 100%;
  height: 100%;
}

.video-container {
  position: relative;
  display: flex;
  justify-content: center;
  margin-inline: auto;
  width: 90%;
  max-width: 1000px;
  background-color: #333;
  box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px,
    rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px,
    rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
  border-radius: 0.5rem;
  overflow: hidden;
  transition: width ease-in-out 200ms;
}

/* add diff. w & h when having theater or full-screen class on video-container */
.video-container.full-screen,
.video-container.theater {
  max-width: initial;
  width: 100%;
}
.video-container.theater {
  max-height: 85vh;
}

.video-container.full-screen {
  max-height: 100vh;
}
video {
  width: 100%;
}

.video-controls-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  opacity: 0;
  color: white;
  transition: opacity ease-in-out 150ms;
}

/* Overlay to make controls more visible */
.video-controls-container::before {
  content: "";
  position: absolute;
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  width: 100%;
  aspect-ratio: 6 / 1;
  z-index: -1;
  pointer-events: none;
}

/* if hovered/has paused class/tab on video-container show video-controls-container */
.video-container:hover .video-controls-container,
.video-container:focus-within .video-controls-container,
.video-container.paused .video-controls-container {
  opacity: 1;
}

.video-controls-container .controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem;
}

/* remove default styles of btns and add hard coded h & w for svg aspect ratio */
.video-controls-container .controls button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  height: 25px;
  width: 30px;
  font-size: 1.1rem;
  opacity: 0.65;
  transition: opacity ease-in-out 150ms;
}

.video-controls-container .controls button:hover {
  opacity: 1;
}

/* Toggle icon based on a class's presence*/

.video-container.paused .pause-icon {
  display: none;
}

.video-container:not(.paused) .play-icon {
  display: none;
}
.video-container.theater .enter-theater-icon {
  display: none;
}

.video-container:not(.theater) .exit-theater-icon {
  display: none;
}
.video-container.full-screen .enter-full-icon {
  display: none;
}

.video-container:not(.full-screen) .exit-full-icon {
  display: none;
}

/* conditionally show or hide volume level icons based-on data attr. injected on video-container section */
.volume-high-icon,
.volume-low-icon,
.volume-mute-icon {
  display: none;
}

.video-container[data-volume-level="high"] .volume-high-icon {
  display: block;
}
.video-container[data-volume-level="low"] .volume-low-icon {
  display: block;
}
.video-container[data-volume-level="mute"] .volume-mute-icon {
  display: block;
}

.volume-container {
  display: flex;
  align-items: center;
}
/* hide and show volume slider with a delay and transition same as youtube video player */
.volume-slider {
  width: 0;
  transform-origin: left;
  transform: scaleX(0);
  transition: width ease-in-out 150ms, transform ease-in-out 150ms;
}

/* if volume-container is hovered && slider is focused by TAB apply below styles */
.volume-container:hover .volume-slider,
.volume-slider:focus-within {
  width: 5rem;
  height: 0.3rem;
  transform: scaleX(1);
}

.duration-container {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-grow: 1;
}

/* adding a hardcoded spacing for speed btn */
.video-controls-container .controls button.wide-space {
  width: 50px;
}

/* using the in-built range input as slider for forward and backward video moments */
.timeline-container {
  padding: 0 0.5rem;
  position: absolute;
  width: 100%;
  bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-slider {
  flex-grow: 1;
  height: 0.25rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  main {
    margin-top: 5rem;
  }
  header {
    height: 20rem;
    flex-direction: column;
    gap: 0.3rem;
  }
  header > img {
    height: 3rem;
  }
  .title {
    text-align: center;
    font-size: 1.5rem;
  }
  .video-container {
    border-radius: 0.2rem;
  }
  .video-controls-container .controls {
    gap: 0.5rem;
    padding: 0.2rem;
  }
  .video-controls-container .controls button {
    font-size: 1rem;
  }
  .volume-container:hover .volume-slider,
  .volume-slider:focus-within {
    width: 3.2rem;
    height: 0.3rem;
  }
  .duration-container {
    gap: 0.1rem;
    font-size: 0.8rem;
  }
  .video-controls-container .controls button.wide-space {
    width: 2rem;
  }
}

@media only screen and (max-height: 500px) and (orientation: landscape) {
  body {
    overflow: auto;
    height: 130vh;
  }
}
