UNPKG

20.2 kBCSSView Raw
1/* Readium CSS
2 Config module
3
4 A file allowing implementers to customize flags for reading modes,
5 user settings, etc.
6
7 Repo: https://github.com/readium/readium-css */
8
9/* Custom medias
10 Syntax: @custom-media --variable (prop: value) */
11
12/* Responsive columns
13 The minimum width for which responsive columns (2 -> 1 and vice versa,
14 depending on the current font-size) must be enabled */
15
16/* Mobile columns
17 The minimum and maximum width for mobile devices.
18 We’re forcing the landscape orientation by default,
19 and must still investigate large tablets (iPad Pro, Surface Pro 3, etc.). */
20
21/* Custom selectors
22 Syntax: @custom-selector :--variable selector
23 The selectors you will use for flags/switches
24 You can alternatively use classes or custom data-* attributes */
25
26/* User view = paged | scrolled */
27
28/* Font-family override */
29
30/* Advanced settings */
31
32/* Reading Modes */
33
34/* Filters (images) */
35
36/* Accessibility normalization */
37
38/* Accessibility font. You can add selectors, using “, ” as a separator, if you have multiple fonts */
39
40/* Direction i.e. ltr and rtl */
41
42/* Readium CSS
43 Pagination module for vertical writing
44
45 A set of styles to paginate ePublications in “writing-mode: vertical-*”
46
47 Repo: https://github.com/readium/readium-css */
48
49/* Config */
50
51/* We must simplify the pagination model for vertical writing, and can’t fake spreads. */
52
53/* Default for smartphone portrait (small screens) */
54
55:root {
56 /* The column will be the height of the web view/iframe */
57 --RS__colWidth: 100vh;
58
59 /* Since columns are laid out on the y-axis in vertical-*, we can only use 1 */
60 --RS__colCount: 1;
61
62 /* Gap between columns (in pixels so that it won’t resize with font-size) */
63 --RS__colGap: 0;
64
65 /* Optimal line-length (rem will take :root font-size into account, whatever the body’s font-size) */
66 --RS__maxLineLength: 40rem;
67
68 /* Default page vertical margins (in pixels so that it won’t resize with font-size) */
69 --RS__pageGutter: 20px; /* See if colGap and pageGutter can be the same var */
70}
71
72/* Reset page margins for Forward compatibility */
73
74@page {
75 margin: 0 !important;
76}
77
78/* :root selector has same specificity as a class i.e. 0010
79 We might have to change that to html / context
80 -> https://css-tricks.com/almanac/selectors/r/root/ */
81
82:root {
83
84 /* In case you use left position to scroll, can be removed if using transform: translateX() */
85 position: relative;
86
87 -webkit-column-width: var(--RS__colWidth);
88 -moz-column-width: var(--RS__colWidth);
89 column-width: var(--RS__colWidth);
90
91 /* Init pagination */
92 /* TODO: document columns’ logic cos it might feel weird at first */
93 -webkit-column-count: var(--RS__colCount);
94 -moz-column-count: var(--RS__colCount);
95 column-count: var(--RS__colCount);
96
97 -webkit-column-gap: var(--RS__colGap);
98 -moz-column-gap: var(--RS__colGap);
99 column-gap: var(--RS__colGap);
100
101 /* Default is balance and we want columns to be filled entirely (100vh) */
102 -moz-column-fill: auto;
103 column-fill: auto;
104 width: 100%;
105 height: 100vh;
106 max-width: 100%;
107 max-height: 100vh;
108 min-width: 100%;
109 min-height: 100vh;
110 padding: 0 var(--RS__pageGutter) !important;
111 margin: 0 !important;
112
113 /* Column size will depend on this if we want to make it responsive */
114 font-size: 100% !important;
115
116 -webkit-text-size-adjust: 100%;
117
118 /* Switch to newer box model (not inherited by authors’ styles) */
119 box-sizing: border-box;
120
121 hanging-punctuation: last allow-end;
122
123 /* Fix bug for older Chrome */
124 -webkit-perspective: 1;
125 /* Prevents options pop-up when long tap in webkit */
126 -webkit-touch-callout: none;
127
128 /* The reason why we don’t force -webkit-column-axis is that it switches the column-box model to a paged overflow model.
129 In other words, columns become useless, the sizing of the :root itself will be used for pagination */
130
131 /* Ensure the correct writing-mode is used */
132 -ms-writing-mode: tb-rl;
133 -webkit-writing-mode: vertical-rl;
134 writing-mode: vertical-rl;
135}
136
137:root:lang(mn-Mong) {
138 /* Ensure the correct writing-mode is used for mongolian if vertical */
139 -ms-writing-mode: tb;
140 -webkit-writing-mode: vertical-lr;
141 writing-mode: vertical-lr;
142}
143
144body {
145 /* overflow: hidden; bugfix: contents won’t paginate in Firefox and one sample in Safari */
146 width: 100%;
147
148 /* Limit line-length but we have to reset when 2 columns and control the viewport.
149 By using max-width + margin auto, margins will shrink when font-size increases,
150 which is what would be expected in terms of typography. */
151 max-height: var(--RS__maxLineLength) !important;
152 padding: var(--RS__pageGutter) 0 !important;
153 margin: auto 0 !important;
154
155 /* We need a minimum padding on body so that descandants/ascendants in italic/script are not cut-off.
156 Drawback: we have to use border-box so that it doesn’t screw the box model,
157 which means it impacts colWidth and max-width */
158 box-sizing: border-box;
159}
160
161/* We’ll now redefine margins and columns depending on the minimum width available
162 The goal is having the simplest model possible and avoid targeting devices */
163
164/* Smartphone landscape */
165
166@media screen and (min-width: 35em) {
167 :root {
168 --RS__pageGutter: 30px;
169 }
170}
171
172/* Tablet portrait */
173
174@media screen and (min-width: 45em) {
175 :root {
176 --RS__pageGutter: 40px;
177 }
178}
179
180/* Desktop small + phablet + tablet landscape */
181
182@media screen and (min-width: 60em) {
183 :root {
184 --RS__pageGutter: 50px;
185 }
186}
187
188/* Desktop + tablet large */
189
190/* We get the previous settings, we just change the margins */
191
192@media screen and (min-width: 75em) {
193 :root {
194 --RS__pageGutter: 60px;
195 }
196}
197
198/* At this point (80em or so), constraining line length must be done at the web view/iframe level, or by limiting the size of :root itself */
199
200/* Readium CSS
201 Scroll module for vertical-writing
202
203 A set of styles to scroll ePublications in “writing-mode: vertical-*”
204 This module overrides pagination
205
206 Repo: https://github.com/readium/readium-css */
207
208:root[style*="readium-scroll-on"] {
209
210 /* Reset columns, auto + auto = columns can’t be created */
211 /* There is a weird gap in Safari/Webkit, as if overflow paged-x… */
212 -webkit-columns: auto auto !important;
213 -moz-columns: auto auto !important;
214 columns: auto auto !important;
215 width: auto !important;
216 max-width: none !important;
217 max-height: 100vh !important;
218 /* Reset html size so that the user can scroll */
219 min-width: 0 !important;
220}
221
222/* Make sure line-length is limited in all configs */
223
224:root[style*="readium-scroll-on"] body {
225 --RS__maxLineLength: 40.01rem !important; /* Fixes fragmentation update issues in Webkit i.e. value must be slightly different than the one for pagination */
226}
227
228/* Scroll mode horizontal */
229
230/* Do we add a top/bottom margin for body in vertical scroll or not? */
231
232/* Readium CSS
233 Default highlights
234
235 A stylesheet for user highlights
236
237 Repo: https://github.com/readium/readium-css */
238
239/* User Highlights */
240
241.readiumCSS-yellow-highlight {
242 background-color: rgba(255, 255, 0, 0.5);
243}
244
245.readiumCSS-green-highlight {
246 background-color: rgba(0, 255, 0, 0.5);
247}
248
249.readiumCSS-orange-highlight {
250 background-color: rgba(255, 165, 0, 0.5);
251}
252
253.readiumCSS-pink-highlight {
254 background-color: rgba(255, 105, 180, 0.5);
255}
256
257/* Media overlays */
258
259.readiumCSS-mo-active-default {
260 color: black !important;
261 background-color: yellow !important;
262}
263
264/* Readium CSS
265 Night mode
266
267 A preset theme for night mode
268
269 Repo: https://github.com/readium/readium-css */
270
271/* CONFIG */
272
273/* [style*="--USER__appearance"] can be used to increase specificity but performance hit */
274
275:root[style*="readium-night-on"] {
276 --RS__backgroundColor: #000000;
277 --RS__textColor: #FEFEFE;
278
279 --RS__linkColor: #63caff;
280 --RS__visitedColor: #0099E5;
281
282 /* This can be customized but initial will re-use default value of the browser */
283 --RS__selectionBackgroundColor: #b4d8fe;
284 --RS__selectionTextColor: inherit;
285}
286
287/* we don’t need to redeclare bg-color and color for :root since we will inherit and update from day/default mode */
288
289:root[style*="readium-night-on"] *:not(a) {
290 color: inherit !important;
291 background-color: transparent !important;
292 border-color: currentColor !important;
293}
294
295:root[style*="readium-night-on"] svg text {
296 fill: currentColor !important;
297 stroke: none !important;
298}
299
300:root[style*="readium-night-on"] a:link,
301:root[style*="readium-night-on"] a:link * {
302 color: var(--RS__linkColor) !important;
303}
304
305:root[style*="readium-night-on"] a:visited,
306:root[style*="readium-night-on"] a:visited * {
307 color: var(--RS__visitedColor) !important;
308}
309
310:root[style*="readium-night-on"] img[class*="gaiji"],
311:root[style*="readium-night-on"] *[epub\:type~="titlepage"] img:only-child {
312 -webkit-filter: invert(100%);
313 filter: invert(100%);
314}
315
316/* Darken all images on user’s demand */
317
318:root[style*="readium-night-on"][style*="readium-darken-on"] img {
319 -webkit-filter: brightness(80%);
320 filter: brightness(80%);
321}
322
323/* Invert all images on user’s demand */
324
325:root[style*="readium-night-on"][style*="readium-invert-on"] img {
326 -webkit-filter: invert(100%);
327 filter: invert(100%);
328}
329
330/* Darken and invert on user’s demand */
331
332:root[style*="readium-night-on"][style*="readium-darken-on"][style*="readium-invert-on"] img {
333 -webkit-filter: brightness(80%) invert(100%);
334 filter: brightness(80%) invert(100%);
335}
336
337/* Readium CSS
338 Sepia mode
339
340 A preset theme for sepia mode
341
342 Repo: https://github.com/readium/readium-css */
343
344/* CONFIG */
345
346:root[style*="readium-sepia-on"] {
347 --RS__backgroundColor: #faf4e8;
348 --RS__textColor: #121212;
349
350 --RS__linkColor: #0000EE;
351 --RS__visitedColor: #551A8B;
352
353 /* This can be customized but initial will re-use default value of the browser */
354 --RS__selectionBackgroundColor: #b4d8fe;
355 --RS__selectionTextColor: inherit;
356
357 --RS__maxLineLength: 40.01rem; /* Forcing a reflow in Blink/Webkit so that blend mode can work */
358}
359
360/* we don’t need to redeclare bg-color and color for :root since we will inherit and update from day/default mode */
361
362:root[style*="readium-sepia-on"] body {
363 /* Should be transparent but Chrome bug https://bugs.chromium.org/p/chromium/issues/detail?id=711955&q=mix-blend-mode&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified */
364
365 color: inherit;
366 background-color: var(--RS__backgroundColor);
367}
368
369:root[style*="readium-sepia-on"] a:link,
370:root[style*="readium-sepia-on"] a:link * {
371 color: var(--RS__linkColor);
372}
373
374:root[style*="readium-sepia-on"] a:visited,
375:root[style*="readium-sepia-on"] a:visited * {
376 color: var(--RS__visitedColor);
377}
378
379:root[style*="readium-sepia-on"] svg,
380:root[style*="readium-sepia-on"] img {
381 /* Make sure the proper bg-color is used for the blend mode */
382 background-color: transparent !important;
383 mix-blend-mode: multiply;
384}
385
386/* Readium CSS
387 OS Accessibility Modes
388
389 A stylesheet to deal with OS accessibility settings
390
391 Repo: https://github.com/readium/readium-css */
392
393/* Windows high contrast colors are mapped to CSS system color keywords
394 See http://www.gwhitworth.com/blog/2017/04/how-to-use-ms-high-contrast */
395
396@media screen and (-ms-high-contrast: active) {
397 :root {
398 color: windowText !important;
399 background-color: window !important;
400 }
401
402 /* The following selectors are super funky but it makes sure everything is inherited, this is indeed critical for this mode */
403 :root :not(#\#):not(#\#):not(#\#),
404 :root :not(#\#):not(#\#):not(#\#) :not(#\#):not(#\#):not(#\#)
405 :root :not(#\#):not(#\#):not(#\#) :not(#\#):not(#\#):not(#\#) :not(#\#):not(#\#):not(#\#) {
406 color: inherit !important;
407 background-color: inherit !important;
408 }
409
410 .readiumCSS-mo-active-default {
411 color: highlightText !important;
412 background-color: highlight !important;
413 }
414
415 /* For links, hyperlink keyword is automatically set */
416
417 /* Should we also set user highlights? */
418}
419
420@media screen and (-ms-high-contrast: white-on-black) {
421 :root[style*="readium-night-on"] img[class*="gaiji"],
422 :root[style*="readium-night-on"] *[epub\:type~="titlepage"] img:only-child {
423 -webkit-filter: none !important;
424 filter: none !important;
425 }
426 :root[style*="readium-night-on"][style*="readium-invert-on"] img {
427 -webkit-filter: none !important;
428 filter: none !important;
429 }
430 :root[style*="readium-night-on"][style*="readium-darken-on"][style*="readium-invert-on"] img {
431 -webkit-filter: brightness(80%);
432 filter: brightness(80%);
433 }
434}
435
436/* Will be true on recent versions of iOS and MacOS if inverted setting enabled by the user */
437
438@media screen and (inverted-colors) {
439 :root[style*="readium-night-on"] img[class*="gaiji"],
440 :root[style*="readium-night-on"] *[epub\:type~="titlepage"] img:only-child {
441 -webkit-filter: none !important;
442 filter: none !important;
443 }
444 :root[style*="readium-night-on"][style*="readium-invert-on"] img {
445 -webkit-filter: none !important;
446 filter: none !important;
447 }
448 :root[style*="readium-night-on"][style*="readium-darken-on"][style*="readium-invert-on"] img {
449 -webkit-filter: brightness(80%);
450 filter: brightness(80%);
451 }
452}
453
454@media screen and (monochrome) {
455 /* Grayscale (Implemented in Safari, what about eInk?) */
456 /* Must deal with anything color (contrast) so must be managed at the night/sepia/theme level :( */
457}
458
459@media screen and (prefers-reduced-motion) {
460 /* If reduced motion is set on MacOS, in case we have animation/transition */
461}
462
463/* Readium CSS
464 Page margins pref
465
466 A submodule managing page margins for user settings
467 Part of “Chrome Advanced” class – no flag required.
468
469 Repo: https://github.com/readium/readium-css */
470
471/* Page Margins: the user margin is a factor of the page gutter e.g. 0.5, 0.75, 1, 1.25, 1.5, etc. */
472
473:root[style*="--USER__pageMargins"] body {
474 padding: calc(var(--RS__pageGutter) * var(--USER__pageMargins)) 0 !important;
475}
476
477/* Readium CSS
478 Custom colors pref
479
480 A submodule managing custom colors for user settings
481 Part of “Chrome Advanced” class – no flag required.
482
483 Repo: https://github.com/readium/readium-css */
484
485:root[style*="--USER__backgroundColor"] {
486 background-color: var(--USER__backgroundColor) !important;
487}
488
489:root[style*="--USER__backgroundColor"] * {
490 background-color: transparent !important;
491}
492
493:root[style*="--USER__textColor"] {
494 color: var(--USER__textColor) !important;
495}
496
497:root[style*="--USER__textColor"] *:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(pre) {
498 color: inherit !important;
499}
500
501/* Readium CSS
502 Font Family pref
503
504 A submodule managing font-family for user settings
505 Part of “User Overrides” class – “font override” flag required.
506
507 Repo: https://github.com/readium/readium-css */
508
509:root[style*="readium-font-on"][style*="--USER__fontFamily"] {
510 font-family: var(--USER__fontFamily) !important;
511}
512
513:root[style*="readium-font-on"][style*="--USER__fontFamily"] body,
514:root[style*="readium-font-on"][style*="--USER__fontFamily"] p,
515:root[style*="readium-font-on"][style*="--USER__fontFamily"] li,
516:root[style*="readium-font-on"][style*="--USER__fontFamily"] div,
517:root[style*="readium-font-on"][style*="--USER__fontFamily"] dt,
518:root[style*="readium-font-on"][style*="--USER__fontFamily"] dd {
519 font-family: inherit !important;
520}
521
522:root[style*="readium-font-on"][style*="--USER__fontFamily"] i:not([lang]),
523:root[style*="readium-font-on"][style*="--USER__fontFamily"] i:not([xml\:lang]),
524:root[style*="readium-font-on"][style*="--USER__fontFamily"] em:not([lang]),
525:root[style*="readium-font-on"][style*="--USER__fontFamily"] em:not([xml\:lang]),
526:root[style*="readium-font-on"][style*="--USER__fontFamily"] cite:not([lang]),
527:root[style*="readium-font-on"][style*="--USER__fontFamily"] cite:not([xml\:lang]),
528:root[style*="readium-font-on"][style*="--USER__fontFamily"] b:not([lang]),
529:root[style*="readium-font-on"][style*="--USER__fontFamily"] b:not([xml\:lang]),
530:root[style*="readium-font-on"][style*="--USER__fontFamily"] strong:not([lang]),
531:root[style*="readium-font-on"][style*="--USER__fontFamily"] strong:not([xml\:lang]),
532:root[style*="readium-font-on"][style*="--USER__fontFamily"] span:not([lang]),
533:root[style*="readium-font-on"][style*="--USER__fontFamily"] span:not([xml\:lang]) {
534 font-family: inherit !important;
535}
536
537/* Readium CSS
538 Font size pref
539
540 A submodule managing font-size for user settings
541 Part of “User Overrides” class – no flag required.
542
543 Repo: https://github.com/readium/readium-css */
544
545:root[style*="--USER__fontSize"] {
546 font-size: var(--USER__fontSize) !important;
547}
548
549/* Readium CSS
550 Line height pref
551
552 A submodule managing line-height for user settings
553 Part of “User Overrides Advanced” class – “advanced settings” flag required.
554
555 Repo: https://github.com/readium/readium-css */
556
557:root[style*="readium-advanced-on"][style*="--USER__lineHeight"] {
558 line-height: var(--USER__lineHeight) !important;
559}
560
561:root[style*="readium-advanced-on"][style*="--USER__lineHeight"] body,
562:root[style*="readium-advanced-on"][style*="--USER__lineHeight"] p,
563:root[style*="readium-advanced-on"][style*="--USER__lineHeight"] li,
564:root[style*="readium-advanced-on"][style*="--USER__lineHeight"] div {
565 line-height: inherit;
566}
567
568/* Readium CSS
569 Para spacing pref
570
571 A submodule managing paragraphs’ top and bottom margins for user settings
572 Part of “User Overrides Advanced” class – “advanced settings” flag required.
573
574 Repo: https://github.com/readium/readium-css */
575
576:root[style*="readium-advanced-on"][style*="--USER__paraSpacing"] p {
577 margin-right: var(--USER__paraSpacing) !important;
578 margin-left: var(--USER__paraSpacing) !important;
579}
580
581/* Readium CSS
582 Font size normalize
583
584 A stylesheet to normalize font-size
585
586 Repo: https://github.com/readium/readium-css */
587
588/* STYLES */
589
590/* :root is used so that you can quickly add a class or attribute if you prefer e.g. `:root[data-rs-normalize]` */
591
592/* We create a default so that you don’t need to explicitly set one in the DOM.
593 Once the “Publisher’s styles” checkbox is unchecked, the normalize is applied automatically */
594
595:root[style*="readium-advanced-on"] {
596 --USER__typeScale: 1.2; /* This is the default type scale you’ll find in most publications */
597}
598
599:root[style*="readium-advanced-on"] p,
600:root[style*="readium-advanced-on"] li,
601:root[style*="readium-advanced-on"] div,
602:root[style*="readium-advanced-on"] pre,
603:root[style*="readium-advanced-on"] dd {
604 font-size: 1rem !important;
605}
606
607:root[style*="readium-advanced-on"] h1 {
608 /* Fallback if browser doesn’t support vars */
609 font-size: 1.75rem !important;
610 font-size: calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale)) !important;
611}
612
613:root[style*="readium-advanced-on"] h2 {
614 /* Fallback if browser doesn’t support vars */
615 font-size: 1.5rem !important;
616 font-size: calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) !important;
617}
618
619:root[style*="readium-advanced-on"] h3 {
620 /* Fallback if browser doesn’t support vars */
621 font-size: 1.25rem !important;
622 font-size: calc(1rem * var(--USER__typeScale)) !important;
623}
624
625:root[style*="readium-advanced-on"] h4,
626:root[style*="readium-advanced-on"] h5,
627:root[style*="readium-advanced-on"] h6 {
628 font-size: 1rem !important;
629}
630
631:root[style*="readium-advanced-on"] small {
632 font-size: smaller !important;
633}
634
635:root[style*="readium-advanced-on"] sub,
636:root[style*="readium-advanced-on"] sup {
637 font-size: 67.5% !important;
638}
639
640/* The following styles kick in if you define the typeScale variable in the DOM.
641 No need to repeat declarations which don’t make use of the variable */
642
643:root[style*="readium-advanced-on"][style*="--USER__typeScale"] h1 {
644 font-size: calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale)) !important;
645}
646
647:root[style*="readium-advanced-on"][style*="--USER__typeScale"] h2 {
648 font-size: calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) !important;
649}
650
651:root[style*="readium-advanced-on"][style*="--USER__typeScale"] h3 {
652 font-size: calc(1rem * var(--USER__typeScale)) !important;
653}
654/*# sourceMappingURL=ReadiumCSS-after.css.map */
\No newline at end of file