/* This layer is sized to the actual picture, excluding object-fit letterboxing. */
.subtitle-layer {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 var(--subtitle-gutter, 6px) var(--subtitle-bottom, 16px);
  pointer-events: none;
  overflow: hidden;
  direction: ltr;
}

.subtitle-layer.controls-visible {
  padding-bottom: max(var(--subtitle-bottom, 16px), 48px);
}
.subtitle-layer[data-position=top] { align-items: flex-start; padding-block: var(--subtitle-bottom, 16px) 0; }
.subtitle-layer[data-position=middle] { align-items: center; padding-block: 0; }
.subtitle-layer[data-align=left] { justify-content: flex-start; }
.subtitle-layer[data-align=right] { justify-content: flex-end; }
.subtitle-layer[data-align=left] .subtitle-box { text-align: left; }
.subtitle-layer[data-align=right] .subtitle-box { text-align: right; }

.subtitle-box {
  box-sizing: border-box;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: var(--subtitle-radius, 9px);
  background: rgba(8, 10, 14, var(--subtitle-opacity, 0.58));
  color: #fff;
  font-family: 'Cairo', Tahoma, Arial, sans-serif;
  font-size: var(--subtitle-font-size, 14px);
  font-weight: 500;
  line-height: 1.65;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.fullscreen-button {
  display: none;
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(8, 10, 14, 0.55);
  color: #eee;
}

.player.started .fullscreen-button { display: flex; }
.fullscreen-button:hover { background: rgba(8, 10, 14, 0.8); }
.fullscreen-button svg { width: 16px; height: 16px; }
/* Fullscreen the complete player so its custom subtitles remain visible. */
#video::-webkit-media-controls-fullscreen-button { display: none; }
.player:fullscreen { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
