summaryrefslogtreecommitdiffstats
path: root/toolkit/themes/shared/pictureinpicture/texttracks.css
blob: ec7af4a7b42afff199dd4e3834f44b79f16c9773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

:root {
    --min-font-size: 14px;
    --max-font-size: 40px;
    --font-scale: 0.06;
    --texttracks-bottom: calc(var(--font-scale) * 100vh);

    /*
     * Move text tracks if they visually overlap with pip player controls
     * New text tracks position is determined by adding together:
     *  1) bottom distance of #controls
     *  2) height of #controls-bottom,
     *  3) border size of player controls buttons
     *  4) hardcoded px value (to ensure consistent distance, regardless of pip window size)
     * NOTE: if changing player.css values, change values here too.
     */
    --resize-margin: 5px;
    --player-controls-height: calc(100vh - 2 * var(--resize-margin));
    --player-controls-bottom-distance: calc(100vh - var(--player-controls-height));
    --player-controls-button-height: 10vmax;
    --player-controls-button-max-height: 32px;
    --player-controls-button-min-height: 16px;
    --player-controls-button-outline-width: 2px;
    --player-controls-scrubber-height: 0px;
    --player-bottom-controls-height: calc(var(--player-controls-scrubber-height) + clamp(var(--player-controls-button-min-height), var(--player-controls-button-height), var(--player-controls-button-max-height)));
    --distance-from-player-controls: 20px;
    --texttracks-bottom-overlapped: calc(var(--player-controls-button-outline-width) + var(--player-controls-bottom-distance) + var(--player-bottom-controls-height) + var(--distance-from-player-controls));
}

#texttracks {
    background-color: black;
    opacity: 80%;
    position: absolute;
    text-align: center;
    box-sizing: border-box;
    color: white;
    margin: 0;
    display: block;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px;
    max-width: calc(0.88 * 100vw);
    bottom: var(--texttracks-bottom);
    font-size: clamp(var(--min-font-size), calc(var(--font-scale) * 100vh), var(--max-font-size));
    line-height: clamp(14.4px, calc(var(--font-scale) * 1.2 * 100vh), 48px);
    white-space: pre-line;
    width: max-content;
    font-family: sans-serif;
    transition: bottom 0.3s;
    transition-delay: 0.1s;
}

#texttracks[overlap-video-controls] {
    bottom: var(--texttracks-bottom-overlapped)
}

#texttracks:empty {
    visibility: hidden;
}

@media (prefers-reduced-motion) {
    #texttracks {
        transition: none;
    }
}

@media screen and (max-width: 319px) {
    #texttracks {
        display: none;
    }
}