/* Shared display themes for pages using menu.php. Dark values match the current site. */
:root[data-theme="dark"] {
	color-scheme: dark;
	--dark-bg: #0f172a;
	--card-bg: #27364e;
	--text-light: #f1f5f9;
	--text-light-light: #ffffff;
	--text-gray: #C1CCE0;
	--text-active: #cacaca;
	--primary-bg: #32343D;
	--overlay: rgba(0, 0, 0, .7);
	--filter-bg: rgba(30, 41, 59, .8);
	--theme-page: #0f172a;
	--theme-surface: #1e293b;
	--theme-surface-raised: #27364e;
	--theme-text: #f1f5f9;
	--theme-muted: #aab8ca;
	--theme-link: #f8fafc;
	--theme-border: rgba(148, 163, 184, .2);
	--theme-input: #172338;
	--primary: #094CB8;
	--linktext: #ffffff;
	--list-bg: rgba(255, 255, 255, 0.05);
	--toptext: #ffffff;
	--code-bg: #363636;	
}

:root[data-theme="light"] {
	color-scheme: light;
	--dark-bg: #D7E0EB;
	--card-bg: #CAD2DB;
	--text-light: #1f2937;
	--text-light-light: #ffffff;
	--text-gray: #34384D;
	--text-active: #1d4ed8;
	--primary-bg: #BEC6D4;
	--overlay: rgba(15, 23, 42, .28);
	--filter-bg: rgba(30, 41, 59, .6);
	--theme-page: #D7E0EB;
	--theme-surface: #CAD2DB;
	--theme-surface-raised: #f8fafc;
	--theme-text: #1f2937;
	--theme-muted: #526174;
	--theme-link: #1d4ed8;
	--theme-border: #d7e0eb;
	--theme-input: #ffffff;
	--primary: #094CB8;
	--linktext: #004EC9;
	--list-bg: rgba(0, 0, 0, .1);
	--toptext: #094CB8;
	--code-bg: #E9ECF2;
}

html[data-theme="light"] body {
	background: var(--theme-page) !important;
	color: var(--theme-text) !important;
}

html[data-theme="light"] .light-button-a {
	color: #ffffff !important;
}

/* 社群連結本身是 .social-icon；LINE 文字則由子元素繼承顏色。 */
html[data-theme="light"] body .social-icon:hover,
html[data-theme="light"] body .social-icon:hover .line-social-mark,
html[data-theme="light"] body .social-icon:focus-visible,
html[data-theme="light"] body .social-icon:focus-visible .line-social-mark {
	color: #ffffff !important;
}

html[data-theme="light"] body,
html[data-theme="light"] body p,
html[data-theme="light"] body li,
html[data-theme="light"] body label,
html[data-theme="light"] body small,
html[data-theme="light"] body .text-muted,
html[data-theme="light"] body .muted {
	color: var(--theme-text);
}

/* html[data-theme="light"] body a:not(.btn):not([class*="btn-"]):not(.navbar-brand) { */
	/* color: #ffffff; */
/* } */

html[data-theme="light"] body .comment-header a,
html[data-theme="light"] body .comment-header a:hover {
	color: #ffffff !important;
}

html[data-theme="light"] .navbar,
html[data-theme="light"] .mobile-nav,
html[data-theme="light"] .footer,
html[data-theme="light"] .footer-content,
html[data-theme="light"] .copyright {
	background-color: #D7E0EB !important;
	color: #1f2937 !important;
}

html[data-theme="light"] .navbar,
html[data-theme="light"] .mobile-nav,
html[data-theme="light"] .footer {
	border-color: var(--theme-border) !important;
}

html[data-theme="light"] .navbar a,
html[data-theme="light"] .mobile-nav a,
html[data-theme="light"] .footer a,
html[data-theme="light"] .brand-text {
	color: #26364a !important;
}

html[data-theme="light"] .nav-links a:hover,
html[data-theme="light"] .mobile-nav-links a:hover,
html[data-theme="light"] .nav-links a.active,
html[data-theme="light"] .mobile-nav-links a.active {
	color: #1d4ed8 !important;
}

html[data-theme="light"] .login-card,
html[data-theme="light"] .card,
html[data-theme="light"] .course,
html[data-theme="light"] .course-card,
html[data-theme="light"] .course-item,
html[data-theme="light"] .article-card,
html[data-theme="light"] .leaderboard,
html[data-theme="light"] .leaderboard-item,
html[data-theme="light"] .leaderboard-header,
html[data-theme="light"] .filter-section,
html[data-theme="light"] .filter-card,
html[data-theme="light"] .dashboard-card,
html[data-theme="light"] .profile-card,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .content-card,
html[data-theme="light"] .article-content,
html[data-theme="light"] .article-reading-layout > .article-content,
html[data-theme="light"] .comments-section,
html[data-theme="light"] .toc,
html[data-theme="light"] .article-sidebar-drawer,
html[data-theme="light"] .article-sidebar-drawer .toc,
html[data-theme="light"] .notice,
html[data-theme="light"] .alert,
html[data-theme="light"] .modal-content,
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .table-container,
html[data-theme="light"] .pagination {
	background-color: var(--theme-surface) !important;
	color: var(--theme-text) !important;
	border-color: var(--theme-border) !important;
	box-shadow: 0 8px 24px rgba(31, 41, 55, .08);
}

html[data-theme="light"] .leaderboard-item:hover {
	background-color: var(--list-bg) !important;
	border-radius: 10px;
}

html[data-theme="light"] .article-reading-layout > .article-content {
	background: #ffffff !important;
}

html[data-theme="light"] .hero,
html[data-theme="light"] .page-header {
	background: linear-gradient(135deg, #4E77C2 0%, #7F94B3 100%) !important;
}

html[data-theme="light"] .article-header {
	background: radial-gradient(circle at 15% 0%, rgba(59, 130, 246, .12), transparent 34%), linear-gradient(135deg, #4E77C2 0%, #7F94B3 100%) !important;
	color: #1f2937 !important;
}

html[data-theme="light"] .article-tasks,
html[data-theme="light"] .homework-section,
html[data-theme="light"] .upload-form,
html[data-theme="light"] .progress-bar {
	background: #eef3f8 !important;
	color: #26364a !important;
	border-color: var(--theme-border) !important;
}

html[data-theme="light"] .task-item,
html[data-theme="light"] .article-content-tutorial {
	background: #ffffff !important;
	color: #26364a !important;
}

html[data-theme="light"] .task-title,
html[data-theme="light"] .task-content,
html[data-theme="light"] .article-tasks h3,
html[data-theme="light"] .kv {
	color: #26364a !important;
}

html[data-theme="light"] .article-title-top,
html[data-theme="light"] .leaderboard-title,
html[data-theme="light"] .course-title,
html[data-theme="light"] .card h1,
html[data-theme="light"] .card h2,
html[data-theme="light"] .card h3,
html[data-theme="light"] .login-card h1,
html[data-theme="light"] .login-card h2,
html[data-theme="light"] .article-content h1,
html[data-theme="light"] .article-content h2,
html[data-theme="light"] .article-content h3,
html[data-theme="light"] .article-content h4 {
	color: #172338 !important;
}

html[data-theme="light"] .article-meta-top,
html[data-theme="light"] .article-meta-top .meta-item,
html[data-theme="light"] .course-meta,
html[data-theme="light"] .course-description,
html[data-theme="light"] .lead,
html[data-theme="light"] .helper,
html[data-theme="light"] .field-hint,
html[data-theme="light"] .pagination-info {
	color: var(--theme-muted) !important;
}

html[data-theme="light"] body .leaderboard-list .rank:not(.rank-1):not(.rank-2):not(.rank-3) {
	background: linear-gradient(135deg, #FCFCFC, #F7F7F7);
	color: #334155;
	border: 1px solid #D7E0EB;
}

html[data-theme="light"] .small,
html[data-theme="light"] .pg-btn:hover:not(.pg-disabled):not(.pg-current) {
	color: var(--theme-muted) !important;
}

html[data-theme="light"] .pg-btn:hover:not(.pg-disabled):not(.pg-current) {
	background: #e8eef6 !important;
	border-color: #cbd5e1 !important;
}

/* Keep the student dashboard pagination legible in light mode on both pages. */
html[data-theme="light"] body .pagination-nav .pg-btn {
	background: #ffffff;
	border-color: #cbd5e1;
}
html[data-theme="light"] body .pagination-nav a.pg-btn:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .pagination-nav a.pg-btn:link:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .pagination-nav a.pg-btn:visited:not(.btn):not([class*="btn-"]):not(.navbar-brand) {
	color: #475569 !important;
}
html[data-theme="light"] body .pagination-nav a.pg-btn:hover:not(.pg-disabled):not(.pg-current):not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .pagination-nav a.pg-btn:focus-visible:not(.pg-disabled):not(.pg-current):not(.btn):not([class*="btn-"]):not(.navbar-brand) {
	background: #e8eef6 !important;
	border-color: #94a3b8 !important;
	color: #0f172a !important;
}
html[data-theme="light"] body .pagination-nav .pg-btn.pg-current {
	background: linear-gradient(135deg, #094CB8, #094CB8);
	border-color: transparent;
	color: #ffffff !important;
}
html[data-theme="light"] body .pagination-nav .pg-ellipsis,
html[data-theme="light"] body .pg-info {
	color: #64748b !important;
}

html[data-theme="light"] .article-item {
	border-color: #d7e0eb !important;
}

html[data-theme="light"] .thumb-placeholder {
	background: #e8eef6 !important;
}

/* Light theme scrollbar track */
html[data-theme="light"] {
	scrollbar-color: #0072ff #D7E0EB;
}
html[data-theme="light"]::-webkit-scrollbar-track,
html[data-theme="light"] *::-webkit-scrollbar-track {
	background: #D7E0EB !important;
	border-color: #D7E0EB !important;
}
html[data-theme="light"]::-webkit-scrollbar-corner,
html[data-theme="light"] *::-webkit-scrollbar-corner {
	background: #D7E0EB !important;
}
html[data-theme="light"]::-webkit-scrollbar-thumb,
html[data-theme="light"] *::-webkit-scrollbar-thumb {
	border-color: #D7E0EB !important;
}

html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .form-control,
html[data-theme="light"] .input-group input,
html[data-theme="light"] .search-input {
	background-color: var(--theme-input) !important;
	color: #1f2937 !important;
	border-color: #bdc9d8 !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
	color: #718096 !important;
	opacity: 1;
}

html[data-theme="light"] .login-card .error,
html[data-theme="light"] .error,
html[data-theme="light"] .alert-danger {
	background-color: #fff1f0 !important;
	color: #9f2525 !important;
	border-color: #f3b8b3 !important;
}

html[data-theme="light"] .success-msg,
html[data-theme="light"] .alert-success {
	background-color: #eaf8ef !important;
	color: #176b35 !important;
	border-color: #a8dfb8 !important;
}

html[data-theme="light"] .article-sidebar-backdrop,
html[data-theme="light"] .overlay {
	background-color: rgba(15, 23, 42, .35) !important;
}

html[data-theme="light"] .article-sidebar-close,
html[data-theme="light"] .label {
	background-color: #e8eef6 !important;
	color: #26364a !important;
}

html[data-theme="light"] table:not(.ql-editor table) th {
	background-color: #e8eef6;
	color: #26364a;
}

html[data-theme="light"] table:not(.ql-editor table) td {
	color: #26364a;
	border-color: var(--theme-border);
}

html[data-theme="light"] .responsive-table-wrapper,
html[data-theme="light"] .responsive-table-wrapper table,
html[data-theme="light"] .responsive-table-wrapper table tbody tr:nth-child(odd) {
	background: #ffffff !important;
}

html[data-theme="light"] .responsive-table-wrapper table td {
	color: #26364a !important;
	border-color: var(--theme-border) !important;
}

html[data-theme="light"] .responsive-table-wrapper table tbody tr:nth-child(even) {
	background: #f3f6fb !important;
}

html[data-theme="light"] .responsive-table-wrapper table tbody tr:hover {
	background: #e8f1ff !important;
}

html[data-theme="light"] .theme-toggle {
	background: #eff6ff;
	color: #1e40af;
	border-color: #bfdbfe;
}

.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .45rem;
	min-height: 36px;
	padding: .4rem .7rem;
	border: 1px solid rgba(148, 163, 184, .45);
	border-radius: 999px;
	background: rgba(15, 23, 42, .2);
	color: inherit;
	font: inherit;
	font-size: .85rem;
	cursor: pointer;
}
.theme-toggle:hover { filter: brightness(1.12); }
.theme-toggle:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
html[data-theme="dark"] body a.dashboard-article-link,
html[data-theme="dark"] body a.dashboard-article-link:link,
html[data-theme="dark"] body a.dashboard-article-link:visited,
html[data-theme="dark"] body .comment-header a.dashboard-article-link,
html[data-theme="dark"] body .comment-header a.dashboard-article-link:link,
html[data-theme="dark"] body .comment-header a.dashboard-article-link:visited,
html[data-theme="light"] body a.dashboard-article-link,
html[data-theme="light"] body a.dashboard-article-link:link,
html[data-theme="light"] body a.dashboard-article-link:visited,
html[data-theme="light"] body .comment-header a.dashboard-article-link,
html[data-theme="light"] body .comment-header a.dashboard-article-link:link,
html[data-theme="light"] body .comment-header a.dashboard-article-link:visited {
	color: var(--theme-link) !important;
	font-weight: 600;
	text-decoration: none;
}
html[data-theme="dark"] body a.dashboard-article-link:hover,
html[data-theme="dark"] body a.dashboard-article-link:focus-visible,
html[data-theme="dark"] body .comment-header a.dashboard-article-link:hover,
html[data-theme="dark"] body .comment-header a.dashboard-article-link:focus-visible,
html[data-theme="light"] body a.dashboard-article-link:hover,
html[data-theme="light"] body a.dashboard-article-link:focus-visible,
html[data-theme="light"] body .comment-header a.dashboard-article-link:hover,
html[data-theme="light"] body .comment-header a.dashboard-article-link:focus-visible {
	color: var(--linktext) !important;
	text-decoration: none !important;
}
/* Keep dashboard article links readable against the light-theme global link rule. */
html[data-theme="light"] body a.dashboard-article-link:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body a.dashboard-article-link:link:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body a.dashboard-article-link:visited:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .comment-header a.dashboard-article-link:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .comment-header a.dashboard-article-link:link:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .comment-header a.dashboard-article-link:visited:not(.btn):not([class*="btn-"]):not(.navbar-brand) {
	color: var(--theme-link) !important;
}
html[data-theme="light"] body a.dashboard-article-link:hover:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body a.dashboard-article-link:focus-visible:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .comment-header a.dashboard-article-link:hover:not(.btn):not([class*="btn-"]):not(.navbar-brand),
html[data-theme="light"] body .comment-header a.dashboard-article-link:focus-visible:not(.btn):not([class*="btn-"]):not(.navbar-brand) {
	color: var(--primary) !important;
}
html[data-theme="dark"] body a.dashboard-article-link,
html[data-theme="light"] body a.dashboard-article-link {
	position: relative;
	display: inline-block;
	text-decoration: none !important;
	transition: color .3s ease, transform .2s ease;
}
html[data-theme="dark"] body a.dashboard-article-link::after,
html[data-theme="light"] body a.dashboard-article-link::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: -2px;
	width: 0;
	height: 2px;
	background: currentColor;
	transition: width .3s ease;
}
html[data-theme="dark"] body a.dashboard-article-link:hover,
html[data-theme="dark"] body a.dashboard-article-link:focus-visible,
html[data-theme="light"] body a.dashboard-article-link:hover,
html[data-theme="light"] body a.dashboard-article-link:focus-visible {
	transform: translateY(-1px);
}
html[data-theme="dark"] body a.dashboard-article-link:hover::after,
html[data-theme="dark"] body a.dashboard-article-link:focus-visible::after,
html[data-theme="light"] body a.dashboard-article-link:hover::after,
html[data-theme="light"] body a.dashboard-article-link:focus-visible::after {
	width: 100%;
}
.theme-toggle-floating {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 1200;
	padding: .65rem .9rem;
	background: #1e293b;
	color: #f8fafc;
	box-shadow: 0 6px 18px rgba(15, 23, 42, .22);
}

.newsletter-honeypot {
	position: absolute !important;
	left: -10000px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}
.newsletter-message {
	margin: .6rem 0 0;
	font-size: .85rem;
}
.newsletter-message-success { color: #15803d !important; }
.newsletter-message-info { color: var(--theme-muted) !important; }
.newsletter-message-error { color: #b91c1c !important; }
html[data-theme="dark"] .newsletter-message-success { color: #86efac !important; }
html[data-theme="dark"] .newsletter-message-error { color: #fca5a5 !important; }
.newsletter-unsubscribe { margin-top: .8rem; font-size: .85rem; }
.newsletter-unsubscribe summary { cursor: pointer; color: var(--theme-link); }
.newsletter-unsubscribe p { margin: .5rem 0; color: var(--theme-muted); }

@media (max-width: 768px) {
	.nav-links > .theme-toggle { display: none; }
	.mobile-nav-links > .theme-toggle { margin: .5rem 1rem; }
}

@media (min-width: 769px) {
	.mobile-nav-links > .theme-toggle { display: none; }
}
