/**
 * plugins/generic/hmpAssistant/styles/assistant.css
 *
 * Warna diambil dari variabel skin jurnal (--j-main / --j-light / --j-dark /
 * --j-accent) yang sudah didefinisikan di public/journals/<id>/hmp-skin-*.css,
 * jadi asisten ini otomatis ikut warna khas tiap jurnal. Nilai cadangan navy
 * dipakai bila skin-nya belum dimuat.
 */

.hmpa {
	--a-main: var(--j-main, #0f2f52);
	--a-light: var(--j-light, #1b4f7e);
	--a-dark: var(--j-dark, #08203a);
	--a-gold: var(--j-accent, #d9a441);
	--a-ink: #22303b;
	--a-line: rgba(15, 47, 82, .13);

	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 9999;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.55;
}

/* ── Tombol pembuka ─────────────────────────────────────────────────────── */

.hmpa__toggle {
	display: flex;
	align-items: center;
	gap: .55rem;
	margin-left: auto;
	padding: .7rem 1.15rem .7rem .9rem;
	font: inherit;
	font-weight: 700;
	color: #fff;
	background: linear-gradient(150deg, var(--a-light) 0%, var(--a-main) 62%, var(--a-dark) 100%);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 6px 22px rgba(8, 32, 58, .3), inset 0 1px 0 rgba(255, 255, 255, .22);
	cursor: pointer;
	transition: transform .18s ease, box-shadow .18s ease;
}

.hmpa__toggle:hover,
.hmpa__toggle:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 12px 30px rgba(8, 32, 58, .38), inset 0 1px 0 rgba(255, 255, 255, .28);
	outline: 0;
}

.hmpa__toggle:focus-visible {
	outline: 3px solid var(--a-gold);
	outline-offset: 3px;
}

.hmpa__toggle svg {
	width: 22px;
	height: 22px;
	flex: 0 0 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.9;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Titik berkedip halus, memberi kesan "siap membantu". */
.hmpa__pulse {
	position: absolute;
	top: .55rem;
	right: .55rem;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--a-gold);
	box-shadow: 0 0 0 0 rgba(217, 164, 65, .7);
	animation: hmpaPulse 2.4s ease-out infinite;
}

@keyframes hmpaPulse {
	0% { box-shadow: 0 0 0 0 rgba(217, 164, 65, .65); }
	70% { box-shadow: 0 0 0 12px rgba(217, 164, 65, 0); }
	100% { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0); }
}

.hmpa.is-open .hmpa__toggle { display: none; }

/* ── Panel ──────────────────────────────────────────────────────────────── */

/* Atribut hidden harus menang atas display:flex di bawah — tanpa aturan ini
   panel tampil terbuka sejak halaman dimuat. */
.hmpa [hidden] { display: none !important; }

.hmpa__panel {
	width: min(23.5rem, calc(100vw - 2.5rem));
	max-height: min(34rem, calc(100vh - 4rem));
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border-radius: 18px;
	border: 1px solid var(--a-line);
	box-shadow: 0 24px 60px rgba(8, 32, 58, .28);
	transform-origin: bottom right;
	animation: hmpaIn .22s cubic-bezier(.2, .8, .3, 1);
}

@keyframes hmpaIn {
	from { opacity: 0; transform: translateY(14px) scale(.97); }
	to { opacity: 1; transform: none; }
}

.hmpa__head {
	display: flex;
	align-items: center;
	gap: .8rem;
	padding: 1rem 1rem 1rem 1.1rem;
	color: #fff;
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.09' stroke-width='1.4'%3E%3Cpath d='M28 0L56 16v32L28 64L0 48V16z'/%3E%3Cpath d='M28 33L56 49v32L28 97L0 81V49z'/%3E%3C/g%3E%3C/svg%3E"),
		linear-gradient(150deg, var(--a-light) 0%, var(--a-main) 60%, var(--a-dark) 100%);
	border-bottom: 3px solid var(--a-gold);
}

.hmpa__badge {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	min-width: 2.6rem;
	height: 2.6rem;
	padding: 0 .5rem;
	font-size: .8rem;
	font-weight: 800;
	letter-spacing: .03em;
	color: var(--a-dark);
	background: linear-gradient(180deg, #fff 0%, #e8edf2 100%);
	border-radius: 50px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}

.hmpa__titles { min-width: 0; flex: 1; }

.hmpa__titles strong {
	display: block;
	font-size: .98rem;
	line-height: 1.25;
}

.hmpa__titles span {
	display: block;
	margin-top: .1rem;
	font-size: .76rem;
	color: rgba(255, 255, 255, .82);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hmpa__close {
	flex: 0 0 auto;
	width: 2rem;
	height: 2rem;
	display: grid;
	place-items: center;
	font-size: 1.5rem;
	line-height: 1;
	color: #fff;
	background: rgba(255, 255, 255, .14);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.hmpa__close:hover { background: rgba(255, 255, 255, .26); }

.hmpa__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: .9rem 1rem 1rem;
	background: #fbfcfd;
}

.hmpa__intro {
	margin: 0 0 .8rem;
	font-size: .85rem;
	color: #5c6a75;
}

/* ── Pencarian ──────────────────────────────────────────────────────────── */

.hmpa__search {
	width: 100%;
	box-sizing: border-box;
	margin: 0 0 .8rem;
	padding: .55rem .8rem;
	font: inherit;
	font-size: .88rem;
	color: var(--a-ink);
	background: #fff;
	border: 1px solid var(--a-line);
	border-radius: 10px;
}

.hmpa__search:focus {
	outline: 0;
	border-color: var(--a-main);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-main) 18%, transparent);
}

.hmpa__empty {
	margin: .4rem 0;
	font-size: .85rem;
	color: #6a7885;
}

/* ── Daftar pertanyaan ──────────────────────────────────────────────────── */

.hmpa__topic {
	margin: 0 0 .45rem;
	background: #fff;
	border: 1px solid var(--a-line);
	border-radius: 12px;
	overflow: hidden;
}

.hmpa__topic.is-open {
	border-color: color-mix(in srgb, var(--a-main) 38%, #fff);
	box-shadow: 0 4px 14px rgba(8, 32, 58, .08);
}

.hmpa__q {
	display: flex;
	align-items: center;
	gap: .6rem;
	width: 100%;
	padding: .7rem .85rem;
	font: inherit;
	font-size: .88rem;
	font-weight: 600;
	text-align: left;
	color: var(--a-ink);
	background: none;
	border: 0;
	cursor: pointer;
}

.hmpa__q:hover { background: color-mix(in srgb, var(--a-main) 5%, #fff); }

.hmpa__q::after {
	content: "";
	flex: 0 0 auto;
	margin-left: auto;
	width: .5rem;
	height: .5rem;
	border-right: 2px solid var(--a-main);
	border-bottom: 2px solid var(--a-main);
	transform: rotate(45deg);
	transition: transform .18s ease;
}

.hmpa__topic.is-open .hmpa__q::after { transform: rotate(-135deg); }

.hmpa__a {
	padding: 0 .85rem .8rem;
	font-size: .86rem;
	color: #4b5763;
}

.hmpa__a p { margin: 0 0 .6rem; }

.hmpa__link {
	display: inline-flex;
	align-items: center;
	gap: .3rem;
	margin: 0 .35rem .35rem 0;
	padding: .32rem .7rem;
	font-size: .8rem;
	font-weight: 600;
	text-decoration: none;
	color: var(--a-main);
	background: color-mix(in srgb, var(--a-main) 6%, #fff);
	border: 1px solid color-mix(in srgb, var(--a-main) 26%, #fff);
	border-radius: 999px;
}

.hmpa__link:hover {
	color: #fff;
	background: var(--a-main);
	border-color: transparent;
}

/* ── Kontak ─────────────────────────────────────────────────────────────── */

.hmpa__contact {
	padding: .85rem 1rem;
	background: #fff;
	border-top: 1px solid var(--a-line);
}

.hmpa__contact strong {
	display: block;
	margin-bottom: .45rem;
	font-size: .74rem;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: #6a7885;
}

.hmpa__contact a {
	display: block;
	margin-bottom: .3rem;
	font-size: .84rem;
	font-weight: 600;
	color: var(--a-main);
	text-decoration: none;
	word-break: break-word;
}

.hmpa__contact a:hover { text-decoration: underline; }

/* ── Layar kecil: panel jadi lembar penuh dari bawah ────────────────────── */

@media (max-width: 640px) {
	.hmpa { right: .75rem; bottom: .75rem; left: .75rem; }
	.hmpa__panel {
		width: auto;
		/* disisakan ruang di atas supaya kepala halaman jurnal tetap terlihat
		   dan pembaca tidak merasa terkurung di dalam widget */
		max-height: min(30rem, calc(100vh - 9rem));
		border-radius: 16px;
	}
	.hmpa__toggle { padding: .65rem 1rem .65rem .8rem; }
}

@media (prefers-reduced-motion: reduce) {
	.hmpa__toggle,
	.hmpa__panel,
	.hmpa__q::after { transition: none; animation: none; }
	.hmpa__pulse { animation: none; }
}
