/*
 * iCoach Member Dashboard — front end. Colours follow the existing dashboard design.
 *
 * Thrive Architect styles text with high-specificity selectors (ids such as #tve_editor and
 * :not(#tve)), which made our sizes impossible to change. Every rule is therefore scoped with
 * `.icmd:not(#icmd-a):not(#icmd-b)` (two id-level weights), and font sizes carry !important.
 * Sizes come from --icmd-fs / --icmd-fs-heading, set in 會員專區 → 設定.
 */

.icmd {
	--icmd-fs: 15px;
	--icmd-fs-heading: 26px;
	container-type: inline-size;
	width: 100%;
}

.icmd:not(#icmd-a):not(#icmd-b) {
	--icmd-gold: #d6a63a;
	--icmd-gold-dark: #b98a22;
	--icmd-orange: #e2702a;
	--icmd-ink: #1d1d1d;
	--icmd-text: #555;
	--icmd-muted: #8a8378;
	--icmd-card: #faf6ef;
	--icmd-soft: #f5f2ec;
	--icmd-line: #dcd2c3;
	--icmd-ok: #2f8a4c;
	--icmd-error: #c0392b;

	color: var(--icmd-text);
	font-size: var(--icmd-fs) !important;
	line-height: 1.8 !important;
	font-weight: 400;
	box-sizing: border-box;
}

.icmd:not(#icmd-a):not(#icmd-b) *,
.icmd:not(#icmd-a):not(#icmd-b) *::before,
.icmd:not(#icmd-a):not(#icmd-b) *::after {
	box-sizing: inherit;
}

.icmd:not(#icmd-a):not(#icmd-b) + .icmd {
	margin-top: 24px;
}

/* ------------------------------------------------------------ cards */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-card {
	background: var(--icmd-card);
	border: 1px solid var(--icmd-line);
	border-radius: 6px;
	padding: 22px 24px;
	margin: 0 0 20px;
	transition: opacity 0.2s;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-card:last-child {
	margin-bottom: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-card.is-busy {
	opacity: 0.6;
	pointer-events: none;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-card-heading,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-section-heading {
	margin: 0 0 12px;
	padding: 0;
	color: var(--icmd-ink);
	font-size: var(--icmd-fs-heading) !important;
	font-weight: 700;
	line-height: 1.3 !important;
	letter-spacing: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-section-heading {
	font-size: calc(var(--icmd-fs-heading) - 4px) !important;
	margin-top: 8px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-empty {
	margin: 0;
	color: var(--icmd-muted);
	font-size: var(--icmd-fs) !important;
}

/* ------------------------------------------------------------ buttons */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-btn {
	display: inline-block;
	padding: 0.65em 1.5em;
	border: 0;
	border-radius: 6px;
	background: var(--icmd-gold);
	color: #fff;
	font-family: inherit;
	font-size: calc(var(--icmd-fs) + 1px) !important;
	font-weight: 600;
	line-height: 1.4 !important;
	letter-spacing: 0.08em;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	white-space: nowrap;
	cursor: pointer;
	box-shadow: none;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-btn:hover,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-btn:focus-visible {
	background: var(--icmd-gold-dark);
	color: #fff;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-btn:focus-visible,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-link:focus-visible {
	outline: 2px solid var(--icmd-ink);
	outline-offset: 2px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-btn[disabled] {
	opacity: 0.55;
	cursor: default;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-toggle.is-on {
	background: #fff;
	color: var(--icmd-gold-dark);
	box-shadow: inset 0 0 0 2px var(--icmd-gold);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--icmd-muted);
	font-family: inherit;
	font-size: calc(var(--icmd-fs) - 1px) !important;
	line-height: 1.6 !important;
	text-decoration: underline;
	cursor: pointer;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-link:hover {
	color: var(--icmd-error);
}

/* ------------------------------------------------------------ news */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-main {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 24px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-body {
	flex: 1 1 240px;
	min-width: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-side {
	flex: 0 0 auto;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-date {
	color: var(--icmd-text);
	font-size: var(--icmd-fs) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-title {
	margin: 2px 0 6px;
	padding: 0;
	color: var(--icmd-ink);
	font-size: calc(var(--icmd-fs) + 3px) !important;
	font-weight: 700;
	line-height: 1.5 !important;
}

/*
 * The content comes from the editor. Paragraphs follow our size; sizes, colours and bold set
 * on words inside the editor (inline styles / <strong>) are kept.
 */
.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-content,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-desc {
	color: var(--icmd-text);
	font-size: var(--icmd-fs) !important;
	font-weight: 400;
	line-height: 1.8 !important;
	overflow-wrap: anywhere;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-content :is(p, li, ul, ol, div, blockquote),
.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-desc :is(p, li, ul, ol, div, blockquote) {
	font-size: inherit !important;
	line-height: inherit !important;
	font-weight: inherit;
	letter-spacing: inherit;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-content p,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-desc p {
	margin: 0 0 0.6em;
	padding: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-news-content p:last-child,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-desc p:last-child {
	margin-bottom: 0;
}

/* coupon (scratch card) */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 16px;
	margin: 16px 0 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon-btn {
	background: linear-gradient(135deg, var(--icmd-orange), var(--icmd-gold));
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon-btn::before {
	content: "🎁 ";
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket-wrap {
	position: relative;
	display: inline-block;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	min-width: 200px;
	padding: 8px 26px 10px;
	background: #fff;
	border: 2px dashed var(--icmd-gold);
	border-radius: 10px;
	overflow: hidden;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket-label {
	color: var(--icmd-muted);
	font-size: calc(var(--icmd-fs) - 2px) !important;
	line-height: 1.5 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket-code {
	color: var(--icmd-orange);
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
	font-size: calc(var(--icmd-fs) + 11px) !important;
	font-weight: 800;
	line-height: 1.3 !important;
	letter-spacing: 0.14em;
	user-select: all;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket-foil {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transition: opacity 0.35s;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-ticket-foil.is-fading {
	opacity: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon.is-revealed .icmd-ticket {
	animation: icmd-pop 0.45s ease-out;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-sparkles {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 0;
	height: 0;
	pointer-events: none;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-sparkles i {
	position: absolute;
	left: -4px;
	top: -4px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--icmd-gold);
	opacity: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-sparkles i:nth-child(3n) {
	background: var(--icmd-orange);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-sparkles i:nth-child(4n) {
	width: 6px;
	height: 6px;
	border-radius: 1px;
	background: #f4c542;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon.is-revealed .icmd-sparkles i {
	animation: icmd-spark 0.8s ease-out var(--d, 0ms) forwards;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon-note {
	flex-basis: 100%;
	margin: 0;
}

@keyframes icmd-pop {
	0% { transform: scale(1); }
	40% { transform: scale(1.08); }
	100% { transform: scale(1); }
}

@keyframes icmd-spark {
	0% { transform: translate(0, 0) scale(1); opacity: 1; }
	100% { transform: translate(var(--x), var(--y)) scale(0.3) rotate(160deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon.is-revealed .icmd-ticket,
	.icmd:not(#icmd-a):not(#icmd-b) .icmd-coupon.is-revealed .icmd-sparkles i {
		animation: none;
	}
}

/* poll & feedback */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-interact {
	margin: 18px 0 0;
	padding: 16px 0 0;
	border-top: 1px dashed var(--icmd-line);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-poll {
	margin: 0 0 12px;
	padding: 0;
	border: 0;
	min-width: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-poll-question {
	margin: 0 0 8px;
	padding: 0;
	color: var(--icmd-ink);
	font-size: var(--icmd-fs) !important;
	font-weight: 600;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-option {
	display: block;
	margin: 0 0 8px;
	padding: 6px 12px;
	background: #fff;
	border: 1px solid var(--icmd-line);
	border-radius: 6px;
	font-size: var(--icmd-fs) !important;
	line-height: 1.6 !important;
	font-weight: 400;
	cursor: pointer;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-option-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-option input {
	margin: 0;
	accent-color: var(--icmd-gold);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-bar {
	display: block;
	height: 6px;
	margin: 4px 0 0;
	background: var(--icmd-soft);
	border-radius: 3px;
	overflow: hidden;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-bar-fill {
	display: block;
	height: 100%;
	background: var(--icmd-gold);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-bar-text {
	display: block;
	color: var(--icmd-muted);
	font-size: calc(var(--icmd-fs) - 3px) !important;
	line-height: 1.5 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-feedback {
	display: block;
	margin: 0 0 12px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-feedback-prompt {
	display: block;
	margin-bottom: 6px;
	color: var(--icmd-ink);
	font-size: var(--icmd-fs) !important;
	font-weight: 600;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-feedback textarea {
	display: block;
	width: 100%;
	padding: 8px 12px;
	border: 1px solid var(--icmd-line);
	border-radius: 6px;
	background: #fff;
	color: var(--icmd-ink);
	font-family: inherit;
	font-size: var(--icmd-fs) !important;
	line-height: 1.6 !important;
	resize: vertical;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-note {
	margin: 8px 0 0;
	color: var(--icmd-muted);
	font-size: calc(var(--icmd-fs) - 2px) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-actions .icmd-note {
	margin: 0;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-msg {
	font-size: calc(var(--icmd-fs) - 2px) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-msg:empty {
	display: none;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-msg.is-ok {
	color: var(--icmd-ok);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-msg.is-error {
	color: var(--icmd-error);
}

/* ------------------------------------------------------------ event */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event {
	background: #fafafa;
	border-color: #d9d9d9;
	padding: 22px 20px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-inner {
	display: flex;
	align-items: center;
	gap: 16px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-date-badge {
	flex: 0 0 66px;
	align-self: flex-start;
	text-align: center;
	border: 1px solid #cfcfcf;
	background: #fff;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-date-month {
	display: block;
	padding: 4px 0;
	background: var(--icmd-gold);
	color: #fff;
	font-size: 19px !important;
	font-weight: 700;
	line-height: 1.4 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-date-day {
	display: block;
	padding: 8px 0;
	color: #444;
	font-size: 22px !important;
	font-weight: 700;
	line-height: 1.4 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-body {
	flex: 1 1 auto;
	min-width: 0;
	padding: 12px 16px;
	background: var(--icmd-soft);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-subtitle {
	color: var(--icmd-text);
	font-size: var(--icmd-fs) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-title {
	margin: 2px 0;
	padding: 0;
	color: var(--icmd-orange);
	font-size: calc(var(--icmd-fs) + 3px) !important;
	font-weight: 700;
	line-height: 1.5 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-time {
	color: #b1561d;
	font-size: calc(var(--icmd-fs) - 1px) !important;
	font-weight: 700;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-desc {
	margin-top: 6px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-details {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 4px 14px;
	margin: 12px 0 0;
	padding: 10px 0 0;
	border-top: 1px dashed var(--icmd-line);
	font-size: calc(var(--icmd-fs) - 1px) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-details dt {
	margin: 0;
	color: var(--icmd-muted);
	font-weight: 400;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-details dd {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-action {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	max-width: 150px;
	text-align: center;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status {
	color: var(--icmd-muted);
	font-size: var(--icmd-fs) !important;
	font-weight: 700;
	line-height: 1.5 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status.is-ok {
	color: var(--icmd-ok);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status.is-wait {
	color: var(--icmd-gold-dark);
}

/* ------------------------------------------------------------ events page */

.icmd:not(#icmd-a):not(#icmd-b) .icmd-my-regs {
	margin-top: 28px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-table-wrap {
	overflow-x: auto;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	font-size: calc(var(--icmd-fs) - 1px) !important;
	line-height: 1.6 !important;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-table th,
.icmd:not(#icmd-a):not(#icmd-b) .icmd-table td {
	padding: 9px 12px;
	border: 0;
	border-bottom: 1px solid var(--icmd-line);
	font-size: inherit !important;
	text-align: left;
	vertical-align: top;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-table th {
	color: var(--icmd-ink);
	background: var(--icmd-card);
	font-weight: 600;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status-cell.is-confirmed {
	color: var(--icmd-ok);
	font-weight: 600;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status-cell.is-waitlist {
	color: var(--icmd-gold-dark);
	font-weight: 600;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-status-cell.is-cancelled {
	color: var(--icmd-muted);
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-pager {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 16px;
}

.icmd:not(#icmd-a):not(#icmd-b) .icmd-pager a {
	color: var(--icmd-gold-dark);
}

/* ------------------------------------------------------------ narrow boxes
 * Container queries follow the width of the box the shortcode sits in (e.g. the right-hand
 * column of the dashboard), not the screen, so the event card stacks inside narrow columns.
 */

@container (max-width: 560px) {
	.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-inner {
		flex-wrap: wrap;
		align-items: flex-start;
	}

	.icmd:not(#icmd-a):not(#icmd-b) .icmd-date-badge {
		flex-basis: 58px;
	}

	.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-body {
		flex-basis: calc(100% - 74px);
	}

	.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-action {
		flex-basis: 100%;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: flex-end;
		max-width: none;
	}

	.icmd:not(#icmd-a):not(#icmd-b) .icmd-card {
		padding: 18px 16px;
	}
}

/* Browsers without container queries fall back to the screen width. */
@supports not (container-type: inline-size) {
	@media (max-width: 600px) {
		.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-inner {
			flex-wrap: wrap;
			align-items: flex-start;
		}

		.icmd:not(#icmd-a):not(#icmd-b) .icmd-date-badge {
			flex-basis: 58px;
		}

		.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-body {
			flex-basis: calc(100% - 74px);
		}

		.icmd:not(#icmd-a):not(#icmd-b) .icmd-event-action {
			flex-basis: 100%;
			max-width: none;
		}
	}
}
