/**
 * jwk-portfolio — block styles for core blocks (see class-core-blocks.php).
 * Loaded in the block editor, and served to the SPA through
 * /wp-json/jwk-portfolio/v1/block-styles.css — single source, no mirror.
 *
 * Why the `:root` prefix on most rules: WordPress prints its own layout and
 * element rules (block gap margins, the theme.json button) at specificity
 * 0,1,0 — and it prints them in a different ORDER in the editor canvas than
 * in block-styles.css. Equal specificity + different order is exactly why
 * the editor and jwk.dk used to disagree on spacing and buttons. `:root`
 * lifts these rules to 0,2,0 so they win in both places, regardless of
 * load order. Preset classes (.has-*-font-size, .has-*-color) still win —
 * WordPress gives those !important.
 *
 * Neutral colors come from currentColor → works on light or dark pages.
 * Typography, button colors and radii are theme.json (Appearance → Editor
 * → Styles); what's here is only what theme.json can't express.
 */

/* ----- Paragraph: Badge ("Open for new projects" pill) ----- */
:root .is-style-badge {
	--jwk-badge-dot: var(--wp--preset--color--green, #4ade80);
	display: flex;
	align-items: center;
	gap: 9px;
	width: fit-content;
	padding: 7px 12px;
	border: 1px solid color-mix(in srgb, currentColor 11%, transparent);
	border-radius: 999px;
	background-color: color-mix(in srgb, currentColor 3.5%, transparent);
	color: color-mix(in srgb, currentColor 62%, transparent);
	font-size: 0.68rem;
	font-weight: 600;
	line-height: 1.2;
}

.is-style-badge::before {
	content: "";
	flex: none;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--jwk-badge-dot);
	box-shadow:
		0 0 0 4px color-mix(in srgb, var(--jwk-badge-dot) 10%, transparent),
		0 0 15px color-mix(in srgb, var(--jwk-badge-dot) 60%, transparent);
	animation: jwk-badge-pulse 2s infinite;
}

@keyframes jwk-badge-pulse {
	50% {
		opacity: 0.4;
		transform: scale(0.8);
	}
}

/* ----- Paragraph: Eyebrow (small purple line above a heading) ----- */
:root .is-style-eyebrow {
	color: var(--wp--preset--color--purple-light, #c084fc);
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.4;
}

/* ----- Paragraph: Tag (small purple pill — "Arbejde", "Uddannelse") -----
 * Preset colors and font sizes are !important classes, custom ones inline
 * styles, so anything picked in the editor wins over these defaults. */
:root .is-style-tag {
	width: fit-content;
	padding: 4px 10px;
	border-radius: 999px;
	background-color: color-mix(in srgb, var(--wp--preset--color--purple, #a855f7) 9%, transparent);
	color: var(--wp--preset--color--purple-light, #c084fc);
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	line-height: 1.4;
	text-transform: uppercase;
}

/* An empty tag isn't shown on the site (the editor keeps it clickable). */
:root .is-style-tag:empty:not([contenteditable]) {
	display: none;
}

/* ----- Heading: Display (the big hero headline) ----- */
:root .is-style-display {
	font-size: var(--wp--preset--font-size--xx-large, min(clamp(3.6rem, 6vw, 6.4rem), 11vw));
	font-weight: 850;
	line-height: 0.94;
	letter-spacing: -0.05em;
	text-wrap: balance;
}

/* ----- Headings on phones: long words never run off the screen -----
 * A big headline can be wider than the screen for one long Danish word
 * ("webteknologier" at 61px is ~430px on a 390px iPhone, so it was cut
 * off). hyphens splits it at a real syllable — the page is lang="da" —
 * and overflow-wrap is the fallback for a browser without a Danish
 * dictionary. Phones only, so desktop headlines are never hyphenated
 * just to fill out a line. Only words of 10+ letters, split 5+5 at the
 * least, so a short word like "websites" is never cut into "webs-ites".
 * (Safari reads the -webkit-hyphenate-limit-* pair instead.) */
@media (max-width: 600px) {
	:root :is(h1, h2, h3, h4, h5, h6) {
		-webkit-hyphens: auto;
		hyphens: auto;
		hyphenate-limit-chars: 10 5 5;
		-webkit-hyphenate-limit-before: 5;
		-webkit-hyphenate-limit-after: 5;
		overflow-wrap: break-word;
	}
}

/* ----- Paragraph: Lead ----- */
:root .is-style-lead {
	max-width: 560px;
	color: color-mix(in srgb, currentColor 62%, transparent);
	font-size: 0.98rem;
	line-height: 1.6;
}

/* ----- Position: Badge, Tag and Lead ----- *
 * All three are narrower than their column (fit-content / max-width).
 * A constrained Group — the Group default, and the editor canvas itself —
 * gives every child `margin-inline: auto !important`, which pulled them
 * into the middle while the heading beside them sat on the left.
 * Here they follow the block's own alignment (toolbar → Align text):
 * left (default) on the column's start edge, center centered, right on
 * the end edge. !important is the only way past WordPress' !important;
 * :root keeps the specificity above it.
 *
 * --jwk-col-start / --jwk-col-end: where the content column sits inside a
 * constrained group wider than the content size (0 when it's narrower).
 * A group with a custom content width uses the global one here — only
 * matters when that group is wider than 1180px. */
:root :is(.is-style-badge, .is-style-tag, .is-style-lead) {
	--jwk-col-start: 0px;
	--jwk-col-end: 0px;
	margin-inline: var(--jwk-col-start) 0 !important;
}

:root .is-layout-constrained > :is(.is-style-badge, .is-style-tag, .is-style-lead) {
	--jwk-col-start: max(0px, (100% - var(--wp--style--global--content-size, 100%)) / 2);
	--jwk-col-end: var(--jwk-col-start);
}

:root .is-layout-constrained.is-content-justification-left > :is(.is-style-badge, .is-style-tag, .is-style-lead) {
	--jwk-col-start: 0px;
	--jwk-col-end: max(0px, 100% - var(--wp--style--global--content-size, 100%));
}

:root .is-layout-constrained.is-content-justification-right > :is(.is-style-badge, .is-style-tag, .is-style-lead) {
	--jwk-col-start: max(0px, 100% - var(--wp--style--global--content-size, 100%));
	--jwk-col-end: 0px;
}

:root :is(.is-style-badge, .is-style-tag, .is-style-lead).has-text-align-center {
	margin-inline: auto !important;
}

:root :is(.is-style-badge, .is-style-tag, .is-style-lead).has-text-align-right {
	margin-inline: auto var(--jwk-col-end) !important;
}

/* ----- Vertical rhythm inside a hero ----- *
 * WordPress puts a flat block gap (24px, theme.json) between blocks. These
 * few pairs get the tighter/looser spacing the design uses. Only
 * margin-block-start, same property the block gap sets, so there's
 * nothing left over to fight with. */
:root .is-style-badge + * {
	margin-block-start: 25px;
}

:root .is-style-eyebrow + * {
	margin-block-start: 10px;
}

:root * + .is-style-lead {
	margin-block-start: 28px;
}

:root * + .wp-block-buttons {
	margin-block-start: 34px;
}

:root * + .is-style-key-figures {
	margin-block-start: 48px;
}

/* ----- Buttons ----- *
 * Colors, font, padding and radius: theme.json → styles.elements.button.
 * Here: layout and motion only. */
:root .wp-block-buttons {
	gap: 12px;
}

:root .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	min-height: 49px;
	text-decoration: none;
	transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

:root .wp-block-button__link:hover {
	transform: translateY(-3px);
}

:root .is-style-gradient .wp-block-button__link {
	background: var(--wp--preset--gradient--brand, linear-gradient(120deg, #a855f7, #6366f1, #ec4899));
	color: #fff;
	box-shadow: 0 15px 40px rgba(168, 85, 247, 0.2);
}

:root .is-style-gradient .wp-block-button__link:hover {
	box-shadow: 0 18px 45px rgba(168, 85, 247, 0.32);
}

/* Core's own outline rule is .wp-block-button.is-style-outline > a
   (0,3,0) with a 2px border and em padding — :root beats it. Padding is
   the theme.json button padding minus the 1px border. */
:root .wp-block-button.is-style-outline > .wp-block-button__link {
	padding: 14px 20px;
	border: 1px solid color-mix(in srgb, currentColor 11%, transparent);
	background: color-mix(in srgb, currentColor 3.5%, transparent);
	color: inherit;
	box-shadow: none;
}

:root .wp-block-button.is-style-outline > .wp-block-button__link:hover {
	border-color: color-mix(in srgb, currentColor 22%, transparent);
}

/* ----- Paragraph: Big link (a large e-mail / call-to-action link) -----
 * Write the link inside the paragraph (e.g. "din@mail.dk ↗"). Size yields
 * to a picked font size; the link takes the paragraph's color unless a
 * link color is picked (Color → Link adds a wp-elements-* class). */
:root .is-style-big-link {
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.04em;
	/* Wraps at the <wbr> before "@" (added in class-core-blocks.php,
	 * big_link_breaks()), with the two lines balanced; only a single word
	 * too wide for the line on its own is ever split mid-word. */
	overflow-wrap: break-word;
	text-wrap: balance;
}

:root .is-style-big-link:not([class*="font-size"]):not([style*="font-size"]) {
	/* 24px on phones and up, growing with the viewport to 2.6rem as before.
	 * Below 360px it eases down to 20px, so "Jonas.Wendt.Knudsen" still
	 * fits on its own line after the "@" break even on the smallest
	 * phones (instead of being split mid-word). */
	font-size: max(1.25rem, min(6.67vw, 1.5rem), min(4vw, 2.6rem));
}

:root .is-style-big-link a {
	background-image: var(--wp--preset--gradient--brand, linear-gradient(120deg, #a855f7, #6366f1, #ec4899));
	background-position: 0 100%;
	background-repeat: no-repeat;
	background-size: 0% 2px;
	text-decoration: none;
	transition: background-size 0.4s ease, color 0.3s ease;
}

:root .is-style-big-link:not([class*="wp-elements-"]) a {
	color: inherit;
}

:root .is-style-big-link a:is(:hover, :focus-visible) {
	background-size: 100% 2px;
}

:root .is-style-big-link:not([class*="wp-elements-"]) a:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--purple-light, #c084fc);
}

:root * + .is-style-big-link {
	margin-block-start: 34px;
}

/* ----- Group: Key figures ----- */
:root .is-style-key-figures {
	gap: 18px 28px;
}

:root .is-style-key-figures > * + * {
	padding-left: 28px;
	border-left: 1px solid color-mix(in srgb, currentColor 11%, transparent);
}

/* The value/label pair sits in a flow group; no block gap between them. */
:root .is-style-key-figures > * > * {
	margin-block: 0;
}

/* ----- Paragraph: Figure value / label ----- */
:root .is-style-figure-value {
	font-size: 1.8rem;
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.04em;
}

:root .is-style-figure-label {
	margin-block-start: 4px;
	color: color-mix(in srgb, currentColor 62%, transparent);
	font-size: 0.72rem;
}

/* ----- Group: Card (bordered, softly tinted panel) ----- */
:root .is-style-card {
	padding: clamp(25px, 4vw, 40px);
	border: 1px solid color-mix(in srgb, currentColor 9%, transparent);
	border-radius: var(--wp--custom--radius--card, 17px);
	background: color-mix(in srgb, currentColor 3.5%, transparent);
	transition: transform 0.3s ease, border-color 0.3s ease;
}

:root .is-style-card:hover {
	border-color: rgba(168, 85, 247, 0.3);
}

@media (max-width: 600px) {
	:root .is-style-key-figures > * + * {
		padding-left: 18px;
	}

	:root .is-style-figure-value {
		font-size: 1.4rem;
	}
}

/* ----- Gradient text -----
 * .gradient-text and .has-<slug>-gradient-text are generated from the
 * install's gradient presets — see JWK_Portfolio_Core_Blocks::gradient_text_css().
 * Add a gradient in theme.json or Appearance → Editor → Styles, not here.
 */

/* ----- Entrance animations -----
 * jwk.dk only: every rule is scoped to .jwk-anim, which the SPA's
 * animate.js puts on <html> — never in the block editor, without JS or
 * with reduced motion. The keyframes (jwk-*), the stagger index (--i) and
 * the scroll trigger are defined in the SPA's index.html.
 *
 * A group that's a whole section of a page — top level, or a cell of a
 * Block Grid, like the hero — brings its blocks in one after another.
 */
.jwk-anim :is(.wp-page, .block-grid) > .wp-block-group > * {
	animation: jwk-fade-up 0.8s var(--jwk-ease-out) backwards;
	animation-delay: calc(var(--i, 0) * var(--jwk-stagger));
}

/* The page headline is the LCP element: always start it at 0ms, even with
   a badge or eyebrow above it, so it paints on the very first frame. */
.jwk-anim :is(.wp-page, .block-grid) > .wp-block-group > h1 {
	animation-duration: 1s;
	animation-delay: 0s;
}

/* Key figures: once the row has landed, the figures follow one by one.
   --jwk-row-delay is resolved on the row (its own --i), then inherited. */
.jwk-anim .is-style-key-figures {
	--jwk-row-delay: calc(var(--i, 0) * var(--jwk-stagger) + 0.25s);
}

.jwk-anim .is-style-key-figures > * {
	animation: jwk-fade-up 0.6s var(--jwk-ease-out) backwards;
	animation-delay: calc(var(--jwk-row-delay, 0s) + var(--i, 0) * var(--jwk-stagger));
}

/* Gradient text drifts slowly through the brand gradient. */
.jwk-anim .gradient-text {
	background-size: 200% auto;
	animation: jwk-gradient-shift 8s ease-in-out infinite alternate;
}

/* Gradient button: the gradient slides across on hover. */
:root.jwk-anim .is-style-gradient .wp-block-button__link {
	background-size: 200% auto;
	transition: transform 0.3s ease, box-shadow 0.3s ease, background-position 0.6s ease;
}

:root.jwk-anim .is-style-gradient .wp-block-button__link:hover {
	background-position: 100% 50%;
}

:root.jwk-anim .wp-block-button__link:active {
	transform: translateY(-1px) scale(0.98);
}

/* Card group lifts on hover, like the skill cards. */
:root.jwk-anim .is-style-card:hover {
	transform: translateY(-6px);
}

@media (prefers-reduced-motion: reduce) {
	.is-style-badge::before {
		animation: none;
	}

	:root .wp-block-button__link,
	:root .is-style-card,
	:root .is-style-big-link a {
		transition: none;
	}
}
