/*
 * MisterGadget-owned public and editor content components.
 *
 * V26 rendered the saved profile/list blocks through an in-house compatibility
 * layer modelled on the then-installed block plugin. V27's saved-block
 * migration replaces those third-party class names with neutral mg-* classes.
 * This stylesheet carries the proven V26 proportions, palette families and
 * responsive behaviour forward under the sole mg-experience presentation
 * owner. Retained malformed SWELL style names have a finite scoped display
 * adapter below; supported parent styles stay with SWELL. The editor canvas
 * uses these same component rules; admin
 * controls and full-page skins stay outside this shared content boundary.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/* wp_body_open precedes SWELL's wrapper; this component owns its two colors. */
.mgx-skip-link {
    position: fixed;
    inset-block-start: 12px;
    inset-inline-start: 12px;
    z-index: 100000;
    padding: 12px 18px;
    max-width: calc(100vw - 24px);
    color: #fff;
    background: #111;
    border-radius: 4px;
    font-weight: 700;
    text-decoration: underline;
    transform: translateY(calc(-100% - 24px));
}

.mgx-skip-link:focus {
    transform: none;
}

/*
 * Saved articles can contain names that SWELL never registered. Its broad
 * [class*="is-style-big_icon_"] selector still draws an empty circle for them.
 * Keep the saved blocks intact and supply only the two observed standalone
 * aliases. Glyphs and colors come from the installed parent's information /
 * caution styles; the parent continues to own the box geometry and font.
 * These are display compatibility names, not new authoring recommendations.
 */
:is([data-mg-experience="true"], .editor-styles-wrapper) .wp-block-group.is-style-big_icon_info {
	--mgx-retained-icon-color: var(--color_icon_info, #4a82ba);
	--mgx-retained-icon-glyph: "\e941";
}

/* The retained paragraph's block attributes specify caution; its old HTML
 * contains caption instead. Preserve its warning text and saved background. */
:is([data-mg-experience="true"], .editor-styles-wrapper) p.is-style-big_icon_caption {
	--mgx-retained-icon-color: var(--color_icon_caution, #e7a73b);
	--mgx-retained-icon-glyph: "\e916";
}

/* A registered parent style wins when malformed and valid names coexist. */
:is([data-mg-experience="true"], .editor-styles-wrapper) :is(.wp-block-group.is-style-big_icon_info, p.is-style-big_icon_caption):not(
	.is-style-big_icon_point, .is-style-big_icon_good, .is-style-big_icon_check, .is-style-big_icon_bad,
	.is-style-big_icon_batsu, .is-style-big_icon_hatena, .is-style-big_icon_caution, .is-style-big_icon_memo
) {
	--the-color: var(--mgx-retained-icon-color);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(.wp-block-group.is-style-big_icon_info, p.is-style-big_icon_caption):not(
	.is-style-big_icon_point, .is-style-big_icon_good, .is-style-big_icon_check, .is-style-big_icon_bad,
	.is-style-big_icon_batsu, .is-style-big_icon_hatena, .is-style-big_icon_caution, .is-style-big_icon_memo
)::before {
	content: var(--mgx-retained-icon-glyph);
}

/*
 * Historical raw-HTML news used these unregistered names for a box's title.
 * The parent's substring selector mistakes the title for a second icon box.
 * Restrict the repair to a title directly inside an existing point/memo box
 * or its one WordPress compatibility wrapper:
 * keep one outer icon, restore normal title flow, and leave arbitrary classes
 * and all registered parent styles alone.
 */
:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.is-style-big_icon_point, .is-style-big_icon_memo,
	.is-style-big_icon_point > .wp-block-group__inner-container,
	.is-style-big_icon_memo > .wp-block-group__inner-container
) > :is(
	.is-style-big_icon_point__title,
	.is-style-big_icon_point_title,
	.is-style-big_icon_point_ttl,
	.is-style-big_icon_memo__title,
	.is-style-big_icon_memo-title,
	.is-style-big_icon_title
):not(
	.is-style-big_icon_point, .is-style-big_icon_good, .is-style-big_icon_check, .is-style-big_icon_bad,
	.is-style-big_icon_batsu, .is-style-big_icon_hatena, .is-style-big_icon_caution, .is-style-big_icon_memo
) {
	display: block;
	position: static;
	margin: 0 0 0.75em;
	padding: 0;
	font-weight: 700;
	border: 0;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.is-style-big_icon_point, .is-style-big_icon_memo,
	.is-style-big_icon_point > .wp-block-group__inner-container,
	.is-style-big_icon_memo > .wp-block-group__inner-container
) > :is(
	.is-style-big_icon_point__title,
	.is-style-big_icon_point_title,
	.is-style-big_icon_point_ttl,
	.is-style-big_icon_memo__title,
	.is-style-big_icon_memo-title,
	.is-style-big_icon_title
):not(
	.is-style-big_icon_point, .is-style-big_icon_good, .is-style-big_icon_check, .is-style-big_icon_bad,
	.is-style-big_icon_batsu, .is-style-big_icon_hatena, .is-style-big_icon_caution, .is-style-big_icon_memo
)::before {
	display: none;
	content: none;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel {
	--mgx-panel-accent: #4b5e66;
	--mgx-panel-surface: #fff;
	box-sizing: border-box;
	max-width: 37.5rem;
	margin: 2em auto;
	padding: 0;
	overflow: hidden;
	color: #24292f;
	background: var(--mgx-panel-surface);
	border: 0;
	border-radius: 4px;
	box-shadow: 0 3px 5px rgb(0 0 0 / 7%);
}

/*
 * SWELL keeps WordPress's compatibility wrapper around core/group output.
 * `display: contents` lets the saved children participate in the panel grid
 * without tying the canonical component contract to that wrapper's lifetime.
 */
:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel > .wp-block-group__inner-container {
	display: contents;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--warning {
	--mgx-panel-accent: #825b09;
	--mgx-panel-accent: color-mix(in srgb, var(--pb_colset_yellow, #fdc44f) 66%, #000);
	--mgx-panel-surface: var(--pb_colset_yellow_thin, #fef9ed);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--note {
	--mgx-panel-accent: #9a4650;
	--mgx-panel-accent: color-mix(in srgb, var(--pb_colset_pink, #fd9392) 66%, #000);
	--mgx-panel-surface: var(--pb_colset_pink_thin, #ffefef);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--success {
	--mgx-panel-accent: #52751e;
	--mgx-panel-accent: color-mix(in srgb, var(--pb_colset_green, #91c13e) 66%, #000);
	--mgx-panel-surface: var(--pb_colset_green_thin, #f2f8e8);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--info {
	--mgx-panel-accent: #2f7185;
	--mgx-panel-accent: color-mix(in srgb, var(--pb_colset_blue, #6fc7e1) 66%, #000);
	--mgx-panel-surface: var(--pb_colset_blue_thin, #f0f9fc);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :first-child:is(
	h2,
	h3,
	h4,
	.wp-block-heading,
	.mg-content-panel__title
) {
	margin: 0 !important;
	padding: 1em 2em !important;
	color: #fff !important;
	font-size: 1rem !important;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: 0.05em;
	text-align: center;
	background: var(--mgx-panel-accent) !important;
	border: 0 !important;
	border-radius: 4px 4px 0 0 !important;
	box-shadow: none !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :first-child:is(
	h2,
	h3,
	h4,
	.wp-block-heading,
	.mg-content-panel__title
)::before,
:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :first-child:is(
	h2,
	h3,
	h4,
	.wp-block-heading,
	.mg-content-panel__title
)::after {
	display: none !important;
	content: none !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :not(:first-child) {
	margin-inline: 2em;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :nth-child(2) {
	margin-block-start: 2em;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel,
	.mg-content-panel > .wp-block-group__inner-container
) > :last-child {
	margin-block-end: 2em;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--has-profile {
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(5.5rem, 3fr);
	align-items: center;
	column-gap: 1.5rem;
	padding-block-end: 2em;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > :first-child {
	grid-column: 1 / -1;
	margin-inline: 0;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > .mg-list {
	grid-row: 2 / span 2;
	grid-column: 1;
	margin-block: 2em 0 !important;
	margin-inline: 2em 0 !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > .mg-content-panel__comment,
:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > .mg-content-panel__figure {
	grid-column: 2;
	margin-inline: 0 1.5rem;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > .mg-content-panel__comment {
	grid-row: 2;
	align-self: end;
	margin-block: 2em 0.75rem;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
	.mg-content-panel--has-profile,
	.mg-content-panel--has-profile > .wp-block-group__inner-container
) > .mg-content-panel__figure {
	grid-row: 3;
	align-self: start;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__comment {
	position: relative;
	box-sizing: border-box;
	width: auto;
	padding: 10px;
	color: #333;
	font-size: 0.875rem;
	line-height: 1.5;
	text-align: center;
	background: #fff;
	border: 1px solid #555;
	border-radius: 10px;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__comment::before,
:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__comment::after {
	position: absolute;
	top: 100%;
	left: 50%;
	width: 0;
	height: 0;
	border: solid transparent;
	content: "";
	transform: translateX(-50%);
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__comment::before {
	margin-top: 1px;
	border-width: 11px;
	border-top-color: #555;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__comment::after {
	border-width: 10px;
	border-top-color: #fff;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__figure {
	max-width: 8.75rem;
	margin-block: 0 !important;
	padding: 0;
	text-align: center;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__figure img {
	display: block;
	width: 100%;
	height: auto;
	margin-inline: auto;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list {
	box-sizing: border-box;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	list-style: none !important;
	counter-reset: mgx-list;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list > li {
	position: relative;
	box-sizing: border-box;
	margin: 0.7em 0 !important;
	padding: 0 0 0 1.4em !important;
	line-height: 1.5 !important;
	list-style: none !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list > li:not(:last-child) {
	padding-block-end: 0.7em !important;
	border-block-end: 1px dashed #cdcdcd;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list > li::before {
	position: absolute !important;
	top: 0.1em !important;
	left: 0 !important;
	display: block !important;
	box-sizing: content-box !important;
	margin: 0 !important;
	padding: 0 !important;
	color: var(--mgx-panel-accent, #52751e);
	font-weight: 700;
	line-height: 1;
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list > li::after {
	content: none !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list--check > li::before {
	content: "✓" !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list--comment > li::before {
	top: 0.25em !important;
	font-size: 0.6em;
	content: "●" !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list--chevron-right > li::before {
	font-size: 1.25em;
	content: "›" !important;
}

:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-list--dot > li::before {
	top: 0.25em !important;
	font-size: 0.6em;
	content: "●" !important;
}

/* V26 multilingual article notice, now owned by the child presentation CSS. */
:is([data-mg-experience="true"], .editor-styles-wrapper) .gsm-translation-notice {
	margin-block-start: 2em;
	padding: 1em 1.2em;
	color: #6b7280;
	font-size: 0.8125rem;
	line-height: 1.6;
	background: #f8f9fa;
	border-inline-start: 3px solid #6b7280;
}

@media screen and (max-width: 959px) {
	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel,
		.mg-content-panel > .wp-block-group__inner-container
	) > :first-child:is(
		h2,
		h3,
		h4,
		.wp-block-heading,
		.mg-content-panel__title
	) {
		font-size: 0.875rem !important;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--has-profile {
		grid-template-columns: minmax(0, 7fr) minmax(4.5rem, 3fr);
		column-gap: 0.75rem;
		padding-block-end: 1em;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel,
		.mg-content-panel > .wp-block-group__inner-container
	) > :not(:first-child) {
		margin-inline: 1em;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel,
		.mg-content-panel > .wp-block-group__inner-container
	) > :nth-child(2) {
		margin-block-start: 1em;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel,
		.mg-content-panel > .wp-block-group__inner-container
	) > :last-child {
		margin-block-end: 1em;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel--has-profile,
		.mg-content-panel--has-profile > .wp-block-group__inner-container
	) > .mg-list {
		margin-block-start: 1em !important;
		margin-inline-start: 1em !important;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel--has-profile,
		.mg-content-panel--has-profile > .wp-block-group__inner-container
	) > .mg-content-panel__comment,
	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel--has-profile,
		.mg-content-panel--has-profile > .wp-block-group__inner-container
	) > .mg-content-panel__figure {
		margin-inline-end: 0.75rem;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) :is(
		.mg-content-panel--has-profile,
		.mg-content-panel--has-profile > .wp-block-group__inner-container
	) > .mg-content-panel__comment {
		margin-block-start: 1em;
		font-size: 0.75rem;
	}

	:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel__figure {
		max-width: 6.25rem;
	}
}

@media screen and (max-width: 340px) {
	:is([data-mg-experience="true"], .editor-styles-wrapper) .mg-content-panel--has-profile {
		grid-template-columns: minmax(0, 1fr) 5rem;
	}
}
