/* =========================================================================
   Quarterly Tax Calculator - front end
   All colours, fonts and sizes come from CSS custom properties that the
   plugin prints from the admin settings. Do not hard code brand values here.
   ========================================================================= */

.tbc-app {
	--tbc-field-radius: 8px;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: var(--tbc-outer-padding, 0px);
	font-family: var(--tbc-font-body);
	color: var(--tbc-body-text);
	background: var(--tbc-page-bg);
	-webkit-font-smoothing: antialiased;
}

/* Full width: edge to edge, nothing around it. */
.tbc-app.tbc-width-full {
	max-width: none;
}

/* Boxed: centred inside the configured maximum width. */
.tbc-app.tbc-width-boxed {
	max-width: var(--tbc-max-width, 1040px);
	margin-left: auto;
	margin-right: auto;
}

.tbc-app *,
.tbc-app *::before,
.tbc-app *::after {
	box-sizing: border-box;
}

.tbc-app-title {
	font-family: var(--tbc-font-heading);
	color: var(--tbc-heading);
	font-size: calc(var(--tbc-section-title-size) * 1.3);
	margin: 0 0 18px;
	text-align: center;
}

/* ---------------------------------------------------------------- grid */

.tbc-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
	gap: var(--tbc-gap, 22px);
	align-items: start;
}

.tbc-layout-stacked .tbc-grid {
	grid-template-columns: minmax(0, 1fr);
}

.tbc-col {
	min-width: 0;
	max-width: 100%;
}

.tbc-col-results {
	display: flex;
	flex-direction: column;
	gap: var(--tbc-gap, 22px);
}

.tbc-sticky-results .tbc-col-results {
	position: sticky;
	top: 24px;
}

/* --------------------------------------------------------------- cards */

.tbc-card {
	min-width: 0;
	background: var(--tbc-card-bg);
	border: 1px solid var(--tbc-card-border);
	border-radius: var(--tbc-radius, 12px);
	box-shadow: var(--tbc-shadow);
	padding: var(--tbc-card-padding, 26px);
}

.tbc-card-head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 16px;
}

.tbc-card-head-center {
	flex-direction: column;
	gap: 10px;
	text-align: center;
	margin-bottom: 6px;
}

.tbc-card-title {
	font-family: var(--tbc-font-heading);
	color: var(--tbc-heading);
	font-size: var(--tbc-card-title-size);
	font-weight: var(--tbc-card-title-weight);
	line-height: var(--tbc-card-title-lh);
	margin: 0;
}

/* --------------------------------------------------------- icon circle */

.tbc-icon-circle {
	flex: 0 0 auto;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--tbc-icon-circle-bg);
	color: var(--tbc-icon-color);
}

.tbc-card-head-center .tbc-icon-circle {
	width: 56px;
	height: 56px;
}

.tbc-icon-circle-notes {
	color: var(--tbc-notes-icon);
}

.tbc-icon-image {
	display: block;
	object-fit: contain;
}

/* ------------------------------------------------------------ sections */

.tbc-section + .tbc-section {
	margin-top: 22px;
}

.tbc-section-head {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	margin-bottom: 18px;
}

.tbc-section-titles {
	min-width: 0;
	padding-top: 2px;
}

.tbc-section-title {
	font-family: var(--tbc-font-heading);
	color: var(--tbc-heading);
	font-size: var(--tbc-section-title-size);
	font-weight: var(--tbc-section-title-weight);
	line-height: var(--tbc-section-title-lh);
	margin: 0 0 4px;
}

.tbc-section-sub {
	font-size: var(--tbc-section-sub-size);
	font-weight: var(--tbc-section-sub-weight);
	line-height: var(--tbc-section-sub-lh);
	color: var(--tbc-muted-text);
	margin: 0;
}

.tbc-divider {
	border: 0;
	border-top: 1px solid var(--tbc-divider);
	margin: 24px 0;
}

/* -------------------------------------------------------------- fields */

.tbc-fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 15px;
	min-width: 0;
}

.tbc-field {
	min-width: 0;
	position: relative;
	grid-column: 1 / -1;
}

/*
 * Half width fields.
 *
 * The safe default is full width, because two columns only work when the form
 * column is actually wide enough, and that depends on the container rather than
 * the viewport: the same 1024px screen gives a wide column in stacked layout and
 * a narrow one in two column layout. A container query measures the real column,
 * and a browser without container query support simply keeps full width fields.
 */
.tbc-field-half {
	grid-column: 1 / -1;
}

.tbc-col-form {
	container-type: inline-size;
	container-name: tbcform;
}

@container tbcform (min-width: 520px) {
	.tbc-field-half {
		grid-column: span 1;
	}
}

/* Block, not flex, so a trailing tooltip icon flows after the last word of a
   long label instead of being pushed onto a line of its own. */
.tbc-label {
	display: block;
	font-size: var(--tbc-label-size);
	font-weight: var(--tbc-label-weight);
	line-height: var(--tbc-label-lh);
	color: var(--tbc-label-text);
	margin: 0 0 7px;
}

.tbc-label-text {
	display: inline;
}

.tbc-required {
	color: var(--tbc-accent);
	margin-left: 2px;
}

/* tooltip */

/*
 * The bubble is anchored to the field, not to the icon.
 *
 * Centring it on the icon looks tidy until the icon sits near an edge, and then
 * the bubble hangs outside the card or off the screen. Pinning it to the left of
 * the field and capping it at the field's own width means it is always inside,
 * at every viewport width and in either layout.
 */
.tbc-tip {
	position: static;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	margin: 0 0 0 5px;
	border: 0;
	background: none;
	cursor: pointer;
	color: var(--tbc-heading);
	opacity: .75;
	line-height: 0;
	vertical-align: -3px;
}

.tbc-tip:hover,
.tbc-tip:focus-visible {
	opacity: 1;
}

.tbc-tip-bubble {
	position: absolute;
	bottom: calc(100% + 7px);
	left: 0;
	right: auto;
	max-width: 100%;
	transform: translateY(4px);
	padding: 9px 12px;
	border-radius: 7px;
	background: var(--tbc-tooltip-bg);
	color: var(--tbc-tooltip-text);
	font-size: 12.5px;
	font-weight: 400;
	line-height: 1.45;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .16s ease, transform .16s ease;
	z-index: 40;
	box-shadow: 0 6px 22px rgba(0, 0, 0, .16);
}

.tbc-tip:hover .tbc-tip-bubble,
.tbc-tip:focus-visible .tbc-tip-bubble,
.tbc-tip.is-open .tbc-tip-bubble {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* The first field in a card has nothing above it, so its bubble drops below. */
.tbc-fields > .tbc-field:first-child .tbc-tip-bubble {
	bottom: auto;
	top: 100%;
	transform: translateY(-4px);
	margin-top: 4px;
}

.tbc-fields > .tbc-field:first-child .tbc-tip:hover .tbc-tip-bubble,
.tbc-fields > .tbc-field:first-child .tbc-tip:focus-visible .tbc-tip-bubble,
.tbc-fields > .tbc-field:first-child .tbc-tip.is-open .tbc-tip-bubble {
	transform: translateY(0);
}

/* money input */

.tbc-money {
	display: flex;
	align-items: stretch;
	min-width: 0;
	background: var(--tbc-input-bg);
	border: 1px solid var(--tbc-input-border);
	border-radius: var(--tbc-field-radius);
	overflow: hidden;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.tbc-money:focus-within {
	border-color: var(--tbc-input-focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--tbc-input-focus) 16%, transparent);
}

.tbc-money-prefix {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 42px;
	padding: 0 10px;
	background: var(--tbc-prefix-bg);
	border-right: 1px solid var(--tbc-input-border);
	color: var(--tbc-prefix-text);
	font-size: var(--tbc-input-size);
	font-weight: 500;
}

/* min-width:0 stops the browser's intrinsic input width from forcing the grid
   or flex parent wider than the card it sits in. */
.tbc-app .tbc-input,
.tbc-app .tbc-select {
	width: 100%;
	min-width: 0;
	max-width: 100%;
	border: 0;
	margin: 0;
	background: transparent;
	color: var(--tbc-input-text);
	font-family: var(--tbc-font-body);
	font-size: var(--tbc-input-size);
	font-weight: var(--tbc-input-weight);
	line-height: var(--tbc-input-lh);
	box-shadow: none;
	outline: none;
	min-height: 46px;
}

.tbc-app .tbc-input {
	padding: 11px 14px;
}

.tbc-app .tbc-input::placeholder {
	color: var(--tbc-placeholder);
	opacity: 1;
}

/* Plain text and number fields reuse the money shell without the prefix box. */
.tbc-money-plain .tbc-money-prefix {
	display: none;
}

/* Paragraph field */

.tbc-app .tbc-textarea {
	min-height: 92px;
	padding: 11px 14px;
	resize: vertical;
	background: var(--tbc-input-bg);
	border: 1px solid var(--tbc-input-border);
	border-radius: var(--tbc-field-radius);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.tbc-app .tbc-textarea:focus {
	border-color: var(--tbc-input-focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--tbc-input-focus) 16%, transparent);
}

/* Checkbox field */

.tbc-checkbox {
	display: inline-flex;
	align-items: flex-start;
	gap: 9px;
	cursor: pointer;
	font-size: var(--tbc-input-size);
	line-height: 1.45;
	color: var(--tbc-input-text);
	padding: 4px 0;
}

/* Visually hidden but still focusable. pointer-events is off so the real
   checkbox never sits on top of the drawn box and swallow clicks; the label
   wraps the input, so clicking anywhere on it still toggles. */
.tbc-checkbox input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	opacity: 0;
	pointer-events: none;
}

.tbc-checkbox-box {
	flex: 0 0 auto;
	width: 19px;
	height: 19px;
	margin-top: 1px;
	border: 1px solid var(--tbc-input-border);
	border-radius: 4px;
	background: var(--tbc-input-bg);
	position: relative;
	transition: background-color .12s ease, border-color .12s ease;
}

.tbc-checkbox-box::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 6px;
	width: 4px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(0);
	transition: transform .12s ease;
}

.tbc-checkbox input:checked + .tbc-checkbox-box {
	background: var(--tbc-accent);
	border-color: var(--tbc-accent);
}

.tbc-checkbox input:checked + .tbc-checkbox-box::after {
	transform: rotate(45deg) scale(1);
}

.tbc-checkbox input:focus-visible + .tbc-checkbox-box {
	outline: 2px solid var(--tbc-accent);
	outline-offset: 2px;
}

/* select */

.tbc-select-wrap {
	position: relative;
	min-width: 0;
	background: var(--tbc-input-bg);
	border: 1px solid var(--tbc-input-border);
	border-radius: var(--tbc-field-radius);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.tbc-select-wrap:focus-within {
	border-color: var(--tbc-input-focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--tbc-input-focus) 16%, transparent);
}

.tbc-app .tbc-select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	padding: 11px 40px 11px 14px;
	cursor: pointer;
	border-radius: var(--tbc-field-radius);
}

.tbc-select-chevron {
	position: absolute;
	top: 50%;
	right: 13px;
	transform: translateY(-50%);
	pointer-events: none;
	color: var(--tbc-prefix-text);
	line-height: 0;
}

/* validation */

.tbc-field-error {
	display: block;
	margin-top: 6px;
	font-size: 12.5px;
	color: #c0392b;
}

.tbc-field.is-invalid .tbc-money,
.tbc-field.is-invalid .tbc-select-wrap {
	border-color: #c0392b;
}

/* ------------------------------------------------------------- actions */

.tbc-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 22px;
}

.tbc-app .tbc-submit {
	flex: 1 1 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 15px 22px;
	border: 0;
	border-radius: var(--tbc-field-radius);
	background: var(--tbc-button-bg);
	color: var(--tbc-button-text);
	font-family: var(--tbc-font-body);
	font-size: var(--tbc-button-size);
	font-weight: var(--tbc-button-weight);
	line-height: var(--tbc-button-lh);
	cursor: pointer;
	text-transform: none;
	transition: background-color .15s ease, transform .1s ease;
}

.tbc-app .tbc-submit:hover {
	background: var(--tbc-button-bg-hover);
}

.tbc-app .tbc-submit:active {
	transform: translateY(1px);
}

.tbc-app .tbc-submit[disabled] {
	opacity: .65;
	cursor: default;
}

.tbc-submit-icon {
	display: inline-flex;
	line-height: 0;
	transition: transform .15s ease;
}

.tbc-app .tbc-submit:hover .tbc-submit-icon {
	transform: translateX(3px);
}

.tbc-app .tbc-reset {
	flex: 0 0 auto;
	padding: 15px 20px;
	border: 1px solid var(--tbc-input-border);
	border-radius: var(--tbc-field-radius);
	background: transparent;
	color: var(--tbc-muted-text);
	font-family: var(--tbc-font-body);
	font-size: var(--tbc-button-size);
	cursor: pointer;
}

.tbc-form-note {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 13px 0 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--tbc-muted-text);
}

.tbc-form-note-icon {
	flex: 0 0 auto;
	line-height: 0;
	color: var(--tbc-accent);
	margin-top: 1px;
}

/* -------------------------------------------------------- result card */

.tbc-card-result {
	background: var(--tbc-result-card-bg);
	text-align: center;
}

.tbc-result-amount {
	font-family: var(--tbc-font-heading);
	font-size: var(--tbc-result-amount-size);
	font-weight: var(--tbc-result-amount-weight);
	line-height: var(--tbc-result-amount-lh);
	color: var(--tbc-result-amount);
	margin: 6px 0 10px;
	letter-spacing: -0.5px;
	word-break: break-word;
}

.tbc-result-note {
	margin: 0 auto;
	max-width: 42ch;
	font-size: var(--tbc-note-size);
	line-height: var(--tbc-note-lh);
	color: var(--tbc-muted-text);
}

.tbc-card-result.is-updating .tbc-result-amount {
	opacity: .5;
}

/* ----------------------------------------------------- breakdown rows */

.tbc-rows {
	display: flex;
	flex-direction: column;
}

.tbc-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 11px 12px;
	border-bottom: 1px solid var(--tbc-divider);
	font-size: var(--tbc-row-size);
	line-height: var(--tbc-row-lh);
}

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

.tbc-row-label {
	color: var(--tbc-row-label);
	font-weight: 400;
}

.tbc-row-value {
	color: var(--tbc-row-value);
	font-weight: var(--tbc-row-weight);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.tbc-row-highlight {
	background: var(--tbc-row-highlight-bg);
	border-radius: 6px;
	border-bottom-color: transparent;
}

.tbc-row-highlight .tbc-row-label,
.tbc-row-highlight .tbc-row-value {
	font-weight: 700;
	color: var(--tbc-heading);
}

.tbc-row-value.is-refund {
	color: #1e7f4f;
}

/* ---------------------------------------------------------- notes card */

.tbc-card-notes {
	background: var(--tbc-notes-card-bg);
	border-color: transparent;
}

.tbc-card-notes .tbc-icon-circle {
	background: rgba(255, 255, 255, .72);
	color: var(--tbc-accent);
}

.tbc-notes {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 11px;
}

.tbc-note {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 0;
	font-size: var(--tbc-note-size);
	font-weight: var(--tbc-note-weight);
	line-height: var(--tbc-note-lh);
	color: var(--tbc-notes-text);
}

.tbc-note-icon {
	flex: 0 0 auto;
	line-height: 0;
	margin-top: 2px;
	color: var(--tbc-notes-icon);
}

/* -------------------------------------------------------------- payment */

.tbc-pay-wrap {
	margin-top: 18px;
	padding-top: 18px;
	border-top: 1px solid var(--tbc-divider);
}

.tbc-app .tbc-pay-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	width: 100%;
	padding: 14px 20px;
	border: 0;
	border-radius: var(--tbc-field-radius);
	background: var(--tbc-heading);
	color: #fff;
	font-family: var(--tbc-font-body);
	font-size: var(--tbc-button-size);
	font-weight: var(--tbc-button-weight);
	cursor: pointer;
	transition: opacity .15s ease;
}

.tbc-app .tbc-pay-button:hover {
	opacity: .9;
}

.tbc-app .tbc-pay-button[disabled] {
	opacity: .6;
	cursor: default;
}

.tbc-pay-icon {
	display: inline-flex;
	line-height: 0;
}

.tbc-pay-amount {
	font-variant-numeric: tabular-nums;
}

.tbc-pay-note {
	margin: 9px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--tbc-muted-text);
	text-align: center;
}

.tbc-pay-error {
	margin: 9px 0 0;
	font-size: 12.5px;
	color: #c0392b;
	text-align: center;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 960px) {
	.tbc-grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.tbc-sticky-results .tbc-col-results {
		position: static;
	}
}

@media (max-width: 600px) {
	.tbc-card {
		padding: 20px 18px;
	}

	.tbc-card-result {
		padding: 20px 18px 22px;
	}

	.tbc-icon-circle {
		width: 46px;
		height: 46px;
	}

	.tbc-icon-circle svg {
		width: 22px;
		height: 22px;
	}

	.tbc-result-amount {
		font-size: calc(var(--tbc-result-amount-size) * .78);
	}

	.tbc-section-title,
	.tbc-card-title {
		font-size: calc(var(--tbc-section-title-size) * .88);
	}

	.tbc-row {
		padding: 10px 8px;
		font-size: calc(var(--tbc-row-size) * .96);
	}

	.tbc-tip-bubble {
		right: 0;
		max-width: none;
	}
}

/* ------------------------------------------------------------- a11y */

@media (prefers-reduced-motion: reduce) {
	.tbc-app *,
	.tbc-app *::before,
	.tbc-app *::after {
		transition-duration: .01ms !important;
		animation-duration: .01ms !important;
	}
}

.tbc-app :focus-visible {
	outline: 2px solid var(--tbc-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------------- breakdown card */

.tbc-card-breakdown {
	background: var(--tbc-breakdown-bg);
}

/* --------------------------------------------------- result lead line */

.tbc-result-lead {
	margin: 0 auto 6px;
	font-size: var(--tbc-note-size);
	line-height: var(--tbc-note-lh);
	color: var(--tbc-body-text);
}

/* ------------------------------------------ a field with no label of its own */

.tbc-field-nolabel {
	margin-top: -6px;
}

/* An amount the calculator fills in for you reads as fixed, not broken. */
.tbc-field.is-locked .tbc-money {
	background: var(--tbc-prefix-bg);
}

.tbc-field.is-locked .tbc-input {
	color: var(--tbc-prefix-text);
	cursor: default;
}

/* No deduction chosen: the amount line has nothing to show. */
.tbc-field.is-hidden {
	display: none;
}

/* --------------------------------------------------------- bracket table */

.tbc-card-table {
	background: var(--tbc-table-card-bg);
	border-color: transparent;
}

.tbc-table-head {
	display: flex;
	align-items: center;
	gap: 7px;
	flex-wrap: wrap;
	margin-bottom: 14px;
	position: relative;
}

.tbc-table-head .tbc-card-title {
	margin: 0;
}

.tbc-tip-block {
	position: static;
}

.tbc-table-head .tbc-tip-bubble {
	left: 0;
	right: auto;
	max-width: 100%;
}

/* The table scrolls on its own rather than stretching the page. */
.tbc-table-scroll {
	min-width: 0;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border-radius: 8px;
	background: var(--tbc-table-cell-bg);
	border: 1px solid var(--tbc-table-border);
}

.tbc-app .tbc-bracket-table {
	width: 100%;
	min-width: 0;
	border-collapse: collapse;
	table-layout: auto;
	margin: 0;
	background: var(--tbc-table-cell-bg);
	font-size: var(--tbc-table-size);
	line-height: var(--tbc-table-lh);
	color: var(--tbc-table-text);
}

.tbc-app .tbc-bracket-table th,
.tbc-app .tbc-bracket-table td {
	padding: 9px 12px;
	text-align: center;
	border-right: 1px solid var(--tbc-table-border);
	border-bottom: 1px solid var(--tbc-table-border);
	background: none;
	font-variant-numeric: tabular-nums;
	/* Ranges hold together on one line, but a cramped column may wrap rather
	   than push the whole table out past the card. */
	white-space: nowrap;
}

@media (max-width: 1240px) {
	.tbc-app .tbc-bracket-table th,
	.tbc-app .tbc-bracket-table td {
		padding: 9px 8px;
		white-space: normal;
	}
}

.tbc-app .tbc-bracket-table th:last-child,
.tbc-app .tbc-bracket-table td:last-child {
	border-right: 0;
}

.tbc-app .tbc-bracket-table tr:last-child th,
.tbc-app .tbc-bracket-table tr:last-child td {
	border-bottom: 0;
}

.tbc-app .tbc-bracket-table thead th {
	font-family: var(--tbc-font-body);
	font-weight: 700;
	color: var(--tbc-heading);
}

.tbc-app .tbc-bracket-table tbody th.tbc-col-rate {
	font-weight: 600;
	color: var(--tbc-heading);
}

.tbc-bracket-table tbody tr.is-active {
	background: var(--tbc-table-active-bg);
}

.tbc-bracket-table td.is-active-col {
	font-weight: 700;
	color: var(--tbc-heading);
}

.tbc-bracket-table tbody tr.is-active td.is-active-col {
	box-shadow: inset 0 0 0 2px var(--tbc-accent);
	border-radius: 4px;
}

.tbc-table-note {
	margin: 12px 0 0;
	font-size: var(--tbc-table-note-size);
	font-weight: var(--tbc-table-note-weight);
	line-height: var(--tbc-table-note-lh);
	color: var(--tbc-table-note);
}

@media (max-width: 600px) {
	.tbc-app .tbc-bracket-table th,
	.tbc-app .tbc-bracket-table td {
		padding: 8px 9px;
		font-size: calc(var(--tbc-table-size) * .94);
	}
}
