/* Insight Popup — 프론트 스타일
 * 참고 디자인: 배경 딤 없이 흰 카드 + 하단 회색 바.
 * 기본은 display:none 이고 JS 가 .is-open 을 붙일 때만 보인다(깜빡임 방지).
 */

/* .ipop-root 는 마크업 묶음일 뿐이다. 위치는 각 팝업이 fixed 로 스스로 잡는다. */

.ipop {
	position: fixed;
	z-index: 999999;
	display: none;
	flex-direction: column;
	box-sizing: border-box;
	width: var(--ipop-w, 500px);
	/* fixed 요소의 %는 스크롤바를 뺀 뷰포트 기준이라 vw 와 달리 좌우가 정확히 맞는다. */
	max-width: 92%;
	max-height: 88vh;
	overflow: hidden;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
	text-align: left;
}

.ipop.is-open {
	display: flex;
	animation: ipop-in .25s ease-out both;
}

/* 위치 지정에 transform 을 쓰므로(중앙 정렬) 등장 효과는 불투명도만 다룬다.
   transform 을 애니메이션하면 정렬이 어긋난다. */
@keyframes ipop-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.ipop.is-open { animation: none; }
}

.ipop--fixed-h {
	height: var(--ipop-h, auto);
}

/* --- 위치 ------------------------------------------------------------- */
/* --ipop-off 는 팝업이 여러 개일 때 JS 가 넣는 계단식 오프셋이다. */

.ipop--center {
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%) translate(var(--ipop-off, 0px), var(--ipop-off, 0px));
}

.ipop--top-left {
	left: calc(24px + var(--ipop-off, 0px));
	top: calc(24px + var(--ipop-off, 0px));
}

.ipop--top-right {
	right: calc(24px + var(--ipop-off, 0px));
	top: calc(24px + var(--ipop-off, 0px));
}

.ipop--bottom-left {
	left: calc(24px + var(--ipop-off, 0px));
	bottom: calc(24px + var(--ipop-off, 0px));
}

.ipop--bottom-right {
	right: calc(24px + var(--ipop-off, 0px));
	bottom: calc(24px + var(--ipop-off, 0px));
}

/* --- 본문 ------------------------------------------------------------- */

.ipop__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.ipop__imglink {
	display: block;
	text-decoration: none;
}

.ipop__img,
.ipop__body img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	border: 0;
}

.ipop__content {
	padding: 22px 24px;
	font-size: 15px;
	line-height: 1.7;
	color: #333;
	word-break: keep-all;
}

.ipop__content > :first-child { margin-top: 0; }
.ipop__content > :last-child  { margin-bottom: 0; }

.ipop__content img {
	width: auto;
	margin: 0 auto;
}

/* --- 하단 바 ---------------------------------------------------------- */

.ipop__footer {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	box-sizing: border-box;
	width: 100%;
	padding: 14px 20px;
	background: #fafafa;
	border-top: 1px solid #f0f0f0;
	font-size: 13px;
	line-height: 1.4;
	color: #8b8b8b;
}

.ipop__footer--close-only {
	justify-content: flex-end;
}

.ipop__hide {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	cursor: pointer;
	font-size: 13px;
	color: #8b8b8b;
	white-space: nowrap;
}

.ipop__hide-cb {
	width: 15px;
	height: 15px;
	margin: 0;
	cursor: pointer;
	accent-color: #666;
}

.ipop__close {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	font: inherit;
	font-weight: 600;
	color: #222;
	line-height: 1.4;
	white-space: nowrap;
	cursor: pointer;
}

.ipop__close:hover,
.ipop__close:focus {
	color: #000;
	background: none;
	text-decoration: none;
}

/* --- 모바일 ----------------------------------------------------------- */
/* 구석 배치와 고정 높이는 화면 밖으로 밀려나기 쉬우므로 무시하고 중앙에 세운다. */

@media (max-width: 767px) {
	.ipop {
		left: 50% !important;
		right: auto !important;
		top: 50% !important;
		bottom: auto !important;
		width: calc(100% - 32px) !important;
		max-width: calc(100% - 32px) !important;
		height: auto !important;
		max-height: 85vh;
		transform: translate(-50%, -50%) !important;
	}

	.ipop__content {
		padding: 18px 18px;
		font-size: 14px;
	}

	.ipop__footer {
		padding: 12px 16px;
		font-size: 12px;
	}
}
