/*
 * Filer.pk tax calculator.
 *
 * Everything is namespaced under .ftc and uses local custom properties, so it inherits the
 * brand palette without leaking styles into, or being broken by, the active theme.
 * Palette matches the existing filer.pk Elementor kit (green identity on light backgrounds).
 */

.ftc {
	/*
	 * Accessibility: #42a544 measures only 3.14:1 against white, so it fails WCAG AA
	 * wherever text sits on it or is drawn in it. It is kept as a decorative accent
	 * (card borders, tints) and interactive colours use the darker brand greens:
	 * #257727 is 5.60:1 and #1b5e1d is 7.88:1.
	 */
	--ftc-green-accent: #42a544;
	--ftc-green: #257727;
	--ftc-green-dark: #1b5e1d;
	--ftc-green-deep: #013a08;
	--ftc-ink: #0b141f;
	--ftc-muted: #5b6770;
	--ftc-line: #dde3e8;
	--ftc-bg: #f7f9fb;
	--ftc-bg-alt: #f3faff;
	--ftc-tint: rgba(202, 238, 204, 0.38);
	--ftc-radius: 12px;
	--ftc-gap: 1rem;

	box-sizing: border-box;
	color: var(--ftc-ink);
	font-size: 16px;
	line-height: 1.5;
	container-type: inline-size;
}

.ftc *,
.ftc *::before,
.ftc *::after {
	box-sizing: inherit;
}

/* ---------- form ---------- */

.ftc__form {
	background: var(--ftc-bg);
	border: 1px solid var(--ftc-line);
	border-radius: var(--ftc-radius);
	padding: 1.25rem;
}

.ftc__row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ftc-gap);
	align-items: flex-end;
}

.ftc__field {
	flex: 1 1 16rem;
	min-width: 0;
}

.ftc__field--narrow {
	flex: 0 1 12rem;
}

/* The tax-year label is long ("Tax Year 2027 (2026-27)") - give it room so it isn't clipped. */
.ftc__field--year {
	flex: 0 1 15rem;
}

.ftc__label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	margin-bottom: 0.375rem;
	text-transform: uppercase;
	color: var(--ftc-muted);
}

.ftc__input-wrap {
	display: flex;
	align-items: stretch;
	background: #fff;
	border: 1px solid var(--ftc-line);
	border-radius: 8px;
	overflow: hidden;
}

.ftc__input-wrap:focus-within {
	border-color: var(--ftc-green);
	box-shadow: 0 0 0 3px var(--ftc-tint);
}

.ftc__prefix {
	display: flex;
	align-items: center;
	padding: 0 0.75rem;
	background: var(--ftc-bg-alt);
	border-right: 1px solid var(--ftc-line);
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--ftc-muted);
	/* Without these the currency label wraps to "PK" / "R" once the flex row is tight. */
	white-space: nowrap;
	flex: none;
}

.ftc__input,
.ftc__select {
	width: 100%;
	min-width: 0;
	border: 0;
	padding: 0.7rem 0.85rem;
	font: inherit;
	font-variant-numeric: tabular-nums;
	color: inherit;
	background: #fff;
}

.ftc__input:focus,
.ftc__select:focus {
	outline: none;
}

.ftc__select {
	border: 1px solid var(--ftc-line);
	border-radius: 8px;
}

.ftc__select:focus {
	border-color: var(--ftc-green);
	box-shadow: 0 0 0 3px var(--ftc-tint);
}

/* ---------- period toggle ---------- */

.ftc__toggle {
	display: flex;
	background: #fff;
	border: 1px solid var(--ftc-line);
	border-radius: 8px;
	padding: 3px;
	gap: 3px;
}

.ftc__toggle-btn {
	flex: 1;
	border: 0;
	background: transparent;
	border-radius: 6px;
	padding: 0.5rem 0.5rem;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ftc-muted);
	cursor: pointer;
}

.ftc__toggle-btn.is-active {
	background: var(--ftc-green);
	color: #fff;
}

.ftc__toggle-btn:focus-visible {
	outline: 2px solid var(--ftc-green-dark);
	outline-offset: 1px;
}

/* ---------- result cards ---------- */

.ftc__results {
	margin-top: 1.25rem;
}

.ftc__cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
	gap: 0.75rem;
}

.ftc__card {
	background: #fff;
	border: 1px solid var(--ftc-line);
	border-left: 4px solid var(--ftc-green-accent);
	border-radius: 10px;
	padding: 0.85rem 1rem;
}

.ftc__card--good {
	border-left-color: var(--ftc-green-deep);
	background: var(--ftc-tint);
}

.ftc__card-label {
	display: block;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--ftc-muted);
}

.ftc__card-value {
	display: block;
	margin-top: 0.2rem;
	font-size: 1.4rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	color: var(--ftc-ink);
	overflow-wrap: anywhere;
}

/* ---------- surcharge callout ---------- */

.ftc__surcharge {
	margin-top: 0.85rem;
	padding: 0.7rem 0.9rem;
	border-radius: 8px;
	background: #fff6e5;
	border: 1px solid #f0d9a8;
	font-size: 0.9rem;
}

.ftc__surcharge strong {
	display: block;
}

/* ---------- surcharge cliff warning ---------- */

.ftc__cliff {
	margin-top: 0.85rem;
	padding: 0.8rem 1rem;
	border-radius: 8px;
	background: #fdecea;
	border: 1px solid #f1b0aa;
	border-left: 4px solid #b3261e;
	font-size: 0.9rem;
	line-height: 1.55;
}

.ftc__cliff strong {
	display: block;
	color: #8c1d18;
	margin-bottom: 0.15rem;
}

/* ---------- disclosure panels ---------- */

.ftc__details {
	margin-top: 1rem;
	border: 1px solid var(--ftc-line);
	border-radius: var(--ftc-radius);
	background: #fff;
}

.ftc__summary {
	cursor: pointer;
	padding: 0.8rem 1rem;
	font-weight: 700;
	font-size: 0.95rem;
	list-style: none;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.ftc__summary::-webkit-details-marker {
	display: none;
}

.ftc__summary::before {
	content: "";
	width: 0;
	height: 0;
	border-left: 6px solid var(--ftc-green-accent);
	border-top: 4px solid transparent;
	border-bottom: 4px solid transparent;
	transition: transform 0.15s ease;
	flex: none;
}

.ftc__details[open] > .ftc__summary::before {
	transform: rotate(90deg);
}

.ftc__summary:focus-visible {
	outline: 2px solid var(--ftc-green-dark);
	outline-offset: -2px;
}

/* ---------- tables ---------- */

.ftc__table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border-top: 1px solid var(--ftc-line);
}

.ftc__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}

.ftc__table th,
.ftc__table td {
	padding: 0.6rem 1rem;
	text-align: right;
	border-bottom: 1px solid var(--ftc-line);
	white-space: nowrap;
}

.ftc__table th:first-child,
.ftc__table td:first-child {
	text-align: left;
}

.ftc__table thead th {
	background: var(--ftc-bg-alt);
	font-size: 0.75rem;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--ftc-muted);
}

.ftc__table tbody tr:last-child td {
	border-bottom: 0;
}

.ftc__table tr[data-current="1"] td {
	background: var(--ftc-tint);
	font-weight: 700;
}

.ftc__delta--up {
	color: #b3261e;
}

.ftc__delta--down {
	color: var(--ftc-green-dark);
}

/* ---------- notes ---------- */

.ftc__note {
	margin: 0;
	padding: 0.7rem 1rem;
	font-size: 0.8125rem;
	color: var(--ftc-muted);
}

.ftc__verified {
	margin-top: 1rem;
	font-size: 0.8125rem;
	color: var(--ftc-muted);
}

.ftc__verified strong {
	color: var(--ftc-green-dark);
}

.ftc__disclaimer {
	margin-top: 1rem;
	font-size: 0.8125rem;
	line-height: 1.6;
	color: var(--ftc-muted);
	border-left: 3px solid var(--ftc-line);
	padding-left: 0.85rem;
}

/* ---------- narrow containers ---------- */

@container (max-width: 30rem) {
	.ftc__field,
	.ftc__field--narrow {
		flex: 1 1 100%;
	}

	.ftc__card-value {
		font-size: 1.2rem;
	}
}

/* ---------- dark mode ---------- */

@media (prefers-color-scheme: dark) {
	.ftc {
		--ftc-ink: #e8eef2;
		--ftc-muted: #9fb0bb;
		--ftc-line: #2b3a45;
		--ftc-bg: #131c24;
		--ftc-bg-alt: #17222c;
		--ftc-tint: rgba(66, 165, 68, 0.16);
	}

	.ftc__input,
	.ftc__select,
	.ftc__input-wrap,
	.ftc__toggle,
	.ftc__card,
	.ftc__details {
		background: #0f171e;
		color: var(--ftc-ink);
	}

	.ftc__surcharge {
		background: #2e2410;
		border-color: #5c4a1f;
		color: #f0dcb4;
	}

	.ftc__cliff {
		background: #331916;
		border-color: #6b2b25;
		color: #f4c7c2;
	}

	.ftc__cliff strong {
		color: #f4a19a;
	}
}


/* ---------- late filing calculator ---------- */

.ftp__hint {
	margin: 0.4rem 0 0;
	font-size: 0.8rem;
	color: var(--ftc-muted);
}

.ftp__row--options {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--ftc-line);
}

.ftp__checks {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
	justify-content: flex-end;
}

.ftp__check {
	display: flex;
	align-items: flex-start;
	gap: 0.55rem;
	font-size: 0.9rem;
	line-height: 1.45;
	cursor: pointer;
}

.ftp__check input {
	flex: none;
	margin-top: 0.05rem;
	/* 24px, the WCAG 2.2 minimum target size. The label is a far larger hit area, but the
	   visible box is what a finger aims at. */
	width: 1.5rem;
	height: 1.5rem;
	accent-color: var(--ftc-green);
}

/*
 * The working table is two columns of label and value, not a slab breakdown, so both
 * columns must wrap. The base .ftc__table sets white-space: nowrap, which is right for
 * columns of figures but pushes this table to 475px on a 360px screen - contained by the
 * scroller, but nobody scrolls a table sideways to read their own penalty.
 */
.ftp .ftc__table td {
	white-space: normal;
	vertical-align: top;
}

.ftp .ftc__table td:first-child {
	width: 60%;
}

@container (max-width: 30rem) {
	.ftp .ftc__table td {
		padding: 0.55rem 0.75rem;
	}

	.ftp .ftc__table td:first-child {
		width: 50%;
	}
}


/* ---------- filer status savings calculator ---------- */

.ftw__intro {
	margin: 0 0 1rem;
	font-size: 0.9rem;
	color: var(--ftc-muted);
}

.ftw__item + .ftw__item {
	margin-top: 1.1rem;
	padding-top: 1.1rem;
	border-top: 1px solid var(--ftc-line);
}

/* Section number sits beside the label as a quiet citation, not as part of the sentence. */
.ftw__sec {
	margin-left: 0.4rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	color: var(--ftc-green-dark);
	white-space: nowrap;
}

.ftw__pair {
	align-items: center;
}

.ftw__pair .ftc__input-wrap {
	flex: 1 1 12rem;
	min-width: 0;
}

.ftw__pair .ftc__select {
	flex: 1 1 11rem;
	min-width: 0;
}

.ftw__inline-label {
	flex: none;
	margin-bottom: 0;
}

.ftw__token-band {
	margin-top: 0.75rem;
	max-width: 16rem;
}

.ftw__cards {
	grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
}

.ftw__card--bad {
	border-left-color: #b3261e;
	background: #fdecea;
}

.ftw__delta {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.8rem;
	font-weight: 700;
	color: #8c1d18;
}

.ftw__card--bad .ftw__delta,
.ftw__delta {
	color: #8c1d18;
}

.ftw__headline {
	margin: 1rem 0 0;
	padding: 0.85rem 1rem;
	border-radius: 8px;
	background: var(--ftc-tint);
	border-left: 4px solid var(--ftc-green-deep);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.5;
}

.ftw__table td:first-child {
	white-space: normal;
}

.ftw__line-label {
	display: block;
}

.ftw__line-basis {
	display: block;
	margin-top: 0.15rem;
	font-size: 0.75rem;
	font-weight: 400;
	color: var(--ftc-muted);
}

.ftw__total td {
	background: var(--ftc-bg-alt);
	font-weight: 700;
}

@container (max-width: 30rem) {
	.ftw__pair .ftc__input-wrap,
	.ftw__pair .ftc__select {
		flex: 1 1 100%;
	}

	.ftw__inline-label {
		flex: 1 1 100%;
		margin-top: 0.5rem;
	}

	.ftw__table th,
	.ftw__table td {
		padding: 0.5rem 0.6rem;
		font-size: 0.8rem;
	}
}

@media (prefers-color-scheme: dark) {
	.ftw__card--bad {
		background: #331916;
		border-left-color: #b3261e;
	}

	.ftw__delta {
		color: #f4a19a;
	}

	.ftw__total td {
		background: #17222c;
	}
}
