/* fly-jpn core components. Uses theme tokens when present, with fallbacks so a theme swap still renders. */
:root {
	--fj-ink: var(--wp--preset--color--ink, #1A2230);
	--fj-muted: var(--wp--preset--color--muted, #5B6676);
	--fj-rule: var(--wp--preset--color--rule, #D5DAE1);
	--fj-surface: var(--wp--preset--color--surface, #FFFFFF);
	--fj-paper: var(--wp--preset--color--paper, #F6F7F9);
	--fj-red: var(--wp--preset--color--line-red, #D7141A);
	--fj-blue: var(--wp--preset--color--guide-blue, #0068B7);
	--fj-blue-dark: var(--wp--preset--color--guide-blue-dark, #004F8C);
	--fj-tint-blue: var(--wp--preset--color--tint-blue, #E8F1F9);
	--fj-tint-amber: var(--wp--preset--color--tint-amber, #FFF4D6);
	--fj-r: 3px;
	--fj-r-badge: 6px;
}

/* ---------- Buttons ---------- */
.fj-btn {
	display: inline-flex; align-items: center; justify-content: center;
	min-height: 44px; padding: 0.6rem 1.15rem;
	background: var(--fj-blue); color: #fff; border-radius: var(--fj-r);
	font-weight: 700; text-decoration: none; white-space: nowrap; border: 0; cursor: pointer;
	font: inherit; font-weight: 700;
}
.fj-btn:hover { background: var(--fj-blue-dark); color: #fff; }
.fj-btn:focus-visible { outline: 2px solid var(--fj-ink); outline-offset: 2px; }
.fj-btn--small { min-height: 40px; padding: 0.4rem 0.9rem; font-size: 0.9rem; }

/* ---------- Network badge (station-number style) ---------- */
.fj-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--fj-ink); white-space: nowrap; vertical-align: middle; }
.fj-badge__code {
	display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem;
	border: 3px solid var(--fj-line); border-radius: var(--fj-r-badge); background: #fff;
	font-weight: 800; font-size: 0.8rem; line-height: 1; color: var(--fj-ink);
}

/* ---------- Notices ---------- */
.fj-disclosure {
	display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap;
	margin-block: 0 1.5rem; padding: 0.6rem 0.8rem;
	background: var(--fj-surface); border: 1px solid var(--fj-rule); border-left: 4px solid var(--fj-ink); border-radius: var(--fj-r);
	font-size: 0.9rem; color: var(--fj-muted);
}
.fj-disclosure__tag { font-weight: 700; color: var(--fj-ink); white-space: nowrap; }
.fj-sample {
	margin: 0 0 0.75rem; padding: 0.45rem 0.75rem; background: var(--fj-tint-amber);
	border-radius: var(--fj-r); font-size: 0.85rem; font-weight: 600;
}
.fj-verified { font-size: 0.85rem; color: var(--fj-muted); white-space: nowrap; }
.fj-verified--no { color: #8A5A00; }

/* ---------- Comparison table ---------- */
.fj-compare__controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.fj-seg { display: inline-flex; border: 1px solid var(--fj-rule); border-radius: var(--fj-r); background: var(--fj-surface); overflow: hidden; }
.fj-seg__btn { font: inherit; font-size: 0.9rem; min-height: 40px; padding: 0.35rem 0.85rem; border: 0; border-right: 1px solid var(--fj-rule); background: transparent; color: var(--fj-ink); cursor: pointer; }
.fj-seg__btn:last-child { border-right: 0; }
.fj-seg__btn[aria-pressed="true"] { background: var(--fj-ink); color: #fff; }
.fj-seg__btn:focus-visible { outline: 2px solid var(--fj-blue); outline-offset: -2px; }
.fj-sort { font-size: 0.9rem; display: inline-flex; gap: 0.5rem; align-items: center; }
.fj-sort select, .fj-calc select, .fj-calc input {
	font: inherit; font-size: 0.95rem; min-height: 40px; padding: 0.3rem 0.5rem;
	border: 1px solid var(--fj-rule); border-radius: var(--fj-r); background: var(--fj-surface); color: var(--fj-ink);
}
.fj-table-wrap { background: var(--fj-surface); border: 1px solid var(--fj-rule); border-radius: var(--fj-r); }
.fj-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.fj-table th, .fj-table td { padding: 0.7rem 0.75rem; text-align: left; border-bottom: 1px solid var(--fj-rule); vertical-align: middle; }
.fj-table thead th { font-size: 0.85rem; font-weight: 700; color: var(--fj-muted); background: var(--fj-paper); white-space: nowrap; }
.fj-table thead th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.fj-table thead th[aria-sort="ascending"] button::after { content: " ▲"; font-size: 0.7em; }
.fj-table thead th[aria-sort="descending"] button::after { content: " ▼"; font-size: 0.7em; }
.fj-table tbody tr:last-child > * { border-bottom: 0; }
.fj-table tbody th { font-weight: 700; }
.fj-table__prov { display: block; margin-bottom: 0.3rem; }
.fj-table__prov a { color: var(--fj-ink); }
.fj-type { display: block; font-size: 0.8rem; color: var(--fj-muted); }
.fj-table__go { text-align: right; }
.fj-compare__note { font-size: 0.85rem; color: var(--fj-muted); margin-top: 0.6rem; }

@media (max-width: 860px) {
	.fj-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	.fj-table, .fj-table tbody { display: block; }
	.fj-table tbody tr {
		display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem;
		padding: 0.9rem; border-bottom: 1px solid var(--fj-rule);
	}
	.fj-table tbody tr[hidden] { display: none; }
	.fj-table tbody tr:last-child { border-bottom: 0; }
	.fj-table tbody th, .fj-table tbody td { padding: 0; border: 0; }
	.fj-table tbody th { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 1.05rem; }
	.fj-table__prov { margin: 0; }
	.fj-table tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--fj-muted); }
	.fj-table tbody td[data-label="Plan"] { grid-column: 1 / -1; }
	.fj-table__go { grid-column: 1 / -1; text-align: left; margin-top: 0.4rem; }
	.fj-table__go .fj-btn { width: 100%; }
}

/* ---------- Quick picks ---------- */
.fj-picks__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--fj-rule); }
.fj-pick {
	display: grid; gap: 0.75rem 1.5rem; padding: 1.25rem 0; border-bottom: 1px solid var(--fj-rule);
	grid-template-columns: 1fr;
}
@media (min-width: 760px) {
	.fj-pick { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) auto; align-items: center; }
}
.fj-pick__label { margin: 0 0 0.2rem; font-size: 0.9rem; font-weight: 700; color: var(--fj-red); }
.fj-pick__name { margin: 0 0 0.35rem; font-size: 1.35rem; }
.fj-pick__name a { color: var(--fj-ink); text-decoration: none; }
.fj-pick__name a:hover { text-decoration: underline; }
.fj-pick__why { margin: 0.5rem 0 0; color: var(--fj-muted); font-size: 0.95rem; }
.fj-pick__facts, .fj-summary__facts { display: grid; grid-template-columns: repeat(3, auto); gap: 0.25rem 1.25rem; margin: 0; font-variant-numeric: tabular-nums; }
.fj-pick__facts dt, .fj-summary__facts dt { font-size: 0.8rem; color: var(--fj-muted); }
.fj-pick__facts dd, .fj-summary__facts dd { margin: 0; font-weight: 700; }
.fj-pick__go { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
@media (min-width: 760px) { .fj-pick__go { align-items: flex-end; } }

/* ---------- Review summary ---------- */
.fj-summary { background: var(--fj-surface); border: 1px solid var(--fj-rule); border-top: 6px solid var(--fj-red); border-radius: var(--fj-r); padding: 1.1rem 1.25rem; margin-block: 1.5rem; }
.fj-summary__facts { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.9rem 1.25rem; }
.fj-summary__go { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 1.1rem; }

/* ---------- Test slot ---------- */
.fj-test { border: 1px dashed var(--fj-rule); border-radius: var(--fj-r); padding: 1rem 1.25rem; background: var(--fj-surface); }
.fj-test__title { margin: 0 0 0.4rem; font-size: 1.1rem; }
.fj-test p { margin: 0; color: var(--fj-muted); }

/* ---------- Plan finder: questions as stops on a route line ---------- */
.fj-finder { background: var(--fj-surface); border: 1px solid var(--fj-rule); border-radius: var(--fj-r); padding: 1.25rem 1.25rem 1.5rem; }
.fj-route { list-style: none; margin: 0; padding: 0 0 0 1.75rem; position: relative; }
.fj-route::before { content: ""; position: absolute; left: 0.55rem; top: 0.6rem; bottom: 1.4rem; width: 6px; background: var(--fj-red); border-radius: 3px; }
.fj-route__stop { position: relative; padding-bottom: 1.1rem; }
.fj-route__stop::before {
	content: ""; position: absolute; left: -1.6rem; top: 0.25rem; width: 1.05rem; height: 1.05rem;
	background: #fff; border: 4px solid var(--fj-red); border-radius: 50%; box-sizing: border-box;
}
.fj-route__stop--end { padding-bottom: 0; }
.fj-route__stop--end::before { background: var(--fj-red); }
.fj-route fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fj-route legend { font-weight: 700; padding: 0; margin-bottom: 0.5rem; }
.fj-choices { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.fj-choice { position: relative; }
.fj-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fj-choice span {
	display: inline-block; padding: 0.45rem 0.8rem; min-height: 40px; box-sizing: border-box;
	border: 1px solid var(--fj-rule); border-radius: var(--fj-r); background: var(--fj-paper); font-size: 0.95rem;
}
.fj-choice input:checked + span { background: var(--fj-ink); border-color: var(--fj-ink); color: #fff; }
.fj-choice input:focus-visible + span { outline: 2px solid var(--fj-blue); outline-offset: 2px; }
.fj-finder__result { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--fj-rule); }
.fj-finder__title { margin: 0 0 0.3rem; font-size: 1.35rem; }
.fj-finder__title:focus { outline: none; }
.fj-finder .fj-sample { margin-top: 1rem; margin-bottom: 0; }

/* ---------- Options list (finder + calculator) ---------- */
.fj-options { list-style: none; margin: 0.75rem 0; padding: 0; }
.fj-option {
	display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 1rem; align-items: center;
	padding: 0.75rem 0; border-bottom: 1px solid var(--fj-rule);
}
.fj-option__who a { color: var(--fj-ink); }
.fj-option__meta { display: block; font-size: 0.85rem; color: var(--fj-muted); }
.fj-option__cost { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.fj-option .fj-btn { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 600px) {
	.fj-option { grid-template-columns: 1fr auto auto; }
	.fj-option .fj-btn { grid-column: auto; }
}

/* ---------- Calculator ---------- */
.fj-calc { background: var(--fj-surface); border: 1px solid var(--fj-rule); border-radius: var(--fj-r); padding: 1.25rem; }
.fj-calc__form { display: grid; gap: 0.75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.fj-calc__form label { display: grid; gap: 0.3rem; font-weight: 700; font-size: 0.9rem; }
.fj-calc__lead { margin: 1rem 0 0; font-weight: 700; }

/* ---------- Sticky mobile CTA ---------- */
.fj-sticky { display: none; }
@media (max-width: 760px) {
	.fj-sticky {
		display: flex; position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
		justify-content: space-between; align-items: center; gap: 0.75rem;
		padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
		background: var(--fj-surface); border-top: 1px solid var(--fj-rule);
	}
	.fj-sticky__text { display: flex; flex-direction: column; line-height: 1.3; font-size: 0.9rem; }
	body.fj-has-sticky { padding-bottom: 4.5rem; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Padding inside the column width, so boxes line up with the text. */
.fj-summary, .fj-test, .fj-disclosure, .fj-finder, .fj-calc, .fj-table-wrap, .fj-sample { box-sizing: border-box; }
.fj-calc select, .fj-calc input { width: 100%; min-width: 0; box-sizing: border-box; }
.fj-btn { box-sizing: border-box; }
@media (max-width: 860px) {
	.fj-table tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem 0.75rem; }
	.fj-table tbody td[data-label] { font-size: 0.95rem; }
}

/* ---------- Test results ---------- */
.fj-tests { display: grid; gap: 1.25rem; }
.fj-tests .fj-test { border-style: solid; padding: 1.25rem; }
.fj-test__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-bottom: 0.9rem; }
.fj-test__head .fj-test__title { margin: 0; }
.fj-test__plan { font-weight: 400; color: var(--fj-muted); font-size: 0.95rem; }
.fj-test__meta { flex-basis: 100%; margin: 0; font-size: 0.9rem; color: var(--fj-muted); }
.fj-test__summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.75rem 1.25rem; margin: 0 0 1rem; font-variant-numeric: tabular-nums; }
.fj-test__summary dt { font-size: 0.8rem; color: var(--fj-muted); }
.fj-test__summary dd { margin: 0; font-weight: 800; font-size: 1.15rem; }
.fj-test__summary div:last-child dd { font-size: 0.95rem; font-weight: 700; }
.fj-test__runs { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.fj-test__runs th, .fj-test__runs td { text-align: left; padding: 0.55rem 0.5rem 0.55rem 0; border-bottom: 1px solid var(--fj-rule); vertical-align: top; }
.fj-test__runs thead th { font-size: 0.8rem; color: var(--fj-muted); }
.fj-test__runs tbody th { font-weight: 600; }
.fj-test__down { min-width: 7.5rem; }
.fj-bar { display: block; height: 6px; width: calc(var(--fj-w) * 0.85); min-width: 3px; background: var(--fj-red); border-radius: 3px; margin: 0.35rem 0 0.25rem; }
.fj-test__notes { margin: 1rem 0 0; padding-left: 1.1rem; color: var(--fj-ink); }
.fj-test__support { margin: 0.75rem 0 0; font-size: 0.92rem; color: var(--fj-muted); }
.fj-test.fj-test--pending p { margin: 0; }
.fj-cta .fj-btn, .fj-summary__go .fj-btn { white-space: normal; text-align: center; }
.fj-note { display: block; margin-top: 0.25rem; font-size: 0.8rem; line-height: 1.4; color: var(--fj-muted); }
@media (min-width: 861px) { .fj-table td[data-label="Plan"] { min-width: 15rem; } .fj-table th[scope="row"] { min-width: 8rem; } }
.fj-unknown { color: var(--fj-muted); font-size: 0.9em; }

.fj-table-wrap { overflow-x: auto; }

/* WCAG 2.2 target size: inline name links in dense rows get at least 24px of height. */
.fj-table__prov a, .fj-option__who a, .fj-pick__name a { display: inline-block; min-height: 24px; line-height: 24px; }
