/**
 * Current-generation single articles, including saved Takt single templates.
 * Native layout widths and authored block styles remain the source of truth.
 * The 0.5 compatibility template keeps its established presentation. Headlines
 * use the whole authored header width instead of the running-text measure.
 */

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-header .wp-block-post-title {
	max-width: none;
	font-size: clamp(2.25rem, 1.5rem + 2vw, 3.5rem);
	font-weight: 650;
	letter-spacing: -0.035em;
	line-height: 1.08;
	text-wrap: pretty;
	overflow-wrap: anywhere;
}

body.single-post:not(.takt-design-0-5):is(.takt-title-long, .takt-title-very-long) :where(.takt-single) .takt-entry-header .wp-block-post-title {
	font-size: clamp(2rem, 1.25rem + 2vw, 3.25rem);
	letter-spacing: -0.025em;
	line-height: 1.14;
	text-wrap: pretty;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-meta {
	row-gap: 0.5rem;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-meta > * {
	margin-block: 0;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-meta .wp-block-post-author-name {
	padding-inline-start: var(--wp--preset--spacing--30);
	border-inline-start: 1px solid var(--wp--preset--color--line);
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-meta a {
	color: inherit;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) :where(.takt-article__image) img {
	display: block;
	width: 100%;
}

/* Magazine layout belongs to the new file template only. Saved single
   templates keep their existing placement of related posts. Source order is
   always article first, recommendations second, including without CSS. */
:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__layout {
	display: grid;
	container-type: inline-size;
	container-name: takt-article;
	grid-template-columns: minmax(0, 1fr);
	gap: clamp(2rem, 4vw, 4rem);
	align-items: start;
}

:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__layout > * {
	min-width: 0;
	margin-block: 0;
}

:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__sidebar {
	padding-block-start: var(--wp--preset--spacing--50);
	border-block-start: 1px solid var(--wp--preset--color--line);
}

/* The reusable related-posts pattern carries three inline settings for its
   original below-article placement. Reset only those in the sidebar; keep the
   pattern and its native query intact everywhere else. */
:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__sidebar > .takt-related {
	margin-block-start: 0 !important;
	padding-block-start: 0 !important;
	border-block-start-width: 0 !important;
}

:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__sidebar .wp-block-post-template {
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--preset--spacing--50);
}

@media (min-width: 1100px) {
	:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__layout {
		grid-template-columns: minmax(0, 1fr) minmax(17rem, 22rem);
	}

	:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__sidebar {
		padding-block-start: 0;
		border-block-start: 0;
	}
}

/* Global Styles or a child theme can choose a narrow wide-size even on a
   large screen. Query the actual layout, then span its children; a container
   cannot query its own size to change its grid definition. Inline containment
   leaves height and overflow natural. Core's lightbox overlay lives outside
   this container in wp_footer. */
@container takt-article (max-width: 54rem) {
	:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__layout > * {
		grid-column: 1 / -1;
	}

	:is(body.single-post:not(.takt-design-0-5), .editor-styles-wrapper) .takt-article__layout > .takt-article__sidebar {
		padding-block-start: var(--wp--preset--spacing--50);
		border-block-start: 1px solid var(--wp--preset--color--line);
	}
}

/* Inherited prose sizing improves existing posts without restyling headings,
   buttons, captions or blocks that carry an explicit font-size choice. */
:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-content:where(:not(.has-custom-font-size):not([class*="-font-size"])) {
	font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
	line-height: 1.8;
	overflow-wrap: break-word;
}

/* A lone full-width group is common in imported articles. Give its text the
   same rhythm as native top-level blocks, without touching nested layouts. */
:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) :is(.takt-entry-content, .takt-entry-content > .wp-block-group.alignfull:only-child) > :where(p, ul, ol, blockquote, pre, figure, table) + :where(p, ul, ol, blockquote, pre, figure, table) {
	margin-block-start: 1.5em;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) :is(.takt-entry-content, .takt-entry-content > .wp-block-group.alignfull:only-child) > * + :is(h2, h3, h4, h5, h6) {
	margin-block-start: 2.25em;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) :is(.takt-entry-content, .takt-entry-content > .wp-block-group.alignfull:only-child) > :is(h2, h3, h4, h5, h6) + * {
	margin-block-start: 0.85em;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) :is(.takt-entry-content, .takt-entry-content > .wp-block-group.alignfull:only-child) > :is(ul, ol) > li + li {
	margin-block-start: 0.5em;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-content :where(blockquote) {
	line-height: 1.65;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-entry-content :where(pre) {
	overflow-x: auto;
	white-space: pre;
	overflow-wrap: normal;
}

/* A deliberately inserted spacer owns its gap. */
:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) :is(.takt-entry-content, .takt-entry-content > .wp-block-group.alignfull:only-child) > .wp-block-spacer + * {
	margin-block-start: 0;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-post-nav {
	padding-block-start: var(--wp--preset--spacing--50);
	border-block-start: 1px solid var(--wp--preset--color--line);
	align-items: flex-start;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-post-nav > * {
	min-width: 0;
	flex: 1 1 16rem;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-post-nav a {
	display: inline-block;
	padding-block: 0.4rem;
}

:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-comments {
	padding-block-start: var(--wp--preset--spacing--50);
	border-block-start: 1px solid var(--wp--preset--color--line);
}

@media (max-width: 600px) {
	:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-post-nav {
		flex-direction: column;
		align-items: stretch;
	}

	:is(body.single-post:not(.takt-design-0-5) :where(.takt-single), .editor-styles-wrapper :where(.takt-article)) .takt-post-nav > * {
		flex-basis: auto;
	}
}
