/**
 * Academy Fence Resources: shared tokens and components.
 *
 * Every token maps to the Academy theme's variables (--afb-*), then to the
 * theme.json presets (--wp--preset--*). The hex values are fallbacks only,
 * so the tools follow the theme's colors, fonts and button shapes.
 */

.ar-tool,
.ar-related,
.ar-hub {
	--ar-primary: var(--afb-primary, var(--wp--preset--color--primary, #cd1141));
	--ar-primary-dark: var(--afb-primary-dark, var(--wp--preset--color--primary-dark, #9a0d31));
	--ar-accent: var(--afb-accent, var(--wp--preset--color--accent, #332e1f));
	--ar-accent-dark: var(--afb-accent-dark, var(--wp--preset--color--accent-dark, #1f1c13));
	--ar-on-accent: var(--afb-on-accent, var(--wp--preset--color--on-accent, #fff));
	--ar-text: var(--afb-text, var(--wp--preset--color--text, #332e1f));
	--ar-muted: var(--afb-muted, var(--wp--preset--color--muted, #666));
	--ar-light: var(--afb-light, var(--wp--preset--color--light, #f7f7f7));
	--ar-border: var(--afb-border, var(--wp--preset--color--border, #e6e6e6));
	--ar-white: var(--afb-white, #fff);
	--ar-font-heading: var(--afb-font-heading, var(--wp--preset--font-family--heading, inherit));
	--ar-font-body: var(--afb-font-body, var(--wp--preset--font-family--body, inherit));
	--ar-radius: clamp(10px, calc(var(--afb-radius, 16px) * 0.6), 20px);
	--ar-radius-sm: 10px;
	--ar-btn-radius: var(--afb-button-radius, 999px);
	--ar-shadow: var(--afb-shadow-sm, 0 1px 2px rgba(16, 24, 20, 0.06), 0 1px 3px rgba(16, 24, 20, 0.08));
	--ar-focus: var(--ar-primary);
	--ar-ok: #14532d;
	--ar-ok-bg: #e8f5ec;
	--ar-warn: #7a4b00;
	--ar-warn-bg: #fff4dc;
	--ar-err: #8a1c1c;
	--ar-err-bg: #fdecec;
	--ar-gap: clamp(1rem, 3vw, 1.5rem);

	color: var(--ar-text);
	font-family: var(--ar-font-body);
	line-height: 1.55;
}

.ar-tool *,
.ar-tool *::before,
.ar-tool *::after,
.ar-related *,
.ar-hub * {
	box-sizing: border-box;
}

.ar-tool {
	margin-block: var(--ar-gap) calc(var(--ar-gap) * 2);
}

/* Without JavaScript, show the fallback and hide the interactive part. */
.ar-tool:not(.ar-js) .ar-app {
	display: none;
}

.ar-tool.ar-js .ar-fallback {
	display: none;
}

.ar-preview {
	pointer-events: none;
}

.ar-fallback {
	padding: var(--ar-gap);
	border: 1px solid var(--ar-border);
	border-radius: var(--ar-radius);
	background: var(--ar-light);
}

.ar-fallback__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-bottom: 0;
}

.ar-visually-hidden,
.ar-hp {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.ar-tool [hidden] {
	display: none !important;
}

/* ------------------------------------------------------------ Panels */

.ar-panel {
	padding: clamp(1.25rem, 4vw, 2rem);
	border: 1px solid var(--ar-border);
	border-radius: var(--ar-radius);
	background: var(--ar-white);
	box-shadow: var(--ar-shadow);
}

.ar-panel--light {
	background: var(--ar-light);
	box-shadow: none;
}

.ar-tool__title {
	margin: 0 0 0.35rem;
	font-family: var(--ar-font-heading);
	font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
	line-height: 1.2;
}

.ar-tool__lede {
	margin: 0 0 1.25rem;
	color: var(--ar-muted);
}

.ar-step__title {
	margin: 0 0 0.5rem;
	font-family: var(--ar-font-heading);
	font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.45rem);
	line-height: 1.25;
}

.ar-step__title:focus {
	outline: none;
}

.ar-step__help {
	margin: 0 0 1rem;
	color: var(--ar-muted);
	font-size: 0.95rem;
}

.ar-layout {
	display: grid;
	gap: var(--ar-gap);
	align-items: start;
}

@media (min-width: 900px) {
	.ar-layout--split {
		grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
	}

	.ar-layout--split > .ar-sticky {
		position: sticky;
		top: calc(var(--afb-header-h, 0px) + 16px);
	}
}

.ar-grid {
	display: grid;
	gap: 0 1rem;
}

@media (min-width: 560px) {
	.ar-grid--2 {
		grid-template-columns: 1fr 1fr;
	}

	.ar-grid--3 {
		grid-template-columns: repeat(3, 1fr);
	}
}

/*
 * The theme indents every list in .entry-content with a selector of
 * specificity (0,5,0) and spaces "li + li". The plugin's lists are layout,
 * not prose, so they reset both.
 */
.ar-tool .ar-progress,
.ar-tool .ar-mt__runs,
.ar-tool .ar-mt__gates,
.ar-cards,
.ar-pill-links {
	padding: 0 !important;
}

.ar-tool .ar-progress li + li,
.ar-tool .ar-mt__runs > li + li,
.ar-tool .ar-mt__gates > li + li,
.ar-tool .ar-cards > li + li,
.ar-hub .ar-cards > li + li,
.ar-related .ar-cards > li + li,
.ar-related .ar-pill-links > li + li {
	margin-top: 0;
}

/* ---------------------------------------------------------- Progress */

.ar-progress {
	display: flex;
	gap: 0.35rem;
	margin: 0 0 0.35rem !important;
	padding: 0;
	list-style: none;
}

.ar-progress li {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: var(--ar-border);
	overflow: hidden;
	text-indent: -9999px;
}

.ar-progress li.is-done,
.ar-progress li.is-current {
	background: var(--ar-primary);
}

.ar-progress li.is-current {
	background: linear-gradient(90deg, var(--ar-primary) 50%, var(--ar-border) 50%);
}

.ar-progress__status {
	margin: 0 0 1rem;
	color: var(--ar-muted);
	font-size: 0.875rem;
}

.ar-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	justify-content: space-between;
	margin-top: 1.25rem;
}

.ar-nav > :only-child {
	margin-left: auto;
}

/* ----------------------------------------------------------- Buttons */

.ar-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 48px;
	padding: 0.7rem 1.4rem;
	border: 2px solid transparent;
	border-radius: var(--ar-btn-radius);
	font-family: var(--ar-font-heading);
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.ar-btn:focus-visible,
.ar-tool a:focus-visible,
.ar-related a:focus-visible,
.ar-hub a:focus-visible {
	outline: 2px solid var(--ar-focus);
	outline-offset: 3px;
}

.ar-btn--primary {
	background: var(--ar-accent);
	color: var(--ar-on-accent);
}

.ar-btn--primary:hover {
	background: var(--ar-accent-dark);
	color: var(--ar-on-accent);
}

.ar-btn--brand {
	background: var(--ar-primary);
	color: #fff;
}

.ar-btn--brand:hover {
	background: var(--ar-primary-dark);
	color: #fff;
}

.ar-btn--secondary {
	background: var(--ar-white);
	border-color: var(--ar-border);
	color: var(--ar-text);
}

.ar-btn--secondary:hover {
	border-color: var(--ar-text);
	color: var(--ar-text);
}

.ar-btn--link {
	min-height: 44px;
	padding-inline: 0.25rem;
	background: none;
	color: var(--ar-text);
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.ar-btn--block {
	display: flex;
	width: 100%;
}

.ar-btn[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

.ar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-top: 1.25rem;
}

@media (max-width: 559px) {
	.ar-actions > .ar-btn {
		flex: 1 1 100%;
	}
}

/* ------------------------------------------------------------ Fields */

.ar-field {
	margin: 0 0 1rem;
	min-width: 0;
}

fieldset.ar-field {
	padding: 0;
	border: 0;
}

.ar-label {
	display: block;
	margin-bottom: 0.35rem;
	font-size: 0.95rem;
	font-weight: 600;
}

legend.ar-label {
	padding: 0;
}

.ar-hint {
	margin: -0.15rem 0 0.4rem;
	color: var(--ar-muted);
	font-size: 0.875rem;
}

.ar-input,
.ar-select {
	display: block;
	width: 100%;
	min-height: 48px;
	padding: 0.65rem 0.85rem;
	border: 1px solid #8a8a8a;
	border-radius: var(--ar-radius-sm);
	background: var(--ar-white);
	color: var(--ar-text);
	font: inherit;
	font-size: max(16px, 1rem);
}

textarea.ar-input {
	min-height: 96px;
	resize: vertical;
}

.ar-input:focus,
.ar-select:focus {
	outline: 2px solid var(--ar-focus);
	outline-offset: 1px;
	border-color: var(--ar-focus);
}

.ar-input[aria-invalid="true"] {
	border-color: var(--ar-err);
}

.ar-input--big {
	font-size: 1.5rem;
	font-weight: 600;
}

.ar-input-unit {
	display: flex;
	align-items: stretch;
}

.ar-input-unit .ar-input {
	border-top-right-radius: 0;
	border-bottom-right-radius: 0;
}

.ar-input-unit__suffix {
	display: flex;
	align-items: center;
	padding: 0 0.9rem;
	border: 1px solid #8a8a8a;
	border-left: 0;
	border-radius: 0 var(--ar-radius-sm) var(--ar-radius-sm) 0;
	background: var(--ar-light);
	color: var(--ar-muted);
	font-weight: 600;
}

.ar-field__error {
	margin: 0.35rem 0 0;
	color: var(--ar-err);
	font-size: 0.875rem;
	font-weight: 600;
}

.ar-field__error::before {
	content: "! ";
}

.ar-field--check {
	display: flex;
	gap: 0.65rem;
	align-items: flex-start;
}

.ar-field--check .ar-label {
	margin: 0;
	font-weight: 400;
	font-size: 0.9rem;
}

.ar-check,
.ar-radio {
	flex: none;
	width: 22px;
	height: 22px;
	margin: 0.1rem 0 0;
	accent-color: var(--ar-accent);
}

.ar-choices--inline {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
}

.ar-choices--inline legend {
	flex: 1 1 100%;
}

.ar-choice-inline {
	display: inline-flex;
	gap: 0.5rem;
	align-items: center;
	min-height: 44px;
}

.ar-choice-inline label {
	cursor: pointer;
}

/* Option cards (radio/checkbox styled as tappable cards). */
.ar-options {
	display: grid;
	gap: 0.65rem;
	margin: 0;
	padding: 0;
	border: 0;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
}

.ar-options--wide {
	grid-template-columns: 1fr;
}

@media (min-width: 560px) {
	.ar-options--wide {
		grid-template-columns: 1fr 1fr;
	}
}

.ar-option {
	position: relative;
}

.ar-option input {
	position: absolute;
	opacity: 0;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.ar-option__card {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	height: 100%;
	min-height: 56px;
	padding: 0.75rem 0.9rem;
	border: 2px solid var(--ar-border);
	border-radius: var(--ar-radius-sm);
	background: var(--ar-white);
	transition: border-color 0.15s, background-color 0.15s;
}

.ar-option__card::after {
	content: "";
	flex: none;
	width: 22px;
	height: 22px;
	margin-left: auto;
	border: 2px solid #8a8a8a;
	border-radius: 50%;
	background: var(--ar-white);
}

.ar-option input[type="checkbox"] + .ar-option__card::after {
	border-radius: 5px;
}

.ar-option input:checked + .ar-option__card {
	border-color: var(--ar-accent);
	background: var(--ar-light);
}

.ar-option input:checked + .ar-option__card::after {
	border-color: var(--ar-accent);
	background: var(--ar-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.ar-option input:focus-visible + .ar-option__card {
	outline: 2px solid var(--ar-focus);
	outline-offset: 2px;
}

.ar-option input:disabled + .ar-option__card {
	opacity: 0.55;
}

.ar-option:hover input:not(:disabled) + .ar-option__card {
	border-color: var(--ar-text);
}

.ar-option__media {
	flex: none;
	width: 56px;
	height: 56px;
	border-radius: 8px;
	overflow: hidden;
	background: var(--ar-light);
}

.ar-option__media img,
.ar-option__media svg {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ar-option__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ar-option__label {
	font-weight: 600;
	line-height: 1.3;
}

.ar-option__desc {
	color: var(--ar-muted);
	font-size: 0.875rem;
	line-height: 1.35;
}

/* Number stepper (- 0 +). */
.ar-counter {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	justify-content: space-between;
	padding: 0.65rem 0;
	border-bottom: 1px solid var(--ar-border);
}

.ar-counter__label {
	font-weight: 600;
}

.ar-counter__label small {
	display: block;
	color: var(--ar-muted);
	font-weight: 400;
}

.ar-counter__controls {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.ar-counter__btn {
	width: 44px;
	height: 44px;
	border: 2px solid var(--ar-border);
	border-radius: 50%;
	background: var(--ar-white);
	color: var(--ar-text);
	font-size: 1.35rem;
	line-height: 1;
	cursor: pointer;
}

.ar-counter__btn:hover {
	border-color: var(--ar-text);
}

.ar-counter__btn:focus-visible {
	outline: 2px solid var(--ar-focus);
	outline-offset: 2px;
}

.ar-counter__value {
	width: 3.2rem;
	min-height: 44px;
	border: 0;
	background: transparent;
	color: var(--ar-text);
	font: inherit;
	font-size: 1.15rem;
	font-weight: 700;
	text-align: center;
}

/* ----------------------------------------------------------- Results */

.ar-result {
	padding: clamp(1.25rem, 4vw, 1.75rem);
	border-radius: var(--ar-radius);
	background: var(--ar-light);
}

.ar-result__label {
	margin: 0 0 0.25rem;
	color: var(--ar-muted);
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ar-result__value {
	margin: 0 0 0.5rem;
	font-family: var(--ar-font-heading);
	font-size: clamp(2rem, 1.5rem + 2.5vw, 2.9rem);
	font-weight: 600;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.ar-result__sub {
	margin: 0 0 1rem;
	color: var(--ar-muted);
}

.ar-tool .ar-breakdown {
	width: 100%;
	margin: 1rem 0;
	border: 0;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

/* Win over theme rules like ".entry-content td" with one extra class. */
.ar-tool .ar-breakdown th,
.ar-tool .ar-breakdown td,
.ar-tool .ar-table th,
.ar-tool .ar-table td {
	border-width: 0 0 1px;
	border-style: solid;
	border-color: var(--ar-border);
	background: none;
}


.ar-tool .ar-breakdown th,
.ar-tool .ar-breakdown td {
	padding: 0.45rem 0;
	border-bottom: 1px solid var(--ar-border);
	text-align: left;
	vertical-align: top;
}

.ar-tool .ar-breakdown td:last-child,
.ar-tool .ar-breakdown th:last-child {
	text-align: right;
	white-space: nowrap;
}

.ar-tool .ar-breakdown tfoot th,
.ar-tool .ar-breakdown tfoot td {
	border-bottom: 0;
	font-weight: 700;
}

.ar-tool .ar-table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-size: 0.95rem;
	font-variant-numeric: tabular-nums;
}

.ar-tool .ar-table caption {
	margin-bottom: 0.5rem;
	font-family: var(--ar-font-heading);
	font-size: 1.15rem;
	text-align: left;
}

.ar-tool .ar-table th,
.ar-tool .ar-table td {
	padding: 0.6rem 0.5rem;
	border-bottom: 1px solid var(--ar-border);
	text-align: left;
}

.ar-tool .ar-table th:first-child,
.ar-tool .ar-table td:first-child {
	padding-left: 0;
}

.ar-tool .ar-table .is-num {
	text-align: right;
	white-space: nowrap;
}

.ar-tool .ar-table tr.is-current td,
.ar-tool .ar-table tr.is-current th {
	font-weight: 700;
}

.ar-tool .ar-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.ar-disclaimer {
	margin: 1rem 0 0;
	color: var(--ar-muted);
	font-size: 0.85rem;
}

.ar-notice {
	margin: 0 0 1rem;
	padding: 0.85rem 1rem;
	border-left: 4px solid var(--ar-primary);
	border-radius: 6px;
	background: var(--ar-light);
	font-size: 0.95rem;
}

.ar-notice--warn {
	border-color: #b7791f;
	background: var(--ar-warn-bg);
	color: var(--ar-warn);
}

.ar-notice--ok {
	border-color: var(--ar-ok);
	background: var(--ar-ok-bg);
	color: var(--ar-ok);
}

.ar-notice p {
	margin: 0;
}

/* -------------------------------------------------------- Lead form */

.ar-lead-slot {
	margin-top: var(--ar-gap);
	scroll-margin-top: calc(var(--afb-header-h, 0px) + 16px);
}

.ar-lead,
.ar-thanks {
	padding: clamp(1.25rem, 4vw, 2rem);
	border: 1px solid var(--ar-border);
	border-radius: var(--ar-radius);
	background: var(--ar-white);
	box-shadow: var(--ar-shadow);
}

.ar-lead__title {
	margin: 0 0 0.35rem;
	font-family: var(--ar-font-heading);
	font-size: 1.4rem;
	line-height: 1.25;
}

.ar-lead__title:focus {
	outline: none;
}

.ar-lead__intro {
	margin: 0 0 1rem;
	color: var(--ar-muted);
}

.ar-lead__privacy {
	margin: 0.75rem 0 0;
	color: var(--ar-muted);
	font-size: 0.85rem;
	text-align: center;
}

.ar-form-status:not(:empty) {
	margin: 0 0 1rem;
	padding: 0.75rem 1rem;
	border-radius: 6px;
	background: var(--ar-err-bg);
	color: var(--ar-err);
	font-weight: 600;
}

.ar-thanks {
	border-color: var(--ar-ok);
	background: var(--ar-ok-bg);
}

.ar-thanks p {
	margin: 0.5rem 0 0;
}

.ar-turnstile {
	margin-bottom: 1rem;
}

/* ------------------------------------------- Related tools and hub cards */

.ar-related {
	margin-block: calc(var(--ar-gap) * 2);
}

.ar-related__title {
	margin: 0 0 1rem;
}

.ar-related__subtitle {
	margin: 1.5rem 0 0.75rem;
	font-size: 1.15rem;
}

.ar-cards {
	display: grid;
	gap: 1rem;
	margin: 0 !important;
	padding: 0;
	list-style: none;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.ar-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1.25rem;
	border: 1px solid var(--ar-border);
	border-radius: var(--ar-radius);
	background: var(--ar-white);
	box-shadow: var(--ar-shadow);
	transition: border-color 0.2s, box-shadow 0.2s;
}

.ar-card:hover {
	border-color: var(--ar-text);
}

.ar-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: var(--ar-light);
	color: var(--ar-primary);
}

.ar-icon {
	width: 24px;
	height: 24px;
}

.ar-card__title {
	margin: 0.25rem 0 0;
	font-family: var(--ar-font-heading);
	font-size: 1.2rem;
	line-height: 1.3;
}

.ar-card__title a {
	color: inherit;
	text-decoration: none;
}

/* Whole card is clickable; the link stays the accessible name. */
.ar-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.ar-card__text {
	margin: 0;
	color: var(--ar-muted);
	font-size: 0.95rem;
}

.ar-card__more {
	margin-top: auto;
	padding-top: 0.5rem;
	color: var(--ar-primary);
	font-weight: 600;
}

.ar-pill-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0 !important;
	padding: 0;
	list-style: none;
}

.ar-pill-links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0.4rem 1rem;
	border: 1px solid var(--ar-border);
	border-radius: 999px;
	color: var(--ar-text);
	text-decoration: none;
}

.ar-pill-links a:hover {
	border-color: var(--ar-text);
}

/* ------------------------------------------------------ Compact teasers */

.ar-compact {
	padding: clamp(1rem, 3vw, 1.5rem);
	border-radius: var(--ar-radius);
	background: var(--ar-light);
}

.ar-compact__title {
	margin: 0 0 0.75rem;
	font-family: var(--ar-font-heading);
	font-size: 1.3rem;
	line-height: 1.25;
}

.ar-compact__row {
	display: grid;
	gap: 0.75rem;
	align-items: end;
}

@media (min-width: 700px) {
	.ar-compact__row {
		grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
	}
}

.ar-compact .ar-field {
	margin: 0;
}

@media print {
	.ar-tool .ar-btn,
	.ar-related,
	.ar-lead-slot {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ar-tool *,
	.ar-hub * {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
