/*
 * image_format_demo.css
 * 画像フォーマット比較の体験デモ（3種）
 * - #image-format-demo      … 拡張子切り替えデモ（ピラー記事）
 * - #image-transparency-demo … 透過が壊れる瞬間デモ（クラスター記事：画像の透過）
 * - #svg-live-demo          … SVGライブ操作デモ（クラスター記事：SVG活用ガイド）
 * 共通クラスは ifd- を接頭辞にしています。
 */

#image-format-demo,
#image-transparency-demo,
#svg-live-demo {
	box-sizing: border-box;
	margin: 1.4rem 0;
	padding: 1rem 1.1rem 1.6rem;
	background: #f4f8fb;
	border-radius: 1rem;
	scroll-margin-top: 90px;
}

#image-format-demo *,
#image-format-demo *::before,
#image-format-demo *::after,
#image-transparency-demo *,
#image-transparency-demo *::before,
#image-transparency-demo *::after,
#svg-live-demo *,
#svg-live-demo *::before,
#svg-live-demo *::after {
	box-sizing: border-box;
}

/* ---------- 見出しエリア ---------- */

.ifd-container {
	max-width: 780px;
	margin: 0 auto;
}

.ifd-head {
	text-align: center;
	margin-bottom: 1.2rem;
}

.ifd-badge {
	display: inline-block;
	padding: .6rem 2rem;
	border-radius: 999px;
	background: #0175d8;
	color: #fff;
	font-size: 1.56rem;
	font-weight: 700;
	letter-spacing: .06em;
	margin-bottom: .6rem;
}

h3.ifd-headline {
	display: block;
	margin: .7rem auto 0;
	max-width: 32rem;
	font-size: 1.22rem;
	font-weight: 800;
	line-height: 1.65;
	color: #12233f;
	letter-spacing: .01em;
	background: none;
	padding: 0;
	box-decoration-break: initial;
	-webkit-box-decoration-break: initial;
}

.ifd-headline__mark {
	color: #0175d8;
	white-space: nowrap;
}

.ifd-lead {
	font-size: .86rem;
	color: #555;
	line-height: 1.9;
	margin: .6rem auto 0;
	max-width: 34rem;
}

.ifd-sample-note {
	font-size: .74rem;
	color: #8a8a8a;
	text-align: center;
	margin: .5rem 0 0;
}

/* ---------- タブ ---------- */

.ifd-tabs {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: .5rem;
	margin: 0 0 1rem;
}

.ifd-tab {
	appearance: none;
	cursor: pointer;
	border: 1px solid #d5dee7;
	background: #fff;
	color: #445;
	border-radius: 999px;
	padding: .5rem 1.05rem;
	font-size: .84rem;
	font-weight: 700;
	letter-spacing: .02em;
	transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.ifd-tab:hover {
	border-color: #7bb8f2;
	background: #f2f9ff;
}

.ifd-tab.is-active {
	background: #0175d8;
	border-color: #0175d8;
	color: #fff;
	transform: translateY(-1px);
}

/* ---------- パネル本体 ---------- */

.ifd-panel {
	background: #fff;
	border-radius: 1rem;
	box-shadow: 0 .6rem 1.8rem rgba(0, 30, 70, .08);
	padding: 1.4rem 1.3rem;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.4rem;
	align-items: start;
}

/* ---------- プレビュー ---------- */

.ifd-preview {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .6rem;
}

.ifd-preview__stage {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	border-radius: .7rem;
	overflow: hidden;
	background: #eef2f5;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ifd-preview__stage--checker {
	background-image:
		linear-gradient(45deg, #e3e8ee 25%, transparent 25%),
		linear-gradient(-45deg, #e3e8ee 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #e3e8ee 75%),
		linear-gradient(-45deg, transparent 75%, #e3e8ee 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
	background-color: #fff;
}

.ifd-preview__stage img,
.ifd-preview__stage svg {
	max-width: 78%;
	max-height: 78%;
	display: block;
}

.ifd-preview__stage--opaque {
	background-color: #fff5f5;
	background-image: none;
}

.ifd-preview__badge {
	position: absolute;
	top: .6rem;
	right: .6rem;
	font-size: .72rem;
	font-weight: 700;
	padding: .28rem .65rem;
	border-radius: 999px;
	background: #eafbf1;
	color: #1f9d5c;
	border: 1px solid #a8ddb5;
}

.ifd-preview__badge--no {
	background: #fdecec;
	color: #d1382f;
	border-color: #efb0b0;
}

.ifd-preview__caption {
	font-size: .78rem;
	color: #8a8a8a;
	text-align: center;
	margin: 0;
}

/* ---------- 情報パネル ---------- */

.ifd-info__format {
	font-size: 1.05rem;
	font-weight: 800;
	color: #12233f;
	margin: 0 0 .5rem;
}

.ifd-info__desc {
	font-size: .84rem;
	line-height: 1.85;
	color: #333;
	margin: 0 0 .8rem;
}

.ifd-spec {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: .45rem;
}

.ifd-spec li {
	display: flex;
	gap: .5rem;
	font-size: .8rem;
	line-height: 1.7;
	padding: .4rem .6rem;
	background: #f7fafc;
	border-radius: .4rem;
}

.ifd-spec__label {
	flex: 0 0 auto;
	min-width: 5.6rem;
	font-weight: 700;
	color: #0175d8;
}

.ifd-spec__value {
	color: #333;
}

/* ---------- コード表示エリア（パネル全幅・アコーディオン） ---------- */

.ifd-code-area {
	grid-column: 1 / -1;
	margin-top: .4rem;
	padding-top: 1.1rem;
	border-top: 1px dashed #dfe6ec;
}

.ifd-accordion {
	border: 1px solid #dfe6ec;
	border-radius: .6rem;
	overflow: hidden;
}

.ifd-accordion__toggle {
	appearance: none;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .6rem;
	background: #f7fafc;
	border: none;
	cursor: pointer;
	padding: .65rem .9rem;
	font-size: .8rem;
	font-weight: 700;
	color: #0175d8;
	text-align: left;
}

.ifd-accordion__toggle:hover {
	background: #eef4fb;
}

.ifd-accordion__icon {
	flex: 0 0 auto;
	display: inline-block;
	transition: transform .2s ease;
	color: #7a8794;
}

.ifd-accordion.is-open .ifd-accordion__icon {
	transform: rotate(180deg);
}

.ifd-accordion__panel {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows .25s ease;
}

.ifd-accordion.is-open .ifd-accordion__panel {
	grid-template-rows: 1fr;
}

.ifd-accordion__panel-inner {
	overflow: hidden;
	min-height: 0;
}

.ifd-code-label {
	font-size: .76rem;
	font-weight: 700;
	color: #55606c;
	margin: 0;
	padding: .8rem .9rem 0;
}

.ifd-code {
	position: relative;
	max-height: 16rem;
	overflow: auto;
	background: #12233f;
	color: #d6e6ff;
	border-radius: 0 0 .5rem .5rem;
	padding: .7rem .8rem;
	font-size: .74rem;
	line-height: 1.6;
	font-family: 'Courier New', monospace;
	white-space: pre-wrap;
	word-break: break-all;
	margin: .5rem .9rem .9rem;
	border-radius: .5rem;
}

/* コピー防止：選択不可＋透かし（あくまで簡易的な抑止） */
.ifd-code--protected {
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
}

.ifd-code--protected::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: .16;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='90'%3E%3Ctext x='0' y='50' font-family='sans-serif' font-size='16' fill='%23ffffff' transform='rotate(-18 85 45)'%3ESAMPLE%3C/text%3E%3C/svg%3E");
	background-repeat: repeat;
}

/* ============================================================
   透過が壊れる瞬間デモ（itb-）
   ============================================================ */

.itb-panel {
	background: #fff;
	border-radius: 1rem;
	box-shadow: 0 .6rem 1.8rem rgba(0, 30, 70, .08);
	padding: 1.4rem 1.3rem;
}

.itb-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 1.6rem;
	margin-bottom: 1.2rem;
}

.itb-control-group {
	display: flex;
	flex-direction: column;
	gap: .4rem;
}

.itb-control-label {
	font-size: .74rem;
	font-weight: 700;
	color: #55606c;
}

.ifd-action-btn {
	appearance: none;
	cursor: pointer;
	border: none;
	border-radius: 999px;
	padding: .65rem 1.3rem;
	background: linear-gradient(90deg, #0175d8, #29b16d);
	color: #fff;
	font-size: .86rem;
	font-weight: 700;
	box-shadow: 0 .4rem 1rem rgba(1, 117, 216, .28);
	transition: transform .15s ease, opacity .15s ease;
}

.ifd-action-btn:hover {
	opacity: .92;
	transform: translateY(-1px);
}

.ifd-action-btn--ghost {
	background: #eef2f5;
	color: #445;
	box-shadow: none;
}

.itb-stage {
	position: relative;
	width: 100%;
	max-width: 420px;
	aspect-ratio: 4 / 3;
	margin: 0 auto;
	border-radius: .8rem;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .3s ease;
	border: 1px solid #e3e8ee;
}

.itb-stage img {
	max-width: 78%;
	max-height: 78%;
	display: block;
}

.itb-stage--broken img {
	filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
	outline: 3px dashed #d1382f;
	outline-offset: 4px;
}

@keyframes itb-shake {
	0%, 100% { transform: translateX(0); }
	20% { transform: translateX(-6px); }
	40% { transform: translateX(6px); }
	60% { transform: translateX(-4px); }
	80% { transform: translateX(4px); }
}

.itb-stage--shake {
	animation: itb-shake .45s ease;
}

.itb-status {
	max-width: 420px;
	margin: 1rem auto 0;
	padding: .7rem .9rem;
	border-radius: .6rem;
	font-size: .84rem;
	line-height: 1.8;
	text-align: center;
}

.itb-status--ok {
	background: #eafbf1;
	color: #1a7d4c;
	border: 1px solid #a8ddb5;
}

.itb-status--ng {
	background: #fdecec;
	color: #b8271e;
	border: 1px solid #efb0b0;
}

/* ============================================================
   SVGライブ操作デモ（svglive-）
   ============================================================ */

.svglive-panel {
	background: #fff;
	border-radius: 1rem;
	box-shadow: 0 .6rem 1.8rem rgba(0, 30, 70, .08);
	padding: 1.4rem 1.3rem;
}

.svglive-stages {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.2rem;
	margin-bottom: 1.2rem;
}

.svglive-stage-col {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .5rem;
}

.svglive-stage-label {
	font-size: .76rem;
	font-weight: 700;
	color: #55606c;
	text-align: center;
}

#svgLiveStage svg,
#svgCompareStage img {
	max-width: 78%;
	max-height: 78%;
	display: block;
}

.svglive-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1.1rem 1.6rem;
	padding: 1rem;
	background: #f7fafc;
	border-radius: .7rem;
	margin-bottom: .4rem;
}

.svglive-control {
	display: flex;
	align-items: center;
	gap: .5rem;
	font-size: .82rem;
	font-weight: 700;
	color: #333;
}

.svglive-control input[type="color"] {
	width: 2.2rem;
	height: 2.2rem;
	border: none;
	border-radius: .4rem;
	padding: 0;
	background: none;
	cursor: pointer;
}

.svglive-control input[type="range"] {
	width: 8rem;
}

.svglive-control--checkbox {
	font-weight: 400;
}

.svg-pulse.is-pulsing {
	animation: svglive-pulse 1.1s ease-in-out infinite;
	transform-origin: center;
}

@keyframes svglive-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: .4; transform: scale(1.5); }
}

/* ---------- レスポンシブ ---------- */

@media screen and (max-width: 640px) {

	#image-format-demo,
	#image-transparency-demo,
	#svg-live-demo {
		padding: 1rem .8rem 1.4rem;
		border-radius: .7rem;
	}

	.ifd-panel {
		grid-template-columns: 1fr;
		padding: 1.1rem .9rem;
		border-radius: .7rem;
	}

	.ifd-badge {
		padding: .45rem 1.2rem;
		font-size: 1.1rem;
		white-space: normal;
		text-align: center;
	}

	.ifd-tab {
		padding: .45rem .85rem;
		font-size: .78rem;
	}

	.itb-panel,
	.svglive-panel {
		padding: 1.1rem .9rem;
		border-radius: .7rem;
	}

	.svglive-stages {
		grid-template-columns: 1fr;
	}

	.svglive-controls {
		gap: .8rem 1.2rem;
	}
}
