/* ============================================================
   ASTKOHTH Navigation Chat — 専用スタイル
   TOPページ（投稿ID 754）だけに wp_enqueue_scripts で読み込まれる。
   すべてのセレクタは #astkohth-nav-chat / .astkohth-nav-chat 名前空間の
   配下に限定しており、bodyへの一時的なスクロール停止クラス付与を除き、
   サイトの既存要素へ影響する汎用セレクタは使用していない。
   ============================================================ */

#astkohth-nav-chat,
#astkohth-nav-chat *,
#astkohth-nav-chat *::before,
#astkohth-nav-chat *::after,
#astkohth-nav-chat-overlay {
	box-sizing: border-box;
	font-family: "游ゴシック体", "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック", YuGothic,
		"ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif;
}

#astkohth-nav-chat {
	position: fixed;
	inset: auto;
	z-index: 999990;
}

/* ------------------------------------------------------------
   起動ボタン「お困りですか？」
   ------------------------------------------------------------ */

#astkohth-nav-chat-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 999991;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 48px;
	padding: 0 20px 0 18px;
	background: #111111;
	color: #ffffff;
	border: none;
	border-radius: 999px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	font-size: 14.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
	line-height: 1;
	transition: box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}
#astkohth-nav-chat-launcher:hover {
	background: #262626;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.26);
}
#astkohth-nav-chat-launcher:focus-visible {
	outline: 2px solid #7ac142;
	outline-offset: 2px;
}
#astkohth-nav-chat-launcher .astkohth-nav-chat__launcher-icon {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}
#astkohth-nav-chat-launcher[aria-expanded="true"] {
	display: none;
}

/* 初回表示時のみ・1回限りの控えめな注目アニメーション（点滅・永続バウンド禁止・強い拡大禁止） */
@media (prefers-reduced-motion: no-preference) {
	#astkohth-nav-chat-launcher.astkohth-nav-chat__launcher--attention {
		animation: astkohth-nav-chat-attention-pulse 0.6s ease-in-out 1;
	}
}
@keyframes astkohth-nav-chat-attention-pulse {
	0% { transform: scale(1); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
	45% { transform: scale(1.035); box-shadow: 0 9px 24px rgba(0, 0, 0, 0.26); }
	100% { transform: scale(1); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
}

/* ------------------------------------------------------------
   背景幕（スマホでチャットを開いた時のみ、JSでhidden切替）
   ------------------------------------------------------------ */

#astkohth-nav-chat-overlay {
	position: fixed;
	inset: 0;
	z-index: 999991;
	background: rgba(0, 0, 0, 0.28);
	opacity: 0;
	transition: opacity 0.2s ease;
}
#astkohth-nav-chat-overlay[hidden] {
	display: none;
}
#astkohth-nav-chat-overlay.astkohth-nav-chat__overlay--visible {
	opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
	#astkohth-nav-chat-overlay {
		transition: none;
	}
}

/* 背景スクロール停止用の専用クラス（スマホでチャットを開いている間だけ
   bodyへ付与し、閉じた際に必ず解除する。JS側のtopオフセットと併用） */
body.astkohth-nav-chat-scroll-lock {
	position: fixed;
	left: 0;
	right: 0;
	width: 100%;
}

/* ------------------------------------------------------------
   チャットパネル本体（PC：右下フローティング）
   ------------------------------------------------------------ */

#astkohth-nav-chat-dialog {
	position: fixed;
	right: 24px;
	bottom: 88px;
	z-index: 999992;
	width: clamp(320px, 29vw, 360px);
	max-width: calc(100vw - 32px);
	max-height: 70vh;
	background: #ffffff;
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.22s ease, transform 0.22s ease;
}
#astkohth-nav-chat-dialog[hidden] {
	display: none;
}
#astkohth-nav-chat-dialog.astkohth-nav-chat__dialog--open {
	opacity: 1;
	transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
	#astkohth-nav-chat-dialog {
		transition: none;
	}
}

/* ドラッグ中はテキスト選択やアニメーションを止める */
#astkohth-nav-chat-dialog.astkohth-nav-chat__dialog--dragging {
	transition: none;
	user-select: none;
}

#astkohth-nav-chat-header {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 54px;
	padding: 0 8px 0 18px;
	background: #111111;
	color: #ffffff;
	border-bottom: 3px solid #7ac142;
}
#astkohth-nav-chat-header.astkohth-nav-chat__header--draggable {
	cursor: grab;
}
#astkohth-nav-chat-header.astkohth-nav-chat__header--draggable:active,
#astkohth-nav-chat-dialog.astkohth-nav-chat__dialog--dragging #astkohth-nav-chat-header {
	cursor: grabbing;
}
.astkohth-nav-chat__header-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.astkohth-nav-chat__grip {
	flex-shrink: 0;
	color: rgba(255, 255, 255, 0.4);
}
#astkohth-nav-chat-title {
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.03em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#astkohth-nav-chat-close {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	background: transparent;
	border: none;
	border-radius: 8px;
	color: #ffffff;
	cursor: pointer;
}
#astkohth-nav-chat-close:hover {
	background: rgba(255, 255, 255, 0.14);
}
#astkohth-nav-chat-close:focus-visible {
	outline: 2px solid #7ac142;
	outline-offset: 2px;
}
#astkohth-nav-chat-close svg {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

#astkohth-nav-chat-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 20px;
	background: #ffffff;
}

.astkohth-nav-chat__screen[hidden] {
	display: none;
}

/* 二階層目へ移動する際の控えめなフェード＋横移動（180〜220ms） */
@media (prefers-reduced-motion: no-preference) {
	.astkohth-nav-chat__screen.astkohth-nav-chat__screen--enter-forward {
		animation: astkohth-nav-chat-slide-in-right 0.2s ease-out;
	}
	.astkohth-nav-chat__screen.astkohth-nav-chat__screen--enter-back {
		animation: astkohth-nav-chat-slide-in-left 0.2s ease-out;
	}
}
@keyframes astkohth-nav-chat-slide-in-right {
	from { opacity: 0; transform: translateX(14px); }
	to { opacity: 1; transform: translateX(0); }
}
@keyframes astkohth-nav-chat-slide-in-left {
	from { opacity: 0; transform: translateX(-14px); }
	to { opacity: 1; transform: translateX(0); }
}

.astkohth-nav-chat__msg {
	margin: 0 0 18px;
	font-size: 15px;
	line-height: 1.75;
	color: #333333;
}

.astkohth-nav-chat__options {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.astkohth-nav-chat__option {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 52px;
	padding: 12px 16px;
	background: #ffffff;
	border: 1px solid #e2e2e2;
	border-radius: 12px;
	text-align: left;
	font-size: 14.5px;
	font-weight: 700;
	color: #111111;
	cursor: pointer;
	transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}
.astkohth-nav-chat__option:hover,
.astkohth-nav-chat__option:focus-visible {
	border-color: #bfe3a4;
	background: #f3f9ee;
	transform: translateX(2px);
}
.astkohth-nav-chat__option:focus-visible {
	outline: 2px solid #7ac142;
	outline-offset: 1px;
}
@media (prefers-reduced-motion: reduce) {
	.astkohth-nav-chat__option {
		transition: border-color 0.18s ease, background-color 0.18s ease;
	}
	.astkohth-nav-chat__option:hover,
	.astkohth-nav-chat__option:focus-visible {
		transform: none;
	}
}
.astkohth-nav-chat__option-icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	color: #3f6b1f;
}
.astkohth-nav-chat__option span {
	flex: 1 1 auto;
	min-width: 0;
}
.astkohth-nav-chat__option-chevron {
	flex-shrink: 0;
	margin-left: auto;
	color: #b7b7b7;
}

/* ------------------------------------------------------------
   二階層目：カテゴリ表示・戻るボタン・アクション
   ------------------------------------------------------------ */

.astkohth-nav-chat__back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 4px 6px;
	background: transparent;
	border: none;
	color: #666666;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
}
.astkohth-nav-chat__back:hover {
	color: #111111;
	text-decoration: underline;
}
.astkohth-nav-chat__back:focus-visible {
	outline: 2px solid #7ac142;
	outline-offset: 1px;
}
.astkohth-nav-chat__back svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}
.astkohth-nav-chat__back--top {
	margin: 0 0 14px;
}

.astkohth-nav-chat__category {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 14px;
	color: #3f6b1f;
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
}
.astkohth-nav-chat__category svg {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
}

.astkohth-nav-chat__actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 6px;
}

.astkohth-nav-chat__btn {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 50px;
	width: 100%;
	padding: 10px 44px;
	border-radius: 8px;
	font-size: 14.5px;
	font-weight: 700;
	text-decoration: none;
	text-align: center;
	line-height: 1.4;
	transition: background-color 0.18s ease;
}
.astkohth-nav-chat__btn-icon {
	position: absolute;
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
	flex-shrink: 0;
}
.astkohth-nav-chat__btn--primary {
	background: #7ac142;
	color: #111111;
}
.astkohth-nav-chat__btn--primary:hover {
	background: #68ac37;
}
.astkohth-nav-chat__btn--secondary {
	background: #ffffff;
	color: #222222;
	border: 1px solid #333333;
}
.astkohth-nav-chat__btn--secondary:hover {
	background: #f5f5f5;
}
.astkohth-nav-chat__btn:focus-visible {
	outline: 2px solid #7ac142;
	outline-offset: 1px;
}

.astkohth-nav-chat__note {
	margin: 0 0 14px;
	padding: 12px 14px;
	background: #f7f7f7;
	border-radius: 6px;
	font-size: 12.5px;
	line-height: 1.7;
	color: #777777;
}
.astkohth-nav-chat__actions .astkohth-nav-chat__note {
	margin: -2px 0 4px;
}

/* ------------------------------------------------------------
   スマホ（640px以下）：ボトムシート表示・ドラッグ無効・背景幕
   ------------------------------------------------------------ */

@media (max-width: 640px) {
	#astkohth-nav-chat-launcher {
		right: 16px;
		bottom: max(16px, env(safe-area-inset-bottom));
	}

	#astkohth-nav-chat-dialog {
		left: 8px !important;
		right: 8px !important;
		bottom: 0 !important;
		top: auto !important;
		width: calc(100% - 16px) !important;
		max-width: calc(100% - 16px);
		max-height: 78vh;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
		transform: translateY(16px);
	}
	#astkohth-nav-chat-dialog.astkohth-nav-chat__dialog--open {
		transform: translateY(0);
	}
	#astkohth-nav-chat-header.astkohth-nav-chat__header--draggable {
		cursor: default;
	}
	.astkohth-nav-chat__grip {
		display: none;
	}
	#astkohth-nav-chat-close {
		width: 44px;
		height: 44px;
	}
	#astkohth-nav-chat-body {
		max-height: calc(78vh - 54px);
		padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
	}
}

/* タッチ端末ではPC用ドラッググリップを表示しない（幅に関わらず） */
@media (pointer: coarse) {
	.astkohth-nav-chat__grip {
		display: none;
	}
}

/* 横スクロール対策：万一パネルが画面幅を超えないよう明示的に制限 */
@media (max-width: 380px) {
	#astkohth-nav-chat-dialog {
		left: 8px !important;
		right: 8px !important;
		width: calc(100% - 16px) !important;
		max-width: calc(100% - 16px);
	}
}
