/**
 * Content blocks - text alignment, the Button block and Columns.
 *
 * SHARED, like content-image.css: the lesson / course front end AND every
 * editor load this one file, so what an author sees while writing is what a
 * student sees. Classes are written by Content_HTML (block_to_html) and read
 * back by node_to_block. Basecamp 10529578497.
 *
 * Token-driven (light, dark), logical properties (RTL), 40/48 control ladder.
 *
 * @package Learnomy
 */

/* ── Text alignment (paragraphs, headings) ───────────────────────────────────
 * WordPress's own class names, so a theme that already styles them wins
 * nothing and loses nothing. The author picked a SIDE, so "left" must stay on
 * the left on an RTL site too: written with logical values (Rule 26) and
 * swapped under [dir="rtl"], which lands on the same physical side. No class
 * means the theme default, which follows the reading direction. */
.has-text-align-left   { text-align: start; }
.has-text-align-center { text-align: center; }
.has-text-align-right  { text-align: end; }
[dir="rtl"] .has-text-align-left  { text-align: end; }
[dir="rtl"] .has-text-align-right { text-align: start; }

/* ── Button block ────────────────────────────────────────────────────────── */
.lrn-button-block {
	margin-block: var(--lrn-sp-4);
}

.lrn-content-button {
	display:         inline-flex;
	align-items:     center;
	justify-content: center;
	min-height:      40px;
	padding-block:   var(--lrn-sp-2);
	padding-inline:  var(--lrn-sp-5, 20px);
	border:          1px solid var(--lrn-accent-solid, var(--lrn-accent));
	border-radius:   var(--lrn-radius-md);
	background:      var(--lrn-accent-solid, var(--lrn-accent));
	color:           var(--lrn-text-inverse, #fff);
	font-size:       var(--lrn-text-base);
	font-weight:     var(--lrn-weight-medium, 500);
	line-height:     var(--lrn-leading-tight, 1.25);
	text-align:      center;
	text-decoration: none;
	max-inline-size: 100%;
	overflow-wrap:   anywhere;
	transition:      background var(--lrn-dur, 150ms) var(--lrn-ease, ease);
}

.lrn-content-button--lg {
	min-height:     48px;
	padding-inline: var(--lrn-sp-6, 24px);
	font-size:      var(--lrn-text-lg, 1.125rem);
}

/* Themes restyle every <a> in content (underline, visited purple, hover
 * color); a button keeps its own look in every state. */
.lrn-content-button:link,
.lrn-content-button:visited,
.lrn-content-button:hover,
.lrn-content-button:focus,
.lrn-content-button:active {
	color:           var(--lrn-text-inverse, #fff);
	text-decoration: none;
}

.lrn-content-button:hover {
	background:   var(--lrn-accent-hover-solid, var(--lrn-accent));
	border-color: var(--lrn-accent-hover-solid, var(--lrn-accent));
}

.lrn-content-button:focus-visible {
	outline:        3px solid var(--lrn-focus-ring, var(--lrn-accent));
	outline-offset: 2px;
}

/* ── Columns ─────────────────────────────────────────────────────────────── */
.lrn-columns {
	display:      grid;
	gap:          var(--lrn-sp-6, 24px);
	margin-block: var(--lrn-sp-6, 24px);
}

.lrn-columns--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lrn-columns--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.lrn-columns__col {
	min-inline-size: 0;
}

.lrn-columns__col > :first-child { margin-block-start: 0; }
.lrn-columns__col > :last-child  { margin-block-end: 0; }

/* Phones: one column at a time, in reading order. */
@media (max-width: 640px) {
	.lrn-columns--2,
	.lrn-columns--3 {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ── In the editor ───────────────────────────────────────────────────────── */
.lrn-editor-columns {
	margin-block: var(--lrn-sp-2);
}

.lrn-editor-columns__col {
	padding:       var(--lrn-sp-2);
	border:        1px dashed var(--lrn-border);
	border-radius: var(--lrn-radius-md);
}

.lrn-editor-columns__col .codex-editor__redactor {
	padding-bottom: var(--lrn-sp-4) !important; /* Editor.js sets it inline */
}

.lrn-editor-button {
	display:        flex;
	flex-direction: column;
	align-items:    flex-start;
	gap:            var(--lrn-sp-2);
	margin-block:   var(--lrn-sp-2);
}

.lrn-editor-button .lrn-content-button {
	min-inline-size: 8em;
	cursor:          text;
	outline:         none;
}

.lrn-editor-button .lrn-content-button:empty::before {
	content: attr(data-placeholder);
	opacity: 0.75;
}

.lrn-editor-button__fields {
	display:     flex;
	flex-wrap:   wrap;
	align-items: center;
	gap:         var(--lrn-sp-2);
	inline-size: 100%;
}

.lrn-editor-button__url.cdx-input {
	flex:       1 1 16em;
	min-height: 40px;
}

.lrn-editor-button__size {
	min-height: 40px;
}

.lrn-editor-button__toggle {
	display:     inline-flex;
	align-items: center;
	gap:         var(--lrn-sp-2);
	min-height:  40px;
	font-size:   var(--lrn-text-sm);
}

/* A column's editor uses the column's full width (Editor.js caps block
 * content at 650px and leaves room for its toolbar on the side). */
.lrn-editor-columns__col .ce-block__content,
.lrn-editor-columns__col .ce-toolbar__content {
	max-width:          none;
	padding-inline-end: 0;
}

/* Editor.js's narrow mode reserves a 50px gutter for its toolbar; a column is
 * narrow by design, so give the text the room (the toolbar overlays on hover). */
.lrn-editor-columns__col .codex-editor--narrow .codex-editor__redactor {
	/* Editor.js sets it inline (on the right, or the left in RTL mode). */
	margin-inline: 0 !important;
}

.lrn-editor-columns__col .codex-editor--narrow .ce-toolbox .ce-popover {
	inset-inline-start: 0;
}

/* ── Code stays left-to-right ────────────────────────────────────────────────
 * Code is written left to right in every language. Inside an RTL page the
 * inherited direction moved trailing punctuation to the wrong end, so
 * `demo();` read `;()demo`. Code blocks (lesson page + Code / HTML tool
 * editors) and inline code run LTR and isolated, while the page around them
 * stays RTL. :where() keeps it at zero specificity so a theme can still style
 * them. */
:where(pre, code, kbd, samp, .lrn-code, .ce-code__textarea, .ce-rawtool__textarea) {
	direction:    ltr;
	unicode-bidi: isolate;
}

/* With direction ltr, start is the left edge, whatever the page direction. */
:where(pre, .lrn-code, .ce-code__textarea, .ce-rawtool__textarea) {
	text-align: start;
}
