:root {
  --theme-text: ;
  --theme-background: ;
  --theme-link: ;
  --theme-visited: ;
  --theme-subdue: ;
  --theme-disable: ;
  --theme-hover: ;
  --theme-onHover: ;
  --theme-select: ;
  --theme-onSelect: ;
  --theme-focus: ;
  --theme-elevate: ;
  --theme-immerse: ;

  --layout-radius: ;
  --layout-spacing: ;
}

/* Reset */

button {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  text-align: inherit;
  background: none;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
  border: none;
  color: inherit;
  font: inherit;

  /* Focus no outline */
  outline: none;
  /* No tap highlight on mobile */
  -webkit-tap-highlight-color: transparent;
}

input {
  font-size: 1rem;
  border-radius: 0;
  text-align: inherit;
  background: none;
  box-shadow: none;
  padding: 0;
  cursor: text;
  border: none;
  color: inherit;
  font: inherit;
  /* Focus no outline */
  outline: none;
}

::selection {
  background-color: var(--theme-select);
  color: var(--theme-onSelect);
}

/* Layout */

html,
body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  background-color: var(--theme-background);
  color: var(--theme-text);
  position: relative;
}

#wrapper {
  height: 100%;
  width: 100%;
  margin: 0;
}

#reader-main {
  width: 100%;
  height: 100%;
  margin: 0;
}

#reader-shell {
  width: 100%;
  height: 100%;
  margin: 0;
}

.left-dock {
  height: 100vh;
  height: 100dvh;
}

.right-dock {
  height: 100vh;
  height: 100dvh;
}

/* Top and bottom bars */

#bottom-bar,
#top-bar {
  box-sizing: border-box;
  gap: 2px;
  touch-action: manipulation;
  background-color: var(--theme-background);
}

#bottom-bar {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Stacked UI */

.stacked-ui {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  height: 100vh;
  height: 100dvh;
  background-color: var(--theme-background);
}

.stacked-ui #top-bar,
.stacked-ui #bottom-bar {
  /* Need both. Otherwise it will shrink/grow when switching from stacked/layered */
  flex: 0 0 calc(var(--icon-size, 24px) * 2.5);
  height: calc(var(--icon-size, 24px) * 2.5);
}

.stacked-ui.isImmersive:not(.isHovering) #top-bar,
.stacked-ui.isImmersive:not(.isHovering) #bottom-bar {
  opacity: var(--theme-immerse);
}

/* Layered UI */

.layered-ui {
  position: relative;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  background-color: var(--theme-background);
}

.layered-ui #top-bar,
.layered-ui #bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--icon-size, 24px) * 2.5);
  z-index: 2;
  box-shadow: var(--theme-elevate);
  overflow: hidden;
  transition-property: transform, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: ease-in-out;
  transform: translateY(0);
}

.layered-ui #top-bar {
  top: 0;
}

.layered-ui #bottom-bar {
  bottom: 0;
}

.layered-ui.isImmersive:not(.isHovering) #top-bar {
  transform: translateY(calc(var(--icon-size, 24px) * -2.5));
  box-shadow: none;
  /* For overflow button to be visible due to transforms being applied */
  overflow: unset;
}

.layered-ui.isImmersive:not(.isHovering) #bottom-bar {
  transform: translateY(calc(var(--icon-size, 24px) * 2.5));
  box-shadow: none;
}

.layered-ui .bar-overlay {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--icon-size, 24px) * 2.5);
  pointer-events: auto;
  opacity: 0;
  z-index: 1000;
}

.layered-ui #reader-header-overlay {
  top: 0;
}

.layered-ui #reader-footer-overlay {
  bottom: 0;
}

/* iFrame + its container */

#container {
  contain: content;
  width: 100%;
  height: 100%;
  margin: 0 auto;
}

.readium-navigator-iframe {
  width: 100%;
  height: 100%;
  border-width: 0;
}

/* FXL: Loading spinner for resources */

@keyframes loading {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

div:has(> .readium-navigator-iframe.blank)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -30px;
  margin-left: -30px;
  width: 50px;
  height: 50px;
  border-radius: 50px;
  border: 5px solid grey;
  border-top-color: black;
  animation: loading 2s linear infinite;
}

/* Utils */

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}