/**
 * 横軸タイムスケジュール フロントエンド表示
 */

.wp-ts {
	--ts-label-width: 100px;
	--ts-hour-width: 80px;
	--ts-track-width: 800px;
	--ts-row-height: 110px;
	--ts-head-height: 30px;
	--ts-border: #d0d0d0;
	--ts-grid: #e2e2e2;
	--ts-head-bg: #6b6b6b;
	--ts-head-color: #ffffff;
	--ts-label-bg: #f4f8fc;

	box-sizing: border-box;
	position: relative;
	margin: 1.5em 0;
	color: #333;
	font-size: 13px;
	line-height: 1.4;
}

.wp-ts *,
.wp-ts *::before,
.wp-ts *::after {
	box-sizing: border-box;
}

.wp-ts-title {
	margin: 0 0 .6em;
	font-size: 1.4em;
	font-weight: 700;
}

/* 横スクロール領域(モバイル対応) */
.wp-ts-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--ts-border);
	border-radius: 4px;
}

.wp-ts-table {
	width: max-content;
	min-width: 100%;
}

/* ===== 横スクロールボタン ===== */
.wp-ts-scroll-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	font-size: 22px;
	line-height: 1;
	color: #333;
	background: rgba(255, 255, 255, .92);
	border: 1px solid var(--ts-border);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
	cursor: pointer;
}

.wp-ts-scroll-btn:hover {
	background: #fff;
}

.wp-ts-scroll-btn[hidden] {
	display: none;
}

.wp-ts-scroll-prev {
	left: 6px;
}

.wp-ts-scroll-next {
	right: 6px;
}

/* 行(ラベル + トラック) */
.wp-ts-row {
	display: flex;
	align-items: stretch;
	border-bottom: 1px solid var(--ts-border);
}

.wp-ts-row:last-child {
	border-bottom: 0;
}

/* 左側の固定ラベル列 */
.wp-ts-label {
	flex: 0 0 var(--ts-label-width);
	width: var(--ts-label-width);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 6px 8px;
	text-align: center;
	font-weight: 700;
	background: var(--ts-label-bg);
	border-right: 1px solid var(--ts-border);
	position: sticky;
	left: 0;
	z-index: 3;
}

/* タイムライン領域 */
.wp-ts-track {
	position: relative;
	flex: 0 0 var(--ts-track-width);
	width: var(--ts-track-width);
	min-height: var(--ts-row-height);
	/* 1時間ごとの縦罫線 */
	background-image: repeating-linear-gradient(
		to right,
		var(--ts-grid) 0,
		var(--ts-grid) 1px,
		transparent 1px,
		transparent var(--ts-hour-width)
	);
}

/* ===== ヘッダー(時間目盛り) ===== */
.wp-ts-head .wp-ts-label,
.wp-ts-head .wp-ts-track {
	min-height: var(--ts-head-height);
	background-color: var(--ts-head-bg);
	color: var(--ts-head-color);
}

.wp-ts-head .wp-ts-track {
	background-image: repeating-linear-gradient(
		to right,
		rgba(255, 255, 255, .35) 0,
		rgba(255, 255, 255, .35) 1px,
		transparent 1px,
		transparent var(--ts-hour-width)
	);
}

.wp-ts-axis {
	height: var(--ts-head-height);
	min-height: var(--ts-head-height);
}

.wp-ts-tick {
	position: absolute;
	top: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	font-size: 12px;
	font-weight: 700;
	transform: translateX(-50%);
	white-space: nowrap;
	pointer-events: none;
}

.wp-ts-tick.is-last {
	transform: translateX(-100%);
}

.wp-ts-tick:first-child {
	transform: translateX(0);
}

/* ===== イベントブロック ===== */
.wp-ts-event {
	position: absolute;
	top: 3px;
	bottom: 3px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	padding: 2px;
	border: 1px solid rgba(255, 255, 255, .9);
	border-radius: 2px;
	cursor: pointer;
}

.wp-ts-event:hover {
	filter: brightness(.95);
}

.wp-ts-event:focus-visible {
	outline: 2px solid #1a73e8;
	outline-offset: 1px;
}

.wp-ts-event-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1px;
	width: 100%;
	text-align: center;
	overflow: hidden;
}

.wp-ts-event-time {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.2;
	opacity: .9;
	white-space: normal;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.wp-ts-event-title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	white-space: normal;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.wp-ts-empty {
	padding: 1.5em;
	text-align: center;
	color: #888;
}

/* ===== 詳細モーダル ===== */
.wp-ts-modal[hidden] {
	display: none;
}

.wp-ts-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.wp-ts-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
}

.wp-ts-modal-dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 420px;
	max-height: 80vh;
	overflow-y: auto;
	background: #fff;
	color: #333;
	border-radius: 6px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
	padding: 24px;
}

.wp-ts-modal-dialog:focus {
	outline: none;
}

.wp-ts-modal-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 32px;
	height: 32px;
	padding: 0;
	font-size: 22px;
	line-height: 1;
	color: #666;
	background: transparent;
	border: 0;
	cursor: pointer;
}

.wp-ts-modal-close:hover {
	color: #000;
}

.wp-ts-modal-time {
	margin: 0 0 .4em;
	font-size: 14px;
	font-weight: 700;
	color: #555;
}

.wp-ts-modal-title {
	margin: 0 0 .6em;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
}

.wp-ts-modal-desc {
	font-size: 14px;
	line-height: 1.6;
}

body.wp-ts-modal-open {
	overflow: hidden;
}

/* 狭いイベント用に文字を縮小 */
@media (max-width: 600px) {
	.wp-ts {
		font-size: 12px;
	}
	.wp-ts-event-time {
		font-size: 12px;
	}
	.wp-ts-event-title {
		font-size: 14px;
	}
}
