/*
Theme Name: HK Buffalo Research
Theme URI: https://hkbuffaloresearch.org/
Description: Bilingual (English / Traditional Chinese) block theme for HK Buffalo Research, migrated from Google Sites. Navigation is rendered by the [hkb_nav] shortcode for Polylang compatibility.
Version: 1.1.0
Requires at least: 6.4
Requires PHP: 7.4
Text Domain: hkb-buffalo
License: GPL-2.0-or-later
*/

/* ---------- Base ---------- */
:root { --hkb-gutter: 20px; --hkb-navy: #1b4557; --hkb-green: #387b5b; --hkb-sage: #d5e4d9; }
body { background: var(--hkb-sage); -webkit-font-smoothing: antialiased; }
:lang(zh), :lang(zh-HK), :lang(zh-TW) { line-height: 1.8; }
img { max-width: 100%; height: auto; }
.hkb-main { overflow-x: clip; }
.wp-block-post-content > :not(.alignfull) { box-sizing: border-box; padding-left: var(--hkb-gutter); padding-right: var(--hkb-gutter); }
.wp-block-post-content > .alignfull { padding-left: 0; padding-right: 0; }
.wp-block-post-content p { font-size: .95rem; }

/* ---------- Header ---------- */
.hkb-site-header { position: sticky; top: 0; z-index: 50; }
.admin-bar .hkb-site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .hkb-site-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .hkb-site-header { top: 0; } }
.hkb-header { box-shadow: 0 1px 0 rgba(27, 69, 87, .12), 0 2px 10px rgba(0, 0, 0, .04); }
.hkb-header__inner { position: relative; gap: 16px; }
.hkb-brand { min-width: 0; flex: 0 0 auto; }
.hkb-brand__logo { display: block; flex: 0 0 auto; line-height: 0; }
.hkb-brand__logo img { width: 44px; height: 44px; object-fit: contain; display: block; }
.hkb-brand__title { margin: 0; line-height: 1.2; white-space: nowrap; }
.hkb-brand__title a { text-decoration: none; }

/* ---------- Navigation ([hkb_nav]) ---------- */
.hkb-nav { position: static; }
.hkb-nav__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: 2px 2px; }
.hkb-nav__item { margin: 0; position: relative; white-space: nowrap; }
.hkb-nav__link, .hkb-nav__more-btn {
	display: inline-block; padding: 8px 10px; color: var(--wp--preset--color--navy);
	text-decoration: none; font-size: .95rem; font-weight: 600; line-height: 1.3; font-family: inherit;
	background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; transition: color .2s, border-color .2s;
}
.hkb-nav__link:hover, .hkb-nav__link:focus-visible, .hkb-nav__more-btn:hover, .hkb-nav__more-btn:focus-visible,
.hkb-nav__item.is-current > .hkb-nav__link {
	color: var(--wp--preset--color--green); border-bottom-color: var(--wp--preset--color--green);
}
.hkb-nav__caret { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.hkb-nav__dropdown {
	display: none; position: absolute; right: 0; top: 100%; min-width: 180px; margin: 0; padding: 6px 0; list-style: none;
	background: #fff; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); z-index: 60;
}
.hkb-nav__more.is-open > .hkb-nav__dropdown { display: block; }
.hkb-nav__dropdown .hkb-nav__link { display: block; padding: 10px 18px; border-bottom: 0; }
.hkb-nav__dropdown .hkb-nav__link:hover { background: rgba(213, 228, 217, .5); }

/* Pure-CSS toggle for the mobile menu (hidden on desktop) */
.hkb-nav__toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.hkb-nav__burger { display: none; }

@media (max-width: 1019px) {
	.hkb-nav__burger {
		display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
		padding: 8px 12px; border: 1px solid rgba(27, 69, 87, .25); border-radius: 8px;
		color: var(--wp--preset--color--navy); font-weight: 600; font-size: .9rem;
	}
	.hkb-nav__toggle:focus-visible + .hkb-nav__burger { outline: 2px solid var(--wp--preset--color--green); outline-offset: 2px; }
	.hkb-nav__burger-icon, .hkb-nav__burger-icon::before, .hkb-nav__burger-icon::after {
		display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative; transition: transform .2s, background .2s;
	}
	.hkb-nav__burger-icon::before, .hkb-nav__burger-icon::after { content: ""; position: absolute; left: 0; }
	.hkb-nav__burger-icon::before { top: -6px; }
	.hkb-nav__burger-icon::after { top: 6px; }
	.hkb-nav__toggle:checked + .hkb-nav__burger .hkb-nav__burger-icon { background: transparent; }
	.hkb-nav__toggle:checked + .hkb-nav__burger .hkb-nav__burger-icon::before { transform: translateY(6px) rotate(45deg); }
	.hkb-nav__toggle:checked + .hkb-nav__burger .hkb-nav__burger-icon::after { transform: translateY(-6px) rotate(-45deg); }

	.hkb-nav__list {
		display: none; position: absolute; top: calc(100% + 10px); left: -16px; right: -16px;
		flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px 16px;
		background: #fff; box-shadow: 0 12px 24px rgba(0, 0, 0, .12); border-top: 1px solid rgba(27, 69, 87, .12);
	}
	.hkb-nav__toggle:checked ~ .hkb-nav__list { display: flex; }
	.hkb-nav__link { display: block; padding: 12px 4px; border-bottom: 1px solid rgba(27, 69, 87, .08); }
	.hkb-nav__item.is-current > .hkb-nav__link { border-bottom-color: var(--wp--preset--color--green); }
	/* the More dropdown is flattened: its items are always listed, the button is hidden */
	.hkb-nav__more-btn { display: none; }
	.hkb-nav__dropdown { display: block; position: static; box-shadow: none; padding: 0; min-width: 0; background: none; }
	.hkb-nav__dropdown .hkb-nav__link { padding: 12px 4px; border-bottom: 1px solid rgba(27, 69, 87, .08); }
}
@media (max-width: 480px) { .hkb-brand__title { font-size: 1rem !important; } }

/* ---------- Hero cover ---------- */
.wp-block-cover.hkb-hero { min-height: 340px; margin-top: 0; margin-bottom: 2.5rem; }
.hkb-hero h1, .hkb-hero .wp-block-heading { color: var(--hkb-ink, #1c1c1c); font-weight: 700; text-shadow: none; }
.hkb-hero .wp-block-cover__inner-container { padding: 0 var(--hkb-gutter); }
.wp-block-post-content > .alignfull:first-child { margin-top: 0; }

/* Post banner (single template): same landscape hero as the pages */
.hkb-post-hero {
	position: relative; min-height: 340px; display: flex; align-items: center; justify-content: center; margin: 0 0 2.5rem;
	background: url("assets/hero.jpg") center / cover no-repeat; padding: 0 var(--hkb-gutter);
}
.hkb-post-hero::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .45); }
.hkb-post-hero > * { position: relative; max-width: 1000px; margin: 0; }
.hkb-post-hero .wp-block-post-title { color: #1c1c1c; font-size: clamp(1.8rem, 4vw, 2.75rem); }

/* ---------- Rows (Google Sites rows/columns) ---------- */
.hkb-row { gap: 2rem; margin-bottom: 1.5rem; }
.hkb-row .wp-block-column > * + * { margin-top: 1rem; }
.hkb-span { margin-left: auto; margin-right: auto; }
.hkb-span-2 { max-width: 260px; } .hkb-span-3 { max-width: 300px; } .hkb-span-4 { max-width: 40%; }
.hkb-span-5 { max-width: 50%; } .hkb-span-6 { max-width: 60%; } .hkb-span-7 { max-width: 70%; }
.hkb-span-8 { max-width: 76%; } .hkb-span-9 { max-width: 85%; } .hkb-span-10 { max-width: 92%; } .hkb-span-11 { max-width: 96%; }
.wp-block-post-content .wp-block-heading.has-text-align-center { margin-top: 2rem; }
.hkb-sep { border: 0; border-top: 1px solid rgba(28, 28, 28, .35); margin: 1.5rem auto; max-width: 100%; }
.wp-block-group.hkb-span > .wp-block-columns { margin-bottom: 0; }

/* Navy band (home investigators) */
.hkb-band { background: var(--hkb-navy); color: #fff; padding: 40px var(--hkb-gutter); margin: 2rem 0; }
.hkb-band .wp-block-heading, .hkb-band a, .hkb-band p { color: #fff; text-align: center; font-size: 1.1rem; font-weight: 400; margin-top: .4rem; margin-bottom: .4rem; }
.hkb-band .hkb-row { margin-bottom: 0; }

/* ---------- Media ---------- */
.hkb-caption { font-size: .8rem; color: #444; text-align: left; margin-top: .4rem; }
.wp-block-image figcaption, .wp-block-gallery figcaption { font-size: .8rem; color: #444; text-align: left; margin-top: .4rem; }
.wp-block-image img { border-radius: 0; }
.wp-block-embed.is-type-video iframe { border-radius: 0; }
.hkb-form-embed iframe { width: 100% !important; max-width: 100%; border: 0; display: block; min-height: 600px; }
.wp-block-post-content .wp-block-image { margin: 0; }
.wp-block-post-content .wp-block-image > img, .wp-block-post-content .wp-block-image > a > img { width: 100%; height: auto; }
.hkb-row { align-items: flex-start; }
.wp-block-column .wp-block-heading.wp-block-heading { margin-top: .6rem; }
.hkb-row:not(.hkb-band .hkb-row) .wp-block-column h2.wp-block-heading { font-size: 1.1rem; text-align: center; }

/* Slideshow (works without JS as a plain stack; JS adds .is-ready) */
.wp-block-gallery.hkb-slideshow.is-ready { display: block; position: relative; aspect-ratio: 2.15 / 1; overflow: hidden; margin: 0; }
.wp-block-gallery.hkb-slideshow.is-ready.has-nested-images > figure.wp-block-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; margin: 0; opacity: 0; transition: opacity .8s ease; }
.wp-block-gallery.hkb-slideshow.is-ready.has-nested-images > figure.wp-block-image.is-active { opacity: 1; z-index: 1; }
.wp-block-gallery.hkb-slideshow.is-ready.has-nested-images > figure.wp-block-image img { width: 100% !important; height: 100% !important; max-width: none !important; object-fit: cover; }
.hkb-dots { display: flex; justify-content: center; gap: 10px; margin: 14px 0 6px; }
.hkb-dot { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 0; background: rgba(28, 28, 28, .25); cursor: pointer; }
.hkb-dot[aria-current="true"] { background: var(--hkb-navy); }
.hkb-dot:focus-visible { outline: 2px solid var(--hkb-green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .wp-block-gallery.hkb-slideshow.is-ready.has-nested-images > figure.wp-block-image { transition: none; } }

/* ---------- Buttons (navy, full column width) ---------- */
.wp-block-button__link, .wp-element-button { border-radius: 4px; text-decoration: none; transition: background-color .2s, color .2s; text-align: center; }
.wp-block-button.hkb-btn { width: 100%; }
.wp-block-button.hkb-btn .wp-block-button__link { display: block; width: 100%; }
.wp-block-button.is-style-outline > .wp-block-button__link {
	background: transparent; color: var(--wp--preset--color--navy); border: 2px solid var(--wp--preset--color--navy);
}

/* ---------- Lists (publications etc.) ---------- */
.wp-block-post-content ul, .wp-block-post-content ol { line-height: 1.6; padding-left: 1.4em; font-size: .95rem; }
.wp-block-post-content li + li { margin-top: .6em; }
.wp-block-post-content li { overflow-wrap: anywhere; }

/* ---------- Blog index rows (.hkb-rows query) ---------- */
.hkb-rows .wp-block-post-template { list-style: none; margin: 0; padding: 0; display: block; }
.hkb-rows .wp-block-post-template > li { margin: 0 0 3rem; }
.hkb-rows .wp-block-columns { gap: 2rem; align-items: flex-start; margin: 0; }
.hkb-rows .wp-block-post-featured-image { margin: 0; }
.hkb-rows .wp-block-post-featured-image img { width: 100%; height: auto; display: block; }
.hkb-rows .wp-block-post-title { margin: 0 0 1rem; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.2; font-weight: 700; }
.hkb-rows .wp-block-post-title a { color: var(--hkb-green); text-decoration: none; }
.hkb-rows .wp-block-post-title a:hover { text-decoration: underline; }
.hkb-rows .hkb-index-excerpt { margin: 0 0 1rem; font-size: .9rem; }
.hkb-rows .wp-block-read-more {
	display: block; width: 100%; box-sizing: border-box; text-align: center; text-decoration: none; padding: .55em 1em;
	background: var(--hkb-navy); color: #fff; font-weight: 600; border-radius: 4px;
}
.hkb-rows .wp-block-read-more:hover { background: var(--hkb-green); color: #fff; }

/* ---------- Post cards (archives, .hkb-cards query) ---------- */
.hkb-cards .wp-block-post-template { gap: 28px; margin-top: 1rem; }
.hkb-cards .wp-block-post-template > li { display: flex; flex-direction: column; margin: 0; background: #fff; border-radius: 8px; overflow: hidden; }
.hkb-cards .wp-block-post-featured-image img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.hkb-cards .wp-block-post-title { margin: 16px 18px 6px; font-size: 1.15rem; }
.hkb-cards .wp-block-post-title a { color: var(--wp--preset--color--green); text-decoration: none; }
.hkb-cards .wp-block-post-excerpt { margin: 6px 18px 18px; font-size: .95rem; }
@media (max-width: 900px) { .hkb-cards .wp-block-post-template.is-layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .hkb-cards .wp-block-post-template.is-layout-grid { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.hkb-footer { margin-top: 0; }
.hkb-footer p { margin: 0; }
.hkb-footer a { text-decoration: underline; text-underline-offset: 3px; }
.hkb-footer a:hover { opacity: .85; }
.hkb-footer__copy { opacity: .8; }

/* ---------- Mobile: gutters, stacking ---------- */
@media (max-width: 781px) {
	:root { --hkb-gutter: 18px; }
	.hkb-row { gap: 1.25rem; }
	.hkb-span, .hkb-span-2, .hkb-span-3, .hkb-span-4, .hkb-span-5, .hkb-span-6, .hkb-span-7, .hkb-span-8, .hkb-span-9, .hkb-span-10, .hkb-span-11 { max-width: 100%; }
	.hkb-span-2 { max-width: 260px; }
	.wp-block-columns.hkb-row > .wp-block-column { flex-basis: 100% !important; }
	.hkb-rows .wp-block-columns { gap: .75rem; }
	.hkb-band { padding: 28px var(--hkb-gutter); }
	.hkb-post-hero, .wp-block-cover.hkb-hero { min-height: 220px; }
	.hkb-footer, .hkb-header { padding-left: var(--hkb-gutter) !important; padding-right: var(--hkb-gutter) !important; }
}

/* Long URLs must wrap instead of running off narrow screens */
.entry-content a, .entry-content p, .entry-content li { overflow-wrap: anywhere; }
