/* AK Campus 动画专区：算法演示 */

/* ---------- 算法切换 ---------- */
.an-tabs {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin: 0 0 16px;
}
.an-tab {
	display: flex;
	align-items: center;
	gap: 9px;
	text-align: left;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 10px 12px;
	cursor: pointer;
	transition: .15s;
	font-family: inherit;
}
.an-tab:hover {
	border-color: #99f6e4;
	background: #f8fdfc;
}
.an-tab.is-on {
	border-color: #0f766e;
	background: #f0fdfa;
	box-shadow: 0 0 0 1px #0f766e inset;
}
.an-tab-ico {
	font-size: 19px;
	line-height: 1;
}
.an-tab-tx {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.an-tab-tx strong {
	font-size: 13.5px;
	color: #0f172a;
	line-height: 1.4;
}
.an-tab-tx em {
	font-style: normal;
	font-size: 11.5px;
	color: #94a3b8;
	line-height: 1.45;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.an-tab.is-on .an-tab-tx strong {
	color: #0f766e;
}

/* ---------- 主面板 ---------- */
.an-board {
	display: grid;
	grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
	gap: 14px;
	align-items: start;
}
.an-main,
.an-side {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	padding: 14px 16px 15px;
	min-width: 0;
}
.an-stage-hd {
	display: flex;
	align-items: baseline;
	gap: 10px;
	flex-wrap: wrap;
	margin-bottom: 4px;
}
.an-stage-hd h2 {
	margin: 0;
	font-size: 17px;
	color: #0f172a;
	line-height: 1.5;
}
.an-stage-sub {
	font-size: 12.5px;
	color: #94a3b8;
}

/* 舞台：柱子 / 格子都在这里绝对定位 */
.an-stage {
	position: relative;
	height: 268px;
	margin: 6px 0 0;
	padding-bottom: 26px;
	box-sizing: border-box;
}
.an-stage::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 26px;
	height: 2px;
	background: #e2e8f0;
	border-radius: 2px;
}

/* ---------- 柱状图（排序） ---------- */
.an-bar {
	position: absolute;
	bottom: 26px;
	height: calc(100% - 26px);
	display: flex;
	align-items: flex-end;
	justify-content: center;
	transition: left .3s cubic-bezier(.4, 0, .2, 1), width .2s;
	will-change: left, transform;
}
.an-bar-body {
	width: calc(100% - 8px);
	border-radius: 7px 7px 3px 3px;
	background: linear-gradient(180deg, #a5b4fc 0%, #818cf8 100%);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 4px;
	box-sizing: border-box;
	transition: background .2s, height .25s, transform .2s, box-shadow .2s;
	position: relative;
}
.an-bar-v {
	color: #fff;
	font-size: 12.5px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	text-shadow: 0 1px 1px rgba(15, 23, 42, .18);
}
.an-bar-i {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -22px;
	text-align: center;
	font-size: 11px;
	color: #94a3b8;
	font-variant-numeric: tabular-nums;
}

/* 状态色 */
.an-bar.is-cmp .an-bar-body {
	background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
	box-shadow: 0 0 0 2px #fde68a;
}
.an-bar.is-swap .an-bar-body {
	background: linear-gradient(180deg, #fb7185 0%, #e11d48 100%);
	transform: translateY(-10px);
	box-shadow: 0 8px 16px rgba(225, 29, 72, .22);
}
.an-bar.is-ok .an-bar-body {
	background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}
.an-bar.is-pivot .an-bar-body {
	background: linear-gradient(180deg, #c4b5fd 0%, #7c3aed 100%);
}
.an-bar.is-key .an-bar-body {
	background: linear-gradient(180deg, #67e8f9 0%, #0891b2 100%);
	box-shadow: 0 0 0 2px #a5f3fc;
}

/* ---------- 格子（二分查找） ---------- */
.an-stage.is-cells {
	height: 236px;
	padding-bottom: 0;
}
.an-stage.is-cells::after {
	display: none;
}
.an-cells {
	position: absolute;
	inset: 0 0 26px 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}
.an-stage.is-cells .an-cells {
	inset: 0;
	align-items: stretch;
	padding: 14px 0 6px;
}
.an-cell {
	flex: 1 1 0;
	max-width: 78px;
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	border-radius: 10px;
	border: 2px solid #e2e8f0;
	background: #f8fafc;
	padding: 14px 4px 10px;
	text-align: center;
	transition: .22s;
}
.an-cell-v {
	display: block;
	font-size: 19px;
	font-weight: 700;
	color: #1e293b;
	font-variant-numeric: tabular-nums;
	line-height: 1.35;
}
.an-cell-i {
	display: block;
	font-size: 10.5px;
	color: #94a3b8;
	font-variant-numeric: tabular-nums;
}
.an-cell-tag {
	position: absolute;
	top: -9px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 10px;
	font-weight: 700;
	line-height: 1.6;
	padding: 0 5px;
	border-radius: 5px;
	background: #0f766e;
	color: #fff;
	white-space: nowrap;
}
.an-cell.is-out {
	border-color: #eef2f7;
	border-style: dashed;
	background: #fff;
}
.an-cell.is-out .an-cell-v {
	color: #b9c3d0;
}
.an-cell.is-out .an-cell-i {
	color: #dbe2ea;
}
.an-cell.is-cmp {
	border-color: #f59e0b;
	background: #fffbeb;
	transform: translateY(-4px);
}
.an-cell.is-cmp .an-cell-v {
	color: #b45309;
}
.an-cell.is-mid {
	border-color: #0f766e;
	background: #f0fdfa;
	transform: translateY(-4px);
	box-shadow: 0 6px 14px rgba(15, 118, 110, .14);
}
.an-cell.is-found {
	border-color: #059669;
	background: #ecfdf5;
	transform: translateY(-6px) scale(1.04);
	box-shadow: 0 8px 18px rgba(5, 150, 105, .2);
}

/* ---------- 序列格（切片 / 字符串 / 列表） ---------- */
.an-stage.is-seq {
	height: auto;
	min-height: 124px;
	padding: 4px 0 0;
}
.an-stage.is-seq::after {
	display: none;
}
.an-cells.is-seq {
	position: static;
	inset: auto;
	flex-wrap: wrap;
	align-items: stretch;
	justify-content: center;
	gap: 7px;
	padding: 22px 0 2px;
}
.an-cells.is-seq .an-cell {
	flex: 0 0 auto;
	min-width: 38px;
	max-width: 76px;
	padding: 9px 5px 6px;
}
/* 字符格子：等分收缩，永远排成一行 */
.an-cells.is-seq.is-str .an-cell {
	flex: 1 1 0;
	min-width: 0;
}
.an-cells.is-list .an-cell {
	min-width: 48px;
}
.an-cells.is-str .an-cell-v {
	font-size: 17px;
}
.an-cells.is-seq.is-wide .an-cell {
	flex: 0 0 auto;
	min-width: 62px;
	max-width: 132px;
}
.an-cell-neg {
	display: none;
	font-size: 10px;
	color: #cbd5e1;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	white-space: nowrap;
}
.an-cell-v {
	white-space: nowrap;
}
.an-cells.is-neg .an-cell-neg {
	display: block;
}
.an-cell.is-space .an-cell-v {
	color: #94a3b8;
}
.an-cell.is-new {
	animation: anPop .36s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes anPop {
	0% { transform: scale(.55); opacity: 0; }
	100% { transform: scale(1); opacity: 1; }
}

/* 结果框 */
.an-out {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 4px;
	padding: 8px 12px;
	border-radius: 10px;
	background: #0f172a;
	font-size: 13px;
}
.an-out[hidden] {
	display: none !important;
}
.an-out-lb {
	flex: none;
	font-size: 11.5px;
	color: #94a3b8;
	letter-spacing: .04em;
}
.an-out-v {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-width: 0;
}
.an-out-item {
	font-family: Consolas, "SFMono-Regular", Menlo, monospace;
	font-size: 13px;
	line-height: 1.6;
	color: #a7f3d0;
	background: rgba(255, 255, 255, .08);
	border-radius: 6px;
	padding: 1px 8px;
	word-break: break-all;
}
.an-out-item.is-one {
	color: #fde68a;
}
.an-chip[hidden] {
	display: none !important;
}
.an-legend span[hidden] {
	display: none !important;
}

/* ---------- 解说 / 控制 ---------- */
.an-narr {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	min-height: 42px;
	margin: 12px 0 10px;
	padding: 9px 12px;
	border-radius: 10px;
	background: #f8fafc;
	border: 1px solid #eef2f7;
	font-size: 13.5px;
	line-height: 1.65;
	color: #334155;
}
.an-narr-dot {
	flex: none;
	width: 7px;
	height: 7px;
	margin-top: 7px;
	border-radius: 50%;
	background: #cbd5e1;
}
.an-narr.is-live .an-narr-dot {
	background: #0f766e;
	box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
}
.an-narr.is-done {
	background: #f0fdf4;
	border-color: #bbf7d0;
	color: #14532d;
}
.an-narr.is-done .an-narr-dot {
	background: #059669;
}
.an-narr b {
	color: #0f766e;
}
.an-narr.is-done b {
	color: #047857;
}

.an-ctrl {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}
.an-btn {
	font-family: inherit;
	font-size: 13px;
	line-height: 1.4;
	padding: 7px 13px;
	border-radius: 9px;
	border: 1px solid #d1d5db;
	background: #fff;
	color: #334155;
	cursor: pointer;
	transition: .15s;
	white-space: nowrap;
}
.an-btn:hover:not(:disabled) {
	border-color: #94a3b8;
	background: #f8fafc;
}
.an-btn.is-primary {
	background: #0f766e;
	border-color: #0f766e;
	color: #fff;
	font-weight: 600;
	min-width: 86px;
}
.an-btn.is-primary:hover {
	background: #115e59;
}
.an-btn:disabled {
	opacity: .45;
	cursor: not-allowed;
}
.an-speed {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin-left: auto;
	font-size: 12.5px;
	color: #64748b;
}
.an-speed input {
	width: 92px;
	accent-color: #0f766e;
}

.an-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 11px;
}
.an-chip {
	background: #f8fafc;
	border: 1px solid #eef2f7;
	border-radius: 8px;
	padding: 3px 10px;
	font-size: 12px;
	color: #64748b;
	font-variant-numeric: tabular-nums;
}
.an-chip b {
	color: #0f766e;
	font-size: 13px;
}
.an-chip.is-grow {
	flex: 1 1 120px;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.an-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px dashed #eef2f7;
}
.an-btn.ghost {
	background: #f8fafc;
	font-size: 12.5px;
	padding: 6px 11px;
}
.an-custom {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	color: #64748b;
}
.an-custom input {
	width: 150px;
	padding: 5px 9px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 12.5px;
	font-family: inherit;
	color: #334155;
	background: #fff;
}
.an-custom input:focus {
	outline: 2px solid #99f6e4;
	border-color: #0f766e;
}
.an-tip {
	font-size: 12px;
	color: #b45309;
	min-height: 1em;
}
.an-tip.is-on {
	color: #b45309;
}

/* ---------- 代码面板 ---------- */
.an-code-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid #eef2f7;
	margin-bottom: 8px;
}
.an-code-hd span {
	font-size: 12.5px;
	font-weight: 700;
	color: #334155;
	letter-spacing: .02em;
}
.an-code-hd em {
	font-style: normal;
	font-size: 11.5px;
	color: #0f766e;
	font-variant-numeric: tabular-nums;
}
.an-code {
	margin: 0;
	padding: 0;
	background: #0f172a;
	border-radius: 10px;
	overflow: auto;
	max-height: 300px;
	font-family: Consolas, "SFMono-Regular", Menlo, monospace;
	font-size: 12.5px;
	line-height: 1.85;
	counter-reset: anln;
}
.an-code .an-ln {
	display: block;
	padding: 0 12px 0 0;
	white-space: pre;
	color: #cbd5e1;
	border-left: 3px solid transparent;
}
.an-code .an-ln::before {
	counter-increment: anln;
	content: counter(anln);
	display: inline-block;
	width: 26px;
	margin-right: 10px;
	text-align: right;
	color: #475569;
	font-size: 11px;
	user-select: none;
}
.an-code .an-ln.is-on {
	background: rgba(45, 212, 191, .16);
	border-left-color: #2dd4bf;
	color: #f0fdfa;
}
.an-code .an-ln.is-on::before {
	color: #5eead4;
}
.an-code .an-ln .cm {
	color: #64748b;
}

.an-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 9px;
	font-size: 11.5px;
	color: #64748b;
}
.an-legend span {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}
.an-legend i {
	width: 11px;
	height: 11px;
	border-radius: 4px;
	display: inline-block;
}
.an-legend i.is-cmp {
	background: #f59e0b;
}
.an-legend i.is-swap {
	background: #e11d48;
}
.an-legend i.is-ok {
	background: #059669;
}

/* ---------- 讲解 ---------- */
.an-learn {
	margin: 14px 0 4px;
	padding: 16px 18px;
	border-radius: 14px;
	background: linear-gradient(135deg, #f0fdfa 0%, #eef2ff 100%);
	border: 1px solid #e2e8f0;
}
.an-learn-hd h2 {
	margin: 0 0 4px;
	font-size: 15px;
	color: #0f172a;
}
.an-learn-hd p {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.75;
	color: #334155;
}
.an-learn-line {
	margin: 10px 0 0;
	font-size: 12px;
	color: #0f766e;
	font-weight: 600;
}

.an-tb td {
	font-size: 13px;
}

/* ---------- 手机 ---------- */
@media (max-width: 900px) {
	.an-board {
		grid-template-columns: minmax(0, 1fr);
	}
	.an-code {
		max-height: 240px;
	}
}
@media (max-width: 640px) {
	.an-tabs {
		grid-template-columns: repeat(2, 1fr);
		gap: 8px;
	}
	.an-tab {
		padding: 8px 10px;
	}
	.an-tab-tx em {
		display: none;
	}
	.an-main,
	.an-side {
		padding: 12px 12px 13px;
	}
	.an-stage {
		height: 220px;
	}
	.an-bar-v {
		font-size: 11px;
	}
	.an-cell {
		padding: 12px 2px 8px;
	}
	.an-cell-v {
		font-size: 14px;
	}
	.an-cells.is-seq {
		gap: 2px;
		padding: 20px 0 2px;
	}
	.an-cells.is-seq .an-cell {
		padding: 6px 0 4px;
	}
	.an-cells.is-seq.is-str .an-cell {
		flex: 1 1 20px;
		min-width: 20px;
		max-width: 44px;
	}
	.an-cells.is-str .an-cell-v {
		font-size: 13px;
	}
	.an-cell-i,
	.an-cell-neg {
		font-size: 9px;
	}
	.an-cells.is-list .an-cell {
		min-width: 42px;
	}
	.an-cell-neg {
		font-size: 9px;
	}
	.an-out {
		padding: 7px 10px;
		gap: 7px;
	}
	.an-out-item {
		font-size: 12px;
	}
	.an-ctrl {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 7px;
	}
	.an-btn {
		font-size: 12.5px;
		padding: 8px 10px;
		width: 100%;
	}
	.an-speed {
		grid-column: 1 / -1;
		width: 100%;
		margin-left: 0;
		justify-content: flex-end;
	}
	.an-custom {
		width: 100%;
	}
	.an-custom input {
		flex: 1;
		width: auto;
	}
	.an-stage-sub {
		display: none;
	}
	.an-code {
		font-size: 11.5px;
	}
}
