/*====// CSS File Structure //====
  1. Root styles
  2. Global styles
  3. Media player styles
    -Subtitle container
    -General message display
    -Loading icon display

  4. Video controls styles
  5. Video control elements
    -Buffer
    -Context menu
    -About Window

  6. Cinematic mode
  7. Settings menu
  8. Plug
  ================================ */

/* Root styles */
:root {
  --videoPlayer-ui-bg-color: #7a7a7a;
  --videoPlayer-ui-dark-color: #202020;
  --videoPlayer-ui-border-color: #363636;
  --videoPlayer-ui-light-color: #d0d0d0;
  --slider-active-color: #ff0000;
  --videoPlayer-width: 600px;
  --videoPlayer-height: 100vh;
  --videoPlayer-font: Arial, sans-serif;
  --osp-thumb-width: 1em;
}

video::-webkit-media-text-track-container,
video::-webkit-media-text-track-background,
video::-webkit-media-text-track-display-backdrop,
video::-webkit-media-text-track-display,
video::-moz-caption-text,
video::cue {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  z-index: -1000;
}

/* Media player */
.osp-player {
  position: relative;
  min-width: 330px;
  min-height: calc(41px + 0.8rem);
  background-color: var(--videoPlayer-ui-dark-color);
  overflow: hidden;
}

.osp-player video {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  margin: 0 auto;
  max-height: inherit;
  max-width: inherit;
  min-width: inherit;
  min-height: inherit;
  background-color: #000;
  overflow: hidden;
}

.osp-player audio {
  background-color: var(--videoPlayer-ui-dark-color);
}

.osp-player:has(audio) {
  overflow: visible;
}

.osp-player-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  z-index: 0;
  filter: blur(20px) brightness(50%);
}

.osp-player:fullscreen,
.osp-player:-webkit-full-screen,
.osp-player:-moz-full-screen,
.osp-player:-ms-fullscreen,
.osp-player video:fullscreen,
.osp-player video:-webkit-full-screen,
.osp-player video:-moz-full-screen,
.osp-player video:-ms-fullscreen {
  display: flex;
  align-items: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
}

/* Subtitle container */
.osp-track {
  position: absolute;
  left: 50%;
  bottom: calc(46px + 0.8em);
  transform: translateX(-50%);
  display: none;
  text-align: center;
}

.osp-track-subtitle {
  display: inline-block;
  padding: 0 5px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 2px;
  font-family: var(--videoPlayer-font);
  font-size: 1.6rem;
  color: white;
  transition: all 0.1s ease-in;
}

@media screen and (max-width: 768px) {
  .osp-track-subtitle {
    font-size: 1.2rem;
  }
}

@media screen and (max-width: 384px) {
  .osp-track-subtitle {
    font-size: 0.8rem;
  }
}

/* General message display */
.osp-message-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 100%;
  font-family: var(--videoPlayer-font);
  font-size: 1.7rem;
  text-align: center;
  text-wrap: wrap;
  color: var(--videoPlayer-ui-light-color);
  z-index: 1000;
  overflow: hidden;
}

/* Loading icon display */
.osp-loading-display {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  transform: translate(-50%, -50%);
  width: 5em;
  height: 5em;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top: 5px solid white;
  border-radius: 50%;
  animation: spin 2s linear infinite;
  z-index: 1000;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Video controls */
.osp-controls-outter {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0.8rem;
  height: 46px;
  padding: 0;
  color: var(--videoPlayer-ui-light-color);
  background-color: rgba(0, 0, 0, 0.5);
  font-family: var(--videoPlayer-font);
  transition: opacity 0.3s ease-out;
  z-index: 1;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.osp-controls-outter:hover {
  opacity: 1;
}

.osp-controls-inner {
  display: flex;
  align-items: center;
  width: inherit;
  margin: 0 0.4rem;
}

.osp-controls-inner > * {
  margin: 0 .3em;
}

.osp-padding {
  flex-grow: 1;
}

/* Video control elements */
.osp-controls-inner svg {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  fill: currentColor;
}

.osp-button {
  margin: 0 5px;
  font-size: 1.5rem;
  cursor: pointer;
}

.osp-timestamp,
.osp-time-length {
  font-size: 0.9em;
  line-height: 1.53rem;
}

.osp-seeker-bar-container {
  position: absolute;
  top: -0.5rem;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  z-index: 2;
}

.osp-seeker-bar {
  width: 100%;
  min-width: 10rem;
  border-radius: none;
}

.osp-volume-bar {
  width: clamp(3rem, 20%, 6rem);
  border-radius: 5px;
}

.osp-play-pause {
  min-width: 1em;
}

.osp-volume-bar,
.osp-seeker-bar {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  margin: 0;
  padding: 0;
  height: calc((var(--osp-thumb-width)) / 2);
  background: transparent;
  outline: none;
  border: none;
}

.osp-seeker-bar {
  background: linear-gradient(to right,
    var(--slider-active-color) 0%,
    var(--slider-active-color) var(--current-percentage),
    var(--videoPlayer-ui-light-color) var(--current-percentage),
    var(--videoPlayer-ui-light-color) var(--buffered-percentage),
    var(--videoPlayer-ui-bg-color) var(--buffered-percentage),
    var(--videoPlayer-ui-bg-color) 100%
  );
}

.osp-volume-bar {
   background: linear-gradient(to right,
    var(--slider-active-color) 0%,
    var(--slider-active-color) var(--current-percentage),
    var(--videoPlayer-ui-bg-color) var(--current-percentage),
    var(--videoPlayer-ui-bg-color) 100%
  );
}

.osp-volume-bar::-webkit-slider-thumb,
.osp-seeker-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--osp-thumb-width);
  height: var(--osp-thumb-width);
  margin-top: calc((var(--osp-thumb-width)) / 4 - 0.25rem);
  background: var(--videoPlayer-ui-dark-color);
  border-radius: 50%;
  border: 2px solid var(--videoPlayer-ui-border-color);
  transform: scale(1.2);
  cursor: pointer;
}

.osp-volume-bar::-moz-range-thumb,
.osp-seeker-bar::-moz-range-thumb {
  width: var(--osp-thumb-width);
  height: var(--osp-thumb-width);
  background: var(--videoPlayer-ui-dark-color);
  border-radius: 50%;
  border: 2px solid var(--videoPlayer-ui-border-color);
  cursor: pointer;
}

/* Buffer */
.osp-seeker-bar::-webkit-slider-runnable-track {
  background: none;
  border: none;
}

.osp-seeker-bar::-moz-range-track {
  background: none;
  border: none;
}

@media (max-width: 768px) {
  .osp-button {
    font-size: 1.2rem;
  }
}

.osp-seeker-bar-container {
  text-wrap: initial;
}

/* Right Click Menu */
.osp-context {
  position: fixed;
  display: none;
  width: 105px;
  height: auto;
  flex-direction: column;
  margin-left: 3px;
  background-color: rgba(0, 0, 0, 0.7);
  font-family: inherit;
  border-radius: 5px;
  z-index: 10;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.osp-context.visible {
  display: flex;
}

.osp-context span {
  padding: 4px 6px;
  color: var(--videoPlayer-ui-light-color);
  font: 0.8rem Consolas, monospace;
  border-bottom: 1px solid #00000036;
  cursor: pointer;
  transition: background-color 0.2s ease-out;
}

.osp-context span:hover {
  background-color: rgba(0, 0, 0, 0.8);
  border-radius: 5px;
}

.osp-context span.first {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.osp-context span.last {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

.contextAboutWindow {
  display: none;
  max-width: 100%;
  height: auto;
  background-color: inherit;
  font: 0.7rem Consolas, monospace;
  color: var(--videoPlayer-ui-light-color);
  word-break: break-all;
}

.contextAboutWindow a:visited,
.contextAboutWindow a:hover,
.contextAboutWindow a:active,
.contextAboutWindow a {
  color: var(--videoPlayer-ui-light-color);
}

/* Cinematic mode */
.osp-cinema {
  width: 100%;
  height: 100%;
  background-color: black;
  transition: background-color 0.3s ease-out;
}

.osp-cinema body *:not(.osp-player) {
  transition: background-color 0.3s ease-out;
}

/* Extra elements to be hidden in cinematic mode
.osp-cinema element,
.osp-cinema .element {
  opacity: 0;
}*/

.osp-cinema .osp-player  {
  z-index: 10000;
}

/* Settings menu */
.osp-settings-outter {
  position: relative;
}

.osp-settings {
  position: absolute;
  display: none;
  bottom: calc(100% + 0.9em);
  right: 100%;
  transform: translateX(70%);
  padding: 0;
  max-height: 0;
  opacity: 0;
  transition: max-height 1s ease-in;
  transition: opacity 0.5s ease-out;
}

.osp-settings.open {
  position: absolute;
  right: calc(50% + 4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-height: 400px;
  padding: 6px 4px;
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 4px 6px 0 rgba(0,0,0,0.6);
  border-radius: 5px;
  z-index: 1000;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(8px);
}

.osp-settings span {
  display: none;
  height: 0;
  transition: height 0.3s ease-out;
}

.osp-settings.open span {
  display: block;
  max-height: 400px;
  width: auto;
  height: auto;
  background-color: transparent;
  opacity: 1;
  z-index: 100;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: none;
}

.osp-settings.open span:hover {
  transform: scale(1.2);
}

.osp-settings.open .osp-subtitle {
  display: none;
  font-size: 0.9em;
}
@media screen and (max-width: 768px) {
  .osp-settings.open .osp-subtitle {
    font-size: 1em;
  }
}

/* Plug */
.osp-plug-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 15;
  color: var(--videoPlayer-ui-light-color);
  text-align: center;
  box-sizing: border-box;
  overflow: hidden;
}

.osp-plug-inner {
  position: relative;
  width: clamp(200px, 80%, 600px);
  height: clamp(100px, 80%, 600px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: rgba(70, 70, 70, 0.35);
  border-radius: 1.25rem;
}

.osp-plug-content {
  max-width: 80%;
  max-height: 80%;
  width: fit-content;
  height: fit-content;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--videoPlayer-font);
  color: var(--videoPlayer-ui-light-color);
  text-align: center;
}

.osp-plug-ext-content,
.osp-plug-ext-content * {
  max-width: 100%;
  max-height: 100%;
  width: 400px;
  height: 300px;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--videoPlayer-font);
  color: var(--videoPlayer-ui-light-color);
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto;
}

.osp-plug-content img,
.osp-plug-content video {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
}

.osp-plug-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background-color: var(--videoPlayer-ui-light-color);
  color: var(--videoPlayer-ui-dark-color);
  border: 1px solid var(--videoPlayer-ui-border-color);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  z-index: 16;
  transition: background-color 0.2s ease;
}

.osp-plug-close:hover {
  background-color: var(--videoPlayer-ui-bg-color) !important;
}

.osp-plug-close:focus {
  outline: 2px solid skyblue;
}

.osp-plug-close:disabled {
  cursor: default;
  opacity: 0.5;
}