/* Readium CSS
   Font size pref

   A submodule managing font-size for user settings
   Part of “User Overrides” class – no flag required.

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

:root:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] body {
  zoom: var(--USER__fontSize) !important;
}

:root:not(:--deprecated-font-size):--iOS-patch[style*="--USER__fontSize"] body {
  -webkit-text-size-adjust: var(--USER__fontSize) !important;
}

@supports selector(figure:has(> img)) {
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> img),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> video),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> svg),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> canvas),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> iframe),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figure:has(> audio),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> img:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> video:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> svg:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> canvas:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> iframe:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] div:has(> audio:only-child),
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] table {
    zoom: calc(100% / var(--USER__fontSize)) !important;
  }

  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] figcaption,
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] caption,
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] td,
  :root:--experimental-zoom:not(:--deprecated-font-size):not(:--iOS-patch)[style*="--USER__fontSize"] th {
    zoom: var(--USER__fontSize) !important;
  }
}

/* Older deprecated implementation for when zoom is not supported
   or it is explicitly enabled because you don’t want the new one */

@supports not (zoom: 1) {
  :root[style*="--USER__fontSize"] {
    font-size: var(--USER__fontSize) !important;
  }
}

:root:--deprecated-font-size[style*="--USER__fontSize"] {
  font-size: var(--USER__fontSize) !important;
}