/**
 * Dialogix layout system
 *
 * Only layout, spacing, borders, image fitting and link affordances live here.
 * Typography and colours belong to the active theme and native block controls.
 * Every selector is opt-in: unrelated WordPress blocks are left alone.
 *
 * Optional theme-level overrides (define on :root AND in editor styles):
 * --dialogix-content-width: 72rem;
 * --dialogix-gutter: clamp(1.25rem, 5vw, 4rem);
 * --dialogix-section-space: clamp(2.5rem, 5vw, 5rem);
 * --dialogix-column-gap: clamp(1.5rem, 4vw, 4rem);
 * --dialogix-flow-space: 1.25rem;
 */

.wp-block-group.dialogix-section,
.wp-block-group.dialogix-site-part {
	box-sizing: border-box;
	margin-block: 0;
	padding-inline: var(--dialogix-gutter, clamp(1.25rem, 5vw, 4rem));
}

.wp-block-group.dialogix-section {
	padding-block: var(--dialogix-section-space, clamp(2.5rem, 5vw, 5rem));
}

.wp-block-group.dialogix-site-part {
	padding-block: 1.5rem;
}

.wp-block-group.dialogix-section-ruled {
	padding-block-end: 0;
}

.wp-block-group.dialogix-shell {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--dialogix-content-width, var(--wp--style--global--wide-size, 72rem));
	margin-block: 0;
	margin-inline: auto;
}

.wp-block-group.dialogix-rule {
	border-block-end: 1px solid currentColor;
	padding-block-end: var(--dialogix-section-space, clamp(2.5rem, 5vw, 5rem));
}

.dialogix-site-part > .dialogix-rule {
	padding-block-end: 1.5rem;
}

/* Inset surfaces reuse the section shell; colours are native Group controls. */
.wp-block-group.dialogix-section-panel {
	padding-block: 0;
	/* Extend the surface, keeping its text aligned with other section content. */
	padding-inline: max(.5rem, calc(var(--dialogix-gutter, clamp(1.25rem, 5vw, 4rem)) - var(--dialogix-panel-space, clamp(.75rem, 1.5vw, 1.25rem))));
}

.dialogix-section-panel > .wp-block-group.dialogix-shell {
	max-width: calc(var(--dialogix-content-width, var(--wp--style--global--wide-size, 72rem)) + var(--dialogix-panel-space, clamp(.75rem, 1.5vw, 1.25rem)) + var(--dialogix-panel-space, clamp(.75rem, 1.5vw, 1.25rem)));
}

.wp-block-group.is-style-dialogix-panel {
	box-sizing: border-box;
	padding: var(--dialogix-panel-space, clamp(.75rem, 1.5vw, 1.25rem));
}

/* New framed heroes let the media meet the horizontal rules. */
.wp-block-group.dialogix-section-flush {
	padding-block: 0;
}

.dialogix-section-flush > .wp-block-group.dialogix-rule {
	border-block-start: 1px solid currentColor;
	padding-block: 0;
}

.dialogix-section-flush > .dialogix-shell > .wp-block-group.dialogix-layout {
	gap: 0;
}

.dialogix-section-flush > .dialogix-shell > .dialogix-layout > .wp-block-group:first-child {
	padding-block: var(--dialogix-section-space, clamp(2.5rem, 5vw, 5rem));
	padding-inline-end: var(--dialogix-column-gap, clamp(1.5rem, 4vw, 4rem));
}

.dialogix-section[id],
.dialogix-sample[id] {
	scroll-margin-block-start: var(--dialogix-anchor-offset, 6rem);
}

/* A secondary CTA is still a native Button, with all normal link controls. */
.wp-block-button.is-style-dialogix-text-link > .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 2.75rem;
	padding: .25rem 0;
	border: 0;
	border-block-end: 1px solid currentColor;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	text-decoration: none;
}

.wp-block-button.is-style-dialogix-text-link > .wp-block-button__link:hover {
	text-decoration: underline;
	text-underline-offset: .2em;
}

.wp-block-button.is-style-dialogix-text-link > .wp-block-button__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

/* A form plugin owns the actual form. Only constrain it to its layout column. */
.dialogix-form-slot,
.dialogix-form-slot :where(form, fieldset) {
	min-width: 0;
}

.dialogix-form-slot :where(input, textarea, select, iframe) {
	box-sizing: border-box;
	max-width: 100%;
}

/* Editor instructions are never presented as a working form to site visitors. */
.dialogix-form-placeholder {
	display: none;
}

.editor-styles-wrapper .dialogix-form-placeholder {
	display: block;
	padding: 1.25rem;
	border: 1px dashed currentColor;
}

/* The same style choices work on the section columns and nested Groups. */
.wp-block-group:is(
	.is-style-dialogix-equal,
	.is-style-dialogix-label,
	.is-style-dialogix-wide-left,
	.is-style-dialogix-wide-right,
	.is-style-dialogix-single
) {
	display: grid;
	grid-template-columns: var(--dialogix-columns, minmax(0, 1fr));
	gap: var(--dialogix-column-gap, clamp(1.5rem, 4vw, 4rem));
	align-items: start;
	min-width: 0;
}

.wp-block-group.is-style-dialogix-equal {
	--dialogix-columns: repeat(2, minmax(0, 1fr));
}

.wp-block-group.is-style-dialogix-label {
	--dialogix-columns: minmax(0, 1fr) minmax(0, 3fr);
}

.wp-block-group.is-style-dialogix-wide-left {
	--dialogix-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.wp-block-group.is-style-dialogix-wide-right {
	--dialogix-columns: minmax(0, 2fr) minmax(0, 3fr);
}

.wp-block-group.is-style-dialogix-single {
	--dialogix-columns: minmax(0, 1fr);
}

/* Grid children must be allowed to shrink, including long titles and URLs. */
.wp-block-group:is(
	.is-style-dialogix-equal,
	.is-style-dialogix-label,
	.is-style-dialogix-wide-left,
	.is-style-dialogix-wide-right,
	.is-style-dialogix-single
) > * {
	min-width: 0;
	max-width: none;
	margin-block: 0;
	overflow-wrap: anywhere;
}

.wp-block-group.dialogix-align-center {
	align-items: center;
}

/* Stacks keep paragraph/heading rhythm without empty Spacer blocks. */
.wp-block-group.dialogix-stack > * {
	margin-block: 0;
}

.wp-block-group.dialogix-stack > * + * {
	margin-block-start: var(--dialogix-flow-space, 1.25rem);
}

/* Align links at the bottom when card descriptions have different lengths. */
.wp-block-group.dialogix-cards {
	align-items: stretch;
}

.wp-block-group.dialogix-card {
	display: flex;
	flex-direction: column;
	align-items: stretch;
}

.dialogix-card > .wp-block-list {
	margin-block-start: auto;
	padding-block-start: var(--dialogix-flow-space, 1.25rem);
}

/*
 * Reviews use the existing section and grid styles. Each item is a native Quote
 * with a thin top rule, free-flowing copy and bottom-aligned attribution. Theme
 * typography and colours still apply. Content never gets clipped to a height.
 */
.wp-block-group.dialogix-reviews {
	align-items: stretch;
}

/* A single review fills both columns, including beside the editor's appender. */
.dialogix-reviews > blockquote.wp-block-quote:only-of-type {
	grid-column: 1 / -1;
}

.wp-block-quote.is-style-dialogix-review {
	box-sizing: border-box;
	min-width: 0;
	margin: 0;
	padding: 0 0 1.5rem;
	border: 0;
	border-left: none !important;
	border-block-end: 1px solid currentColor;
	border-radius: 0;
	overflow-wrap: anywhere;
	font-style: normal;
}

/* Suppress theme-generated quotation ornaments only on this opt-in style. */
.wp-block-quote.is-style-dialogix-review::before,
.wp-block-quote.is-style-dialogix-review::after {
	content: none;
}

.wp-block-quote.is-style-dialogix-review > * {
	margin-block: 0;
}
.is-style-dialogix-review-quote {
	margin-bottom: 20px !important
}
.is-style-dialogix-review-name{
	text-align: right;
}
.is-style-dialogix-review-cite{
	font-size: .7rem;
	text-align: right;
	max-width: 500px;
	margin-left: auto;
}

.wp-block-quote.is-style-dialogix-review > cite {
	display: block;
	margin-block-start: auto;
	padding-block-start: .5rem;
}

/* Image styles are native Image block styles; None returns to natural sizing. */
.wp-block-image:is(
	.dialogix-media,
	.is-style-dialogix-square,
	.is-style-dialogix-landscape,
	.is-style-dialogix-contain
) {
	max-width: 100%;
}

.wp-block-image:is(
	.dialogix-media,
	.is-style-dialogix-square,
	.is-style-dialogix-landscape,
	.is-style-dialogix-contain
) img {
	display: block;
	width: 100%;
	height: auto;
}

.wp-block-image.is-style-dialogix-square img {
	aspect-ratio: 1;
	object-fit: cover;
}

.wp-block-image.is-style-dialogix-landscape img {
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

.wp-block-image.is-style-dialogix-contain img {
	aspect-ratio: 4 / 5;
	object-fit: contain;
}

/* Native List blocks: item text is a single, descriptive and editable link. */
.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) {
	list-style: disc outside;
	padding-inline-start: 0;
	margin-block: 0;
}

/* Keep a real list style and hide only its marker, preserving list semantics. */
.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) > li::marker {
	color: transparent;
	font-size: 0;
}

.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) > li {
	margin: 0;
	min-width: 0;
	padding: 0;
}

.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.25rem;
	min-height: 2.75rem;
	padding-block: .5rem;
	border-block-end: 1px solid currentColor;
	text-decoration: none;
	overflow-wrap: anywhere;
}

/* A purely decorative arrow with no extra text in the accessible link name. */
.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) a::after {
	content: "";
	display: block;
	flex: 0 0 1em;
	width: 1em;
	height: 1em;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20 20 4M4 4h16v16' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20 20 4M4 4h16v16' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) a:hover {
	text-decoration: underline;
	text-underline-offset: .2em;
}

.wp-block-list:is(.is-style-dialogix-links, .is-style-dialogix-link-grid) a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

.wp-block-list.is-style-dialogix-link-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: var(--dialogix-column-gap, clamp(1.5rem, 4vw, 4rem));
	row-gap: .5rem;
}

/*
 * Core Groups save valid OL/LI tags. Keep LI display:list-item so native
 * numbering remains semantic and updates when rows are added or reordered.
 * Each LI contains a normal two-area Group, with independent Heading/Paragraph.
 */
ol.wp-block-group.dialogix-numbered {
	display: block;
	/*list-style: decimal outside;*/
	list-style: none;
	margin-block: 0;
	padding-inline-start: 0;
}

ol.dialogix-numbered > li.wp-block-group.dialogix-numbered-item {
	display: list-item;
	margin-block: 0;
	padding-block: 1.75rem;
	padding-inline-start: 0;
	border-block-end: 1px solid currentColor;
}

ol.dialogix-numbered > li.dialogix-numbered-item:first-child {
	padding-block-start: 0;
}

ol.dialogix-numbered > li.dialogix-numbered-item:last-child {
	padding-block-end: 0;
	border-block-end: 0;
}
/* Stack main sections before narrow desktop columns become uncomfortable. */
@media (max-width: 55rem) {
	.dialogix-section-flush > .dialogix-shell > .dialogix-layout > .wp-block-group:first-child {
		padding-inline-end: 0;
	}
	.wp-block-group:is(
		.is-style-dialogix-equal,
		.is-style-dialogix-label,
		.is-style-dialogix-wide-left,
		.is-style-dialogix-wide-right
	):not(.dialogix-cards) {
		grid-template-columns: minmax(0, 1fr);
	}
	.dialogix-numbered-item > .dialogix-layout {
		gap: .75rem;
	}
}

@media (max-width: 40rem) {
	.wp-block-group.dialogix-cards,
	.wp-block-list.is-style-dialogix-link-grid {
		grid-template-columns: minmax(0, 1fr);
	}
	.wp-block-group.dialogix-cards.dialogix-twocol-mobile{
		grid-template-columns: 1fr 1fr
	}
}

/*
 * Editor-only layout adjustments. Modern core Group uses direct inner blocks.
 * Keep its inserter control out of the grid so it cannot create a spare cell.
 * These rules never hide controls or change the saved content.
 */
.editor-styles-wrapper .dialogix-layout {
	position: relative;
}

.editor-styles-wrapper .dialogix-layout > .block-list-appender {
	position: absolute;
	inset-inline-end: 0;
	inset-block-end: -1.5rem;
}

.editor-styles-wrapper ol.dialogix-numbered > .block-list-appender {
	list-style: none;
}

.editor-styles-wrapper .dialogix-card > .block-list-appender {
	flex: 0 0 auto;
}
