/*
Theme Name: Men-tal Hospital
Theme URI: https://thementalhospital.co.za/
Author: The Men-tal Hospital
Author URI: https://thementalhospital.co.za/
Description: A calm, card-based magazine theme for The Men-tal Hospital. Clean reading pages, light and dark modes, and marked positions for ads managed by the companion Men-tal Hospital Ads plugin.
Requires at least: 6.6
Tested up to: 7.0
Requires PHP: 8.1
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: men-tal-hospital
Tags: blog, news, entertainment, grid-layout, two-columns, right-sidebar, block-patterns, full-site-editing, custom-colors, custom-logo, custom-menu, editor-style, featured-images, threaded-comments, translation-ready, wide-blocks
*/

/* ---------- Dark mode: swap the palette tokens ---------- */
:root[data-theme="dark"] {
	--wp--preset--color--base: #0F1115;
	--wp--preset--color--surface: #181B22;
	--wp--preset--color--contrast: #F2F2F0;
	--wp--preset--color--body: #D9DCE1;
	--wp--preset--color--muted: #A6ABB5;
	--wp--preset--color--border: #2A2E37;
	--wp--preset--color--accent: #FB923C;
	--wp--preset--color--accent-soft: #3A2416;
	--wp--preset--color--accent-strong: #FDBA74;
	color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--wp--preset--color--base: #0F1115;
		--wp--preset--color--surface: #181B22;
		--wp--preset--color--contrast: #F2F2F0;
		--wp--preset--color--body: #D9DCE1;
		--wp--preset--color--muted: #A6ABB5;
		--wp--preset--color--border: #2A2E37;
		--wp--preset--color--accent: #FB923C;
		--wp--preset--color--accent-soft: #3A2416;
		--wp--preset--color--accent-strong: #FDBA74;
		color-scheme: dark;
	}
}

/* ---------- Accessibility ---------- */
:where(a, button, input, textarea, select, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.skip-link.screen-reader-text:focus {
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

/* ---------- Header ---------- */
.mh-header {
	background: var(--wp--preset--color--surface);
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.mh-header__inner {
	padding-block: 0.75rem;
	gap: 1.5rem;
}

.mh-header .wp-block-site-logo img {
	height: 60px;
	width: auto;
}

/* The logo is artwork on white; give it a white badge in dark mode so it stays readable. */
:root[data-theme="dark"] .mh-header .wp-block-site-logo a {
	display: block;
	background: #FFFFFF;
	border-radius: 10px;
	padding: 4px 8px;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .mh-header .wp-block-site-logo a {
		display: block;
		background: #FFFFFF;
		border-radius: 10px;
		padding: 4px 8px;
	}
}

.mh-nav {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 600;
	font-size: 0.875rem;
}

.mh-nav .wp-block-navigation__container {
	gap: 0.15rem;
}

.mh-nav .wp-block-navigation-item__content {
	padding: 0.7rem 0.8rem;
	border-radius: 999px;
}

@media (min-width: 600px) and (max-width: 1279px) {
	.mh-nav .wp-block-navigation-item__content {
		padding-inline: 0.55rem;
	}
}

/* Tablets: core only switches to the hamburger below 600px, so keep the menu on one scrollable row. */
@media (min-width: 600px) and (max-width: 1023px) {
	.mh-nav .wp-block-navigation__responsive-container-content,
	.mh-nav .wp-block-navigation__container {
		min-width: 0;
		max-width: 100%;
	}

	.mh-nav .wp-block-navigation__container {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: thin;
		justify-content: flex-start;
	}

	.mh-nav .wp-block-navigation-item {
		flex: none;
	}
}

.mh-nav .current-menu-item > .wp-block-navigation-item__content,
.mh-nav .wp-block-navigation-item__content:hover {
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--accent-strong);
}

.mh-header__actions {
	gap: 0.5rem;
}

.mh-icon-button,
.mh-search .wp-block-search__button {
	width: 44px;
	height: 44px;
	min-width: 44px;
	padding: 0;
	border: 0;
	border-radius: 22px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.mh-icon-button:hover,
.mh-search .wp-block-search__button:hover {
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--accent-strong);
}

.mh-search .wp-block-search__button svg {
	fill: currentColor;
	min-width: 22px;
}

.mh-search .wp-block-search__input {
	border-radius: 999px;
	border: 1px solid var(--wp--preset--color--border);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	padding-inline: 1rem;
}

.mh-theme-toggle .mh-icon-sun,
:root[data-theme="dark"] .mh-theme-toggle .mh-icon-moon {
	display: none;
}

:root[data-theme="dark"] .mh-theme-toggle .mh-icon-sun {
	display: block;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .mh-theme-toggle .mh-icon-moon {
		display: none;
	}

	:root:not([data-theme="light"]) .mh-theme-toggle .mh-icon-sun {
		display: block;
	}
}

/* ---------- Cards ---------- */
.mh-card,
.is-style-mh-card {
	background: var(--wp--preset--color--surface);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

/* Story cards fill their grid cell so a row lines up. */
.mh-card {
	height: 100%;
	display: flex;
	flex-direction: column;
}

.mh-card .wp-block-post-featured-image {
	margin: 0;
}

.mh-card .wp-block-post-featured-image img {
	aspect-ratio: 16 / 10;
	object-fit: cover;
	width: 100%;
}

.mh-card__body {
	flex: 1 1 auto;
	padding: 1.25rem 1.375rem 1.375rem;
}

.mh-card .wp-block-post-title {
	font-size: 1.0625rem;
	line-height: 1.3;
	margin: 0;
}

.mh-card .wp-block-post-date {
	font-size: 0.8125rem;
}

.mh-card--lead .wp-block-post-featured-image img {
	aspect-ratio: 16 / 9;
}

.mh-card--lead .mh-card__body {
	padding: 1.75rem 2rem 2rem;
}

.mh-card--lead .wp-block-post-title {
	font-size: clamp(1.5rem, 2.6vw, 2.25rem);
	line-height: 1.08;
}

.mh-card--lead .wp-block-post-excerpt {
	font-size: 1rem;
	line-height: 1.6;
}

.mh-card--side .wp-block-post-featured-image img {
	aspect-ratio: 2 / 1;
}

.mh-card--side .wp-block-post-title {
	font-size: 1.125rem;
	line-height: 1.25;
}

.mh-top-stories .wp-block-post-template {
	gap: 1.5rem;
}

/* Lead story stretches to the height of the two side stories. */
.mh-top-stories .mh-lead,
.mh-top-stories .mh-lead .wp-block-post-template,
.mh-top-stories .mh-lead .wp-block-post-template > li {
	height: 100%;
	margin: 0;
}

/* Post templates laid out as card grids */
.mh-cards .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
	gap: 1.5rem;
}

.mh-cards .wp-block-post-template > li {
	margin: 0;
}

/* Fixed three-across rows, e.g. "You might also like". */
.mh-cards--three .wp-block-post-template {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 781px) {
	.mh-cards--three .wp-block-post-template {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ---------- Category pill ---------- */
.is-style-mh-pill a,
.mh-pill a {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
	padding: 0.4rem 0.65rem;
	border-radius: 999px;
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--accent-strong);
}

.is-style-mh-pill .wp-block-post-terms__separator,
.mh-pill .wp-block-post-terms__separator {
	display: none;
}

.is-style-mh-pill a + a,
.mh-pill a + a {
	margin-left: 0.35rem;
}

/* ---------- Topic chips (tag cloud) ---------- */
.mh-topics .wp-block-tag-cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
}

.mh-topics .wp-block-tag-cloud a {
	font-size: 0.8125rem !important;
	font-weight: 600;
	padding: 0.7rem 1rem;
	border-radius: 999px;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	margin: 0;
}

/* ---------- Sidebar ---------- */
.mh-sidebar {
	gap: 1.5rem;
}

.mh-sticky {
	position: sticky;
	top: 1.5rem;
}

.mh-mini-list .wp-block-post-template > li {
	padding-block: 0.65rem;
	border-top: 1px solid var(--wp--preset--color--border);
}

.mh-mini-list .wp-block-post-featured-image img {
	width: 72px;
	height: 56px;
	object-fit: cover;
	border-radius: 10px;
}

.mh-mini-list .wp-block-post-title {
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.3;
	margin: 0;
}

/* ---------- Single post ---------- */
.mh-entry-header {
	text-align: center;
}

.mh-entry-header .is-style-mh-pill {
	justify-content: center;
}

.mh-entry-meta {
	gap: 0.75rem;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

.mh-entry-meta .wp-block-avatar img {
	border-radius: 999px;
}

.mh-entry-image img {
	border-radius: 20px;
	aspect-ratio: 21 / 9;
	object-fit: cover;
	width: 100%;
}

/* Everything in the article column shares the 720px reading width, so edges line up. */
.mh-article-main > * {
	max-width: 720px;
}

.mh-entry-content {
	font-size: 1.0625rem;
	line-height: 1.7;
}

/* Old embeds carry fixed pixel sizes; keep them inside the column on phones. */
.mh-entry-content :where(iframe, embed, object, video) {
	max-width: 100%;
}

.mh-entry-content iframe[src*="youtube"],
.mh-entry-content iframe[src*="vimeo"] {
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
}

.mh-entry-content :where(img) {
	max-width: 100%;
	height: auto;
}

.mh-entry-content > * + h2,
.mh-entry-content > * + h3 {
	margin-top: 2.25rem;
}

.mh-entry-content a {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.mh-tags .wp-block-post-terms a,
.mh-tags a {
	display: inline-block;
	padding: 0.55rem 0.85rem;
	border-radius: 999px;
	border: 1px solid var(--wp--preset--color--border);
	font-size: 0.8125rem;
	font-weight: 600;
	margin: 0 0.35rem 0.35rem 0;
}

.mh-tags .wp-block-post-terms__separator {
	display: none;
}

.mh-author-box {
	gap: 1.1rem;
	padding: 1.5rem;
}

.mh-author-box .wp-block-avatar img {
	border-radius: 999px;
}

/* "At a glance" pattern */
.mh-glance {
	padding: 1.5rem 1.6rem;
}

.mh-glance .wp-block-table table {
	border-collapse: collapse;
	width: 100%;
}

.mh-glance .wp-block-table td {
	border: 0;
	border-top: 1px solid var(--wp--preset--color--border);
	padding: 0.75rem 0;
}

.mh-glance .wp-block-table td:first-child {
	color: var(--wp--preset--color--muted);
}

.mh-glance .wp-block-table td:last-child {
	font-weight: 700;
	text-align: right;
	color: var(--wp--preset--color--contrast);
}

/* ---------- Archive header ---------- */
.mh-archive-header {
	padding: clamp(1.5rem, 4vw, 2.5rem);
}

.mh-archive-header .wp-block-query-title {
	margin: 0;
}

/* ---------- Pagination ---------- */
.wp-block-query-pagination {
	gap: 0.5rem;
}

.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 1rem;
	border-radius: 22px;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	font-weight: 700;
	box-sizing: border-box;
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* ---------- Comments ---------- */
.mh-comments {
	padding: clamp(1.25rem, 3vw, 1.75rem);
}

.mh-comments input[type="text"],
.mh-comments input[type="email"],
.mh-comments input[type="url"],
.mh-comments textarea {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #9CA3AF;
	border-radius: 12px;
	padding: 0.75rem 0.9rem;
	font: inherit;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

/* ---------- Footer ---------- */
.mh-footer {
	background: var(--wp--preset--color--surface);
	border-top: 1px solid var(--wp--preset--color--border);
}

.mh-footer-label {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
}

.mh-footer .wp-block-site-logo img {
	height: 56px;
	width: auto;
}

.mh-footer .wp-block-categories-list,
.mh-footer .wp-block-navigation {
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.5;
}

.mh-footer .wp-block-categories-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

/* Both footer columns use the same rhythm: 0.5rem between links. */
.mh-footer .wp-block-categories-list li + li {
	margin-top: 0.5rem;
}

.mh-footer .wp-block-navigation__container {
	gap: 0.5rem;
}

/* ---------- Ad slots (rendered by the Men-tal Hospital Ads plugin) ---------- */
.mh-header-ad {
	padding-top: 1.5rem;
}

/* No header ad running: don't leave an empty gap under the header. */
.mh-header-ad:not(:has([data-mhads-wrap]:not([hidden]))) {
	display: none;
}

.mh-cards .mhads-feed-item {
	background: var(--wp--preset--color--surface);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (max-width: 781px) {
	.mh-entry-image img {
		aspect-ratio: 16 / 10;
		border-radius: 14px;
	}

	.mh-header .wp-block-site-logo img {
		height: 46px;
	}

	.mh-sticky {
		position: static;
	}
}

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