/*
	活動預定頁面樣式（需搭配 base-page.css 一起載入）
	全屏月曆，左右滑動切換月份，右側（手機為底部）顯示活動細節
*/

	:root {
		--c-confirmed: #8fd8b3;   /* 確定出席 */
		--c-tentative: #e8c56a;   /* 尚未確定 */
		--c-full:      #e08a8a;   /* 已額滿 */
		--line:        rgba(255, 255, 255, 0.14);
		--line-strong: rgba(255, 255, 255, 0.3);
	}

/* ---------- 進場動畫 ----------
	body 一開始帶著 is-preload，schedule.js 在 load 之後 100ms 拿掉它，
	下面這些元素就會從「起始狀態」過渡到正常狀態。
	改動畫速度就調 transition 的秒數，改先後順序就調 transition-delay。
*/

	#topbar,
	#months,
	.month-head,
	.weekdays,
	.days {
		opacity: 1;
		transform: none;
		transition: opacity 0.7s ease-out, transform 0.7s ease-out;
	}

	#panel {
		transition: opacity 0.7s ease-out, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
		transition-delay: 0.3s;
	}

	/* 起始狀態：整體往上浮現，右側面板收在畫面外 */
	body.is-preload #topbar     { opacity: 0; transform: translateY(-0.8rem); }
	body.is-preload #months     { opacity: 0; }
	body.is-preload .month-head { opacity: 0; transform: translateY(1.2rem); }
	body.is-preload .weekdays   { opacity: 0; transform: translateY(1.2rem); }
	body.is-preload .days       { opacity: 0; transform: translateY(1.8rem); }
	body.is-preload #panel      { opacity: 0; transform: translateX(100%); }

	/* 依序浮現：標題 → 星期列 → 日期格 */
	.month-head { transition-delay: 0.15s; }
	.weekdays   { transition-delay: 0.28s; }
	.days       { transition-delay: 0.40s; }

	/* 使用者若在系統設定關閉動態效果，就直接顯示不做動畫 */
	@media (prefers-reduced-motion: reduce) {

		#topbar, #months, .month-head, .weekdays, .days, #panel {
			transition: none !important;
			transition-delay: 0s !important;
		}

		body.is-preload #topbar,
		body.is-preload #months,
		body.is-preload .month-head,
		body.is-preload .weekdays,
		body.is-preload .days,
		body.is-preload #panel {
			opacity: 1;
			transform: none;
		}

	}

/* ---------- 整體版面 ---------- */

	#calendar {
		position: absolute;
		top: 0; left: 0;
		width: 100%;
		height: 100vh;
		height: 100dvh;
		z-index: 2;
		display: flex;
	}

/* ---------- 月份捲動容器 ---------- */

	#months {
		flex: 1 1 auto;
		min-width: 0;
		display: flex;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		/* 注意：這裡不能加 scroll-behavior: smooth，
		   它和 scroll-snap mandatory 併用會讓程式控制的捲動整個失效，
		   月份切換的動畫改由 schedule.js 的 animateTo() 自己跑 */
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

		#months::-webkit-scrollbar { display: none; }

	.month {
		flex: 0 0 100%;
		scroll-snap-align: start;
		scroll-snap-stop: always;
		height: 100%;
		display: flex;
		flex-direction: column;
		padding: 5.5rem 2.5rem 4rem;
	}

/* ---------- 月份標題與前後切換 ---------- */

	.month-head {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 1.5rem;
		margin-bottom: 1.5rem;
	}

		.month-head h2 {
			margin: 0;
			min-width: 12rem;
			text-align: center;
			font-size: 1.1rem;
			font-weight: 300;
			letter-spacing: 0.35rem;
			line-height: 1.3;
		}

			.month-head h2 .count {
				display: block;
				margin-top: 0.3em;
				font-size: 0.55rem;
				letter-spacing: 0.2rem;
				opacity: 0.55;
			}

				/* 中北部互惠名額：還有 = 綠、用掉了 = 紅，跟活動狀態的色票一致 */
				.month-head h2 .count.is-open  { color: var(--c-confirmed); opacity: 0.85; }
				.month-head h2 .count.is-taken { color: var(--c-full);      opacity: 0.7; }

		.month-head .nav {
			width: 2.25rem;
			height: 2.25rem;
			border: solid 1px var(--line-strong);
			border-radius: 100%;
			font-size: 0.75rem;
			line-height: 1;
			opacity: 0.8;
			transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
		}

			.month-head .nav:hover {
				background-color: rgba(255, 255, 255, 0.1);
				opacity: 1;
			}

			.month-head .nav[disabled] {
				opacity: 0.2;
				cursor: default;
			}

/* ---------- 星期列 ---------- */

	.weekdays {
		display: grid;
		grid-template-columns: repeat(7, 1fr);
		border-bottom: solid 1px var(--line-strong);
		padding-bottom: 0.6rem;
		margin-bottom: 0.4rem;
	}

		.weekdays span {
			text-align: center;
			font-size: 0.55rem;
			letter-spacing: 0.25rem;
			opacity: 0.55;
		}

		.weekdays span:first-child,
		.weekdays span:last-child { opacity: 0.75; }

/* ---------- 日期格 ---------- */

	.days {
		flex: 1 1 auto;
		display: grid;
		grid-template-columns: repeat(7, 1fr);
		grid-auto-rows: minmax(0, 1fr);
		gap: 1px;
		min-height: 0;
	}

	.day {
		position: relative;
		display: flex;
		flex-direction: column;
		gap: 0.25rem;
		padding: 0.5rem 0.45rem;
		border: solid 1px transparent;
		border-radius: 3px;
		background-color: rgba(255, 255, 255, 0.02);
		overflow: hidden;
		text-align: left;
		transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
	}

		/* 鄰月的日期只是補格子，不可點 */
		.day.is-other-month {
			opacity: 0.28;
			cursor: default;
			pointer-events: none;
		}

		.day { cursor: pointer; }

		.day:not(.is-other-month):hover,
		.day.is-selected:not(.is-other-month) {
			background-color: rgba(255, 255, 255, 0.09);
			border-color: var(--line-strong);
		}

		.day .num {
			flex: 0 0 auto;
			display: inline-flex;
			align-items: center;
			justify-content: center;
			width: 1.55em;
			height: 1.55em;
			border-radius: 100%;
			font-size: 0.65rem;
			letter-spacing: 0.05rem;
			opacity: 0.8;
		}

		.day.is-today .num {
			background-color: #ffffff;
			color: #1b1f22;
			opacity: 1;
			font-weight: 600;
		}

		.day .chips {
			flex: 1 1 auto;
			display: flex;
			flex-direction: column;
			gap: 0.2rem;
			min-height: 0;
			overflow: hidden;
		}

		.chip {
			display: flex;
			align-items: center;
			gap: 0.4em;
			font-size: 0.55rem;
			letter-spacing: 0.05rem;
			line-height: 1.4;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}

			.chip:before {
				content: "";
				flex: 0 0 auto;
				width: 0.45em;
				height: 0.45em;
				border-radius: 100%;
				background-color: var(--dot, #ffffff);
			}

			.chip .chip-text {
				overflow: hidden;
				text-overflow: ellipsis;
			}

		.chip.status-confirmed { --dot: var(--c-confirmed); }
		.chip.status-tentative { --dot: var(--c-tentative); }
		.chip.status-full      { --dot: var(--c-full); }

		.day .more {
			font-size: 0.5rem;
			letter-spacing: 0.1rem;
			opacity: 0.5;
		}

/* ---------- 側邊細節面板 ---------- */

	#panel {
		flex: 0 0 24rem;
		max-width: 40vw;
		height: 100%;
		overflow-y: auto;
		padding: 5.5rem 2rem 3rem;
		border-left: solid 1px var(--line-strong);
		background-color: rgba(15, 17, 20, 0.72);
		-webkit-backdrop-filter: blur(6px);
		backdrop-filter: blur(6px);
	}

		#panel .panel-title {
			margin: 0 0 1rem 0;
			padding-bottom: 0.8rem;
			border-bottom: solid 1px var(--line);
			font-size: 0.7rem;
			font-weight: 300;
			letter-spacing: 0.3rem;
			text-transform: uppercase;
			opacity: 0.7;
		}

		#panel .panel-close {
			display: none;
		}

		#panel .empty {
			font-size: 0.7rem;
			letter-spacing: 0.1rem;
			opacity: 0.5;
		}

	.event {
		padding: 0 0 1.4rem 0.9rem;
		margin-bottom: 1.4rem;
		border-left: solid 2px var(--dot, #ffffff);
		border-bottom: solid 1px var(--line);
	}

		.event:last-child { border-bottom: 0; margin-bottom: 0; }

		.event.status-confirmed { --dot: var(--c-confirmed); }
		.event.status-tentative { --dot: var(--c-tentative); }
		.event.status-full      { --dot: var(--c-full); }

		.event h3 {
			margin: 0 0 0.4em 0;
			font-size: 0.85rem;
			font-weight: 300;
			letter-spacing: 0.12rem;
			line-height: 1.4;
		}

		.event dl {
			margin: 0;
			display: grid;
			grid-template-columns: auto 1fr;
			gap: 0.2em 0.9em;
			font-size: 0.6rem;
			letter-spacing: 0.06rem;
		}

			.event dt { opacity: 0.45; white-space: nowrap; }
			.event dd { margin: 0; }

		.event .note {
			margin: 0.7em 0 0 0;
			font-size: 0.65rem;
			line-height: 1.7;
			opacity: 0.8;
			/* 讓 note 字串裡的 \n 變成真正的換行（多餘的空白仍會被收合） */
			white-space: pre-line;
		}

		.event .event-link {
			display: inline-block;
			margin-top: 0.7em;
			border-bottom: solid 1px var(--line-strong);
			font-size: 0.55rem;
			letter-spacing: 0.15rem;
			text-transform: uppercase;
			transition: border-bottom-color 0.2s ease-in-out;
		}

			.event .event-link:hover { border-bottom-color: transparent; }

/* ---------- 圖例 ---------- */

	.legend {
		display: flex;
		flex-wrap: wrap;
		gap: 0.2rem 1.2rem;
		margin: 0 0 1.6rem 0;
		padding-bottom: 1.1rem;
		border-bottom: solid 1px var(--line);
		font-size: 0.55rem;
		letter-spacing: 0.12rem;
		opacity: 0.65;
	}

		.legend span { display: inline-flex; align-items: center; gap: 0.5em; }

		.legend span:before {
			content: "";
			width: 0.5em; height: 0.5em;
			border-radius: 100%;
			background-color: var(--dot, #ffffff);
		}

		.legend .status-confirmed { --dot: var(--c-confirmed); }
		.legend .status-tentative { --dot: var(--c-tentative); }
		.legend .status-full      { --dot: var(--c-full); }

/* ---------- 頂部列的「今天」 ---------- */

	#topbar .today-btn {
		border-bottom: solid 1px var(--line-strong);
		padding-bottom: 0.15em;
		font-size: 0.6rem;
		letter-spacing: 0.2rem;
		text-transform: uppercase;
		transition: border-bottom-color 0.2s ease-in-out;
	}

		#topbar .today-btn:hover { border-bottom-color: transparent; }

	#topbar .right {
		display: flex;
		align-items: center;
		gap: 1.5rem;
	}

/* ---------- 平板 ---------- */

	@media screen and (max-width: 1280px) {

		#panel { flex-basis: 20rem; }

		.month { padding: 5.5rem 1.5rem 3rem; }

	}

/* ---------- 手機：面板改成從底部滑出 ---------- */

	@media screen and (max-width: 980px) {

		#calendar { display: block; }

		#months { width: 100%; height: 100%; }

		.month { padding: 5rem 1rem 3.5rem; }

		#panel {
			position: fixed;
			left: 0; bottom: 0;
			width: 100%;
			max-width: none;
			height: auto;
			max-height: 62vh;
			z-index: 25;
			padding: 1.5rem 1.5rem 2rem;
			border-left: 0;
			border-top: solid 1px var(--line-strong);
			border-radius: 8px 8px 0 0;
			background-color: rgba(15, 17, 20, 0.94);
			transform: translateY(101%);
			transition: transform 0.35s ease-in-out;
		}

			/* 手機版面板是從底部滑出的，不套用桌機那組「從右側滑入」的進場 */
			body.is-preload #panel { opacity: 1; transform: translateY(101%); }

			body.panel-open #panel { transform: translateY(0); }

			#panel .panel-close {
				display: block;
				position: absolute;
				top: 1.1rem; right: 1.2rem;
				font-size: 1.1rem;
				line-height: 1;
				opacity: 0.6;
			}

			#panel .panel-title { padding-right: 2.5rem; }

		.day { padding: 0.35rem 0.25rem; gap: 0.15rem; }

		.day .num { font-size: 0.7rem; }

		/* 格子太窄，只留彩色圓點 */
		.chip .chip-text { display: none; }

		.chip { gap: 0; }

			.chip:before { width: 0.5em; height: 0.5em; }

		.day .chips {
			flex-direction: row;
			flex-wrap: wrap;
			gap: 0.2rem;
			align-content: flex-start;
		}

		.day .more { display: none; }

		.legend { margin-bottom: 1.2rem; padding-bottom: 0.9rem; }

	}

	@media screen and (max-width: 736px) {

		/* 手機空間有限，右上角的頁名先收起來
		   （這條原本在 base-page.css，但作品集頁的 .title 現在是返回按鈕不能隱藏） */
		#topbar .title { display: none; }

	}
