/**
 * Mej Jesuites Character Creator - frontend styles.
 *
 * Everything is scoped under .mjc-app so it cannot leak into the theme, and
 * the theme cannot easily leak in. The character is the loud element; the
 * controls stay deliberately quiet around it.
 *
 * The interface is Arabic and right-to-left. Three things that matters for:
 *
 *   - Fredoka has no Arabic glyphs, so Cairo carries every piece of UI text.
 *     Fredoka is still loaded, but only for the Latin chest print in the SVG.
 *   - Arabic is a joined script: letter-spacing breaks the joins, so it is
 *     never applied to UI text here.
 *   - Anything with a side (padding, borders) uses logical properties, so it
 *     follows the text direction instead of being pinned to the left.
 */

.mjc-app {
	--mjc-ink: #22332f;
	--mjc-ink-soft: #5c6b66;
	--mjc-paper: #ffffff;
	--mjc-stage: #e4ece7;
	--mjc-stage-edge: #cbdad3;
	--mjc-accent: #b9751a;
	--mjc-accent-dark: #93590f;
	--mjc-line: #dfe0dc;
	--mjc-radius: 14px;
	--mjc-font: "Cairo", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;

	box-sizing: border-box;
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: 28px;
	align-items: start;
	max-width: 1040px;
	margin: 0 auto;
	color: var(--mjc-ink);
	font-family: var(--mjc-font);
	line-height: 1.75;
}

.mjc-app *,
.mjc-app *::before,
.mjc-app *::after {
	box-sizing: inherit;
}

/* ------------------------------------------------------------------ stage */

.mjc-stage {
	position: sticky;
	top: 24px;
	background: var(--mjc-stage);
	border: 1px solid var(--mjc-stage-edge);
	border-radius: var(--mjc-radius);
	padding: 18px 18px 12px;
	text-align: center;
}

.mjc-figure svg {
	display: block;
	width: 100%;
	height: auto;
	max-height: 62vh;
	margin: 0 auto;
}

.mjc-stage__read {
	margin: 6px 0 2px;
	font-family: var(--mjc-font);
	font-size: 1.08rem;
	font-weight: 600;
	color: var(--mjc-ink);
}

/* ------------------------------------------------------------------ panel */

.mjc-panel {
	background: var(--mjc-paper);
	border-radius: var(--mjc-radius);
}

.mjc-title {
	margin: 0 0 6px;
	font-family: var(--mjc-font);
	font-size: 1.7rem;
	font-weight: 700;
	line-height: 1.45;
}

.mjc-intro {
	margin: 0 0 24px;
	max-width: 46ch;
	color: var(--mjc-ink-soft);
}

.mjc-field {
	margin: 0 0 26px;
	padding: 0;
	border: 0;
}

.mjc-field__label {
	display: block;
	margin-bottom: 8px;
}

.mjc-field__name {
	display: block;
	padding: 0;
	font-family: var(--mjc-font);
	font-size: 1.08rem;
	font-weight: 600;
	line-height: 1.55;
}

.mjc-field__question {
	display: block;
	margin-top: 1px;
	font-size: 0.86rem;
	color: var(--mjc-ink-soft);
}

/* In RTL the first span lands on the right, under the empty end of the
   track, so "إطلاقًا" reads first and "تمامًا" last. */
.mjc-scale {
	display: flex;
	justify-content: space-between;
	margin-top: -2px;
	font-size: 0.78rem;
	color: var(--mjc-ink-soft);
	opacity: 0.8;
}

.mjc-caption {
	min-height: 1.5em;
	margin: 10px 0 0;
	padding-inline-start: 11px;
	border-inline-start: 3px solid var(--mjc-accent);
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--mjc-ink);
}

/* ----------------------------------------------------------------- slider */

.mjc-range {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 26px;
	margin: 0;
	background: transparent;
	cursor: pointer;
}

.mjc-range {
	--mjc-fill: 50%;
	/* Reverses the control, so 0 sits on the right and the value grows to the
	   left - the direction an Arabic reader scans. The track gradient below is
	   physical, not logical, so it is painted from the right to match. */
	direction: rtl;
}

.mjc-range::-webkit-slider-runnable-track {
	height: 8px;
	border-radius: 4px;
	background: linear-gradient(
		to left,
		var(--mjc-accent) 0 var(--mjc-fill),
		var(--mjc-line) var(--mjc-fill) 100%
	);
}

.mjc-range::-moz-range-track {
	height: 8px;
	border-radius: 4px;
	background: var(--mjc-line);
}

.mjc-range::-moz-range-progress {
	height: 8px;
	border-radius: 4px;
	background: var(--mjc-accent);
}

.mjc-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 24px;
	height: 24px;
	margin-top: -8px;
	border: 3px solid var(--mjc-paper);
	border-radius: 50%;
	background: var(--mjc-accent);
}

.mjc-range::-moz-range-thumb {
	width: 20px;
	height: 20px;
	border: 3px solid var(--mjc-paper);
	border-radius: 50%;
	background: var(--mjc-accent);
}

.mjc-range:focus-visible {
	outline: 3px solid var(--mjc-accent);
	outline-offset: 4px;
	border-radius: 4px;
}

/* ---------------------------------------------------------------- choices */

.mjc-choices {
	display: grid;
	gap: 8px;
}

.mjc-choices--two {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mjc-choices--grid {
	grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.mjc-choice {
	display: block;
	position: relative;
}

.mjc-choice input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.mjc-choice span {
	display: block;
	padding: 9px 12px;
	border: 1px solid var(--mjc-line);
	border-radius: 10px;
	text-align: center;
	font-size: 0.94rem;
	transition: background-color 120ms ease, border-color 120ms ease;
}

.mjc-choice input:checked + span {
	border-color: var(--mjc-accent);
	background: var(--mjc-accent);
	color: #fff;
}

.mjc-choice input:focus-visible + span {
	outline: 3px solid var(--mjc-accent);
	outline-offset: 2px;
}

/* --------------------------------------------------------------- text box */

.mjc-textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--mjc-line);
	border-radius: 10px;
	font: inherit;
	color: inherit;
	resize: vertical;
}

.mjc-textarea:focus-visible {
	outline: 3px solid var(--mjc-accent);
	outline-offset: 1px;
}

/* --------------------------------------------------------------- actions */

.mjc-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 26px;
}

.mjc-button {
	display: inline-block;
	padding: 12px 22px;
	border: 1px solid var(--mjc-accent);
	border-radius: 999px;
	background: var(--mjc-accent);
	color: #fff;
	font-family: var(--mjc-font);
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.mjc-button:hover {
	background: var(--mjc-accent-dark);
	border-color: var(--mjc-accent-dark);
	color: #fff;
}

.mjc-button:disabled {
	opacity: 0.55;
	cursor: progress;
}

.mjc-button--quiet {
	background: transparent;
	color: var(--mjc-accent-dark);
}

.mjc-button--quiet:hover {
	background: rgba(185, 117, 26, 0.1);
	color: var(--mjc-accent-dark);
}

.mjc-button:focus-visible {
	outline: 3px solid var(--mjc-ink);
	outline-offset: 2px;
}

/* ------------------------------------------------------- status & notices */

.mjc-status {
	min-height: 1.5em;
	margin: 12px 0 0;
	font-size: 0.95rem;
}

.mjc-status.is-ok {
	color: #1f6b42;
}

.mjc-status.is-error {
	color: #a32b21;
}

.mjc-status.is-busy {
	color: var(--mjc-ink-soft);
}

.mjc-notice {
	padding: 14px 16px;
	border-radius: 10px;
	background: #f3f1ec;
}

.mjc-notice--info {
	margin-bottom: 22px;
	font-size: 0.94rem;
}

.mjc-notice--login {
	max-width: 42ch;
}

/* ------------------------------------------------------------ small print */

@media (max-width: 860px) {
	.mjc-app {
		grid-template-columns: minmax(0, 1fr);
		gap: 20px;
	}

	.mjc-stage {
		position: static;
	}

	.mjc-figure svg {
		max-height: 46vh;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mjc-choice span {
		transition: none;
	}
}
