summaryrefslogtreecommitdiffstats
path: root/toolkit/themes/shared/media/pipToggle.css
blob: 2a2ddeac58f9259321e676bc4781d4e01d07135f (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/* 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/. */

/* This CSS file is for the Picture-in-Picture toggle.
 *
 * The "experiment" class is used to enable styling for the VARIANT version
 * of the toggle for upcoming PiP Nimbus experiments.
 * @see Bug 1811314.
 *
 * To see each section of style changes, search "PIP STYLING" in this file.
 */

/* SHARED PIP STYLING */

.controlsOverlay[hidetoggle="true"].hovering > .pip-wrapper:not(.hovering) {
  /* If this isn't !important, it will fail to override the other opacity
   * rules, which are currently defined below this point in this file. */
  opacity: 0 !important;
}

.pip-wrapper {
  position: absolute;
  cursor: pointer;
  -moz-appearance: none;
  background: none;
  color: inherit;
  border: none;
  text-align: unset;
  top: calc(70% - 40px);
  opacity: 0;
  padding-inline: 0;
  transition: opacity 200ms;
  --pip-icon-size: 24px;
  --pip-icon-width-with-margins: calc(2 * var(--pip-toggle-margin) + var(--pip-icon-size));
  --pip-highlight-style: solid rgba(0, 254, 255, 1);
  --pip-highlight-width: 2px;
  --pip-toggle-distanceFromVideoEdge: 18px;
  --pip-toggle-focus-outline-offset: 1px;
  --pip-toggle-margin: 8px;
  --pip-border-radius-toggle: 4px;
  --pip-box-shadow-default: 0 0 4px rgba(255, 255, 255, 0.9);
  --pip-box-shadow-hover: 0 0 10px rgba(255, 255, 255, 0.7);
  --pip-expanded-height: 40px;
  --pip-expanded-min-width: 200px;
  --pip-expanded-max-width: max-content;
}

/* Adjust sizing of the regular toggle wrapper to correctly show the
 * focus outline when navigating via keyboard. */
.pip-wrapper[has-used],
.pip-wrapper[small-video] {
  height: var(--pip-icon-width-with-margins);
  width: var(--pip-icon-width-with-margins);
  border-radius: var(--pip-border-radius-toggle);
  margin-right: calc(var(--pip-icon-width-with-margins) * -1);
}

.pip-wrapper[policy="hidden"] {
  display: none;
}

.pip-wrapper[policy="top"] {
  top: 0%;
  translate: var(--pip-toggle-translate-x);
}

.pip-wrapper[policy="one-quarter"] {
  top: 25%;
}

.pip-wrapper[policy="middle"] {
  top: 50%;
}

.pip-wrapper[policy="three-quarters"] {
  top: 75%;
}

.pip-wrapper[policy="bottom"] {
  top: 100%;
  translate: var(--pip-toggle-translate-x) -100%;
}

.pip-wrapper[medium-video] > .pip-expanded > .pip-icon-label > .pip-label {
  font-size: 13px;
}

.pip-wrapper[medium-video] > .pip-expanded {
  font-size: 11px;
}

.pip-wrapper[position="right"] {
  /* move from the right by total width of pip toggle so that it is at least visible in the video element */
  right: calc(var(--pip-icon-width-with-margins) + var(--pip-toggle-distanceFromVideoEdge));
}

/* Re-position the first-time toggle such that it will always be the same distance away from the right edge
 * of the video, even if the label and/or message string(s) are long. */
.pip-wrapper[position="right"] > .pip-expanded {
  translate: calc(-100% + var(--pip-icon-width-with-margins));
  transform-origin: right;
}

.pip-wrapper[position="left"] {
  left: var(--pip-toggle-distanceFromVideoEdge);
}

.pip-expanded,
.pip-small,
.pip-icon,
.pip-explainer {
  position: absolute;
  left: 0;
  top: 0;
}

.pip-wrapper > .pip-expanded {
  display: flex;
  opacity: 0;
  align-items: center;
  scale: 0.33 1;
  font-size: 14px;
}

.pip-wrapper:not([small-video], [has-used]) > .pip-small {
  opacity: 0;
  transition: opacity 200ms;
}

.pip-wrapper:not([small-video], [has-used]) > .pip-expanded {
  opacity: 1;
  scale: 1;
  pointer-events: none;
}

.pip-wrapper:not([small-video], [has-used]).hovering > .pip-expanded {
  pointer-events: auto;
}

.pip-icon {
  top: 8px;
  left: 8px;
  pointer-events: none;
  background-image: url("chrome://global/skin/media/picture-in-picture-open.svg");
  background-position: center, center;
  background-repeat: no-repeat;
  background-size: var(--pip-icon-size) var(--pip-icon-size);
  -moz-context-properties: fill;
  fill: currentColor;
  height: var(--pip-icon-size);
  width: var(--pip-icon-size);
}

.videocontrols[localedir="rtl"] .pip-icon {
  transform: scaleX(-1);
}

.pip-wrapper[position="left"] > .pip-expanded > .pip-icon-label > .pip-label {
  margin-left: var(--pip-icon-width-with-margins);
  margin-right: var(--pip-toggle-margin);
}

.pip-small {
  width: 40px;
  height: 40px;
}

.pip-wrapper[position="left"] > .pip-expanded > .pip-icon-label > .pip-icon {
  display: none;
}

.pip-wrapper:is([small-video], [has-used]) > .pip-expanded,
.pip-wrapper[position="right"]:not([small-video], [has-used]) > .pip-icon {
  display: none;
}

.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label > .pip-icon {
  position: relative;
  top: 0;
  left: 0;
  display: inline-block;
}

.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label {
  display: flex;
  flex-direction: row;
  align-content: center;
}

.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label > .pip-icon,
.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label > .pip-label {
  margin-block: auto;
}

.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label > .pip-icon {
  margin-inline: var(--pip-toggle-margin);
}

.pip-wrapper[position="right"] > .pip-expanded > .pip-icon-label > .pip-label {
  margin-right: var(--pip-toggle-margin);
}

@media (prefers-reduced-motion) {
  .pip-wrapper,
  .pip-expanded,
  .pip-small,
  .pip-explainer {
    /* Transition changes in other rules may override this one if reduced motion is preferred.
     * Make sure this one always takes priority. */
    transition: none !important;
  }
}


/* NO EXPERIMENT - PIP STYLING */

.controlsOverlay:not(.experiment).hovering > .pip-wrapper:not(:focus-visible) {
  opacity: 0.8;
}

.controlsOverlay:not(.experiment).hovering > .pip-wrapper.hovering {
  opacity: 1;
}

/* If the PiP toggle is keyboard focused, always show it at 100% opacity */
.pip-wrapper:not([policy="hidden"], .experiment):focus-visible {
  opacity: 1;
}

/* If showing the expanded PiP toggle, don't outline the
 * parent wrapper element - the expanded toggle handles its
 * own outline. This also affects the regular toggle for small-videos. */
.pip-wrapper:not([policy="hidden"], [has-used], .experiment):focus-visible {
  outline: none;
}

/* Override outline set by ua.css for the regular toggle. */
.pip-wrapper[has-used]:not([policy="hidden"], .experiment):focus-visible {
  outline: var(--control-focus-outline);
}

.pip-wrapper:not(.experiment) > .pip-small {
  background-color: rgba(12, 12, 13, 0.65);
  box-shadow: 0 4px 4px rgba(12, 12, 13, 0.25);
  border-radius: var(--pip-border-radius-toggle);
}

.pip-wrapper:not(.experiment) > .pip-expanded,
.pip-wrapper:not(.experiment) > .pip-small {
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
}

/* If first-time toggle is visible and then switched to the regular toggle for smaller videos,
 * maintain the border shown on the first-time toggle. */
.pip-wrapper:not([has-used], .experiment) > .pip-small {
  border: var(--pip-highlight-width) var(--pip-highlight-style);
}

.pip-wrapper:not(.experiment) > .pip-expanded {
  border: var(--pip-highlight-width) var(--pip-highlight-style);
  transition: opacity 250ms, scale 200ms;
  height: var(--pip-expanded-height);
  background-color: rgba(12, 12, 13, 0.9);
  box-shadow: 0 4px 4px rgba(12, 12, 13, 0.25);
  width: var(--pip-expanded-max-width);
  min-width: var(--pip-expanded-min-width);
  border-radius: 8px;
}

.pip-wrapper:not(.experiment).hovering > .pip-expanded {
  box-shadow: none;
  border: var(--pip-highlight-width) var(--pip-highlight-style);
  /* Remove bottom border but keep text centred with padding. */
  border-bottom: none;
  padding-bottom: var(--pip-highlight-width);
}

.pip-wrapper:not([small-video], [has-used], .experiment).hovering > .pip-expanded {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

/* Toggle message only appears for CONTROL variant. */
.pip-wrapper:not(.experiment) > .pip-expanded > .pip-explainer {
  padding: 6px 16px 8px 8px;
  translate: 0;
  transition: opacity 250ms, translate 190ms;
  transition-timing-function: cubic-bezier(.07, .95, 0, 1);
  background: rgba(12, 12, 13, 0.65);
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 8px;
  border: var(--pip-highlight-width) var(--pip-highlight-style);
  border-top: 0;
  box-shadow: 0 4px 4px rgba(12, 12, 13, 0.25);
  opacity: 0;
  margin-inline: calc(-1 * var(--pip-highlight-width));
  width: calc(100% - 24px);
  word-break: break-word;
  pointer-events: none;
  user-select: none;
}

.videocontrols[localedir="rtl"] .pip-wrapper:not(.experiment) > .pip-explainer {
  text-align: right;
  direction: rtl;
}

.pip-wrapper:not(.experiment).hovering > .pip-expanded > .pip-explainer {
  pointer-events: auto;
  opacity: 1;
  translate: 0 calc(40px - var(--pip-highlight-width));
}


/* EXPERIMENT ONLY - PIP STYLING */

/* Since we change the outline for the first-time PiP toggle VARIANT,
 * override the focus outline in videocontrols.css as well so that
 * there is design consistency. */
.controlsContainer.experiment {
  --control-focus-outline: 2px solid #0060DF;
}

.pip-wrapper.experiment > .pip-expanded > .pip-icon-label > .pip-label {
  font-size: min(16px, 1.4em);
}

/* Only the background will be set at 70% opacity. The icons and labels will remain at 100%. */
.controlsOverlay.experiment.hovering > .pip-wrapper {
  opacity: 1;
}

/* If the PiP toggle is keyboard focused, always show it and override outline set by ua.css.
 * Opacity only affects the toggle icon and label, not the background, which is handled separately. */
.pip-wrapper.experiment:not([policy="hidden"]):focus-visible {
  opacity: 1;
  /* Wrapper size won't always match pip-small or pip-expanded, so don't apply outline on wrapper. */
  outline: none;
}

/* For the regular PiP toggle, take into consideration small videos and has-used=true. */
.pip-wrapper.experiment:is([has-used], [small-video]):not([policy="hidden"]):focus-visible > .pip-small,
.pip-wrapper.experiment:not([policy="hidden"], [has-used]):focus-visible > .pip-expanded {
  outline: var(--control-focus-outline);
  outline-offset: var(--pip-toggle-focus-outline-offset);
}

.pip-wrapper.experiment > .pip-expanded > .pip-explainer {
  display: none;
}

.pip-wrapper.experiment > .pip-small {
  border-radius: var(--pip-border-radius-toggle);
  transition: background-color 200ms;
}

.pip-wrapper.experiment > .pip-expanded {
  transition: opacity 250ms, scale 200ms, translate 190ms, background-color 200ms;
  height: var(--pip-expanded-height);
  width: var(--pip-expanded-max-width);
  min-width: var(--pip-expanded-min-width);
  border-radius: var(--pip-border-radius-toggle);
}

.pip-wrapper.experiment > .pip-small,
.pip-wrapper.experiment > .pip-expanded {
  background-color: rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
}

.pip-wrapper.experiment.hovering > .pip-small,
.pip-wrapper.experiment.hovering > .pip-expanded {
  background-color: rgba(0, 0, 0, 1);
}

.pip-wrapper.experiment:not([policy="hidden"], :focus-visible) > .pip-small,
.pip-wrapper.experiment:not([policy="hidden"], :focus-visible) > .pip-expanded {
  box-shadow: var(--pip-box-shadow-default);
}

.pip-wrapper.experiment:not([policy="hidden"], :focus-visible).hovering > .pip-small,
.pip-wrapper.experiment:not([policy="hidden"], :focus-visible).hovering > .pip-expanded {
  box-shadow: var(--pip-box-shadow-hover);
}

/* Remove white box shadow if there is keyboard focus on the toggle and
 * replace it with blue box shadow instead. */
.pip-wrapper.experiment:not([policy="hidden"]):focus-visible > .pip-small,
.pip-wrapper.experiment:not([policy="hidden"]):focus-visible > .pip-expanded {
  box-shadow: 0 0 10px rgba(0, 96, 223, 0.9);
}