/**
 * Društvo Trepetlika – Primorska regija: site CSS.
 *
 * Only what a block setting cannot do. Colours, spacing, sizes, borders and grid columns of the
 * pages are block settings (theme.json presets); this file draws the shapes of the block styles
 * registered in functions.php, the browser surfaces (focus, selection) and one overlap.
 * Tokens: theme.json palette + custom.pr (design-plan.md). No hex values here.
 */

/* Browser surfaces: one focus ring for every control, text selection in the brand colour. */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
	outline: 3px solid var(--wp--preset--color--ink);
	outline-offset: 3px;
	border-radius: 4px;
}

::selection {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
}

:where(.wp-site-blocks) a {
	text-underline-offset: 0.2em;
	text-decoration-thickness: 1px;
}

:where(.wp-site-blocks) a:hover {
	text-decoration-thickness: 2px;
}

/* Phone numbers and e-mails line up when listed. */
:where(.wp-site-blocks) a[href^="tel:"] {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* A link that is the whole paragraph (phone, e-mail, "Uradni podatki …") is a full-height row, so it
   is easy to hit with a shaky hand (≥ 44 px, design-plan.md). */
:where(.wp-site-blocks) :is(main, footer) p > a:only-child {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
}

/* Long e-mail addresses wrap instead of pushing the column wider. */
:where(.wp-site-blocks) a[href^="mailto:"] {
	overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------------------------
 * Block style "Card link" (core/group): the first link in the heading covers the whole card, so the
 * card is one large target. An SVG arrow follows the heading (no text glyph). Border, radius, padding
 * and background are the group's own settings.
 * ------------------------------------------------------------------------------------------- */
.is-style-card-link {
	position: relative;
	transition: border-color 150ms ease, box-shadow 150ms ease;
}

.is-style-card-link :is(h2, h3, h4, .forge-pr-link-title) a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	min-height: var(--wp--custom--pr--target);
	line-height: 1.3;
}

.is-style-card-link :is(h2, h3, h4, .forge-pr-link-title) a::after {
	content: "";
	flex: none;
	width: 1.1em;
	height: 1.1em;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 150ms ease-out;
}

/* The stretched target: a layer over the whole card, owned by the heading link. */
.is-style-card-link :is(h2, h3, h4, .forge-pr-link-title) a::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	z-index: 1;
}

.is-style-card-link:has(a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--ink);
	outline-offset: 3px;
}

.is-style-card-link :is(h2, h3, h4, .forge-pr-link-title) a:focus-visible {
	outline: none;
}

.is-style-card-link:hover {
	/* A ring in the brand colour over the card's own border (its colour is a block setting). */
	box-shadow: 0 0 0 2px var(--wp--preset--color--primary), var(--forge-pr-shadow);
}

.is-style-card-link:hover :is(h2, h3, h4, .forge-pr-link-title) a {
	text-decoration: underline;
}

@media (hover: hover) and (pointer: fine) {
	.is-style-card-link:hover :is(h2, h3, h4, .forge-pr-link-title) a::after {
		transform: translateX(2px);
	}
}

/* The one elevation of the site, used only by card links on hover. */
:root {
	--forge-pr-shadow: 0 12px 32px -8px color-mix(in srgb, var(--wp--preset--color--primary) 14%, transparent); /* soft, green-tinted (reference design) */
}

/* ---------------------------------------------------------------------------------------------
 * Block style "Crest on a band" (core/image): a coat of arms centred on a tinted band at the top of a
 * card. The band runs to the card's edges, so the card keeps its padding for the text below.
 * ------------------------------------------------------------------------------------------- */
.wp-block-image.is-style-crest {
	display: grid;
	place-items: center;
	height: var(--wp--custom--pr--crest-band);
	margin: 0;
	background: var(--wp--preset--color--media);
	border-radius: var(--wp--custom--radius--card) var(--wp--custom--radius--card) 0 0;
}

.wp-block-image.is-style-crest img {
	width: auto;
	height: var(--wp--custom--pr--crest-size);
	max-height: var(--wp--custom--pr--crest-size); /* the editor puts height:auto inline on images; the cap still holds */
	max-width: 60%;
	object-fit: contain;
	filter: drop-shadow(0 2px 3px color-mix(in srgb, var(--wp--preset--color--ink) 15%, transparent));
}

/* ---------------------------------------------------------------------------------------------
 * Block style "Ruled items" (core/group with a grid): each child sits under a rule instead of in a box.
 * ------------------------------------------------------------------------------------------- */
.is-style-ruled > * {
	border-top: 2px solid var(--wp--preset--color--line);
	padding-top: var(--wp--preset--spacing--40);
}

/* ---------------------------------------------------------------------------------------------
 * Block style "Panel" (core/details): a large, clearly clickable summary with a drawn chevron.
 * ------------------------------------------------------------------------------------------- */
.wp-block-details.is-style-panel > summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: var(--wp--custom--pr--target);
	list-style: none;
	cursor: pointer;
	font-weight: 700;
	font-size: var(--wp--preset--font-size--medium);
}

.wp-block-details.is-style-panel > summary::-webkit-details-marker {
	display: none;
}

.wp-block-details.is-style-panel > summary::after {
	content: "";
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 200ms ease-out;
}

.wp-block-details.is-style-panel[open] > summary::after {
	transform: rotate(180deg);
}

.wp-block-details.is-style-panel[open] > summary {
	margin-bottom: var(--wp--preset--spacing--40);
}

/* ---------------------------------------------------------------------------------------------
 * Quick links: the bar is lifted over the bottom of the hero (an overlap the editor cannot set).
 * ------------------------------------------------------------------------------------------- */
:root .forge-pr-quick { /* :root matches core's ":root :where(…) > :first-child" weight; this file loads later */
	position: relative;
	z-index: 2;
	margin-block-start: calc(-1 * var(--wp--custom--pr--hero-overlap)); /* overlap with the hero: not a spacing preset */
}

.forge-pr-quick > * {
	min-height: var(--wp--custom--pr--target);
}

/* The header brand line under the logo: the full name of the society, hidden on phones where the
   header has room for the logo and menu only. */
@media (max-width: 599px) {
	.forge-pr-fullname {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.is-style-card-link,
	.is-style-card-link :is(h2, h3, h4, .forge-pr-link-title) a::after,
	.wp-block-details.is-style-panel > summary::after {
		transition: none;
	}
}

/* Phones: the header is the parent's grid (brand · button · menu). The "Kraji na Primorskem" button is
   the fourth quick link right under the hero, so it gives its room to the logo and region name. */
@media (max-width: 781px) {
	.forge-header--site .forge-header__actions {
		display: none;
	}
}

/* The society's logo is a leaf over the word TREPETLIKA: at the parent's fixed 40 px height the word is
   unreadable, so this site shows it taller. The site title is hidden by the parent when a logo is set
   (screen readers keep it); the visible line next to the logo is "Primorska regija". */
.forge-brand .wp-block-site-logo img {
	height: var(--wp--custom--pr--logo-height);
	max-width: none;
}

@media (max-width: 599px) {
	.forge-brand .wp-block-site-logo img {
		height: var(--wp--custom--pr--logo-height-phone);
	}
}

/* Hero photo (the group's background image setting): on narrow screens the leaves sit behind the text,
   so a white fade from the left keeps the heading and lead at full contrast. Decoration only. */
.forge-pr-hero {
	position: relative;
	isolation: isolate;
}

@media (max-width: 781px) {
	.forge-pr-hero::before {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		background: linear-gradient(90deg,
			var(--wp--preset--color--bg) 0%,
			color-mix(in srgb, var(--wp--preset--color--bg) 92%, transparent) 45%,
			color-mix(in srgb, var(--wp--preset--color--bg) 30%, transparent) 100%);
	}
}

/* Header "logo and text" (parts/header.html): the society's lockup as on its own site, logo over the
   full name and the English name, which are real text (readable at any size, translatable). */
.forge-pr-lockup {
	align-items: flex-start;
}

/* Header "logo as one image" (parts/header-logo-image.html): the whole lockup is one picture, which is
   only legible at its full size, so this header scrolls away instead of sticking. */
header.wp-block-template-part:has(> .forge-pr-header-image) {
	position: static;
}

.forge-pr-lockup-image {
	margin: 0;
}

.forge-pr-lockup-image img {
	display: block;
	width: 18.5rem;
	height: auto;
}

@media (max-width: 599px) {
	.forge-pr-lockup-image img {
		width: 12.5rem;
	}
}

/* Header "Primorska regija logo" (parts/header.html, default): compact, one row. The society's leaf (decorative,
   alt="") + "Primorska regija" as real text in the site font, "regija" in the brand green as in the full logo
   (design/logo-concepts/02-family-atkinson.svg, kept for print). The leaf is sized by height. */
.forge-pr-leaf {
	margin: 0;
	flex: none;
}

.forge-pr-leaf img {
	display: block;
	width: auto;
	height: var(--wp--custom--pr--leaf-height);
	max-height: var(--wp--custom--pr--leaf-height); /* the editor puts height:auto inline on images; the cap still holds */
}

.forge-pr-brandname {
	margin: 0;
	white-space: nowrap;
}

.forge-pr-brandname a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
	display: inline-block; /* not flex: flex would drop the space before "regija" */
	padding-block: max(0px, calc((var(--wp--custom--pr--target) - 1.1em) / 2)); /* ≥ 44 px tall target */
}

.forge-pr-brandname a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
}

@media (max-width: 599px) {
	.forge-pr-leaf img {
		height: var(--wp--custom--pr--leaf-height-phone);
		max-height: var(--wp--custom--pr--leaf-height-phone); /* the editor puts height:auto inline on images; the cap still holds */
	}
}

/* Home 2: the next event. The date block keeps its size; the text beside it wraps below it when there is
   less than ~18rem left (phones), instead of becoming a narrow column. */
.forge-pr-date {
	flex: none;
	min-width: 8.5rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.forge-pr-event-text {
	min-width: min(100%, 18rem);
}

/* Home 2: contact on a dark band. The focus ring is the ink colour elsewhere; here it must be light. */
.forge-pr-dark :focus-visible {
	outline-color: var(--wp--preset--color--on-primary);
}

/* A page that ends with a full-width coloured section (wash, dark) meets the footer directly, as the parent
   does for its .forge-band sections (05-layout.css); otherwise a white strip shows between the two. */
.wp-site-blocks:has(main .wp-block-post-content > .alignfull.has-background:last-child) > footer.wp-block-template-part,
.wp-site-blocks:has(main > .alignfull.has-background:last-child) > footer.wp-block-template-part {
	margin-block-start: 0;
}

.wp-site-blocks:has(main .wp-block-post-content > .alignfull.has-background:last-child) > footer > .forge-footer,
.wp-site-blocks:has(main > .alignfull.has-background:last-child) > footer > .forge-footer {
	margin-top: 0;
}

/* Next event: the text takes the room beside the date block, and wraps below it when less than ~18rem is left. */
.forge-pr-event-text {
	flex: 1 1 18rem;
}

/* ---------------------------------------------------------------------------------------------
 * Block styles "Icon: …" (core/paragraph): an icon in front of the line, in the text's accent colour.
 * The icon is drawn with a mask, so it takes the colour of the context (green on light, light on dark).
 * Padding + absolute icon (not flex), so text and links inside the paragraph stay inline.
 * ------------------------------------------------------------------------------------------- */
p[class*="is-style-pr-i-"] {
	position: relative;
	padding-left: 2rem;
}

/* One icon size everywhere (also next to a large phone number), centred on the first line of text. */
p[class*="is-style-pr-i-"]::before {
	content: "";
	position: absolute;
	left: 0;
	top: calc(0.5lh - 0.625rem);
	width: 1.25rem;
	height: 1.25rem;
	background: var(--forge-pr-icon-color, var(--wp--preset--color--primary));
	-webkit-mask: var(--forge-pr-icon) center / contain no-repeat;
	mask: var(--forge-pr-icon) center / contain no-repeat;
}

/* A line that is only a link (phone, e-mail) is a 44 px tall row: centre the icon on that row. */
p[class*="is-style-pr-i-"]:has(> a:only-child)::before {
	top: calc(1.375rem - 0.625rem);
}

.is-style-pr-i-calendar { --forge-pr-icon: url("../icons/calendar.svg"); }
.is-style-pr-i-clock { --forge-pr-icon: url("../icons/clock.svg"); }
.is-style-pr-i-pin { --forge-pr-icon: url("../icons/pin.svg"); }
.is-style-pr-i-pen { --forge-pr-icon: url("../icons/pen.svg"); }
.is-style-pr-i-user { --forge-pr-icon: url("../icons/user.svg"); }
.is-style-pr-i-phone { --forge-pr-icon: url("../icons/phone.svg"); }
.is-style-pr-i-mail { --forge-pr-icon: url("../icons/mail.svg"); }

.forge-pr-dark { --forge-pr-icon-color: var(--wp--preset--color--on-primary-muted); }

/* Block styles "Label" / "Label (strong)" (core/paragraph): a small status pill above a title. */
p.is-style-pr-label,
p.is-style-pr-label-strong {
	width: fit-content;
	padding: 0.2em 0.75em;
	border-radius: var(--wp--custom--radius--pill);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 800;
	line-height: 1.5;
	background: var(--wp--preset--color--media);
	color: var(--wp--preset--color--primary);
}

p.is-style-pr-label-strong {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary);
}

/* Block style "Icon tile" (core/image): an SVG icon centred on a tinted rounded square. */
.wp-block-image.is-style-pr-icon-tile {
	flex: none; /* never squeezed by the text beside it */
	display: grid;
	place-items: center;
	width: 3.75rem;
	height: 3.75rem;
	margin: 0;
	border-radius: 16px;
	background: var(--wp--preset--color--media);
}

.wp-block-image.is-style-pr-icon-tile img {
	width: 1.9rem;
	height: 1.9rem;
}

/* Block style "Date tile" (core/group): day over month, a fixed square so a column of dates lines up.
   Colours are the group's own settings (strong for the next event, tinted for the others). */
.wp-block-group.is-style-pr-date {
	flex: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 7rem; /* a full month name ("november", "december") on one line */
	min-height: 6rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.wp-block-group.is-style-pr-date > * {
	margin: 0;
}

/* The society's leaf as a large, quiet mark in the corner of the dark contact band. Decoration only. */
.forge-pr-dark {
	position: relative;
	overflow: hidden;
	isolation: isolate;
}

.forge-pr-dark::after {
	content: "";
	position: absolute;
	right: -4rem;
	bottom: -6rem;
	z-index: -1;
	width: 26rem;
	height: 32rem;
	background: var(--wp--preset--color--on-primary);
	opacity: 0.05;
	-webkit-mask: url("../icons/leaf.svg") center / contain no-repeat;
	mask: url("../icons/leaf.svg") center / contain no-repeat;
	pointer-events: none;
}

/* Hero card "Naslednji dogodek": sits at the bottom right of the hero on wide screens. */
.forge-pr-hero-card {
	box-shadow: var(--forge-pr-shadow);
}

/* Timeline rows (news and events): the text beside the date tile takes the rest of the row and may
   shrink, so tile and text stay side by side on phones too. */
.forge-pr-row-text {
	flex: 1 1 0;
	min-width: 0;
}

/* The hero card on phones: the hero's own fade is behind it; the card needs no shadow there. */
@media (max-width: 781px) {
	.forge-pr-hero-card {
		box-shadow: none;
		border: 1px solid var(--wp--preset--color--line);
	}
}


/* Buttons: at least 48 px tall (reference design and touch targets). */
:where(.wp-site-blocks) .wp-element-button {
	min-height: 3rem;
}

/* Header menu in ExtraBold as in the reference design; the parent sets 600 on the menu links. */
.forge-header--site .forge-catnav .wp-block-navigation-item__content {
	font-weight: 800;
}

/* ---------------------------------------------------------------------------------------------
 * Phones (≤ 599 px): one calm column. Each rule is a layout the block settings cannot express per
 * device; spacing and column counts are the blocks' own @mobile settings.
 * ------------------------------------------------------------------------------------------- */
@media (max-width: 599px) {
	/* Hero: the photo is a strip at the top, the text sits below it on white (not over the leaves). */
	.forge-pr-hero::before {
		background: linear-gradient(180deg, transparent 0, transparent 8rem, var(--wp--preset--color--bg) 11.5rem);
	}

	/* Hero buttons: equal, full width, one above the other. */
	.forge-pr-hero .wp-block-buttons {
		flex-direction: column;
		align-items: stretch;
	}

	.forge-pr-hero .wp-block-button,
	.forge-pr-hero .wp-block-button__link {
		width: 100%;
		text-align: center;
		justify-content: center;
	}

	/* The next-event card repeats the first item of "Novice in dogodki"; on a phone it only lengthens the page. */
	.wp-block-column:has(> .forge-pr-hero-card) {
		display: none;
	}

	/* Activities: compact rows, icon on the left. */
	.forge-pr-act {
		display: grid;
		grid-template-columns: 3rem minmax(0, 1fr);
		column-gap: 1rem;
		align-items: start;
	}

	.forge-pr-act > * {
		margin: 0;
	}

	.forge-pr-act > .is-style-pr-icon-tile {
		grid-row: 1 / span 2;
		width: 3rem;
		height: 3rem;
		border-radius: 12px;
	}

	.forge-pr-act > .is-style-pr-icon-tile img {
		width: 1.5rem;
		height: 1.5rem;
	}

	/* Towns: one per row (the grid's @mobile setting), each a compact row: crest on the left, name and
	   description on the right. */
	.wp-block-image.is-style-crest {
		height: 5.5rem;
	}

	.wp-block-image.is-style-crest img {
		height: 3.5rem;
		max-height: 3.5rem; /* the editor puts height:auto inline on images; the cap still holds */
	}

	.forge-pr-towns .is-style-card-link {
		display: grid;
		grid-template-columns: 5rem minmax(0, 1fr);
		align-items: stretch;
	}

	.forge-pr-towns .is-style-card-link > * {
		margin: 0;
	}

	.forge-pr-towns .wp-block-image.is-style-crest {
		height: auto;
		min-height: 5.5rem;
		border-radius: var(--wp--custom--radius--card) 0 0 var(--wp--custom--radius--card);
	}

	.forge-pr-towns .wp-block-image.is-style-crest img {
		height: 3rem;
		max-height: 3rem; /* the editor puts height:auto inline on images; the cap still holds */
	}

	/* Timeline: the date is its own small row above the text ("5. december" in one line), the text gets
	   the full width. Sizes are set by re-pointing the size tokens inside the tile (the preset size classes
	   are !important); the tile's padding is its own @mobile setting. */
	.is-layout-flex:has(> .is-style-pr-date) {
		flex-wrap: wrap;
		gap: 0.75rem;
	}

	.is-layout-flex:has(> .is-style-pr-date) > .forge-pr-row-text {
		flex-basis: 100%;
	}

	.wp-block-group.is-style-pr-date {
		--wp--preset--font-size--x-large: 1.0625rem;
		--wp--preset--font-size--x-small: 1.0625rem;
		flex-direction: row;
		align-items: baseline;
		gap: 0.3em;
		width: auto;
		min-height: 0;
	}
}

/* Events list: the "no events" line shows only when every event row has expired (module event-dates). */
.forge-pr-events-empty {
	display: none;
}

.forge-pr-events:not(:has(.forge-pr-event)) > .forge-pr-events-empty {
	display: block;
}

/* Footer signature: the maker's logo (white letters + its own lime accent, made for the dark footer) is a
   44 px tall link like the other links. */
.forge-pr-maker-logo {
	margin: 0;
}

/* The paragraphs of the signature row keep no bottom margin, so they sit on the same centre line as the logo. */
.forge-pr-signature p {
	margin: 0;
}

.forge-pr-maker-logo a {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--pr--target);
}

.forge-pr-maker-logo img {
	display: block;
	width: 5rem;
	height: auto;
}
