/*
 * 旧サイトの CSS（legacy/）の後に読む「部品の違いの吸収」だけを書く。旧サイトの見た目そのものは legacy/ が正。
 * 旧 CSS と同じ強さ（html:root）で書く。
 */

/* スマホとパソコンの出し分け（旧サイトは端末の種類で出し分け。新サイトは画面の幅で：781px 以下がスマホ。Plugin::SP_MAX と同じ） */
@media (max-width: 781px) {
	html:root .ys-pc {
		display: none !important;
	}
	/* 旧サイトのスマホには隠れた PC 用の要素が無いので、その前後の要素が最後・最初の子だった（旧 CSS の > :last-child・> :first-child の余白 0） */
	html:root :not(.ys-pc):has(~ .ys-pc):not(:has(~ :not(.ys-pc))) {
		margin-bottom: 0;
	}
	html:root .ys-pc ~ :not(.ys-pc):not(:not(.ys-pc) ~ *) {
		margin-top: 0;
	}
}
@media (min-width: 782px) {
	html:root .ys-sp {
		display: none !important;
	}
	/* 同じく、旧サイトの PC には隠れたスマホ用の要素が無い */
	html:root :not(.ys-sp):has(~ .ys-sp):not(:has(~ :not(.ys-sp))) {
		margin-bottom: 0;
	}
	html:root .ys-sp ~ :not(.ys-sp):not(:not(.ys-sp) ~ *) {
		margin-top: 0;
	}
}

/* カラムの幅（旧サイトは style="flex-basis:…" で、WordPress の CSS が [style*=flex-basis] に flex-grow:0 を当てていた） */
@media (min-width: 782px) {
	html:root .wp-block-columns:not(.is-not-stacked-on-mobile) > .wp-block-column.ys-flex-basis {
		flex-grow: 0;
	}
}
html:root .wp-block-columns.is-not-stacked-on-mobile > .wp-block-column.ys-flex-basis {
	flex-grow: 0;
}

/* エディターでの、表示しないブロックの印 */
.ys-shimanoeki-placeholder {
	padding: 16px;
	background-color: #f0f0f0;
	font-size: 14px;
}

/*
 * WordPress のブロックの CSS と旧 CSS の強さの順を戻す。旧 CSS は html:root を付けて強くしてあるため、
 * 旧サイトでは WordPress の指定が勝っていたところで、旧 CSS が勝ってしまう。そこだけ WordPress の指定を同じ強さで書き直す。
 */
/* 画像の中央寄せ：旧サイトは WordPress の display: table（画像の幅の箱）が Nishiki Pro の .aligncenter（display: block）に勝っていた */
html:root .wp-block-image .aligncenter,
html:root .wp-block-image .alignleft,
html:root .wp-block-image .alignright,
html:root .wp-block-image.aligncenter,
html:root .wp-block-image.alignleft,
html:root .wp-block-image.alignright {
	display: table;
}

/* 最新の投稿のブロック（トップページの「よみもの」）：旧サイトは WordPress の 2 列の指定（.columns-2:not(.is-layout-grid) li）が、
   子テーマの custom.css の幅 100%・余白 0 に勝っていた（WordPress の指定の方が強い） */
html:root .wp-block-latest-posts.is-grid:not(.is-layout-grid) li {
	margin: 0 1.25em 1.25em 0;
}
@media (min-width: 600px) {
	html:root .wp-block-latest-posts.columns-2:not(.is-layout-grid) li {
		width: calc(50% - .625em);
	}
	html:root .wp-block-latest-posts.columns-2:not(.is-layout-grid) li:nth-child(2n) {
		margin-right: 0;
	}
}

/* Instagram の投稿の埋め込み（マンゴー・メロンの記事。blocks/instagram）：旧サイトは Instagram が配っている HTML の style 属性。同じ見た目。
   Instagram の embed.js が iframe に置き換えるまでと、JS が動かないときの見た目 */
html:root .instagram-media.ys-instagram {
	background: #fff;
	border: 0;
	border-radius: 3px;
	box-shadow: 0 0 1px 0 rgb(0 0 0 / .5), 0 1px 10px 0 rgb(0 0 0 / .15);
	margin: 1px;
	max-width: 540px;
	/* 旧サイトは 326px。320px などの狭い画面では、はみ出さないように枠の幅まで */
	min-width: min(326px, 100%);
	padding: 0;
	width: calc(100% - 2px);
}
