/* Portfolio «Linee guida» (inc/portfolio-brandguide.php). A print brand manual told inline, on the brand's own ground.
 * Base rules = the final state (no JS, reduced motion). Motion only under .is-armed (set by brandguide.js), played
 * once when a section gets .is-in. Easing: settle, never bounce for its own sake. */

.cj-pf-body__content .cj-bg {
	--bg-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--bg-pop: cubic-bezier(0.34, 1.32, 0.5, 1);
	--bg-line: color-mix(in srgb, var(--bg-ink) 22%, transparent);
	max-width: none;
	margin-block: 2.5rem;
	padding: clamp(20px, 4vw, 56px);
	border-radius: 4px;
	background: var(--bg-ground);
	color: var(--bg-ink);
	font-family: var(--cj-font);
	overflow: hidden;
}
.cj-bg__top {
	display: flex; justify-content: space-between;
	font-size: 0.8125rem; letter-spacing: 0.04em; color: var(--bg-muted);
	padding-bottom: clamp(16px, 2.4vw, 28px); border-bottom: 1px solid var(--bg-line);
}
.cj-bg__sec { padding-block: clamp(32px, 5vw, 64px) 0; }
.cj-bg__sec + .cj-bg__sec { border-top: 1px solid var(--bg-line); margin-top: clamp(32px, 5vw, 64px); }
.cj-bg__head { display: flex; gap: 0.4em; align-items: baseline; margin-bottom: 0.75rem; }
.cj-bg__n, .cj-pf-body__content .cj-bg__h { font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); font-weight: 600; color: var(--bg-ink); margin: 0; }
.cj-bg__n { color: var(--bg-num, var(--bg-accent)); font-variant-numeric: tabular-nums; }
.cj-pf-body__content .cj-bg__text, .cj-pf-body__content .cj-bg p.cj-bg__text {
	max-width: 34em; margin: 0 0 clamp(20px, 3vw, 36px);
	font-size: 1rem; line-height: 1.55; color: var(--bg-muted); font-weight: 400;
}
.cj-bg__cap { display: block; margin-top: 0.75rem; font-size: 0.875rem; line-height: 1.4; color: var(--bg-muted); }
.cj-bg__cap b { color: var(--bg-ink); font-weight: 600; margin-right: 0.3em; }
.cj-pf-body__content .cj-bg .cj-bg__src { margin: clamp(32px, 5vw, 56px) 0 0; font-size: 0.8125rem; color: var(--bg-muted); max-width: none; }
.cj-bg ul { list-style: none; margin: 0; padding: 0; }
.cj-pf-body__content .cj-bg li { font-size: inherit; line-height: inherit; font-weight: inherit; }

/* SVG parts: colours from --p-<part> (set per copy) */
.cj-bg__svg { display: block; width: 100%; height: auto; overflow: visible; }
.cj-bg__svg :is(path, g) { transform-box: fill-box; transform-origin: 50% 50%; }
.cj-bg__sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 1. The mark */
.cj-bg__stage--mark { display: grid; place-items: center; padding-block: clamp(8px, 3vw, 40px); }
.cj-bg__stage--mark .cj-bg__svg { width: min(100%, 520px); }

/* 2. Colours: tall bars, values on the colour */
.cj-bg__colors { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 0; border-radius: 3px; overflow: hidden; min-height: clamp(300px, 42vw, 460px); box-shadow: 0 0 0 1px var(--bg-line); }
.cj-bg__color { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1rem; padding: clamp(14px, 2.4vw, 32px) clamp(8px, 1.6vw, 24px); color: #fff; text-align: center; isolation: isolate; }
.cj-bg__color.is-light { color: var(--bg-ground); }
.cj-bg__bar { position: absolute; inset: 0; z-index: -1; background: var(--c); transform-origin: 50% 100%; }
.cj-bg__cname { font-weight: 600; font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.125rem); letter-spacing: 0.02em; }
.cj-bg__vals { display: grid; gap: 0.15rem 0; margin: 0; font-size: 0.8125rem; text-align: left; width: min(100%, 11.5rem); }
.cj-bg__vals dt { font-weight: 600; margin-top: 0.6rem; font-size: 0.75rem; letter-spacing: 0.08em; opacity: 0.85; }
.cj-bg__vals dt:first-child { margin-top: 0; }
.cj-bg__vals dd { margin: 0; font-variant-numeric: tabular-nums; }
.cj-bg__inks { display: grid; gap: 0.3rem; margin-top: 0.25rem !important; }
.cj-bg__inks li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 0.5rem; position: relative; padding-bottom: 5px; }
.cj-bg__inks b { font-weight: 500; text-align: right; min-width: 2ch; }
.cj-bg__ink { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: color-mix(in srgb, currentColor 22%, transparent); overflow: hidden; }
.cj-bg__ink::after { content: ""; position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(calc(var(--v) / 100)); background: currentColor; }
.cj-bg__copy {
	font: inherit; color: inherit; background: none; cursor: pointer;
	padding: 0.15rem 0.45rem; margin-left: -0.45rem; border-radius: 3px; border: 1px solid transparent;
	transition: border-color 0.2s, background-color 0.2s;
}
.cj-bg__copy:hover, .cj-bg__copy:focus-visible { border-color: currentColor; outline: none; }
.cj-bg__copied { margin-left: 0.4rem; font-size: 0.75rem; opacity: 0; transition: opacity 0.3s; }
.cj-bg__copied.is-on { opacity: 0.9; }

/* 3. Versions */
.cj-bg__versions { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(16px, 2.4vw, 28px); }
.cj-bg__version .cj-bg__tile { display: grid; place-items: center; aspect-ratio: 16 / 9; padding: 12% 16%; border-radius: 3px; border: 1px solid var(--bg-line); }
.cj-bg__version.is-light .cj-bg__tile { background: #fff; border-color: #fff; }
.cj-bg__version.is-tone .cj-bg__tile { background: var(--bg-accent); border-color: var(--bg-accent); }
.cj-bg__version .cj-bg__svg--mark { width: min(100%, 230px); }

/* 4. Clear space */
.cj-bg__stage--clear { display: grid; place-items: center; padding-block: clamp(8px, 2vw, 24px); }
.cj-bg__clear { --pad: clamp(30px, 7vw, 60px); position: relative; width: min(100%, 440px); padding: var(--pad); }
.cj-bg__box { position: absolute; inset: calc(var(--pad) - 5px); border: 1px dashed color-mix(in srgb, var(--bg-ink) 75%, transparent); pointer-events: none; }
.cj-bg__box--out { inset: 0; border-color: color-mix(in srgb, var(--bg-ink) 45%, transparent); }
.cj-bg__x { position: absolute; font-size: 0.75rem; font-weight: 600; color: var(--bg-num, var(--bg-accent)); line-height: 1; }
.cj-bg__x--tl { left: calc(var(--pad) / 2); top: calc(var(--pad) / 2); transform: translate(-50%, -50%); }
.cj-bg__x--tr { right: calc(var(--pad) / 2); top: calc(var(--pad) / 2); transform: translate(50%, -50%); }
.cj-bg__x--bl { left: calc(var(--pad) / 2); bottom: calc(var(--pad) / 2); transform: translate(-50%, 50%); }
.cj-bg__x--br { right: calc(var(--pad) / 2); bottom: calc(var(--pad) / 2); transform: translate(50%, 50%); }

/* 5. Incorrect use: base = the wrong state (as in the manual) */
.cj-bg__misuse { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(20px, 3vw, 40px) clamp(16px, 2.4vw, 28px); }
.cj-bg__mis .cj-bg__tile { display: grid; place-items: center; aspect-ratio: 4 / 3; padding: 16% 20%; border-radius: 3px; border: 1px solid var(--bg-line); outline-offset: 3px; }
.cj-bg__mis .cj-bg__tile:focus-visible { outline: 2px solid var(--bg-accent); }
.cj-bg__mis .cj-bg__cap { display: flex; gap: 0.5em; align-items: baseline; color: var(--bg-ink); }
.cj-bg__no { flex: none; position: relative; width: 0.7em; height: 0.7em; }
.cj-bg__no::before, .cj-bg__no::after { content: ""; position: absolute; left: 50%; top: 50%; width: 100%; height: 1.5px; background: var(--bg-accent); transform: translate(-50%, -50%) rotate(45deg); }
.cj-bg__no::after { transform: translate(-50%, -50%) rotate(-45deg); }
.cj-bg__svg.fx-recolor.is-wrong [style*="--wc"] { fill: var(--wc) !important; }
.cj-bg__svg.fx-rotate.is-wrong { transform: rotate(180deg); }
.cj-bg__svg.fx-distort.is-wrong { transform: scale(1.22, 0.58); }
.cj-bg__svg :is(.fx-shrink, .fx-grow) .fx-target, .cj-bg__svg:is(.fx-shrink, .fx-grow) .fx-target { transform-origin: var(--fx-o, 50% 50%); }
.cj-bg__svg.fx-shrink.is-wrong .fx-target { transform: scale(var(--fx-s, 0.3)); }
.cj-bg__svg.fx-grow.is-wrong .fx-target { transform: scale(var(--fx-s, 1.75)); }
.cj-bg__svg .fx-dup { opacity: 0; }
.cj-bg__svg.fx-effects.is-wrong .fx-target { opacity: 0; }
.cj-bg__svg.fx-effects.is-wrong .fx-dup { opacity: 1; }
.cj-bg__svg.fx-effects.is-wrong:not(.fx-all) path:not(.fx-target):not(.fx-dup) { filter: drop-shadow(4px 6px 4px color-mix(in srgb, var(--bg-ink) 40%, transparent)); }
.cj-bg__svg.fx-effects.fx-all.is-wrong { filter: drop-shadow(5px 8px 4px color-mix(in srgb, var(--bg-ink) 45%, transparent)) blur(1.4px); }

/* 6. Application */
.cj-bg__app { display: grid; gap: clamp(28px, 4vw, 48px); }
.cj-bg__min { display: flex; flex-wrap: wrap; gap: clamp(28px, 5vw, 72px); align-items: flex-end; }
.cj-bg__measure { position: relative; display: inline-flex; align-items: center; gap: 14px; }
.cj-bg__minitem.is-h .cj-bg__svg { width: 138px; }
.cj-bg__minitem.is-w .cj-bg__measure { flex-direction: column; align-items: stretch; gap: 10px; }
.cj-bg__minitem.is-w .cj-bg__svg { width: 168px; }
.cj-bg__dim { position: relative; flex: none; font-size: 0.8125rem; color: var(--bg-ink); }
.cj-bg__minitem.is-h .cj-bg__dim { align-self: stretch; width: 4.5em; padding-left: 14px; display: flex; align-items: center; border-left: 1px solid var(--bg-ink); }
.cj-bg__minitem.is-h .cj-bg__dim::before, .cj-bg__minitem.is-h .cj-bg__dim::after { content: ""; position: absolute; left: -5px; width: 9px; height: 1px; background: var(--bg-ink); }
.cj-bg__minitem.is-h .cj-bg__dim::before { top: 0; }
.cj-bg__minitem.is-h .cj-bg__dim::after { bottom: 0; }
.cj-bg__minitem.is-w .cj-bg__dim { text-align: center; padding-top: 10px; border-top: 1px solid var(--bg-ink); }
.cj-bg__minitem.is-w .cj-bg__dim::before, .cj-bg__minitem.is-w .cj-bg__dim::after { content: ""; position: absolute; top: -5px; width: 1px; height: 9px; background: var(--bg-ink); }
.cj-bg__minitem.is-w .cj-bg__dim::before { left: 0; }
.cj-bg__minitem.is-w .cj-bg__dim::after { right: 0; }
.cj-bg__sheets { display: grid; grid-template-columns: 210fr 297fr; gap: clamp(20px, 3vw, 40px); align-items: end; max-width: 640px; }
.cj-bg__paper { display: block; width: 100%; height: auto; overflow: visible; }
.cj-bg__paper-sheet { fill: #fbfaf7; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
.cj-bg__paper-margin { fill: none; stroke: var(--bg-accent); stroke-width: 0.8; stroke-dasharray: 3 2.4; }
.cj-bg__paper-logo { transform: translate(var(--x0), var(--y0)); }

@media (max-width: 640px) {
	.cj-bg__colors { grid-template-columns: 1fr; min-height: 0; }
	.cj-bg__color { min-height: 120px; flex-direction: row; justify-content: space-between; text-align: left; }
	.cj-bg__versions { grid-template-columns: 1fr; }
	.cj-bg__misuse { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- motion (armed by JS, never under reduced motion) ---------- */
@media (prefers-reduced-motion: no-preference) {
	.cj-bg.is-armed .cj-bg__sec { transition: opacity 0.6s var(--bg-ease); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__head, .cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__text { opacity: 0; transform: translateY(14px); }
	.cj-bg.is-armed .cj-bg__head, .cj-bg.is-armed .cj-bg__text { transition: opacity 0.7s var(--bg-ease), transform 0.7s var(--bg-ease); }

	/* the mark assembles: K and B close in, the & lands, the line writes itself */
	.cj-bg.is-armed .is-assemble path { transition: transform 1.5s var(--bg-ease), opacity 1s var(--bg-ease), clip-path 1.1s var(--bg-ease); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-assemble .k { opacity: 0; transform: translateX(-42%); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-assemble .b { opacity: 0; transform: translateX(42%); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-assemble .amp { opacity: 0; transform: translateY(-120%) rotate(-40deg) scale(0.6); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-assemble .tag { clip-path: inset(0 100% 0 0); }
	.cj-bg.is-armed .is-assemble .amp { transition: transform 1.25s var(--bg-pop) 0.75s, opacity 0.6s var(--bg-ease) 0.75s; }
	.cj-bg.is-armed .is-assemble .tag { transition: clip-path 1.1s var(--bg-ease) 1.6s; clip-path: inset(0 0 0 0); }

	/* «mount» (Next): the panels slide in from both sides like cladding, the rule draws, the name settles, the dot lands */
	.cj-bg.is-armed .is-mount :is(path, g) { transition: transform 1.3s var(--bg-ease), opacity 0.8s var(--bg-ease), clip-path 1.1s var(--bg-ease); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount :is(.s1, .s2, .s3) { opacity: 0; transform: translateX(-130%); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount :is(.s4, .s5, .s6) { opacity: 0; transform: translateX(130%); }
	.cj-bg.is-armed .is-mount .s1 { transition-delay: 0s; }
	.cj-bg.is-armed .is-mount .s4 { transition-delay: 0.14s; }
	.cj-bg.is-armed .is-mount .s2 { transition-delay: 0.28s; }
	.cj-bg.is-armed .is-mount .s5 { transition-delay: 0.42s; }
	.cj-bg.is-armed .is-mount .s3 { transition-delay: 0.56s; }
	.cj-bg.is-armed .is-mount .s6 { transition-delay: 0.7s; }
	.cj-bg.is-armed .is-mount .rule { transform-origin: 50% 50%; transition-delay: 1.15s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount .rule { transform: scaleX(0); }
	.cj-bg.is-armed .is-mount .w { transition-delay: 1.3s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount .w { opacity: 0; transform: translateY(45%); }
	.cj-bg.is-armed .is-mount .dot { transition: transform 0.8s var(--bg-pop) 1.75s, opacity 0.4s var(--bg-ease) 1.75s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount .dot { opacity: 0; transform: scale(0); }
	.cj-bg.is-armed .is-mount .tag { clip-path: inset(0 0 0 0); transition: clip-path 1.2s var(--bg-ease) 1.9s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-mount .tag { clip-path: inset(0 100% 0 0); }

	/* «stagger» (generic): the top-level parts of the mark arrive one after the other, in drawing order */
	.cj-bg.is-armed .is-stagger > * { transition: transform 1.2s var(--bg-ease), opacity 0.9s var(--bg-ease); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .is-stagger > * { opacity: 0; transform: translateY(28%) scale(0.94); }
	.cj-bg.is-armed .is-stagger > :nth-child(1) { transition-delay: 0.00s; }
	.cj-bg.is-armed .is-stagger > :nth-child(2) { transition-delay: 0.13s; }
	.cj-bg.is-armed .is-stagger > :nth-child(3) { transition-delay: 0.26s; }
	.cj-bg.is-armed .is-stagger > :nth-child(4) { transition-delay: 0.39s; }
	.cj-bg.is-armed .is-stagger > :nth-child(5) { transition-delay: 0.52s; }
	.cj-bg.is-armed .is-stagger > :nth-child(6) { transition-delay: 0.65s; }
	.cj-bg.is-armed .is-stagger > :nth-child(7) { transition-delay: 0.78s; }
	.cj-bg.is-armed .is-stagger > :nth-child(8) { transition-delay: 0.91s; }
	.cj-bg.is-armed .is-stagger > :nth-child(9) { transition-delay: 1.04s; }
	.cj-bg.is-armed .is-stagger > :nth-child(10) { transition-delay: 1.17s; }
	.cj-bg.is-armed .is-stagger > :nth-child(11) { transition-delay: 1.30s; }
	.cj-bg.is-armed .is-stagger > :nth-child(12) { transition-delay: 1.43s; }
	.cj-bg.is-armed .is-stagger > :nth-child(13) { transition-delay: 1.56s; }
	.cj-bg.is-armed .is-stagger > :nth-child(14) { transition-delay: 1.69s; }
	.cj-bg.is-armed .is-stagger > :nth-child(15) { transition-delay: 1.82s; }
	.cj-bg.is-armed .is-stagger > :nth-child(16) { transition-delay: 1.95s; }
	.cj-bg.is-armed .is-stagger > :nth-child(17) { transition-delay: 2.08s; }
	.cj-bg.is-armed .is-stagger > :nth-child(18) { transition-delay: 2.21s; }
	.cj-bg.is-armed .is-stagger > :nth-child(19) { transition-delay: 2.34s; }
	.cj-bg.is-armed .is-stagger > :nth-child(20) { transition-delay: 2.47s; }
	.cj-bg.is-armed .is-stagger > :nth-child(21) { transition-delay: 2.60s; }
	.cj-bg.is-armed .is-stagger > :nth-child(22) { transition-delay: 2.73s; }
	.cj-bg.is-armed .is-stagger > :nth-child(23) { transition-delay: 2.86s; }
	.cj-bg.is-armed .is-stagger > :nth-child(24) { transition-delay: 2.99s; }

	/* colours rise, the inks fill */
	.cj-bg.is-armed .cj-bg__bar { transition: transform 1s var(--bg-ease) calc(var(--i) * 0.14s); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__bar { transform: scaleY(0); }
	.cj-bg.is-armed .cj-bg__color > :not(.cj-bg__bar) { transition: opacity 0.6s var(--bg-ease) calc(0.55s + var(--i) * 0.14s); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__color > :not(.cj-bg__bar) { opacity: 0; }
	.cj-bg.is-armed .cj-bg__ink::after { transition: transform 1.1s var(--bg-ease) calc(0.9s + var(--j) * 0.12s); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__ink::after { transform: scaleX(0); }

	/* versions and incorrect uses come up in turn */
	.cj-bg.is-armed :is(.cj-bg__version, .cj-bg__mis, .cj-bg__minitem, .cj-bg__sheet) { transition: opacity 0.7s var(--bg-ease) calc(var(--i) * 0.1s), transform 0.7s var(--bg-ease) calc(var(--i) * 0.1s); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) :is(.cj-bg__version, .cj-bg__mis, .cj-bg__minitem, .cj-bg__sheet) { opacity: 0; transform: translateY(18px); }

	/* clear space: the boxes draw, the X land */
	.cj-bg.is-armed .cj-bg__box { transition: clip-path 1s var(--bg-ease) 0.3s; }
	.cj-bg.is-armed .cj-bg__box--out { transition-delay: 0.6s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__box { clip-path: inset(0 100% 100% 0); }
	.cj-bg.is-armed .cj-bg__sec.is-in .cj-bg__box { clip-path: inset(-4px); }
	.cj-bg.is-armed .cj-bg__x { transition: opacity 0.5s var(--bg-ease) calc(1.1s + var(--i) * 0.1s); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__x { opacity: 0; }

	/* incorrect use: each tile shows the right logo, then goes wrong (JS adds .is-wrong in turn; hover replays) */
	.cj-bg.is-armed .cj-bg__mis .cj-bg__svg, .cj-bg.is-armed .cj-bg__mis .cj-bg__svg :is(path, g) { transition: transform 0.9s var(--bg-ease), fill 0.7s var(--bg-ease), opacity 0.7s var(--bg-ease), filter 0.7s var(--bg-ease); }

	/* application: the measures draw, the logo visits the four corners of each sheet once */
	.cj-bg.is-armed .cj-bg__dim { transition: clip-path 0.8s var(--bg-ease) 0.5s; }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__minitem.is-h .cj-bg__dim { clip-path: inset(0 0 100% 0); }
	.cj-bg.is-armed .cj-bg__sec:not(.is-in) .cj-bg__minitem.is-w .cj-bg__dim { clip-path: inset(0 100% 0 0); }
	.cj-bg.is-armed .cj-bg__sec.is-in .cj-bg__dim { clip-path: inset(-6px); }
	.cj-bg.is-armed .cj-bg__sec.is-in .cj-bg__paper-logo { animation: cj-bg-corners 5.2s var(--bg-ease) calc(0.8s + var(--i) * 0.35s) 1 both; }
	@keyframes cj-bg-corners {
		0%, 14% { transform: translate(var(--x0), var(--y0)); }
		25%, 39% { transform: translate(var(--x1), var(--y0)); }
		50%, 64% { transform: translate(var(--x1), var(--y1)); }
		75%, 89% { transform: translate(var(--x0), var(--y1)); }
		100% { transform: translate(var(--x0), var(--y0)); }
	}
}
