/* kaugurs.lv — layered business card (v2)
   Based on Adam Argyle's exploded-layers pen. Hover (or tap) the card to explode it. */

:root {
	--ease: cubic-bezier(0.85, 0, 0.15, 1);
	--card-w: 550px;
	--card-h: 350px;
	--photo-w: 178px;
	--label-w: 620px;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow-x: hidden;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
	background: rgb(240, 240, 240);
}

/* ---------- stage ---------- */
.stack {
	display: grid;
	grid: [stack] / [stack];
	position: relative;
	left: 0;
	transition: left 2s var(--ease);
}
.stack::before {               /* full-page backdrop that darkens on hover */
	content: "";
	position: fixed;
	inset: 0;
	background: rgb(240, 240, 240);
	transition: background 2s ease;
	pointer-events: none;
}
.stack:hover::before, .stack:active::before { background: rgb(30, 30, 32); }
.stack:hover, .stack:active { left: 4vw; }   /* push the exploded card to the right, labels get the left side */

/* ---------- cards ---------- */
.card {
	grid-area: stack;
	position: relative;
	width: var(--card-w);
	height: var(--card-h);
	color: white;
	background: rgba(255, 255, 254, 0.05);
	--z-offset: 0;
	transition: transform 4s ease;
}
.stack:hover .card, .stack:active .card {
	transition-duration: 2s;
	transition-timing-function: var(--ease);
	transform: rotateX(45deg) rotate(45deg) translateZ(var(--z-offset)) translateY(5vh) translateX(22vh) scale(var(--explode-scale, .84));
}
.stack:hover .card:nth-child(1), .stack:active .card:nth-child(1) { --z-offset: 70vh; }
.stack:hover .card:nth-child(2), .stack:active .card:nth-child(2) { --z-offset: 46vh; }
.stack:hover .card:nth-child(3), .stack:active .card:nth-child(3) { --z-offset: 22vh; }
.stack:hover .card:nth-child(4), .stack:active .card:nth-child(4) { --z-offset: -2vh; }
.stack:hover .card:nth-child(5), .stack:active .card:nth-child(5) { --z-offset: -26vh; }

/* layer 1 — the visible business card */
.card.content {
	z-index: 5;
	padding: 40px 36px 36px 0;
	background: transparent;
	border: 5px solid magenta;
	color: rgb(60, 60, 60);
	transition: border-color 4s ease, color 4s ease, box-shadow 2s ease, transform 4s ease;
}
.stack:hover .card.content, .stack:active .card.content {
	color: #fff200;
	border-color: transparent;
	box-shadow: inset 0 0 0 1.5px #fff200;
	transition: border-color 1s var(--ease), color 1s var(--ease), box-shadow 1s var(--ease) 1s, transform 2s var(--ease);
}

/* layer 2 — cyan hatched frame */
.card.padding { z-index: 4; background: transparent; transition-delay: .1s; }
.card.padding::before {
	content: "";
	position: absolute;
	inset: 0;
	clip-path: polygon(0% 0%, 0% 100%, 50px 100%, 50px 50px, calc(100% - 50px) 50px, calc(100% - 50px) calc(100% - 50px), 50px calc(100% - 50px), 50px 100%, 100% 100%, 100% 0%);
	background: transparent;
}
.stack:hover .card.padding, .stack:active .card.padding { transition-delay: .1s; }
.stack:hover .card.padding::before, .stack:active .card.padding::before {
	clip-path: polygon(0% 0%, 0% 100%, 5vmin 100%, 5vmin 5vmin, calc(100% - 5vmin) 5vmin, calc(100% - 5vmin) calc(100% - 5vmin), 5vmin calc(100% - 5vmin), 5vmin 100%, 100% 100%, 100% 0%);
	background: repeating-linear-gradient(-45deg, cyan, cyan 2px, rgba(255, 255, 254, 0.05) 1px, rgba(255, 255, 254, 0.05) 10px);
}

/* layer 3 — magenta border + photo */
.card.border { z-index: 3; background: transparent; transition-delay: .2s; }
.card.border::before {
	content: "";
	position: absolute;
	inset: 0;
	clip-path: polygon(0% 0%, 0% 100%, 5px 100%, 5px 5px, calc(100% - 5px) 5px, calc(100% - 5px) calc(100% - 5px), 5px calc(100% - 5px), 5px 100%, 100% 100%, 100% 0%);
	background: magenta;
}
.stack:hover .card.border, .stack:active .card.border { transition-delay: .2s; }
.image img { display: block; max-height: var(--card-h); }

/* layer 4 — paper */
.card.background { z-index: 2; background: #eee9d3; transition: background-color 4s ease .3s, transform 4s ease .3s; }
.stack:hover .card.background, .stack:active .card.background {
	background: white;
	transition: background-color 2s var(--ease) .3s, transform 2s var(--ease) .2s;
}

/* layer 5 — shadow */
.card.box-shadow {
	z-index: 1;
	background: transparent;
	transition: box-shadow 4s ease .4s, transform 4s ease .4s;
	box-shadow: 0 2.8px 2.2px rgba(0,0,0,.02), 0 6.7px 5.3px rgba(0,0,0,.028), 0 12.5px 10px rgba(0,0,0,.035),
	            0 22.3px 17.9px rgba(0,0,0,.042), 0 41.8px 33.4px rgba(0,0,0,.05), 0 100px 80px rgba(0,0,0,.07);
}
.stack:hover .card.box-shadow, .stack:active .card.box-shadow {
	transition-delay: .4s;
	box-shadow: 0 -1px 25px rgba(0,0,0,.4), 0 7.6px 6.1px rgba(0,0,0,.051), 0 14.3px 11.5px rgba(0,0,0,.059),
	            0 25.5px 20.5px rgba(0,0,0,.07), 0 47.6px 38.4px rgba(0,0,0,.094), 0 114px 92px rgba(0,0,0,.19);
	background: rgba(255, 255, 255, .04);
}

/* ---------- front text ---------- */
.text {
	margin-left: calc(var(--photo-w) + 30px);
	position: relative;
	z-index: 1;
}
#text-name { margin: 0 0 .35em; font-size: 2rem; font-weight: 650; line-height: 1.1; white-space: nowrap; letter-spacing: -.01em; }
.text p { margin: 0 0 .7em; }
.role  { font-size: 1rem; line-height: 1.35; }
.edu   { font-size: .78rem; line-height: 1.4; opacity: .7; }
.contacts {
	list-style: none;
	margin: 1.1em 0 0;
	padding: 0;
	display: grid;
	gap: .35em;
	font-size: .82rem;
}
.contacts a {
	display: inline-flex;
	align-items: center;
	gap: .55em;
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color .2s;
}
.contacts a:hover, .contacts a:focus-visible { border-bottom-color: magenta; }
.contacts svg {
	width: 14px; height: 14px; flex: none;
	fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
	opacity: .8;
}

/* ---------- labels (one per layer) ---------- */
.label {
	position: absolute;
	right: calc(100% + 20px);
	top: 100%;
	width: var(--label-w);
	padding: 18px 26px 20px;
	border-left: 3px solid var(--accent, white);
	border-radius: 4px 14px 14px 4px;
	background: rgba(12, 12, 14, .82);
	backdrop-filter: blur(4px);
	color: #f2f2f2;
	text-align: left;
	opacity: 0;
	pointer-events: none;
	transform-origin: top right;
	transform: rotate(-45deg) rotateY(45deg) translateX(20px);
	transition: opacity .5s ease 0s, transform .5s ease;
	box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.label h2 {
	margin: 0 0 .35em;
	font-size: 1.85rem;
	font-weight: 700;
	letter-spacing: .02em;
	color: var(--accent, white);
}
.label p { margin: 0; font-size: 1.3rem; line-height: 1.45; color: #e4e4e4; }
.stack:hover .label, .stack:active .label {
	opacity: 1;
	transform: rotate(-45deg) rotateY(45deg) translateX(0);
}
.stack:hover .card:nth-child(1) .label { transition-delay: 1.5s; }
.stack:hover .card:nth-child(2) .label { transition-delay: 1.7s; }
.stack:hover .card:nth-child(3) .label { transition-delay: 1.9s; }
.stack:hover .card:nth-child(4) .label { transition-delay: 2.1s; }
.stack:hover .card:nth-child(5) .label { transition-delay: 2.3s; }

/* ---------- hidden art layers (only visible when exploded) ---------- */
.art {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	pointer-events: none;
	transition: opacity .4s ease;
	font-family: inherit;
}
.stack:hover .art, .stack:active .art { opacity: 1; transition: opacity 1.2s ease 1.6s; }
.art-gis { left: 0; }
.rotor { transform-box: view-box; transform-origin: 95px 102px; animation: spin 6s linear infinite; animation-play-state: paused; }
.stack:hover .rotor, .stack:active .rotor { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ---------- keep-open area ----------
   The card explodes when you hover the card itself; once open, it stays open
   while the pointer is anywhere inside this much larger invisible area. */
.hold { position: fixed; inset: 50%; z-index: 0; pointer-events: none; }
.stack:hover .hold { inset: 3vh 3vw; pointer-events: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
	:root { --label-w: 460px; }
	.label p { font-size: 1rem; }
}
@media (max-width: 1024px) {
	.stack:hover, .stack:active { left: 0; }
}
@media (max-height: 980px) and (min-width: 769px) {
	:root { --explode-scale: .76; }
}
@media (max-height: 800px) and (min-width: 769px) {
	:root { --explode-scale: .68; }
	:root { --label-w: 520px; }
	.label { padding: 12px 18px 13px; }
	.label h2 { font-size: 1.25rem; }
	.label p { font-size: .95rem; line-height: 1.4; }
}
@media (max-width: 768px) {
	:root { --card-w: 434px; --card-h: 275px; --photo-w: 140px; --label-w: 240px; }
	.card.content { padding: 26px 20px 20px 0; }
	.text { margin-left: calc(var(--photo-w) + 20px); }
	#text-name { font-size: 1.5rem; }
	.role { font-size: .85rem; }
	.edu { font-size: .7rem; }
	.contacts { font-size: .74rem; margin-top: .7em; gap: .25em; }
	.label { padding: 10px 12px; }
	.label h2 { font-size: .95rem; }
	.label p { font-size: .72rem; }
	.stack:hover, .stack:active { left: 0; }
}
@media (max-width: 480px) {
	:root { --card-w: 350px; --card-h: 230px; --photo-w: 117px; --label-w: 170px; }
	.card.content { padding: 18px 12px 12px 0; }
	.text { margin-left: calc(var(--photo-w) + 12px); }
	#text-name { font-size: 1.2rem; }
	.role { font-size: .74rem; }
	.edu { font-size: .62rem; }
	.contacts { font-size: .66rem; margin-top: .5em; gap: .2em; }
	.contacts svg { width: 11px; height: 11px; }
	.label { padding: 7px 9px; }
	.label h2 { font-size: .78rem; }
	.label p { font-size: .6rem; line-height: 1.35; }
}

@media (prefers-reduced-motion: reduce) {
	.card, .stack, .stack::before, .label, .art { transition-duration: .01s !important; transition-delay: 0s !important; }
	.rotor { animation: none; }
}
