/*
 * TFK Periodic — layout and component styles that theme.json cannot express.
 * Tokens come from theme.json presets (--wp--preset--*).
 */

:root {
	--tfk-ink: var(--wp--preset--color--ink);
	--tfk-paper: var(--wp--preset--color--paper);
	--tfk-white: var(--wp--preset--color--white);
	--tfk-muted: var(--wp--preset--color--muted-border);
	--tfk-display: var(--wp--preset--font-family--display);
	--tfk-section: clamp(32px, 6vw, 64px);
}

*,
*::before,
*::after {
	border-radius: 0 !important;
	box-shadow: none !important;
}

body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 3px solid var(--tfk-ink);
	outline-offset: 2px;
}

.tfk-label {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 800;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

/* Bound paragraphs that have no value render empty: hide them. */
p:empty {
	display: none;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.skip-link:focus {
	z-index: 100000;
	clip: auto;
	width: auto;
	height: auto;
	padding: 12px 16px;
	background: var(--tfk-white);
	color: var(--tfk-ink);
}

/* ---------- Sections ---------- */

.tfk-main {
	margin-block-start: 0;
}

.tfk-section {
	padding-top: var(--tfk-section);
	padding-bottom: var(--tfk-section);
}

.tfk-section + .tfk-section:not(.is-style-dark-section) {
	border-top: 2px solid var(--tfk-ink);
}

.tfk-section > :first-child {
	margin-block-start: 0;
}

.is-style-dark-section {
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.is-style-dark-section a:where(:not(.wp-element-button):not(.tfk-tag)) {
	color: var(--tfk-white);
}

.is-style-dark-section :where(a, button):focus-visible,
.is-style-dark-section a:hover {
	outline-color: var(--tfk-white);
}

.is-style-dark-section .tfk-muted,
.is-style-dark-section .tfk-card__meta {
	color: var(--wp--preset--color--on-dark-muted);
}

.is-style-dark-section .wp-element-button {
	border-color: var(--tfk-white);
	background: var(--tfk-white);
	color: var(--tfk-ink);
}

.is-style-dark-section .wp-element-button:hover {
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.tfk-section-head {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 24px;
}

.tfk-section-head > * {
	margin: 0 !important;
}

.tfk-more a {
	font-weight: 800;
}

.tfk-intro {
	max-width: 760px;
}

.tfk-prose > * {
	max-width: 760px;
}

.tfk-prose > .alignwide,
.tfk-prose > .alignfull,
.tfk-prose > .tfk-labs,
.tfk-prose > .wp-block-group,
.tfk-prose > .wp-block-columns {
	max-width: none;
}

/* ---------- Header ---------- */

.tfk-header {
	position: relative;
	z-index: 20;
	border-bottom: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
}

.tfk-header__in {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 32px;
	align-items: center;
	justify-content: space-between;
	padding-top: 12px;
	padding-bottom: 12px;
}

.tfk-brand {
	display: flex;
	gap: 12px;
	align-items: center;
	min-width: 0;
}

.tfk-logo {
	display: grid;
	flex: none;
	grid-template-rows: auto 1fr;
	width: 64px;
	height: 64px;
	padding: 4px 6px;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-ink);
	color: var(--tfk-white);
	text-decoration: none;
}

.tfk-logo__top {
	font-family: var(--tfk-display);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.tfk-logo__sym {
	place-self: center;
	font-family: var(--tfk-display);
	font-size: 26px;
	font-weight: 800;
	line-height: 1;
}

.tfk-logo:hover {
	outline: 3px solid var(--tfk-ink);
	outline-offset: 2px;
}

.tfk-brand__text {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.tfk-brand__text > * {
	margin: 0 !important;
}

.tfk-brand .wp-block-site-title {
	font-family: var(--tfk-display);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
}

.tfk-brand .wp-block-site-title a {
	color: inherit;
	text-decoration: none;
}

.tfk-badge {
	display: inline-block;
	align-self: flex-start;
	padding: 3px 8px;
	border: 2px solid var(--tfk-ink);
	background: var(--wp--preset--color--el-gg);
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.04em;
	line-height: 1.25;
	text-transform: uppercase;
}

/* ---------- Navigation: periodic cells ---------- */

.wp-block-navigation:not(.is-style-periodic) .tfk-nav-sym {
	display: none;
}

.is-style-periodic {
	--cell-w: 92px;
	--cell-h: 72px;
	font-family: var(--wp--preset--font-family--body);
}

.is-style-periodic .wp-block-navigation__container {
	gap: 6px;
}

.is-style-periodic .wp-block-navigation-item {
	position: relative;
}

.is-style-periodic .wp-block-navigation-item > .wp-block-navigation-item__content {
	display: flex;
	flex-direction: column;
	gap: 6px;
	justify-content: space-between;
	box-sizing: border-box;
	min-width: var(--cell-w);
	max-width: 132px;
	height: var(--cell-h);
	padding: 7px 8px 6px;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
	color: var(--tfk-ink);
	text-decoration: none;
}

.is-style-periodic .tfk-nav-sym {
	font-family: var(--tfk-display);
	font-size: 20px;
	font-weight: 800;
	line-height: 1;
}

.is-style-periodic .wp-block-navigation-item__label {
	display: -webkit-box;
	overflow: hidden;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.15;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow-wrap: anywhere;
}

.is-style-periodic .wp-block-navigation-item > .wp-block-navigation-item__content:hover {
	outline: 3px solid var(--tfk-ink);
	outline-offset: 2px;
}

.is-style-periodic .current-menu-item > .wp-block-navigation-item__content,
.is-style-periodic .current-menu-ancestor > .wp-block-navigation-item__content {
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

/* Submenu toggle sits in the cell's corner. */
.is-style-periodic .wp-block-navigation__submenu-icon {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 16px;
	height: 16px;
	margin: 0;
	padding: 0;
	color: inherit;
}

.is-style-periodic .current-menu-ancestor > .wp-block-navigation__submenu-icon,
.is-style-periodic .current-menu-item > .wp-block-navigation__submenu-icon {
	color: var(--tfk-white);
}

.is-style-periodic .wp-block-navigation__submenu-icon svg {
	width: 12px;
	height: 12px;
	stroke: currentColor;
}

/* Dropdown: column of white cells. */
.is-style-periodic .wp-block-navigation__submenu-container {
	gap: 4px;
	min-width: 0 !important;
	padding: 6px 0 0 !important;
	border: 0 !important;
	background: transparent !important;
}

.is-style-periodic .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	flex-direction: row;
	gap: 12px;
	align-items: center;
	justify-content: flex-start;
	width: 240px;
	max-width: none;
	height: 56px;
	background: var(--tfk-white);
}

.is-style-periodic .wp-block-navigation__submenu-container .tfk-nav-sym {
	flex: none;
	width: 32px;
	font-size: 18px;
}

.is-style-periodic .wp-block-navigation__submenu-container .wp-block-navigation-item__label {
	font-size: 14px;
}

/* Burger and overlay. Core switches at 600px; the cells need 760px. */
.is-style-periodic .wp-block-navigation__responsive-container-open {
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.is-style-periodic .wp-block-navigation__responsive-container-open svg,
.is-style-periodic .wp-block-navigation__responsive-container-close svg {
	width: 28px;
	height: 28px;
}

@media (max-width: 759px) {
	.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}

	.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}
}

.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container.is-menu-open {
	padding: 16px;
	background: var(--tfk-paper);
	color: var(--tfk-ink);
}

.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation__responsive-container-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
}

.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: 72px;
}

.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content .wp-block-navigation__container {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	width: 100%;
}

/* Flatten submenus in the overlay: every item becomes a cell of the 3×N grid. */
.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation-submenu,
.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation__submenu-container {
	display: contents !important;
}

.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation__submenu-icon {
	display: none;
}

.wp-block-navigation.is-style-periodic .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content .wp-block-navigation-item__content {
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	width: 100%;
	min-width: 0;
	max-width: none;
	height: auto;
	min-height: 84px;
	padding: 8px;
}

.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	border-style: dashed;
}

.wp-block-navigation.is-style-periodic .is-menu-open .wp-block-navigation-item__label {
	font-size: 13px;
	-webkit-line-clamp: 3;
}

.wp-block-navigation.is-style-periodic .is-menu-open .tfk-nav-sym {
	font-size: 22px;
}

/* Section sub-navigation (Про ЦК) */
.tfk-subnav.is-style-periodic {
	--cell-w: 120px;
	--cell-h: 64px;
}

/* ---------- Hero ---------- */

.tfk-hero__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
	grid-template-areas:
		"title table"
		"text table";
	gap: 24px 56px;
	align-items: start;
}

.tfk-hero__grid > * {
	margin: 0 !important;
}

.tfk-hero__title {
	grid-area: title;
}

.tfk-hero__table {
	grid-area: table;
}

.tfk-hero__text {
	grid-area: text;
}

.tfk-hero__title > *,
.tfk-hero__text > * {
	margin-top: 0;
}

.tfk-hero h1 {
	margin: 12px 0 0;
	letter-spacing: -0.01em;
}

@media (max-width: 899px) {
	.tfk-hero__grid {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"title"
			"table"
			"text";
		gap: 20px;
	}

	.tfk-hero.tfk-section {
		padding-top: 24px;
	}
}

/* ---------- Method theme quote ---------- */

.tfk-theme-quote {
	margin: 0;
	padding-left: 24px;
	border-left: 6px solid var(--tfk-ink);
}

.tfk-theme-quote p {
	margin: 0;
}

.tfk-theme-quote cite {
	display: block;
	margin-top: 8px;
	font-size: var(--wp--preset--font-size--label);
	font-style: normal;
	font-weight: 800;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

/* ---------- Cards for Query Loops ---------- */

.tfk-cards .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tfk-cards--2 .wp-block-post-template {
	grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

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

.tfk-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
	color: var(--tfk-ink);
}

.is-style-dark-section .tfk-card {
	border-color: var(--tfk-white);
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.tfk-card > .wp-block-post-featured-image {
	margin: 0;
	border-bottom: 2px solid currentColor;
}

.tfk-card > .wp-block-post-featured-image img {
	aspect-ratio: inherit;
}

.tfk-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
}

.tfk-card__body > * {
	margin: 0 !important;
}

.tfk-card__title {
	font-size: 17px;
	line-height: 1.3;
}

.tfk-card__title a {
	color: inherit;
	text-decoration: none;
}

.tfk-card__title a:hover {
	text-decoration: underline;
}

.tfk-card__meta {
	font-size: 16px;
	line-height: 1.45;
	color: var(--wp--preset--color--muted-text);
}

.tfk-card .wp-block-tfk-discipline-tags {
	margin-top: auto !important;
	padding-top: 8px;
}

.is-style-dark-section .tfk-card .tfk-photo-ph {
	background: #2A2D33;
	color: var(--wp--preset--color--on-dark-muted);
}

.is-style-dark-section .tfk-tag {
	border-color: var(--tfk-white);
}

/* Pagination */

.wp-block-query-pagination {
	gap: 8px;
	margin-top: 24px;
}

.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 12px;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
	color: var(--tfk-ink);
	font-weight: 800;
	text-decoration: none;
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

/* ---------- Labs ---------- */

.tfk-labs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
	gap: 16px;
}

.tfk-labs > * {
	margin: 0 !important;
}

.tfk-lab {
	position: relative;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
}

.tfk-lab > * {
	margin: 0 !important;
}

.tfk-lab__photo img {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	filter: grayscale(0.15) contrast(1.05);
	border-bottom: 2px solid var(--tfk-ink);
}

.tfk-lab__body {
	padding: 16px;
}

.tfk-lab__body > * {
	margin: 0 0 8px !important;
}

.tfk-room {
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	margin-top: -48px !important;
	border: 2px solid var(--tfk-ink);
	background: var(--wp--preset--color--el-fz);
	font-family: var(--tfk-display);
	font-size: 15px;
	font-weight: 800;
	line-height: 1;
	position: relative;
}

/* ---------- Contacts ---------- */

.tfk-contacts {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
	gap: 16px;
}

.tfk-contacts > * {
	margin: 0 !important;
	padding: 16px;
	border: 2px solid var(--tfk-ink);
	background: var(--tfk-white);
}

.tfk-contacts > * > * {
	margin: 0 0 8px !important;
}

.tfk-contacts .wp-block-button__link {
	overflow-wrap: anywhere;
}

/* ---------- Page heading ---------- */

.tfk-page-head {
	display: grid;
	gap: 16px;
	margin-bottom: 32px;
}

.tfk-page-head > * {
	margin: 0 !important;
}

.tfk-page-head h1 {
	font-weight: 800;
}

/* ---------- Footer ---------- */

.tfk-footer {
	padding-top: 48px;
	padding-bottom: 32px;
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.tfk-footer a {
	color: var(--tfk-white);
}

.tfk-footer a:hover,
.tfk-footer :focus-visible {
	outline-color: var(--tfk-white);
}

.tfk-footer__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
	gap: 32px;
}

.tfk-footer__grid > * {
	margin: 0 !important;
}

.tfk-footer__grid > * > * {
	margin: 0 0 8px !important;
}

.tfk-footer .tfk-logo {
	border-color: var(--tfk-white);
}

.tfk-footer .wp-element-button {
	border-color: var(--tfk-white);
	background: var(--tfk-white);
	color: var(--tfk-ink);
	overflow-wrap: anywhere;
}

.tfk-footer .wp-element-button:hover {
	background: var(--tfk-ink);
	color: var(--tfk-white);
}

.tfk-footer__muted {
	color: var(--wp--preset--color--on-dark-muted);
	font-size: 16px;
}

.tfk-footer__bottom {
	margin-top: 32px !important;
	padding-top: 16px;
	border-top: 1px solid var(--wp--preset--color--muted-border);
	color: var(--wp--preset--color--on-dark-muted);
	font-size: 16px;
}

/* ---------- Search, 404 ---------- */

.wp-block-search__input {
	min-height: 48px;
	border: 2px solid var(--tfk-ink) !important;
	padding: 8px 12px;
	font: inherit;
}

.wp-block-search__button {
	min-height: 48px;
	margin-left: 0 !important;
}

.tfk-search-results .wp-block-post-template {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 2px solid var(--tfk-ink);
}

.tfk-search-results .wp-block-post-template > li {
	padding: 16px 0;
	border-bottom: 1px solid var(--tfk-muted);
}

/* ---------- Motion ---------- */

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

/* ---------- Print (A4) ---------- */

@media print {
	@page {
		size: A4;
		margin: 16mm 14mm;
	}

	body {
		background: #fff !important;
		color: #000 !important;
		font-size: 11pt;
	}

	.tfk-header .wp-block-navigation,
	.tfk-subnav,
	.tfk-crumbs,
	.wp-block-search,
	.wp-block-query-pagination,
	.tfk-works__filters,
	.tfk-fb,
	.skip-link {
		display: none !important;
	}

	.tfk-header {
		border-bottom: 2px solid #000;
	}

	.is-style-dark-section,
	.tfk-footer,
	.tfk-card,
	.is-style-dark-section .tfk-card {
		border: 2px solid #000 !important;
		background: #fff !important;
		color: #000 !important;
	}

	.is-style-dark-section a,
	.tfk-footer a {
		color: #000 !important;
	}

	.tfk-footer .wp-element-button,
	.is-style-dark-section .wp-element-button {
		background: #fff !important;
		color: #000 !important;
	}

	.tfk-logo {
		background: #fff !important;
		color: #000 !important;
	}

	.tfk-card,
	.tfk-lab,
	.tfk-contacts > *,
	.tfk-section-head {
		break-inside: avoid;
	}

	h1,
	h2,
	h3 {
		break-after: avoid;
	}

	.tfk-section {
		padding-top: 12mm;
		padding-bottom: 0;
	}

	.tfk-section + .tfk-section:not(.is-style-dark-section) {
		border-top: 0;
	}

	a[href^="http"]:not(.tfk-cell):not(.tfk-tag)::after {
		content: " (" attr(href) ")";
		font-size: 9pt;
		word-break: break-all;
	}
}

/* ---------- Small screens ---------- */

@media (max-width: 599px) {
	.tfk-header__in {
		flex-wrap: nowrap;
		gap: 12px;
		padding-top: 10px;
		padding-bottom: 10px;
	}

	.tfk-brand .wp-block-site-title {
		display: none;
	}

	.tfk-logo {
		width: 52px;
		height: 52px;
	}

	.tfk-logo__sym {
		font-size: 22px;
	}

	.tfk-badge {
		font-size: 11px;
	}
}
