/**
 * King front-end rich text editor toolbar.
 *
 * Styles the full editor that replaces the old TinyMCE inlite popup on the
 * submission and edit forms. Light and night mode are both covered.
 *
 * @package King
 */

.king-editor {
	--kge-bg: #ffffff;
	--kge-bar-bg: #f4f6f8;
	--kge-border: #dfe4ea;
	--kge-text: #1f2733;
	--kge-muted: #6b7785;
	--kge-hover: #e6ebf1;
	--kge-active: #4c6ef5;
	--kge-active-bg: #e7ecff;

	position: relative;
	border: 1px solid var(--kge-border);
	border-radius: 10px;
	background: var(--kge-bg);
	overflow: hidden;
}

/* ---------------------------------------------------------------- Toolbar */

.king-editor-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	padding: 6px;
	background: var(--kge-bar-bg);
	border-bottom: 1px solid var(--kge-border);
}

.king-editor-group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	padding: 0 5px;
	border-right: 1px solid var(--kge-border);
}

.king-editor-group:last-child {
	border-right: 0;
}

.king-editor-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 30px;
	height: 30px;
	padding: 0 7px;
	margin: 0;
	border: 1px solid transparent;
	border-radius: 6px;
	background: transparent;
	color: var(--kge-text);
	font-size: 14px;
	line-height: 1;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.king-editor-btn:hover,
.king-editor-btn:focus {
	background: var(--kge-hover);
	border-color: var(--kge-border);
	outline: none;
}

.king-editor-btn.is-active {
	background: var(--kge-active-bg);
	border-color: var(--kge-active);
	color: var(--kge-active);
}

.king-editor-btn b,
.king-editor-btn i,
.king-editor-btn u,
.king-editor-btn s {
	font-size: 15px;
	line-height: 1;
}

.king-editor-select {
	height: 30px;
	max-width: 150px;
	padding: 0 6px;
	border: 1px solid var(--kge-border);
	border-radius: 6px;
	background: var(--kge-bg);
	color: var(--kge-text);
	font-size: 13px;
	font-family: inherit;
	cursor: pointer;
}

.king-editor-select-block {
	min-width: 118px;
}

.king-editor-select-font {
	min-width: 104px;
}

.king-editor-select-size {
	min-width: 70px;
}

/* The colour input sits under its button so the native picker anchors to it. */
.king-editor-color {
	position: relative;
	display: inline-flex;
}

.king-editor-color-input {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 3px;
	padding: 0;
	border: 0;
	opacity: 0;
	pointer-events: none;
}

/* ---------------------------------------------------- Editable content area */

.king-editor-area {
	min-height: 260px;
	max-height: 60vh;
	overflow-y: auto;
	padding: 16px 18px;
	background: var(--kge-bg);
	color: var(--kge-text);
	font-size: 16px;
	line-height: 1.7;
	outline: none;
}

.king-editor-area:focus {
	outline: none;
}

.king-editor-area.is-dropping {
	background: var(--kge-active-bg);
	box-shadow: inset 0 0 0 2px var(--kge-active);
}

/* Headings need visible sizes inside the editor, the theme resets them. */
.king-editor-area h1 { font-size: 2em; }
.king-editor-area h2 { font-size: 1.6em; }
.king-editor-area h3 { font-size: 1.35em; }
.king-editor-area h4 { font-size: 1.18em; }
.king-editor-area h5 { font-size: 1.05em; }
.king-editor-area h6 { font-size: 0.95em; }

.king-editor-area h1,
.king-editor-area h2,
.king-editor-area h3,
.king-editor-area h4,
.king-editor-area h5,
.king-editor-area h6 {
	margin: 0.85em 0 0.4em;
	font-weight: 700;
	line-height: 1.3;
	color: inherit;
}

.king-editor-area p {
	margin: 0 0 1em;
}

.king-editor-area ul,
.king-editor-area ol {
	margin: 0 0 1em;
	padding-left: 2em;
	list-style-position: outside;
}

.king-editor-area ul {
	list-style-type: disc;
}

.king-editor-area ol {
	list-style-type: decimal;
}

.king-editor-area li {
	margin: 0.25em 0;
	display: list-item;
}

.king-editor-area blockquote {
	margin: 0 0 1em;
	padding: 0.5em 1em;
	border-left: 4px solid var(--kge-active);
	background: var(--kge-bar-bg);
	font-style: italic;
}

.king-editor-area pre {
	margin: 0 0 1em;
	padding: 12px 14px;
	border-radius: 8px;
	background: var(--kge-bar-bg);
	font-family: Consolas, Monaco, monospace;
	font-size: 14px;
	white-space: pre-wrap;
}

.king-editor-area a {
	color: var(--kge-active);
	text-decoration: underline;
}

.king-editor-area img {
	max-width: 100%;
	height: auto;
	border-radius: 6px;
}

.king-editor-area hr {
	margin: 1.4em 0;
	border: 0;
	border-top: 2px solid var(--kge-border);
}

.king-editor-area table {
	width: 100%;
	border-collapse: collapse;
}

.king-editor-area td,
.king-editor-area th {
	padding: 6px 10px;
	border: 1px solid var(--kge-border);
}

/* --------------------------------------------------------- Source and status */

.king-editor-source {
	display: block;
	width: 100%;
	min-height: 260px;
	max-height: 60vh;
	padding: 16px 18px;
	border: 0;
	background: var(--kge-bg);
	color: var(--kge-text);
	font-family: Consolas, Monaco, monospace;
	font-size: 13px;
	line-height: 1.6;
	resize: vertical;
	outline: none;
}

.king-editor-status {
	padding: 8px 14px;
	background: var(--kge-bar-bg);
	border-top: 1px solid var(--kge-border);
	color: var(--kge-muted);
	font-size: 13px;
}

/* ------------------------------------------------------------- Fullscreen */

.king-editor.is-fullscreen {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100000;
	border-radius: 0;
	display: flex;
	flex-direction: column;
}

.king-editor.is-fullscreen .king-editor-area,
.king-editor.is-fullscreen .king-editor-source {
	flex: 1 1 auto;
	max-height: none;
}

body.king-editor-locked {
	overflow: hidden;
}

/* ------------------------------------------------------------- Night mode */

html.king-night .king-editor {
	--kge-bg: #1c2028;
	--kge-bar-bg: #242a33;
	--kge-border: #39414e;
	--kge-text: #e6eaf0;
	--kge-muted: #9aa6b5;
	--kge-hover: #303845;
	--kge-active: #7c9cff;
	--kge-active-bg: #2c3550;
}

/* --------------------------------------------------------------- Responsive */

@media (max-width: 767px) {
	.king-editor-toolbar {
		padding: 5px 4px;
	}

	.king-editor-group {
		padding: 0 3px;
	}

	.king-editor-btn {
		min-width: 28px;
		height: 28px;
		padding: 0 5px;
		font-size: 13px;
	}

	.king-editor-select {
		height: 28px;
		font-size: 12px;
	}

	.king-editor-select-block {
		min-width: 96px;
	}

	.king-editor-select-font,
	.king-editor-select-size {
		min-width: 64px;
	}

	.king-editor-area,
	.king-editor-source {
		min-height: 200px;
		padding: 12px 14px;
		font-size: 15px;
	}
}

/* ----------------------------------------------------------- Compatibility
 *
 * king-forms.css and the video package stylesheet style the editable div as a
 * standalone form field. Inside the new wrapper that would draw a second
 * border, so the inner frame is flattened and the wrapper keeps the outline.
 */
.king-editor .king-editor-area,
.king-editor #king_post_content.tinymce,
.kvp-submit-2026 .king-editor #king_post_content.tinymce,
.kvp-submit-2026 .king-editor .kvp-content-editor.tinymce {
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	background: var(--kge-bg) !important;
	color: var(--kge-text) !important;
	margin: 0 !important;
}

.king-editor .king-editor-area.is-dropping {
	box-shadow: inset 0 0 0 2px var(--kge-active) !important;
}

/* ------------------------------------------------------------------ Hidden
 *
 * The rules above give the source view and the editable area an explicit
 * display value, which outranks the browser default for [hidden]. Without
 * this the HTML source textarea stays on screen as a second empty box.
 */
.king-editor [hidden],
.king-editor .king-editor-area[hidden],
.king-editor .king-editor-source[hidden],
.king-editor .king-editor-status[hidden] {
	display: none !important;
}
