/* ==========================================================================
   CONTENT — Gutenberg content width, vertical rhythm, block base styling
   --------------------------------------------------------------------------
   .entry-content is a constrained grid: normal blocks sit in a readable
   column, .alignwide widens, .alignfull spans edge-to-edge — with consistent
   gutters at every screen width and custom canvas width. Vertical rhythm
   follows the brief's rule: tight within a group, generous space before a new
   heading. Everything references tokens, so it adapts to the dark theme and
   the font-size control automatically. (§6.3)
   ========================================================================== */

.entry-content {
	padding-bottom: var(--section-y);
}

/* --- Content-width grid (alignwide / alignfull) -------------------------- */
.entry-content {
	display: grid;
	grid-template-columns:
		[full-start] minmax(var(--gutter), 1fr)
		[wide-start] minmax(0, calc((var(--container) - var(--content-width)) / 2))
		[content-start] min(var(--content-width), 100% - var(--gutter) * 2)
		[content-end] minmax(0, calc((var(--container) - var(--content-width)) / 2))
		[wide-end] minmax(var(--gutter), 1fr)
		[full-end];
}

.entry-content > * {
	grid-column: content-start / content-end;
	margin-block: 0;
	min-width: 0; /* wide children (tables, media) shrink to fit instead of overflowing */
}

.entry-content > .alignwide {
	grid-column: wide-start / wide-end;
}

.entry-content > .alignfull {
	grid-column: full-start / full-end;
}

/* --- Vertical rhythm (flow) ---------------------------------------------- */
/* Uniform gap between blocks, overridden per element via --flow. */
.entry-content > * + * {
	margin-block-start: var(--flow, var(--space-4));
}

/* Generous space BEFORE a heading (starts a new group). */
.entry-content > :where(h2) { --flow: var(--space-7); }
.entry-content > :where(h3) { --flow: var(--space-6); }
.entry-content > :where(h4, h5, h6) { --flow: var(--space-5); }

/* A little more air around set-piece blocks. */
.entry-content > :where(figure, .wp-block-table, pre, hr, .wp-block-separator) {
	--flow: var(--space-6);
}

/* Headings own the gap BELOW them via margin-bottom (in em → scales with the
   heading size), so the following element adds no extra top gap. The `+ *` rule
   is listed last so it also wins the --flow for a heading-after-heading. */
.entry-content > :where(h2, h3, h4, h5, h6) { margin-bottom: 0.5em; }
.entry-content > :where(h2, h3, h4, h5, h6) + * { --flow: 0; }

/* Quotes get generous, symmetric space above and below. Listed after the
   heading rules so a quote following a heading still gets its full top gap. */
.entry-content > :where(blockquote, .wp-block-quote) { --flow: var(--space-7); }
.entry-content > :where(blockquote, .wp-block-quote) + * { --flow: var(--space-7); }

.entry-content :where(h2, h3, h4, h5, h6) {
	scroll-margin-top: calc(var(--header-h) + var(--space-5)); /* anchors clear the fixed header */
}

/* --- Lead + links ------------------------------------------------------ */
/* The opening paragraph reads as a lead (editorial standfirst). */
.entry-content > p:first-child {
	font-size: var(--fs-lead);
	line-height: 1.55;
	color: var(--c-heading);
}

.entry-content a:where(:not([class])) {
	text-decoration-color: color-mix(in srgb, var(--c-accent) 55%, transparent);
	text-decoration-thickness: 1px;
	transition: color var(--dur-1) ease, text-decoration-color var(--dur-1) ease, text-decoration-thickness var(--dur-1) ease;
}

.entry-content a:where(:not([class])):hover {
	text-decoration-color: var(--c-accent);
	text-decoration-thickness: 2px;
}

/* --- Lists --------------------------------------------------------------- */
.entry-content :where(ul, ol) {
	padding-inline-start: var(--space-5);
}

.entry-content li + li {
	margin-top: var(--space-1);
}

.entry-content li > :where(ul, ol) {
	margin-top: var(--space-1);
}

/* --- Blockquote ---------------------------------------------------------- */
/* Pull-quote: the editorial voice (Source Sans 3 italic). Two columns — the
   Swiss guillemet sits in its own area on the LEFT, the text on the right, with
   a small gap between. No left rule. */
.entry-content :where(blockquote, .wp-block-quote) {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: var(--space-4);
	align-items: start;
	margin-inline: 0; /* strip the browser's side margins; flow system owns the gap */
	font-family: var(--font-quote);
	font-style: italic;
	font-weight: 400;
	font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.25rem);
	line-height: 1.25;
	letter-spacing: -0.01em;
	color: var(--c-heading);
}
.entry-content :where(blockquote, .wp-block-quote)::before {
	content: "«";
	grid-column: 1;
	align-self: start;
	font-family: var(--font-quote);
	font-style: normal;
	font-weight: 700;
	font-size: 3.5rem;
	line-height: 0.8; /* ≈ the first text line so the row height matches */
	color: var(--c-accent-text);
}
/* Text (paragraph + citation) go in the right column. */
.entry-content :where(blockquote, .wp-block-quote) > * {
	grid-column: 2;
}

.entry-content :where(blockquote, .wp-block-quote) :where(cite, .wp-block-quote__citation) {
	display: block;
	margin-top: var(--space-4);
	font-family: var(--font-mono);
	font-size: var(--fs-xs);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	font-style: normal;
	color: var(--c-text-muted);
}

/* --- Figures & captions -------------------------------------------------- */
.entry-content figure {
	margin: 0;
}

.entry-content figcaption {
	margin-top: var(--space-2);
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
	text-align: center;
}

/* Wide/full images always fill their track. */
.entry-content > :where(.alignwide, .alignfull) img {
	width: 100%;
}

/* --- Separator ----------------------------------------------------------- */
.entry-content :where(hr, .wp-block-separator) {
	border: 0;
	border-top: 1px solid var(--c-border);
	height: 0;
}

/* --- Code ---------------------------------------------------------------- */
.entry-content :where(code, kbd, samp) {
	font-family: var(--font-mono);
	font-size: 0.88em;
	background: color-mix(in srgb, var(--c-text) 8%, transparent);
	padding: 0.1em 0.35em;
}

.entry-content pre {
	overflow-x: auto;
	padding: var(--space-4);
	background: var(--c-navy-900);
	color: #e3eaf4;
}

.entry-content pre code {
	background: none;
	padding: 0;
	color: inherit;
	font-size: inherit;
}

/* ==========================================================================
   TABLES — clean, and horizontally scrollable at any column count
   --------------------------------------------------------------------------
   The Gutenberg table block (figure.wp-block-table) is the scroll container:
   the table fills the column when it fits and scrolls when it can't, so a
   10-column table never blows out the layout. Bare tables still read cleanly.
   ========================================================================== */
.wp-block-table {
	margin: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.entry-content table,
.wp-block-table table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--fs-sm);
}

/* Inside the scroll container the table may exceed the column width. */
.wp-block-table table {
	width: auto;
	min-width: 100%;
}

.entry-content :where(th, td),
.wp-block-table :where(th, td) {
	padding: var(--space-2) var(--space-3);
	text-align: start;
	vertical-align: top;
	border-bottom: 1px solid var(--c-border);
}

.entry-content thead th,
.wp-block-table thead th {
	font-family: var(--font-heading);
	font-weight: 600;
	color: var(--c-heading);
	border-bottom: 2px solid var(--c-heading);
	white-space: nowrap; /* keep headers on one line → predictable scroll trigger */
}

.entry-content tbody tr:nth-child(even),
.wp-block-table tbody tr:nth-child(even) {
	background: color-mix(in srgb, var(--c-text) 4%, transparent);
}

.entry-content caption,
.wp-block-table figcaption {
	margin-top: var(--space-2);
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
	text-align: start;
}

/* ==========================================================================
   GALLERY (our .sac-gallery, e.g. hütten)
   --------------------------------------------------------------------------
   Self-contained responsive grid so galleries render correctly even when this
   install loads WordPress core block CSS per-block (our raw .wp-block-gallery
   markup wouldn't trigger the gallery/image block styles). Where the core
   gallery CSS IS present it is more specific and takes precedence.
   ========================================================================== */
.sac-gallery {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-3);
	margin: 0;
}

.sac-gallery .wp-block-image {
	margin: 0;
}

.sac-gallery .wp-block-image a {
	display: block;
}

.sac-gallery .wp-block-image img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	transition: transform 1.2s var(--ease-out);
}

.sac-gallery .wp-block-image a {
	overflow: hidden;
}

.sac-gallery .wp-block-image a:hover img {
	transform: scale(1.04);
}

@media (min-width: 600px) {
	.sac-gallery {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ==========================================================================
   FORMS + BUTTONS IN CONTENT (also the comment form)
   ========================================================================== */

/* Fields — content forms and the comment form share one look. */
:where(.entry-content, .sac-comment-form) :where(
	input[type="text"], input[type="email"], input[type="url"], input[type="tel"],
	input[type="number"], input[type="password"], input[type="search"], input[type="date"],
	select, textarea
) {
	width: 100%;
	min-height: 3.25rem;
	padding: var(--space-3) var(--space-4);
	color: var(--c-heading);
	background: var(--c-surface);
	border: 1px solid var(--c-border-strong);
	border-radius: 0;
	transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease;
}

:where(.entry-content, .sac-comment-form) :where(input, select, textarea):focus {
	border-color: var(--c-accent);
	box-shadow: 0 0 0 3px var(--c-accent-soft);
	outline: 0;
}

:where(.entry-content, .sac-comment-form) textarea {
	min-height: 10rem;
	resize: vertical;
}

:where(.entry-content, .sac-comment-form) input[type="checkbox"] {
	width: 1.15rem;
	height: 1.15rem;
	margin-top: 0.2rem;
	accent-color: var(--c-accent);
}

/* Core buttons inside content adopt the theme button. */
.entry-content .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	min-height: 3.25rem;
	padding: 0 var(--space-6);
	color: var(--c-on-accent);
	background: var(--c-accent);
	border-radius: 999px;
	font-size: var(--fs-sm);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-decoration: none;
	transition: background-color var(--dur-2) var(--ease-out), transform var(--dur-1) ease;
}

.entry-content .wp-block-button__link:hover {
	color: var(--c-on-accent);
	background: var(--c-accent-ink);
}

.entry-content .wp-block-button__link:active {
	transform: scale(0.97);
}

.entry-content .is-style-outline .wp-block-button__link {
	color: var(--c-heading);
	background: transparent;
	border: 1px solid var(--c-border-strong);
}

.entry-content .is-style-outline .wp-block-button__link:hover {
	color: var(--c-bg);
	background: var(--c-heading);
}
