/**
 * 🔮 AttuneTech™ Unified MagiTech Core Engine Styles
 *
 * Scoped styling for the Attunement Sigil, Pantheon Matrix, and Persona Injection Terminal.
 */

:root {
	--nx-attune-primary: oklch(89.031% 0.1739 171.301);
	--nx-attune-secondary: oklch(0.789 0.154 211.53);
	--nx-attune-glow: oklch(89.031% 0.1739 171.301 / 0.4);
	--nx-attune-surface: rgba(15, 23, 42, 0.85);
	--nx-attune-border: rgba(255, 255, 255, 0.12);
	--nx-attune-text: #f8fafc;
	--nx-attune-muted: #94a3b8;
}

/* 1. Root Container */
.nx-attunetech-container {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 999999;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.4;
	pointer-events: none;
	color-scheme: dark;
}

/* 2. Attunement Sigil (Trigger Beacon) */
.nx-attune-sigil {
	position: fixed;
	bottom: 35px;
	right: 65px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--nx-attune-surface);
	border: 2px solid var(--nx-attune-primary);
	box-shadow: 0 0 20px var(--nx-attune-glow), 0 8px 32px rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	pointer-events: auto;
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease;
	user-select: none;
}

.nx-attune-sigil:hover {
	transform: scale(1.08);
	box-shadow: 0 0 30px var(--nx-attune-glow), 0 12px 40px rgba(0, 0, 0, 0.8);
}

.nx-sigil-glow-ring {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 1.5px dashed var(--nx-attune-primary);
	opacity: 0.6;
	animation: nx-spin-slow 20s linear infinite;
	pointer-events: none;
}

@keyframes nx-spin-slow {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

.nx-sigil-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	line-height: 1;
}

.nx-sigil-beacon-badge {
	position: absolute;
	top: -6px;
	right: -4px;
	background: var(--nx-attune-primary);
	color: #fff;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
	font-size: 9px;
	font-weight: 800;
	letter-spacing: 0.05em;
	padding: 2px 5px;
	border-radius: 6px;
	text-transform: uppercase;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Quick Action Buttons surrounding Sigil (with seamless hover bridge) */
.nx-sigil-quick-actions {
	position: absolute;
	bottom: 56px;
	left: 0;
	right: 0;
	padding-bottom: 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	opacity: 0;
	transform: translateY(10px) scale(0.9);
	pointer-events: none;
	transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Invisible hover bridge connecting trigger directly to buttons */
.nx-sigil-quick-actions::after {
	content: '';
	position: absolute;
	top: -12px;
	left: -20px;
	right: -20px;
	bottom: -28px;
	z-index: -1;
	pointer-events: auto;
}

.nx-attune-sigil:hover .nx-sigil-quick-actions,
.nx-attune-sigil:focus-within .nx-sigil-quick-actions,
.nx-sigil-quick-actions:hover {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.nx-sigil-btn {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.95);
	border: 1.5px solid var(--nx-attune-primary);
	color: var(--nx-attune-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 10px var(--nx-attune-glow);
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	padding: 0;
}

.nx-sigil-btn:hover {
	background: var(--nx-attune-primary);
	color: #000;
	transform: scale(1.15);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8), 0 0 20px var(--nx-attune-glow);
}

/* 3. The Pantheon Matrix (Tactical Modal) */
.nx-matrix-overlay {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	pointer-events: auto;
}

.nx-matrix-overlay[hidden] {
	display: none !important;
}

.nx-matrix-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(4, 7, 15, 0.85);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	animation: nx-fade-in 0.2s ease-out;
}

.nx-matrix-dialog {
	position: relative;
	width: 100%;
	max-width: 960px;
	max-height: 90vh;
	background: rgba(15, 23, 42, 0.92);
	border: 1px solid var(--nx-attune-border);
	border-radius: 16px;
	box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 40px var(--nx-attune-glow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	animation: nx-zoom-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nx-fade-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes nx-zoom-in {
	from {
		transform: scale(0.94);
		opacity: 0;
	}

	to {
		transform: scale(1);
		opacity: 1;
	}
}

.nx-matrix-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--nx-attune-border);
	background: rgba(15, 23, 42, 0.6);
}

.nx-matrix-title-wrap {
	display: flex;
	align-items: center;
	gap: 14px;
}

.nx-matrix-icon {
	font-size: 32px;
	line-height: 1;
}

.nx-matrix-title {
	margin: 0;
	font-size: 20px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: #fff;
	text-transform: uppercase;
}

.nx-matrix-subtitle {
	margin: 2px 0 0 0;
	font-size: 12px;
	color: var(--nx-attune-muted);
}

.nx-matrix-close {
	background: transparent;
	border: none;
	color: var(--nx-attune-muted);
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 8px;
	transition: color 0.15s ease, background 0.15s ease;
}

.nx-matrix-close:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.1);
}

.nx-matrix-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 16px;
	padding: 24px;
	overflow-y: auto;
}

.nx-matrix-card {
	background: rgba(30, 41, 59, 0.5);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 12px;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	cursor: pointer;
	position: relative;
}

.nx-matrix-card:hover,
.nx-matrix-card.nx-card-active {
	background: rgba(30, 41, 59, 0.85);
	border-color: var(--nx-attune-primary);
	transform: translateY(-2px);
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px var(--nx-attune-glow);
}

.nx-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.nx-card-avatar {
	font-size: 24px;
	line-height: 1;
}

.nx-card-badge {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	padding: 2px 8px;
	border-radius: 9999px;
	background: rgba(255, 255, 255, 0.08);
	color: #cbd5e1;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.nx-card-swatch {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	display: inline-block;
}

.nx-card-name {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: #fff;
}

.nx-card-class {
	font-size: 11px;
	color: var(--nx-attune-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.nx-card-quote {
	margin: 0;
	font-size: 12px;
	color: #94a3b8;
	font-style: italic;
	line-height: 1.5;
	flex-grow: 1;
}

.nx-card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: 10px;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nx-card-alignment {
	font-size: 10px;
	color: #64748b;
	text-transform: uppercase;
}

.nx-attune-action-btn {
	background: transparent;
	border: 1px solid var(--nx-attune-primary);
	color: var(--nx-attune-primary);
	font-size: 11px;
	font-weight: 700;
	padding: 5px 12px;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.15s ease;
}

.nx-matrix-card:hover .nx-attune-action-btn,
.nx-matrix-card.nx-card-active .nx-attune-action-btn {
	background: var(--nx-attune-primary);
	color: #000;
}

.nx-matrix-footer {
	padding: 14px 24px;
	background: rgba(15, 23, 42, 0.8);
	border-top: 1px solid var(--nx-attune-border);
	text-align: center;
}

.nx-matrix-status-text {
	margin: 0;
	font-size: 12px;
	color: #64748b;
}

/* 4. Persona Injection Terminal (Slide-Out Drawer) */
.nx-terminal-drawer {
	position: fixed;
	bottom: 90px;
	right: 24px;
	width: 360px;
	max-width: calc(100vw - 48px);
	background: rgba(15, 23, 42, 0.96) !important;
	color: #f1f5f9 !important;
	border: 1px solid var(--nx-attune-primary);
	border-radius: 12px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px var(--nx-attune-glow);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	pointer-events: auto;
	color-scheme: dark;
	animation: nx-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.nx-terminal-drawer[hidden] {
	display: none !important;
}

@keyframes nx-slide-up {
	from {
		transform: translateY(20px);
		opacity: 0;
	}

	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.nx-terminal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	background: rgba(30, 41, 59, 0.7);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nx-terminal-op-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.nx-term-avatar {
	font-size: 20px;
	line-height: 1;
}

.nx-term-name {
	font-weight: 700;
	font-size: 13px;
	color: #ffffff !important;
}

.nx-term-status {
	font-size: 9px;
	color: var(--nx-attune-primary) !important;
	letter-spacing: 0.05em;
	font-family: monospace;
}

.nx-term-controls {
	display: flex;
	align-items: center;
	gap: 6px;
}

.nx-term-btn {
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.12);
	color: #f1f5f9 !important;
	font-size: 11px;
	font-weight: 600;
	padding: 4px 8px;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.15s ease;
}

.nx-term-btn:hover {
	background: var(--nx-attune-primary);
	color: #000 !important;
	border-color: var(--nx-attune-primary);
}

.nx-term-close {
	background: transparent;
	border: none;
	color: #94a3b8 !important;
	font-size: 16px;
	cursor: pointer;
	padding: 2px 6px;
	border-radius: 4px;
}

.nx-term-close:hover {
	color: #ffffff !important;
	background: rgba(255, 255, 255, 0.1);
}

.nx-terminal-body {
	padding: 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 240px;
	overflow-y: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
	font-size: 12px;
	line-height: 1.5;
	color: #f1f5f9 !important;
	background: rgba(10, 15, 30, 0.4);
}

.nx-terminal-body * {
	color: #f1f5f9;
}

.nx-term-entry {
	line-height: 1.45;
	color: #f1f5f9 !important;
}

.nx-term-text {
	color: #f1f5f9 !important;
}

.nx-term-system {
	color: #94a3b8 !important;
	font-size: 11px;
}

.nx-term-tag {
	color: var(--nx-attune-primary) !important;
	font-weight: 700;
}

.nx-term-voice {
	color: #f8fafc !important;
	padding: 8px 10px;
	background: rgba(255, 255, 255, 0.06);
	border-left: 2px solid var(--nx-attune-primary);
	border-radius: 0 6px 6px 0;
}

.nx-term-voice * {
	color: #f8fafc !important;
}

.nx-term-speaker {
	display: block;
	font-weight: 700;
	color: var(--nx-attune-primary) !important;
	margin-bottom: 2px;
	font-size: 11px;
}

.nx-terminal-footer {
	padding: 8px 14px;
	background: rgba(15, 23, 42, 0.85);
	border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nx-dice-result-tray {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 10px;
	background: rgba(0, 0, 0, 0.5);
	border-radius: 8px;
	border: 1px solid var(--nx-attune-border);
}

.nx-dice-result-tray[hidden] {
	display: none !important;
}

.nx-dice-die {
	font-size: 16px;
	font-weight: 900;
	color: #fff !important;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
	background: var(--nx-attune-primary);
	padding: 2px 8px;
	border-radius: 6px;
	box-shadow: 0 0 10px var(--nx-attune-glow);
}

.nx-dice-commentary {
	font-size: 11px;
	color: #e2e8f0 !important;
	line-height: 1.35;
	font-style: italic;
}