/*
 * What you're currently looking at is the source code of a legally protected, proprietary software.
 * CKEditor 5 Collaboration is licensed under a commercial license and protected by copyright law. Where not otherwise indicated,
 * all CKEditor 5 Collaboration content is authored by CKSource engineers and consists of CKSource-owned intellectual property.
 *
 * Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
 */

:root {
	--ck-color-pagination-divider: hsl(0, 0%, 67%);
}

/*
 * Content styles.
 */

.ck.ck-pagination_enabled {
	&.ck-content .page-break::after {
		display: none;
	}

	&.ck-pagination-view {
		/*
		 * Reset all layout styles for content root as the pagination-view is responsible for page size and margins.
		*/
		& > .ck-content {
			padding: 0;
			margin: 0;
			width: auto;
			height: auto;
			min-width: auto;
			min-height: auto;
			max-width: none;
			max-height: none;
			border: none;
			box-sizing: border-box;
			overflow: unset;
		}

		/**
		 * Hide all UI related elements.
		 */
		& .ck-widget__type-around,
		& .ck-fake-selection-container,
		& .ck-widget__selection-handle,
		& .ck-widget__resizer,
		& .ck-table-column-resizer {
			display: none;
		}

		& .ck-widget {
			outline: none;
		}

		/*
		 * Disable border for image/table caption (existing only in editing view).
		 */
		& .ck-editor__nested-editable:not(td,th) {
			border: 0;
		}

		/*
		 * Chrome ignores padding-top on the first paragraph at the beginning of the page,
		 * causing incorrect page calculations. In documents consisting solely of paragraphs
		 * (especially those with soft line breaks), this may cause the last paragraph to be
		 * unexpectedly pushed to the next page.
		 *
		 * See more: https://github.com/ckeditor/ckeditor5-commercial/issues/7316
		 */
		& p:first-child {
			padding-top: 0;
		}

		/*
		 * From time to time placing page-break directly after a block element with margin causes appending a new blank page in pagination mode.
		 * Removing margin-bottom from the block element fixes that issue and the margin is not being moved to the next blank page.
		 *
		 * Identical CSS rule is also present in the page break CSS files so keep them in sync to make sure that the issue is fixed both in the
		 * editor preview and in the printed content (used by the export document plugins).
		 *
		 * See more: https://github.com/ckeditor/ckeditor5-commercial/issues/6289.
		 */
		& *:has(+ .page-break) {
			margin-bottom: 0;
		}

		& .page-break {
			padding: 0;
			margin: 0;
			break-after: column;
			display: block;
			height: 0;

			& .page-break__label {
				display: none;
			}

			&::after {
				display: none;
			}

		}

		& .table table {

			/*
			 * Tables that have overflow set to hidden are incorrectly split between pages on the chrome. Reset the overflow to initial fixes this issue.
			 *
			 * See: https://github.com/ckeditor/ckeditor5/issues/14426.
			 */
			overflow: initial;
		}

		& blockquote {
			overflow: initial;

			/*
			 * Disable inner margins from merging with outside margins
			 */
			display: flow-root;
		}

		/**
		 * The bookmark widget must not expand content next to it but still it has to be rendered so page-break before it can be recorded.
		 */
		& .ck-bookmark {
			width: 0;
			height: 0;
			overflow: hidden;
		}

		/**
		 * Make ToC page fragmentable.
		 */
		& .table-of-contents {
			border: 0;

			& ol li {
				overflow: visible;
			}
		}
	}
}
