/*
 * Ipahco guides.
 *
 * Reuses Astra's own palette variables so the guides cannot drift away
 * from the rest of the site when the theme's colours are changed in the
 * customiser. Every value degrades to a literal if the variable is gone.
 */

:root {
	--ipahco-green: var(--ast-global-color-0, #54b435);
	--ipahco-green-dark: var(--ast-global-color-1, #379237);
	--ipahco-ink: var(--ast-global-color-2, #0f172a);
	--ipahco-muted: var(--ast-global-color-3, #2f3b40);
	--ipahco-tint: var(--ast-global-color-4, #edfbe2);
	/* Not the brand green: #54b435 on white is 2.4:1 and #379237 is 3.9:1,
	   both under the 4.5:1 that body text needs to be readable. This one
	   is 5.4:1 and still unmistakably the same green. */
	--ipahco-link: #2b7a2b;
	--ipahco-line: #e2e8f0;
	--ipahco-radius: 14px;
}

/* ---------- links in the body of an article ---------- */

/*
 * The theme sets every <a> to white. On the dark hero buttons that is
 * right; inside a paragraph on a white page it meant that every internal
 * link in every guide was invisible -- present in the markup, unreadable
 * on screen, and unclickable in practice. Put back here rather than in
 * the customiser, where the same white is still doing its job.
 *
 * Underlined as well as coloured: colour alone is not enough to mark a
 * link for a reader who cannot distinguish it.
 */

body:not(.home) .entry-content p > a,
body:not(.home) .entry-content li > a,
body:not(.home) .entry-content td > a,
body:not(.home) .entry-content th > a,
body:not(.home) .entry-content figcaption > a {
	color: var(--ipahco-link);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

body:not(.home) .entry-content p > a:hover,
body:not(.home) .entry-content li > a:hover,
body:not(.home) .entry-content p > a:focus-visible,
body:not(.home) .entry-content li > a:focus-visible {
	color: var(--ipahco-ink);
	text-decoration-thickness: 2px;
}

/* The blocks this plugin renders style their own links. */
body:not(.home) .entry-content .ipahco-toc a {
	color: var(--ipahco-ink);
	text-decoration: none;
}

body:not(.home) .entry-content .ipahco-cards a {
	text-decoration: none;
}

body:not(.home) .entry-content .ipahco-cta a {
	color: #1f5a1a;
	text-decoration: none;
}

/* ---------- archive heading ---------- */

.ipahco-archive-head {
	margin: 0 0 2em;
	padding-bottom: 1.2em;
	border-bottom: 1px solid var(--ipahco-line);
}

.ipahco-archive-head h1 {
	margin: 0 0 0.3em;
	font-size: clamp(1.6rem, 4vw, 2.2rem);
	line-height: 1.2;
}

.ipahco-archive-head p {
	margin: 0;
	max-width: 60ch;
	color: var(--ipahco-muted);
	opacity: 0.85;
}

.ipahco-archive-head a {
	color: var(--ipahco-link);
}

/* ---------- breadcrumbs ---------- */

.ipahco-breadcrumbs {
	margin: 0 0 0.9em;
	font-size: 0.82rem;
	color: var(--ipahco-muted);
	opacity: 0.8;
}

.ipahco-breadcrumbs a {
	color: var(--ipahco-link);
	text-decoration: none;
}

.ipahco-breadcrumbs a:hover,
.ipahco-breadcrumbs a:focus-visible {
	text-decoration: underline;
}

.ipahco-breadcrumbs .separator {
	margin: 0 0.4em;
	opacity: 0.6;
}

/* The page's own title is directly underneath; a breadcrumb repeating it
   over two lines on a phone is just noise. Trimmed in CSS, so the markup
   search engines read still carries the whole title. */
.ipahco-breadcrumbs .last {
	display: inline-block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	vertical-align: bottom;
}

.ipahco-breadcrumbs nav p {
	margin: 0;
}

/* ---------- the line under the title ---------- */

.ipahco-readmeta {
	margin: 0 0 1.6em;
	padding-bottom: 0.9em;
	border-bottom: 1px solid var(--ipahco-line);
	font-size: 0.875rem;
	letter-spacing: 0.01em;
	color: var(--ipahco-muted);
	opacity: 0.85;
}

/* ---------- contents ---------- */

.ipahco-toc {
	margin: 2em 0 2.4em;
	padding: 1.1em 1.3em;
	background: var(--ipahco-tint);
	border: 1px solid rgba(55, 146, 55, 0.25);
	border-radius: var(--ipahco-radius);
}

.ipahco-toc summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--ipahco-ink);
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.6em;
}

.ipahco-toc summary::-webkit-details-marker {
	display: none;
}

.ipahco-toc summary::after {
	content: "";
	width: 0.55em;
	height: 0.55em;
	border-right: 2px solid var(--ipahco-green-dark);
	border-bottom: 2px solid var(--ipahco-green-dark);
	transform: rotate(45deg);
	transition: transform 0.15s ease;
	flex: none;
}

.ipahco-toc details[open] summary::after {
	transform: rotate(-135deg);
}

.ipahco-toc ol {
	margin: 1em 0 0;
	padding-left: 1.3em;
	counter-reset: ipahco-toc;
	list-style: none;
}

.ipahco-toc li {
	position: relative;
	margin: 0 0 0.55em;
	line-height: 1.45;
	counter-increment: ipahco-toc;
}

.ipahco-toc li::before {
	content: counter(ipahco-toc) ".";
	position: absolute;
	left: -1.3em;
	color: var(--ipahco-green-dark);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.ipahco-toc a {
	color: var(--ipahco-ink);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

.ipahco-toc a:hover,
.ipahco-toc a:focus-visible {
	border-bottom-color: var(--ipahco-green-dark);
	color: var(--ipahco-green-dark);
}

/* A jump link must not land the heading under a sticky header. */
.entry-content h2[id],
.entry-content h3[id] {
	scroll-margin-top: 90px;
}

/* ---------- the takeaway box, used at the top of a guide ---------- */

.ipahco-key {
	margin: 0 0 2em;
	padding: 1.2em 1.4em;
	border-left: 4px solid var(--ipahco-green);
	background: #f8fafc;
	border-radius: 0 var(--ipahco-radius) var(--ipahco-radius) 0;
}

.ipahco-key > :first-child {
	margin-top: 0;
}

.ipahco-key > :last-child {
	margin-bottom: 0;
}

.ipahco-key p:first-child strong {
	color: var(--ipahco-green-dark);
}

.ipahco-key ul {
	margin-bottom: 0;
}

/* ---------- tables ---------- */

.entry-content .wp-block-table {
	overflow-x: auto;
}

.entry-content .wp-block-table table {
	border-collapse: collapse;
	width: 100%;
	font-size: 0.95rem;
}

.entry-content .wp-block-table th,
.entry-content .wp-block-table td {
	border: 1px solid var(--ipahco-line);
	padding: 0.65em 0.8em;
	text-align: left;
	vertical-align: top;
}

.entry-content .wp-block-table thead th {
	background: var(--ipahco-tint);
	color: var(--ipahco-ink);
	font-weight: 600;
}

.entry-content .wp-block-table tbody tr:nth-child(even) td {
	background: #fafafa;
}

/* ---------- call to action ---------- */

.ipahco-cta {
	margin: 2.4em 0;
	padding: 1.6em;
	border-radius: var(--ipahco-radius);
	background: linear-gradient(135deg, #1f5a1a 0%, #409650 100%);
	color: #fff;
}

.ipahco-cta__title {
	margin: 0 0 0.45em;
	color: #fff;
	font-size: 1.25rem;
	line-height: 1.3;
}

.ipahco-cta__text {
	margin: 0 0 1.1em;
	color: rgba(255, 255, 255, 0.92);
	font-size: 1rem;
}

.ipahco-cta__action {
	margin: 0;
}

.ipahco-cta__button {
	display: inline-block;
	padding: 0.7em 1.5em;
	border-radius: 999px;
	background: #fff;
	color: #1f5a1a !important;
	font-weight: 600;
	text-decoration: none;
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ipahco-cta__button:hover,
.ipahco-cta__button:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

/* ---------- cards: related guides and the index ---------- */

.ipahco-related {
	margin: 3em 0 0;
	padding-top: 2em;
	border-top: 1px solid var(--ipahco-line);
}

.ipahco-related__title {
	margin: 0 0 1em;
	font-size: 1.35rem;
}

.ipahco-cards {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 600px) {
	.ipahco-cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.ipahco-card {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ipahco-card__link {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	border: 1px solid var(--ipahco-line);
	border-radius: var(--ipahco-radius);
	background: #fff;
	color: inherit;
	text-decoration: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ipahco-card__link:hover,
.ipahco-card__link:focus-visible {
	border-color: var(--ipahco-green);
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
	transform: translateY(-2px);
}

.ipahco-card__media img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 40 / 21;
	object-fit: cover;
}

.ipahco-card__body {
	display: block;
	padding: 1em 1.1em 1.2em;
}

.ipahco-card__title {
	display: block;
	margin-bottom: 0.35em;
	font-weight: 600;
	line-height: 1.35;
	color: var(--ipahco-ink);
}

.ipahco-card__link:hover .ipahco-card__title {
	color: var(--ipahco-green-dark);
}

.ipahco-card__text {
	display: block;
	font-size: 0.9rem;
	line-height: 1.5;
	color: var(--ipahco-muted);
	opacity: 0.85;
}

.ipahco-related__all {
	margin: 1.4em 0 0;
	font-weight: 600;
}

/* ---------- the guide index page ---------- */

.ipahco-stage {
	margin: 2.6em 0;
}

.ipahco-stage h2 {
	margin-bottom: 0.2em;
}

.ipahco-stage__blurb {
	margin: 0 0 1.2em;
	color: var(--ipahco-muted);
	opacity: 0.85;
}

/* ---------- sources ---------- */

.ipahco-sources {
	margin: 2.4em 0 0;
	padding: 1.2em 1.4em;
	border: 1px dashed var(--ipahco-line);
	border-radius: var(--ipahco-radius);
	font-size: 0.9rem;
}

.ipahco-sources p:first-child {
	margin-top: 0;
	font-weight: 600;
}

.ipahco-sources ul {
	margin-bottom: 0;
}

/* ---------- small screens ---------- */

@media (max-width: 420px) {
	.ipahco-cta {
		padding: 1.3em;
	}

	.ipahco-cta__button {
		display: block;
		text-align: center;
	}
}
