/* Readium CSS
   HTML5 SR Patch stylesheet

   A set of style to adjust HTML5 Suggested Rendering to paginated content

   Repo: https://github.com/readium/css */

/* Fragmentation */

body {
  orphans: 2;
  widows: 2;
}

figcaption, th, td {
  orphans: 1;
  widows: 1;
}

h2, h3, h4, h5, h6, dt,
hr, caption {
  -webkit-column-break-after: avoid;
  page-break-after: avoid;
  break-after: avoid;
}

h1, h2, h3, h4, h5, h6, dt,
figure, tr {
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  break-inside: avoid;
}

/* Hyphenation */

body {
  -webkit-hyphenate-character: "\002D";
  -moz-hyphenate-character: "\002D";
  -ms-hyphenate-character: "\002D";
  hyphenate-character: "\002D";
  -webkit-hyphenate-limit-lines: 3;
  -ms-hyphenate-limit-lines: 3;
  hyphenate-limit-lines: 3;
}

h1, h2, h3, h4, h5, h6, dt,
figcaption, pre, caption, address,
center, code, var {
  -ms-hyphens: none;
  -moz-hyphens: none;
  -webkit-hyphens: none;
  -epub-hyphens: none;
  hyphens: none;
}

/* OTF */

body {
  font-variant-numeric: oldstyle-nums proportional-nums;
}

:lang(ja) body,
:lang(zh) body,
:lang(ko) body {
  font-variant-numeric: lining-nums proportional-nums;
}

h1, h2, h3, h4, h5, h6, dt {
  font-variant-numeric: lining-nums proportional-nums;
}

table {
  font-variant-numeric: lining-nums tabular-nums;
}

code, var {
  font-variant-ligatures: none;
  font-variant-numeric: lining-nums tabular-nums slashed-zero;
}

rt {
  font-variant-east-asian: ruby;
}

:lang(ar) {
  font-variant-ligatures: common-ligatures;
}

:lang(ko) {
  font-kerning: normal;
}

/* Dark colors */

hr {
  color: inherit;
  border-color: currentColor;
}

table, th, td {
  border-color: currentColor;
}

/* Horizontal Spacing */

figure, blockquote {
  margin: 1em 5%;
}

/*

:lang(ja) figure, :lang(ja) blockquote,
:lang(zh-Hant) figure, :lang(zh-Hant) blockquote,
:lang(zh-TW) figure, :lang(zh-TW) blockquote,
:lang(mn) figure, :lang(mn) blockquote {
  margin: 5% 1em;
}

*/

ul, ol {
  padding-left: 5%;
}

/*

:lang(ja) ul, :lang(ja) ol,
:lang(zh-Hant) ul, :lang(zh-Hant) ol,
:lang(zh-TW) ul, :lang(zh-TW) ol,
:lang(mn) ul, :lang(mn) ol   {
  padding-top: 5%;
}

*/

dd {
  margin-left: 5%;
}

/*

:lang(ja) dd,
:lang(zh-Hant) dd,
:lang(zh-TW) dd,
:lang(mn) dd {
  margin-top: 5%;
}

*/

pre {
  white-space: pre-wrap;
  -ms-tab-size: 2;
  -moz-tab-size: 2;
  -webkit-tab-size: 2;
  tab-size: 2;
}

/* Normalization */

abbr[title], acronym[title] {
  text-decoration: dotted underline;
}

nobr wbr {
  white-space: normal;
}

/* Make ruby text and parentheses non-selectable (TBC) */
ruby > rt, ruby > rp {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Internationalization */

*:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)),
*:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)),
*:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)),
:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) cite, 
:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) dfn, 
:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) em, 
:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) i,
:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) cite, 
:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) dfn, 
:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) em, 
:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) i,
:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) cite, 
:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) dfn, 
:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) em, 
:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) i {
  font-style: normal;
}

:lang(ja) a,
:lang(zh) a,
:lang(ko) a {
  text-decoration: none;
}