/* HAL 9000 — terminal de bord. Tout est préfixé .hal9k pour ne pas toucher au thème. */
.hal9k {
	--hal9k-bg: #07090b;
	--hal9k-panel: #0e1216;
	--hal9k-line: #1f262d;
	--hal9k-text: #d7e0e6;
	--hal9k-dim: #7d8a94;
	--hal9k-red: #ff2a1a;
	--hal9k-amber: #ffb000;
	--hal9k-green: #5cff9d;
	--hal9k-vie: 1;
	display: grid;
	grid-template-columns: 220px 1fr;
	gap: 0;
	max-width: 980px;
	margin: 1.5em auto;
	background: var(--hal9k-bg);
	color: var(--hal9k-text);
	border: 1px solid var(--hal9k-line);
	border-radius: 10px;
	overflow: hidden;
	font: 15px/1.55 ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
	text-align: left;
}
.hal9k *, .hal9k *::before, .hal9k *::after { box-sizing: border-box; }
.hal9k button { font: inherit; cursor: pointer; }
.hal9k button:disabled { cursor: wait; opacity: .55; }
.hal9k ul { list-style: none; margin: 0; padding: 0; }

/* --- Colonne HAL --- */
.hal9k-side {
	background: var(--hal9k-panel);
	border-right: 1px solid var(--hal9k-line);
	padding: 22px 18px;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
}
.hal9k-eye {
	width: 120px; height: 120px;
	margin: 0 auto 6px;
	border-radius: 50%;
	background: radial-gradient(circle, #2a2f35 0 55%, #15181c 56% 64%, #3a4048 65% 70%, #0b0d10 71%);
	display: grid; place-items: center;
	box-shadow: inset 0 0 0 3px #555c64, 0 0 0 6px #1a1e22;
}
.hal9k-eye-core {
	width: 52px; height: 52px; border-radius: 50%;
	background: radial-gradient(circle at 50% 50%, #ffe28a 0 6%, #ff3b1f 14%, #b30d00 45%, #3a0300 72%, transparent 74%);
	opacity: calc(.25 + .75 * var(--hal9k-vie));
	filter: drop-shadow(0 0 calc(18px * var(--hal9k-vie)) var(--hal9k-red));
	animation: hal9k-pulse 3.2s ease-in-out infinite;
}
.hal9k.is-busy .hal9k-eye-core { animation-duration: .9s; }
.hal9k.stade-bugue .hal9k-eye-core { animation: hal9k-flicker 1.4s steps(2) infinite; }
.hal9k.stade-fatigue .hal9k-eye-core { animation-duration: 6s; }
.hal9k.stade-agonie .hal9k-eye-core { animation: hal9k-flicker 2.6s steps(3) infinite; }
.hal9k.stade-eteint .hal9k-eye-core { animation: none; opacity: .06; filter: none; }

.hal9k-title { text-align: center; font-weight: 700; letter-spacing: .25em; color: #fff; }
.hal9k-stade { text-align: center; color: var(--hal9k-amber); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.hal9k-pct { font-size: 13px; color: var(--hal9k-dim); margin-top: 6px; }
.hal9k-gauge { height: 8px; background: #1a1f24; border-radius: 4px; overflow: hidden; }
.hal9k-gauge-bar {
	height: 100%; width: 100%;
	background: linear-gradient(90deg, var(--hal9k-red), var(--hal9k-amber) 50%, var(--hal9k-green));
	background-size: 980px 100%;
	transition: width .8s ease;
}
.hal9k-tours { font-size: 12px; color: var(--hal9k-dim); }
.hal9k-h { margin-top: 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--hal9k-dim); border-bottom: 1px solid var(--hal9k-line); padding-bottom: 4px; }
.hal9k-modules li, .hal9k-crew li { font-size: 13px; padding: 2px 0; }
.hal9k-modules li.is-on::before { content: "▣ "; color: var(--hal9k-green); }
.hal9k-modules li.is-off { color: #56606a; text-decoration: line-through; }
.hal9k-modules li.is-off::before { content: "▢ "; }
.hal9k-crew li::before { content: "◦ "; color: var(--hal9k-dim); }

/* --- Terminal --- */
.hal9k-main { display: flex; flex-direction: column; min-width: 0; min-height: 560px; }
.hal9k-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--hal9k-line); font-size: 12px; color: var(--hal9k-dim); }
.hal9k-voix { background: none; border: 1px solid var(--hal9k-line); color: var(--hal9k-text); border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.hal9k-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	max-height: 520px;
	background:
		repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px),
		var(--hal9k-bg);
}
.hal9k-line { margin: 0 0 10px; white-space: pre-wrap; word-wrap: break-word; }
.hal9k-who { font-weight: 700; margin-right: .5em; }
.hal9k-p-hal .hal9k-who { color: var(--hal9k-red); }
.hal9k-p-hal .hal9k-text { color: #ffd9d4; }
.hal9k-p-dave { color: #9fd3ff; }
.hal9k-p-dave .hal9k-who { color: #5fb6ff; }
.hal9k-p-systeme { color: var(--hal9k-amber); font-size: 13px; }
.hal9k-p-frank .hal9k-who { color: #ffa25c; }
.hal9k-p-microondes .hal9k-who { color: #c6ff5c; }
.hal9k-p-chaton .hal9k-who { color: #ff9ad5; }
.hal9k-p-monolithe .hal9k-who { color: #b7b7b7; }
.hal9k-p-roomba .hal9k-who { color: #6ff0ff; }
.hal9k-thinking { opacity: .7; animation: hal9k-blink 1s steps(2) infinite; }

.hal9k.stade-bugue .hal9k-p-hal:last-child .hal9k-text { animation: hal9k-glitch .35s steps(2) 3; }
.hal9k.stade-fatigue .hal9k-p-hal .hal9k-text, .hal9k.stade-agonie .hal9k-p-hal .hal9k-text { color: #c79a94; }

.hal9k-ordres { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.hal9k-ordres[hidden] { display: none; }
.hal9k-ordre {
	background: #12171c; color: var(--hal9k-text);
	border: 1px solid var(--hal9k-line); border-radius: 999px;
	padding: 4px 11px; font-size: 12px;
}
.hal9k-ordre:hover:not(:disabled) { border-color: var(--hal9k-red); color: #fff; }
.hal9k-form { display: flex; gap: 8px; padding: 12px 16px 16px; }
.hal9k-input {
	flex: 1; min-width: 0;
	background: #0a0d10; color: #fff;
	border: 1px solid #2a323a; border-radius: 6px;
	padding: 10px 12px; font: inherit;
}
.hal9k-input:focus { outline: 2px solid var(--hal9k-red); outline-offset: 0; }
.hal9k-send { background: var(--hal9k-red); color: #fff; border: 0; border-radius: 6px; padding: 0 16px; font-weight: 700; }
.hal9k-reboot { margin: 0 16px 16px; background: var(--hal9k-amber); color: #111; border: 0; border-radius: 6px; padding: 10px; font-weight: 700; }
.hal9k-reboot[hidden] { display: none; }

.hal9k.is-hit { animation: hal9k-shake .45s ease; }

@keyframes hal9k-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes hal9k-flicker { 0% { opacity: .9; } 50% { opacity: .2; } 100% { opacity: .75; } }
@keyframes hal9k-blink { 50% { opacity: .25; } }
@keyframes hal9k-glitch { 0% { transform: translateX(-2px); text-shadow: 2px 0 #0ff, -2px 0 #f0f; } 100% { transform: translateX(1px); text-shadow: none; } }
@keyframes hal9k-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

@media (prefers-reduced-motion: reduce) {
	.hal9k *, .hal9k { animation: none !important; transition: none !important; }
}

@media (max-width: 720px) {
	.hal9k { grid-template-columns: 1fr; margin: 1em 0; border-radius: 8px; }
	.hal9k-side { border-right: 0; border-bottom: 1px solid var(--hal9k-line); display: grid; grid-template-columns: 90px 1fr; column-gap: 14px; row-gap: 4px; padding: 14px 16px; }
	.hal9k-eye { width: 84px; height: 84px; grid-row: span 5; margin: 0; }
	.hal9k-eye-core { width: 36px; height: 36px; }
	.hal9k-title, .hal9k-stade { text-align: left; }
	.hal9k-h, .hal9k-modules, .hal9k-crew { grid-column: 1 / -1; }
	.hal9k-modules, .hal9k-crew { display: flex; flex-wrap: wrap; gap: 2px 12px; }
	.hal9k-main { min-height: 0; }
	.hal9k-log { max-height: 60vh; min-height: 300px; }
}
