/*
 * Linux の道（page-kb-path.php・assets/js/kb-path.js）。項目のページに出す道の札（.kpath-chip）は kb-entry.css。
 * 地下鉄の路線図: 道ごとの色（--c）の太い線、駅は丸、読んだ駅まで線に色が流れる。
 * 図鑑と同じ地（クリーム・墨の太い枠・ずらした影・DIN の数）。ルートの文字サイズは 62.5% なので px で書く。
 */

.kpath {
	--kp-ground: var(--guide-bg, #fff4e1);
	--kp-ink: #1d1813;
	--kp-text: var(--guide-text, #2b2620);
	--kp-muted: var(--guide-muted, #6f6052);
	--kp-accent: var(--guide-accent, #ff5b00);
	--kp-line: var(--guide-border, #e8e1d4);
	--kp-rail: #e3d9c6;
	--kp-surface: var(--guide-surface, #fff);
	--kp-stamp: #c0341d;
	--kp-mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, "BIZ UDGothic", "Noto Sans JP", monospace;
	--kp-num: "Din1451Alt", "Bahnschrift", "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
	--kp-out: cubic-bezier(0.2, 0.8, 0.2, 1);
	--kp-spring: cubic-bezier(0.2, 1.5, 0.4, 1);
	--c: #2f7fd1;
}
.kpath {
	display: block;
	max-width: 880px;
	margin: 0 auto;
	padding: 20px 16px 90px;
	background: var(--kp-ground);
	color: var(--kp-text);
	font: 400 16px/1.75 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
	overflow-wrap: anywhere;
}
.kpath--index {
	max-width: 1080px;
}
body:has(.kpath) {
	background: var(--guide-bg, #fff4e1);
}
.kpath *,
.kpath *::before,
.kpath *::after {
	box-sizing: border-box;
}
.kpath :where(h1, h2, p, ul, ol) {
	margin: 0;
	padding: 0;
}
.kpath :where(ul, ol) {
	list-style: none;
}
.kpath :where(h1, h2)::before,
.kpath :where(h1, h2)::after {
	content: none;
}
.kpath :where(button) {
	font: inherit;
	cursor: pointer;
}

/* ------------------------------------------------------------ 冒頭 */

.kpath-head {
	position: relative;
	margin-bottom: 26px;
	padding: 22px 22px 20px;
	border: 3px solid var(--kp-ink);
	border-radius: 20px;
	background: var(--kp-surface);
	box-shadow: 6px 6px 0 var(--c);
	overflow: hidden;
}
.kpath--index .kpath-head {
	box-shadow: 6px 6px 0 var(--kp-accent);
}
/* 路線の色の帯（駅名標の上の色） */
.kpath-head::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 8px;
	background: var(--c);
}
.kpath--index .kpath-head::before {
	background: linear-gradient(90deg, #2f7fd1 0 33.3%, #1f9e9e 0 66.6%, #c0341d 0);
}
.kpath-eyebrow {
	margin-top: 4px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--kp-muted);
}
.kpath-eyebrow a {
	color: inherit;
	text-decoration: none;
}
.kpath-eyebrow a:hover {
	color: var(--kp-accent);
}
.kpath-title {
	margin-top: 4px;
	font-size: clamp(28px, 6vw, 42px);
	font-weight: 900;
	line-height: 1.2;
	color: var(--kp-ink);
	text-wrap: balance;
}
.kpath-lead {
	margin-top: 8px;
	max-width: 36em;
}

.kpath-progress {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 10px 16px;
	align-items: center;
	margin-top: 18px;
}
.kpath-progress__bar {
	grid-column: 1 / -1;
	position: relative;
	height: 14px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background: var(--kp-rail);
	overflow: hidden;
}
.kpath-progress__bar i {
	--p: 0;
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--p) * 1%);
	border-radius: inherit;
	background:
		repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.22) 0 6px, transparent 6px 12px),
		var(--c);
	transition: width 1.1s var(--kp-out);
}
.kpath-progress__num {
	font-size: 14px;
	font-weight: 700;
	color: var(--kp-muted);
}
.kpath-progress__num b {
	font: 700 30px/1 var(--kp-num);
	font-variant-numeric: tabular-nums;
	color: var(--kp-ink);
	margin-right: 2px;
}
.kpath-progress__go,
.kpath-done__go button,
.kpath-done__go a {
	display: inline-flex;
	align-items: center;
	min-height: 46px;
	padding: 0 20px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background: var(--kp-accent);
	color: #fff;
	font-size: 15px;
	font-weight: 800;
	text-decoration: none;
	box-shadow: 3px 3px 0 var(--kp-ink);
	transition: transform 0.25s var(--kp-spring), box-shadow 0.2s;
}
.kpath-progress__go::after {
	content: "↓";
	margin-left: 8px;
	transition: transform 0.3s var(--kp-spring);
}
.kpath-progress__go:hover {
	transform: translate(-1px, -1px);
	box-shadow: 4px 4px 0 var(--kp-ink);
}
.kpath-progress__go:hover::after {
	transform: translateY(3px);
}
.kpath-progress__go:active,
.kpath-done__go :is(a, button):active {
	transform: translate(2px, 2px);
	box-shadow: 1px 1px 0 var(--kp-ink);
}

/* ------------------------------------------------------------ 路線 */

.kpath-line {
	--rail-x: 21px; /* 線の中心（駅の丸の中心） */
	position: relative;
}
.kpath-group + .kpath-group {
	margin-top: 6px;
}
.kpath-group__name {
	position: relative;
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 6px 0 10px;
	font-size: 17px;
	font-weight: 900;
	color: var(--kp-ink);
}
.kpath-group__name small {
	margin-left: auto;
	font: 700 14px/1 var(--kp-num);
	font-variant-numeric: tabular-nums;
	color: var(--kp-muted);
}
/* 乗り換え駅のような、群の番号の札 */
.kpath-group__no {
	display: grid;
	place-items: center;
	flex: none;
	width: 42px;
	height: 42px;
	border: 3px solid var(--kp-ink);
	border-radius: 12px;
	background: var(--kp-surface);
	color: var(--kp-ink);
	font: 700 20px/1 var(--kp-num);
	box-shadow: inset 0 -6px 0 var(--c);
}

.kpath-st {
	position: relative;
	display: grid;
	grid-template-columns: 42px minmax(0, 1fr);
	gap: 0 12px;
	padding-bottom: 12px;
}
/* 線の 1 区間（この駅から次の駅まで）。灰色の上に、読んだ区間だけ色が流れる */
.kpath-st::before,
.kpath-st::after {
	content: "";
	position: absolute;
	top: 22px;
	bottom: -22px;
	left: calc(var(--rail-x) - 5px);
	width: 10px;
	border-radius: 5px;
	background: var(--kp-rail);
}
.kpath-st::after {
	background: var(--c);
	transform: scaleY(0);
	transform-origin: top;
	transition: transform 0.5s var(--kp-out);
}
.kpath-st.is-run::after {
	transform: scaleY(1);
	transition-delay: calc(var(--i, 0) * 60ms);
}
.kpath-stations > .kpath-st:last-child::before,
.kpath-stations > .kpath-st:last-child::after {
	bottom: 0;
}
.kpath-group:last-child .kpath-stations > .kpath-st:last-child::before,
.kpath-group:last-child .kpath-stations > .kpath-st:last-child::after {
	display: none;
}

.kpath-st__dot {
	position: relative;
	z-index: 1;
	justify-self: center;
	width: 26px;
	height: 26px;
	margin-top: 9px;
	border: 4px solid #b9ad97;
	border-radius: 50%;
	background: var(--kp-surface);
	transition: border-color 0.3s, background 0.3s, transform 0.4s var(--kp-spring);
}
.kpath-st.is-open .kpath-st__dot {
	border-color: var(--c);
}
.kpath-st.is-open .kpath-st__dot::after {
	content: "";
	position: absolute;
	inset: 5px;
	border-radius: 50%;
	background: var(--c);
	opacity: 0.45;
}
.kpath-st.is-read .kpath-st__dot {
	border-color: var(--kp-ink);
	background: var(--c);
}
/* 読んだ駅のチェック */
.kpath-st.is-read .kpath-st__dot::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 2px;
	width: 6px;
	height: 11px;
	border: solid #fff;
	border-width: 0 3px 3px 0;
	border-radius: 1px;
	background: none;
	opacity: 1;
	transform: rotate(45deg);
}

/* いまここ: 次に読む駅 */
.kpath-st.is-here .kpath-st__dot {
	border-color: var(--kp-accent);
	transform: scale(1.12);
	box-shadow: 0 0 0 0 rgba(255, 91, 0, 0.45);
	animation: kpath-ping 1.8s var(--kp-out) infinite;
}
@keyframes kpath-ping {
	0% {
		box-shadow: 0 0 0 0 rgba(255, 91, 0, 0.45);
	}
	70%,
	100% {
		box-shadow: 0 0 0 14px rgba(255, 91, 0, 0);
	}
}
.kpath-st.is-here .kpath-st__card::before {
	content: "いまここ";
	position: absolute;
	top: -11px;
	left: 14px;
	padding: 1px 10px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background: var(--kp-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.08em;
	animation: kpath-bob 2.4s ease-in-out infinite;
}
@keyframes kpath-bob {
	50% {
		transform: translateY(-3px);
	}
}

.kpath-st__card {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0 12px;
	align-items: baseline;
	padding: 12px 14px 12px 16px;
	border: 2px solid var(--kp-ink);
	border-radius: 14px;
	background: var(--kp-surface);
	color: var(--kp-text);
	text-decoration: none;
	transition: transform 0.25s var(--kp-spring), box-shadow 0.25s, background 0.3s;
}
.kpath-st__card:hover {
	transform: translate(-2px, -2px);
	box-shadow: 4px 4px 0 var(--c);
}
.kpath-st__card:active {
	transform: translate(1px, 1px);
	box-shadow: 1px 1px 0 var(--c);
}
.kpath-st__card:focus-visible {
	outline: 3px solid var(--kp-accent);
	outline-offset: 3px;
}
.kpath-st.is-read .kpath-st__card {
	background: color-mix(in srgb, var(--c) 7%, var(--kp-surface));
}
.kpath-st__name {
	font-size: 18px;
	font-weight: 800;
	line-height: 1.35;
	color: var(--kp-ink);
}
.kpath-st__name.is-mono {
	font-family: var(--kp-mono);
	font-weight: 700;
}
.kpath-st__ja {
	grid-column: 1;
	font-size: 13px;
	color: var(--kp-muted);
}
.kpath-st__ja:empty {
	display: none;
}
.kpath-st__desc {
	grid-column: 1;
	margin-top: 2px;
	font-size: 14px;
	line-height: 1.65;
}
.kpath-st__state {
	grid-column: 2;
	grid-row: 1;
	padding: 1px 10px;
	border-radius: 999px;
	background: var(--kp-rail);
	color: var(--kp-muted);
	font-size: 12px;
	font-weight: 800;
	white-space: nowrap;
}
.kpath-st.is-open .kpath-st__state {
	background: color-mix(in srgb, var(--c) 16%, #fff);
	color: var(--kp-ink);
}
.kpath-st.is-read .kpath-st__state {
	background: var(--c);
	color: #fff;
}

/* 飛んで来た駅・新しく読んだ駅 */
.kpath-st.is-target .kpath-st__card {
	animation: kpath-target 1.6s var(--kp-out);
}
@keyframes kpath-target {
	0%,
	30% {
		box-shadow: 0 0 0 4px var(--kp-accent), 4px 4px 0 var(--c);
	}
	100% {
		box-shadow: 0 0 0 0 transparent;
	}
}
.kpath-st.is-fresh .kpath-st__dot {
	animation: kpath-ink 0.9s var(--kp-spring);
}
@keyframes kpath-ink {
	0% {
		transform: scale(0.4);
		background: var(--kp-surface);
	}
	60% {
		transform: scale(1.35);
	}
	100% {
		transform: scale(1);
	}
}
.kpath-st.is-fresh .kpath-st__card {
	animation: kpath-glow 1s var(--kp-out);
}
@keyframes kpath-glow {
	from {
		background: color-mix(in srgb, var(--c) 30%, var(--kp-surface));
	}
}

@media (max-width: 560px) {
	.kpath-line {
		--rail-x: 15px;
	}
	.kpath-st {
		grid-template-columns: 30px minmax(0, 1fr);
		gap: 0 10px;
	}
	.kpath-st__dot {
		width: 22px;
		height: 22px;
		border-width: 3px;
		margin-top: 11px;
	}
	.kpath-st.is-read .kpath-st__dot::after {
		left: 4px;
		top: 1px;
	}
	.kpath-group__no {
		width: 32px;
		height: 32px;
		font-size: 16px;
		border-radius: 10px;
	}
	.kpath-st__card {
		grid-template-columns: minmax(0, 1fr);
	}
	.kpath-st__state {
		grid-column: 1;
		grid-row: auto;
		justify-self: start;
		margin-top: 6px;
	}
}

/* ------------------------------------------------------------ 完走 */

.kpath-done {
	position: relative;
	margin-top: 22px;
	padding: 26px 22px 22px 130px;
	border: 3px solid var(--kp-ink);
	border-radius: 20px;
	background: var(--kp-surface);
	box-shadow: 6px 6px 0 var(--c);
	animation: kpath-rise 0.6s var(--kp-spring);
}
.kpath-done[hidden] {
	display: none;
}
@keyframes kpath-rise {
	from {
		opacity: 0;
		transform: translateY(14px) scale(0.98);
	}
}
/* 判子 */
.kpath-done__stamp {
	position: absolute;
	left: 22px;
	top: 50%;
	display: grid;
	place-items: center;
	width: 88px;
	height: 88px;
	margin-top: -44px;
	border: 4px double var(--kp-stamp);
	border-radius: 50%;
	color: var(--kp-stamp);
	font-size: 26px;
	font-weight: 900;
	letter-spacing: 0.1em;
	transform: rotate(-12deg);
	opacity: 0.9;
	animation: kpath-stamp 0.5s 0.25s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes kpath-stamp {
	from {
		opacity: 0;
		transform: rotate(-12deg) scale(1.8);
	}
}
.kpath-done h2 {
	font-size: 20px;
	font-weight: 900;
	color: var(--kp-ink);
}
.kpath-done p[data-kpath-finish-date] {
	margin-top: 4px;
	color: var(--kp-muted);
	font-size: 14px;
}
.kpath-done__go {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 14px;
}
.kpath-done__go a {
	background: var(--kp-surface);
	color: var(--kp-ink);
}
@media (max-width: 560px) {
	.kpath-done {
		padding: 120px 18px 20px;
		text-align: center;
	}
	.kpath-done__stamp {
		left: 50%;
		top: 18px;
		margin: 0 0 0 -44px;
	}
	.kpath-done__go {
		justify-content: center;
	}
}

.kpath-other {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 28px;
}
.kpath-other a {
	display: inline-flex;
	gap: 8px;
	align-items: center;
	padding: 8px 14px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background: var(--kp-surface);
	color: var(--kp-ink);
	font-weight: 700;
	text-decoration: none;
}
.kpath-other a::before {
	content: "";
	width: 14px;
	height: 6px;
	border-radius: 3px;
	background: var(--c);
}

/* ------------------------------------------------------------ 一覧のカード */

.kpath-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
	gap: 18px;
}
.kpath-card__a {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 8px;
	height: 100%;
	padding: 22px 20px 18px;
	border: 3px solid var(--kp-ink);
	border-radius: 20px;
	background: var(--kp-surface);
	color: var(--kp-text);
	text-decoration: none;
	box-shadow: 5px 5px 0 var(--c);
	transition: transform 0.3s var(--kp-spring), box-shadow 0.3s;
}
.kpath-card__a:hover {
	transform: translate(-3px, -3px) rotate(-0.4deg);
	box-shadow: 8px 8px 0 var(--c);
}
.kpath-card__a:active {
	transform: translate(2px, 2px);
	box-shadow: 2px 2px 0 var(--c);
}
/* 小さな路線図: 駅の数だけ丸、読んだ駅は塗る */
.kpath-card__line {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 0;
	align-items: center;
	margin-bottom: 4px;
}
.kpath-card__line i {
	position: relative;
	flex: 1 0 12px;
	max-width: 22px;
	height: 12px;
}
.kpath-card__line i::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 4px;
	height: 4px;
	background: var(--kp-rail);
}
.kpath-card__line i::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 0;
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border: 2px solid #b9ad97;
	border-radius: 50%;
	background: var(--kp-surface);
	transition: background 0.4s, border-color 0.4s, transform 0.4s var(--kp-spring);
}
.kpath-card__line i.is-read::before {
	background: var(--c);
}
.kpath-card__line i.is-read::after {
	border-color: var(--kp-ink);
	background: var(--c);
}
.kpath-card__title {
	font-size: 22px;
	font-weight: 900;
	line-height: 1.3;
	color: var(--kp-ink);
}
.kpath-card__lead {
	font-size: 14px;
	line-height: 1.7;
	color: var(--kp-text);
}
.kpath-card__meta {
	margin-top: auto;
	padding-top: 6px;
	font-size: 13px;
	font-weight: 700;
	color: var(--kp-muted);
}
.kpath-card__meta span {
	font: 700 22px/1 var(--kp-num);
	color: var(--kp-ink);
	font-variant-numeric: tabular-nums;
}
.kpath-card__go {
	align-self: flex-start;
	padding: 6px 16px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background: var(--c);
	color: #fff;
	font-size: 14px;
	font-weight: 800;
}
.kpath-card__go::after {
	content: " →";
}

/* ------------------------------------------------------------ 動きを減らす */

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

/* 駅の多い道（LPIC-1 など）: 丸の代わりに 1 本の線。目盛りは 10 駅ごと */
.kpath-card__line.is-rail {
	display: block;
	position: relative;
	height: 14px;
	margin: 3px 0 8px;
	border: 2px solid var(--kp-ink);
	border-radius: 999px;
	background:
		repeating-linear-gradient(90deg, transparent 0 calc(1000% / var(--n, 100) - 2px), rgba(29, 24, 19, 0.18) 0 calc(1000% / var(--n, 100))),
		var(--kp-rail);
	overflow: hidden;
}
.kpath-card__line.is-rail b {
	--p: 0;
	position: absolute;
	inset: 0 auto 0 0;
	width: calc(var(--p) * 1%);
	min-width: 0;
	background: var(--c);
	border-radius: inherit;
	transition: width 1.1s var(--kp-out);
}
