/*
* Single post layout
*
* Markup: single.php + template-parts/blog/{toc,rail,related}.php
* Behaviour: assets/scripts/front/hk-post.js (scroll spy)
*
* Grid
*   >= 1280px   contents | article | contact rail
*   1024-1279   article | contact rail, contents collapses above the article
*   < 1024      one column: contents, article, contact rail, more posts
*
* Contents
*   1. Grid
*   2. Table of contents
*   3. Article
*   4. Contact rail
*   5. More posts
*   6. Small screens
*/

/* ---------------------------------------------------------------------------
* 1. Grid
* ------------------------------------------------------------------------- */

.hkp-single {
	--hkp-accent: var(--primary-color, #c9962c);
	--hkp-green: var(--secondary-color, #53624e);
	--hkp-ink: #1a1b1a;
	--hkp-muted: #6f736a;
	--hkp-line: #e6e3dc;
	--hkp-bg-soft: #f7f6f3;
	/* Clears the pinned header, which is 70px plus a little air. */
	--hkp-sticky-top: 92px;
	--hkp-radius: 6px;
}

.hkp-single .hkp-main {
	padding-bottom: 10px;
}

.hkp-wrap {
	display: grid;
	grid-template-columns: 250px minmax(0, 1fr) 320px;
	gap: 48px;
	width: 100%;
	max-width: 1560px;
	margin: 0 auto;
	padding: 0 48px;
}

.hkp-toc-col,
.hkp-rail-col {
	min-width: 0;
}

/* The rails stick; the column itself must be as tall as the article for that
* to have anywhere to travel. */
.hkp-toc,
.hkp-rail {
	position: -webkit-sticky;
	position: sticky;
	top: var(--hkp-sticky-top);
	max-height: calc(100vh - var(--hkp-sticky-top) - 24px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

.hkp-toc::-webkit-scrollbar,
.hkp-rail::-webkit-scrollbar {
	width: 3px;
}

.hkp-toc::-webkit-scrollbar-thumb,
.hkp-rail::-webkit-scrollbar-thumb {
	background: var(--hkp-line);
	border-radius: 3px;
}

/* The theme sizes #primary for its sidebar layout; in the grid the column
* does the sizing. The id keeps this above that rule whatever the body classes
* end up being. */
.hkp-single #content .hkp-content-col,
.hkp-single .hkp-content-col {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	float: none;
}

/*
* #page scrolls on its own (overflow-y: auto with overflow-x hidden), which
* makes it the containing block for position: sticky and stops the rails from
* sticking to the viewport. overflow-x: clip keeps the horizontal guard
* without creating a scroll container.
*/
.hkp-single #page {
	overflow: visible;
}

@supports (overflow: clip) {
	.hkp-single #page {
		overflow-x: clip;
		overflow-y: visible;
	}
}

/*
* The floating contact dock sits against the left edge, over the contents
* column. Once the viewport is wide enough for the grid to be centred with a
* margin of its own, the dock is clear of it and the extra padding is dropped.
*/
@media only screen and (min-width: 1024px) and (max-width: 1719px) {
	.hkp-single .hkp-wrap,
	.hkp-single .hkp-more-inner {
		padding-left: 92px;
	}
}

/* ---------------------------------------------------------------------------
* 2. Table of contents
* ------------------------------------------------------------------------- */

.hkp-toc {
	padding: 0 0 8px;
	font-family: var(--body-font, inherit);
}

.hkp-toc-head {
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 0 0 14px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--hkp-line);
	cursor: default;
	list-style: none;
}

.hkp-toc-head::-webkit-details-marker {
	display: none;
}

.hkp-toc-title {
	color: var(--hkp-ink);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.14em;
	line-height: 1;
	text-transform: uppercase;
}

.hkp-toc-time {
	color: var(--hkp-muted);
	font-size: 12px;
	letter-spacing: 0.04em;
	line-height: 1;
}

.hkp-toc-caret {
	display: none;
}

.hkp-toc-list {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: hkp-toc;
}

.hkp-toc-item {
	position: relative;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hkp-toc-item a {
	display: block;
	padding: 7px 0 7px 16px;
	border-left: 1px solid var(--hkp-line);
	color: var(--hkp-muted);
	font-size: 13.5px;
	line-height: 1.45;
	text-decoration: none;
	transition: color 0.2s ease, border-color 0.2s ease;
}

.hkp-toc-item a:hover {
	color: var(--hkp-ink);
	border-left-color: var(--hkp-accent);
}

.hkp-toc-level-3 a {
	padding-left: 28px;
	font-size: 13px;
}

/* Set by hk-post.js while its section is the one on screen. */
.hkp-toc-item.is-current > a {
	color: var(--hkp-ink);
	font-weight: 500;
	border-left-color: var(--hkp-accent);
	border-left-width: 2px;
	padding-left: 15px;
}

.hkp-toc-level-3.is-current > a {
	padding-left: 27px;
}

/* ---------------------------------------------------------------------------
* 3. Article
* ------------------------------------------------------------------------- */

.hkp-single .hkp-article .entry-content {
	max-width: 760px;
}

/* The anchor lands under the pinned header without this. */
.hkp-single .entry-content h2,
.hkp-single .entry-content h3 {
	scroll-margin-top: calc(var(--hkp-sticky-top) + 8px);
}

.hkp-single .entry-content > h2 {
	margin-top: 1.6em;
}

.hkp-single .entry-content > h2:first-child {
	margin-top: 0;
}

/* ---------------------------------------------------------------------------
* 4. Contact rail
* ------------------------------------------------------------------------- */

.hkp-rail {
	font-family: var(--body-font, inherit);
}

.hkp-cta {
	padding: 26px 24px 24px;
	background: var(--hkp-green);
	border-radius: var(--hkp-radius);
	color: #fff;
}

.hkp-cta-eyebrow {
	margin: 0 0 10px;
	color: var(--hkp-accent);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.18em;
	line-height: 1;
	text-transform: uppercase;
}

.hkp-cta-title {
	margin: 0 0 10px;
	color: #fff;
	font-family: var(--heading-font, inherit);
	font-size: 22px;
	line-height: 1.25;
}

.hkp-cta-text {
	margin: 0 0 18px;
	color: rgba(255, 255, 255, 0.76);
	font-size: 14px;
	line-height: 1.6;
}

.hkp-cta-buttons {
	display: flex;
	flex-direction: column;
	gap: 9px;
}

.hkp-cta-button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	min-height: 46px;
	padding: 0 16px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 3px;
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.hkp-cta-button .hkh-icon {
	display: block;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
}

.hkp-cta-button:hover {
	background: rgba(255, 255, 255, 0.1);
	border-color: #fff;
	color: #fff;
}

.hkp-cta-whatsapp {
	background: #25d366;
	border-color: #25d366;
}

.hkp-cta-whatsapp:hover {
	background: #1fbe5a;
	border-color: #1fbe5a;
}

.hkp-cta-primary {
	background: var(--hkp-accent);
	border-color: var(--hkp-accent);
	font-size: 13px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.hkp-cta-primary:hover {
	background: #b3801d;
	border-color: #b3801d;
}

.hkp-links {
	margin-top: 22px;
	padding: 20px 22px 8px;
	background: var(--hkp-bg-soft);
	border: 1px solid var(--hkp-line);
	border-radius: var(--hkp-radius);
}

.hkp-links-title {
	margin: 0 0 6px;
	color: var(--hkp-ink);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1;
	text-transform: uppercase;
}

.hkp-links-list,
.hkp-links-list .sub-menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hkp-links-list > li {
	margin: 0;
	padding: 0;
	border-bottom: 1px solid var(--hkp-line);
}

.hkp-links-list > li:last-child {
	border-bottom: 0;
}

.hkp-links-list a {
	display: block;
	padding: 11px 0;
	color: var(--hkp-ink);
	font-size: 14px;
	line-height: 1.4;
	text-decoration: none;
	transition: color 0.2s ease;
}

.hkp-links-list a:hover,
.hkp-links-list .current-menu-item > a {
	color: var(--hkp-accent);
}

/* Second level: quieter, indented, no separators. */
.hkp-links-list .sub-menu {
	padding: 0 0 8px 12px;
	border-left: 1px solid var(--hkp-line);
	margin-left: 2px;
}

.hkp-links-list .sub-menu a {
	padding: 6px 0;
	color: var(--hkp-muted);
	font-size: 13px;
}

/* ---------------------------------------------------------------------------
* 5. More posts
* ------------------------------------------------------------------------- */

.hkp-more {
	margin-top: 64px;
	padding: 56px 0 8px;
	border-top: 1px solid var(--hkp-line);
}

.hkp-more-inner {
	width: 100%;
	max-width: 1560px;
	margin: 0 auto;
	padding: 0 48px;
}

.hkp-more-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 20px;
	margin-bottom: 28px;
}

.hkp-more-title {
	margin: 0;
	font-family: var(--heading-font, inherit);
	font-size: 30px;
	line-height: 1.2;
}

.hkp-more-all {
	color: var(--hkp-muted);
	font-size: 13px;
	letter-spacing: 0.08em;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
	transition: color 0.2s ease;
}

.hkp-more-all:hover {
	color: var(--hkp-accent);
}

.hkp-more-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 28px;
}

.hkp-card {
	margin: 0;
}

.hkp-card-link {
	display: block;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

.hkp-card-media {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: 3 / 2;
	background: var(--hkp-bg-soft);
	border-radius: var(--hkp-radius);
}

.hkp-card-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hkp-card-link:hover .hkp-card-img {
	-webkit-transform: scale(1.04);
	transform: scale(1.04);
}

/* Text-only card: the accent rule replaces the missing image. */
.hkp-card-text .hkp-card-link {
	display: flex;
	flex-direction: column;
	padding: 22px 22px 24px;
	background: var(--hkp-bg-soft);
	border-radius: var(--hkp-radius);
	border-top: 2px solid var(--hkp-accent);
	transition: background-color 0.25s ease;
}

.hkp-card-text .hkp-card-link:hover {
	background: #f1efe9;
}

.hkp-card-text .hkp-card-body {
	padding-top: 0;
}

.hkp-card-body {
	display: block;
	padding-top: 16px;
}

.hkp-card-cat {
	display: block;
	margin-bottom: 8px;
	color: var(--hkp-accent);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1;
	text-transform: uppercase;
}

.hkp-card-title {
	display: block;
	color: var(--hkp-ink);
	font-family: var(--heading-font, inherit);
	font-size: 20px;
	line-height: 1.35;
	transition: color 0.2s ease;
}

.hkp-card-link:hover .hkp-card-title {
	color: var(--hkp-accent);
}

.hkp-card-date {
	display: block;
	margin-top: 10px;
	color: var(--hkp-muted);
	font-size: 12.5px;
	letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------------
* 6. Small screens
* ------------------------------------------------------------------------- */

@media only screen and (max-width: 1440px) {
	.hkp-wrap {
		grid-template-columns: 220px minmax(0, 1fr) 300px;
		gap: 36px;
		padding: 0 32px;
	}

	.hkp-more-inner {
		padding: 0 32px;
	}
}

/* Contents moves above the article; the contact rail keeps its column. */
@media only screen and (max-width: 1279px) {
	.hkp-wrap {
		grid-template-columns: minmax(0, 1fr) 300px;
		grid-template-areas:
			"toc  rail"
			"body rail";
	}

	/* The rail spans both rows and must stay stretched: an auto-height column
	* is exactly as tall as the card, and then it has nowhere to stick. */
	.hkp-rail-col {
		align-self: stretch;
	}

	.hkp-toc-col {
		align-self: start;
	}

	.hkp-toc-col {
		grid-area: toc;
	}

	.hkp-content-col {
		grid-area: body;
	}

	.hkp-rail-col {
		grid-area: rail;
	}

	.hkp-toc {
		position: static;
		max-height: none;
		padding: 20px 22px;
		margin-bottom: 28px;
		background: var(--hkp-bg-soft);
		border: 1px solid var(--hkp-line);
		border-radius: var(--hkp-radius);
	}

	.hkp-toc-head {
		padding-bottom: 12px;
	}
}

@media only screen and (max-width: 1023px) {
	.hkp-wrap {
		display: block;
		padding: 0 24px;
	}

	.hkp-rail {
		position: static;
		max-height: none;
		margin-top: 40px;
	}

	.hkp-cta,
	.hkp-links {
		max-width: 760px;
	}

	.hkp-more-inner {
		padding: 0 24px;
	}

	.hkp-more-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px;
	}
}

@media only screen and (max-width: 767px) {
	.hkp-single {
		--hkp-sticky-top: 76px;
	}

	.hkp-wrap,
	.hkp-more-inner {
		padding: 0 16px;
	}

	/* Collapsed by default on a phone: the list can be longer than the screen. */
	.hkp-toc {
		padding: 4px 18px;
		margin-bottom: 24px;
	}

	.hkp-toc-head {
		align-items: center;
		padding: 16px 0;
		margin-bottom: 0;
		border-bottom: 0;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}

	.hkp-toc[open] .hkp-toc-head {
		border-bottom: 1px solid var(--hkp-line);
		margin-bottom: 12px;
	}

	.hkp-toc-caret {
		display: block;
		flex: 0 0 auto;
		width: 8px;
		height: 8px;
		margin-left: auto;
		border-right: 1.5px solid var(--hkp-muted);
		border-bottom: 1.5px solid var(--hkp-muted);
		-webkit-transform: translateY(-2px) rotate(45deg);
		transform: translateY(-2px) rotate(45deg);
		transition: transform 0.25s ease;
	}

	.hkp-toc[open] .hkp-toc-caret {
		-webkit-transform: translateY(1px) rotate(-135deg);
		transform: translateY(1px) rotate(-135deg);
	}

	.hkp-toc-nav {
		padding-bottom: 14px;
	}

	.hkp-more {
		margin-top: 44px;
		padding-top: 40px;
	}

	.hkp-more-head {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
		margin-bottom: 22px;
	}

	.hkp-more-title {
		font-size: 24px;
	}

	.hkp-more-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 26px;
	}

	.hkp-cta {
		padding: 22px 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hkp-card-img,
	.hkp-toc-caret {
		transition: none;
	}
}

/* ---------------------------------------------------------------------------
* 8. Right to left (Arabic)
* ------------------------------------------------------------------------- */

[dir="rtl"] .hkp-toc-item a {
	padding: 7px 16px 7px 0;
	border-right: 1px solid var(--hkp-line);
	border-left: 0;
}

[dir="rtl"] .hkp-toc-level-3 a {
	padding-right: 28px;
	padding-left: 0;
}

[dir="rtl"] .hkp-toc-item.is-current > a {
	padding-right: 15px;
	border-right-width: 2px;
	border-right-color: var(--hkp-accent);
	border-left: 0;
}

[dir="rtl"] .hkp-toc-level-3.is-current > a {
	padding-right: 27px;
}

[dir="rtl"] .hkp-links-list .sub-menu {
	padding: 0 12px 8px 0;
	margin-right: 2px;
	margin-left: 0;
	border-right: 1px solid var(--hkp-line);
	border-left: 0;
}
