/*
 * page.css
 * 子ページ用CSS。ページごとにコメントで区切って管理します。
 */

/* --- カタカムナ八十首講座：埋め込みチャットページ --- */
:root {
	--chat-navy: #061226;
	--chat-navy-2: #0b1b34;
	--chat-navy-3: #122a4a;
	--chat-gold: #d8b96f;
	--chat-gold-light: #f4dca1;
	--chat-cyan: #96d8e7;
	--chat-text: #f5f8fc;
	--chat-muted: #c2cddd;
	--chat-subtle: #91a1b7;
	--chat-line: rgba(216, 185, 111, 0.24);
	--chat-error: #f1b3a6;
	--chat-serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", Georgia, serif;
	--chat-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "Segoe UI", sans-serif;
}

html,
body.chat-page {
	min-width: 300px;
	min-height: 100%;
	margin: 0;
	background:
		radial-gradient(circle at 84% 8%, rgba(216, 185, 111, 0.16), transparent 24rem),
		radial-gradient(circle at 7% 92%, rgba(150, 216, 231, 0.12), transparent 25rem),
		var(--chat-navy);
	color: var(--chat-text);
	overflow-x: hidden;
	color-scheme: dark;
}

body.chat-page {
	font-family: var(--chat-sans);
	font-size: 16px;
	font-weight: 400;
	line-height: 1.85;
	letter-spacing: 0.01em;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.chat-app {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	height: 100vh;
	min-height: 720px;
	background: rgba(5, 14, 29, 0.9);
}

/* ヘッダー：講座名・接続状態・残り質問回数 */
.chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 78px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--chat-line);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.chat-mark,
.chat-avatar {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	border: 1px solid rgba(216, 185, 111, 0.58);
	border-radius: 50%;
	color: var(--chat-gold-light);
	font-family: var(--chat-serif);
	background: rgba(10, 28, 52, 0.9);
}

.chat-mark {
	width: 46px;
	height: 46px;
	font-size: 22px;
	box-shadow: 0 0 24px rgba(216, 185, 111, 0.1);
}

.chat-title {
	min-width: 0;
	line-height: 1.35;
}

.chat-title strong {
	display: block;
	color: #fff;
	font-family: var(--chat-serif);
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0.045em;
	white-space: nowrap;
}

.chat-title span {
	display: block;
	margin-top: 3px;
	color: var(--chat-muted);
	font-size: 9px;
	font-weight: 800;
	letter-spacing: 0.13em;
}

.chat-header-spacer {
	flex: 1;
}

.chat-status {
	display: flex;
	align-items: center;
	gap: 7px;
	color: #d3dce8;
	font-size: 11px;
	white-space: nowrap;
}

.chat-status i {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #78d69e;
	box-shadow: 0 0 12px rgba(120, 214, 158, 0.72);
}

.chat-turn-badge {
	padding: 6px 10px;
	border: 1px solid rgba(216, 185, 111, 0.34);
	border-radius: 999px;
	background: rgba(216, 185, 111, 0.08);
	color: var(--chat-gold-light);
	font-size: 11px;
	font-weight: 800;
	white-space: nowrap;
}

.chat-reset {
	width: 38px;
	height: 38px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.035);
	color: #c4cfdd;
	font-size: 18px;
	cursor: pointer;
}

.chat-reset:hover,
.chat-reset:focus-visible {
	border-color: rgba(216, 185, 111, 0.62);
	background: rgba(216, 185, 111, 0.09);
	color: #fff;
}

/* 会話本文：読みやすさを優先して15px以上を維持 */
.chat-messages {
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 24px 18px 16px;
	scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
	width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
	border-radius: 99px;
	background: rgba(216, 185, 111, 0.25);
}

.chat-message {
	display: flex;
	gap: 11px;
	margin-bottom: 20px;
	animation: chat-message-in 0.24s ease both;
}

.chat-message.user {
	justify-content: flex-end;
}

.chat-avatar {
	width: 34px;
	height: 34px;
	margin-top: 3px;
	font-size: 14px;
}

.chat-message.user .chat-avatar {
	order: 2;
	border-color: rgba(150, 216, 231, 0.45);
	color: #d4f4fa;
}

.chat-message-main {
	max-width: min(90%, 720px);
}

.chat-route {
	display: flex;
	align-items: center;
	gap: 7px;
	margin-bottom: 6px;
	color: #aab8ca;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.11em;
}

.chat-route::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--chat-gold);
	box-shadow: 0 0 8px rgba(216, 185, 111, 0.45);
}

.chat-bubble {
	padding: 16px 17px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 5px 18px 18px;
	background: rgba(255, 255, 255, 0.065);
	color: var(--chat-text);
	font-size: 15.5px;
	font-weight: 400;
	line-height: 1.92;
	letter-spacing: 0.015em;
	white-space: pre-line;
	overflow-wrap: anywhere;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.chat-bubble strong {
	color: var(--chat-gold-light);
	font-weight: 700;
}

.chat-message.user .chat-bubble {
	border-color: rgba(150, 216, 231, 0.28);
	border-radius: 18px 5px 18px 18px;
	background: rgba(150, 216, 231, 0.13);
	color: #fff;
}

/* 回答の次の一手 */
.chat-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.chat-action {
	min-height: 40px;
	padding: 9px 13px;
	border: 1px solid rgba(216, 185, 111, 0.32);
	border-radius: 999px;
	background: rgba(216, 185, 111, 0.075);
	color: #f0dfb5;
	font-family: var(--chat-sans);
	font-size: 12px;
	font-weight: 700;
	line-height: 1.45;
	cursor: pointer;
}

.chat-action:hover,
.chat-action:focus-visible {
	border-color: rgba(244, 220, 161, 0.72);
	background: rgba(216, 185, 111, 0.15);
	color: #fff;
}

.chat-action.primary {
	border-color: var(--chat-gold-light);
	background: linear-gradient(135deg, var(--chat-gold-light), var(--chat-gold));
	color: #14151a;
}

.chat-plan-card {
	margin-top: 12px;
	padding: 14px;
	border: 1px solid rgba(216, 185, 111, 0.3);
	border-radius: 15px;
	background: rgba(216, 185, 111, 0.075);
}

.chat-plan-card small {
	display: block;
	color: var(--chat-muted);
	font-size: 11px;
}

.chat-plan-card b {
	display: block;
	margin: 5px 0;
	color: #fff;
	font-family: var(--chat-serif);
	font-size: 26px;
	font-weight: 600;
}

.chat-plan-card span {
	color: var(--chat-gold-light);
	font-size: 13px;
	line-height: 1.7;
}

/* よくある質問 */
.chat-quick {
	padding: 0 18px 15px;
}

.chat-quick > p {
	margin: 0 0 8px;
	color: var(--chat-muted);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.1em;
}

.chat-chip-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	overflow: visible;
	padding-bottom: 12px;
	/*scrollbar-width: none;*/
}

.chat-chip-row::-webkit-scrollbar {
	display: none;
}

.chat-chip {
	flex: 0 0 auto;
	min-height: 40px;
	padding: 9px 13px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.045);
	color: #e0e6ef;
	font-family: var(--chat-sans);
	font-size: 12px;
	font-weight: 650;
	white-space: nowrap;
	cursor: pointer;
}

.chat-chip:hover,
.chat-chip:focus-visible {
	border-color: rgba(216, 185, 111, 0.55);
	background: rgba(216, 185, 111, 0.1);
	color: #fff;
}

.chat-chip:disabled {
	opacity: 0.42;
	cursor: not-allowed;
}

/* 入力欄 */
.chat-composer {
	padding: 14px 18px 17px;
	border-top: 1px solid rgba(216, 185, 111, 0.18);
	background: rgba(2, 7, 17, 0.82);
}

.chat-input-wrap {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 9px;
	align-items: end;
	padding: 7px 7px 7px 14px;
	border: 1px solid rgba(216, 185, 111, 0.34);
	border-radius: 17px;
	background: #030a16;
}

.chat-input-wrap:focus-within {
	border-color: rgba(244, 220, 161, 0.78);
	box-shadow: 0 0 0 3px rgba(216, 185, 111, 0.09);
}

#chat-input {
	width: 100%;
	min-height: 46px;
	max-height: 140px;
	padding: 10px 0;
	border: 0;
	outline: 0;
	resize: none;
	background: transparent;
	color: #fff;
	font-family: var(--chat-sans);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.7;
}

#chat-input::placeholder {
	color: #8898ae;
	opacity: 1;
}

#chat-input:disabled {
	color: #a6b2c3;
}

#chat-send {
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 13px;
	background: linear-gradient(135deg, var(--chat-gold-light), var(--chat-gold));
	color: #111722;
	font-size: 20px;
	font-weight: 900;
	cursor: pointer;
	box-shadow: 0 10px 24px rgba(216, 185, 111, 0.16);
}

#chat-send:disabled {
	opacity: 0.42;
	cursor: not-allowed;
	box-shadow: none;
}

.chat-meta {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 9px;
	color: #9dadc1;
	font-size: 10.5px;
	line-height: 1.55;
}

.chat-meta span:last-child {
	color: var(--chat-gold-light);
	font-weight: 700;
}

.chat-error {
	border-color: rgba(241, 179, 166, 0.3);
	background: rgba(241, 179, 166, 0.08);
	color: #ffd6cd;
}

@keyframes chat-message-in {
	from { opacity: 0; transform: translateY(7px); }
	to { opacity: 1; transform: none; }
}

@media (max-width: 768px) {
	.chat-app {
		min-height: 700px;
	}

	.chat-header {
		padding: 13px 14px;
	}

	.chat-title strong {
		font-size: 17px;
	}

	.chat-status {
		display: none;
	}

	.chat-messages {
		padding: 19px 12px 12px;
	}

	.chat-message-main {
		max-width: 94%;
	}

	.chat-bubble {
		font-size: 15px;
	}

	.chat-quick,
	.chat-composer {
		padding-inline: 12px;
	}
}

@media (max-width: 480px) {
	.chat-header {
		gap: 9px;
	}

	.chat-mark {
		width: 40px;
		height: 40px;
		font-size: 19px;
	}

	.chat-title strong {
		font-size: 15px;
	}

	.chat-title span {
		display: none;
	}

	.chat-turn-badge {
		padding-inline: 8px;
		font-size: 10px;
	}

	.chat-reset {
		width: 35px;
		height: 35px;
	}

	.chat-bubble {
		padding: 14px;
		font-size: 14.5px;
		line-height: 1.86;
	}

	.chat-action,
	.chat-chip {
		font-size: 11.5px;
	}

	.chat-meta {
		display: block;
		font-size: 10px;
	}

	.chat-meta span:last-child {
		display: block;
		margin-top: 4px;
	}
}

/* 横幅制御：300pxまで意図しない横スクロールを発生させない */
.chat-app,
.chat-header,
.chat-messages,
.chat-quick,
.chat-composer,
.chat-input-wrap,
.chat-message,
.chat-message-main,
#chat-input {
	min-width: 0;
}

.chat-app,
.chat-header,
.chat-messages,
.chat-quick,
.chat-composer {
	width: 100%;
	max-width: 100%;
}

.chat-title strong {
	overflow: hidden;
	text-overflow: ellipsis;
}

/* V10：PCではFAQを折り返して全項目表示。スマートフォンは横スクロールを維持。 */
@media (max-width: 767px) {
	.chat-chip-row {
		flex-wrap: nowrap;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
	}

	.chat-chip {
		scroll-snap-align: start;
	}
}
