/*
 * Onefold work cards: Bento (mixed sizes) and Grid (even) layouts.
 * Card heights come from fixed grid rows (Bento) or a fixed ratio (Grid),
 * so nothing moves while images load. Only transform and opacity animate.
 */

.of-work {
	--of-work-gap: 24px;
	--of-work-row: 280px;
	--of-work-radius: var(--of-radius-lg, 24px);
}

.of-work__heading {
	margin: 0 0 24px;
	font-size: var(--of-text-h2, 2.25rem);
}

.of-work__grid {
	display: grid;
	gap: var(--of-work-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.of-work__more {
	margin: 28px 0 0;
}

/* ---------- Bento ---------- */
.of-work--bento .of-work__grid {
	grid-template-columns: repeat(12, minmax(0, 1fr));
	grid-auto-rows: var(--of-work-row);
	grid-auto-flow: dense;
}

.of-work--bento .of-work-item--large { grid-column: span 8; grid-row: span 2; }
.of-work--bento .of-work-item--tall  { grid-column: span 4; grid-row: span 2; }
.of-work--bento .of-work-item--wide  { grid-column: span 8; }
.of-work--bento .of-work-item--std   { grid-column: span 4; }

/* ---------- Grid ---------- */
.of-work--grid .of-work__grid {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.of-work--grid .of-work-card__stage {
	flex: none;
	aspect-ratio: 4 / 3;
}

/* ---------- Card ---------- */
.of-work-item[hidden] {
	display: none;
}

.of-work-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background:
		radial-gradient(80% 60% at 15% 0%, rgba(108, 92, 231, 0.14), transparent 70%),
		radial-gradient(70% 60% at 100% 10%, rgba(0, 194, 255, 0.14), transparent 70%),
		var(--of-color-surface, #FFFFFF);
	border: 1px solid var(--of-color-border, #E3E6F0);
	border-radius: var(--of-work-radius);
	color: var(--of-color-text, #0B1020);
	text-decoration: none;
	box-shadow: 0 1px 2px rgba(11, 16, 32, 0.04);
	transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}

.of-work-card__stage {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 56px 28px 0; /* room for the tags above the frame */
	overflow: hidden;
}

.of-work-card__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(160deg, rgba(108, 92, 231, 0.55) 0%, rgba(0, 194, 255, 0.35) 100%);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.35s ease;
}

.of-work-card__tags {
	position: absolute;
	top: 16px;
	left: 16px;
	z-index: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.of-work-card__tags li {
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.88);
	color: var(--of-color-text, #0B1020);
	font-size: 0.75rem;
	font-weight: 600;
	box-shadow: 0 1px 2px rgba(11, 16, 32, 0.06);
}

.of-work-card__tags li.is-sample {
	background: #FFF3B0;
	color: #5A4500;
}

.of-work-card__body {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: 1fr auto;
	column-gap: 12px;
	align-items: end;
	padding: 18px 22px 20px;
	background: var(--of-color-surface, #FFFFFF);
	border-top: 1px solid var(--of-color-border, #E3E6F0);
}

.of-work-card__title {
	grid-column: 1;
	margin: 0;
	font-size: 1.125rem;
	line-height: 1.3;
	letter-spacing: -0.01em;
}

.of-work-item--large .of-work-card__title {
	font-size: clamp(1.25rem, 1rem + 0.8vw, 1.625rem);
}

.of-work-card__meta,
.of-work-card__excerpt {
	grid-column: 1;
	margin-top: 4px;
	color: var(--of-color-muted, #4A5068);
	font-size: 0.875rem;
}

.of-work-card__arrow {
	grid-column: 2;
	grid-row: 1 / span 3;
	align-self: center;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--of-gradient-strong, linear-gradient(135deg, #6C5CE7 0%, #2F6FE4 100%));
	color: #fff;
	opacity: 0;
	transform: translate3d(-8px, 8px, 0) scale(0.85);
	transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------- Device frames (CSS only) ---------- */
.of-frame {
	position: relative;
	display: block;
	overflow: hidden;
	background: #FFFFFF;
	box-shadow: 0 24px 48px rgba(11, 16, 32, 0.14), 0 2px 6px rgba(11, 16, 32, 0.06);
	transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.of-frame__screen {
	position: relative;
	display: block;
	overflow: hidden;
	background: #EEF0F8;
}

.of-frame__screen img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Browser: sits at the bottom of the stage, like a window rising out of the card. */
.of-frame--browser {
	align-self: flex-end;
	width: 100%;
	height: 100%;
	border-radius: 14px 14px 0 0;
}

.of-frame--browser .of-frame__bar {
	display: flex;
	gap: 6px;
	align-items: center;
	height: 26px;
	padding: 0 12px;
	background: #F2F3F8;
	border-bottom: 1px solid #E3E6F0;
}

.of-frame--browser .of-frame__bar i {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #D5D8E5;
}

.of-frame--browser .of-frame__screen {
	height: calc(100% - 26px);
}

/* Phone: fixed 9:19 shape centred in the stage. */
/* In short cards the phone keeps a readable size and its bottom is cut off, as if it rises out of the card. */
.of-frame--phone {
	align-self: flex-start;
	height: max(100%, 300px);
	max-width: 62%;
	aspect-ratio: 9 / 19;
	padding: 6px 6px 0;
	border-radius: 30px 30px 0 0;
	background: #23284A;
}

.of-frame--phone::before {
	position: absolute;
	top: 12px;
	left: 50%;
	z-index: 2;
	width: 28%;
	height: 10px;
	border-radius: 999px;
	background: #23284A;
	transform: translateX(-50%);
	content: "";
}

.of-frame--phone .of-frame__screen {
	height: 100%;
	border-radius: 24px 24px 0 0;
}

.of-frame--phone .of-mock {
	padding-top: 32px;
}

/* Video: 16:9 player with a play badge. */
.of-frame--video {
	width: 100%;
	aspect-ratio: 16 / 9;
	max-height: 100%;
	margin-bottom: 28px;
	border-radius: 14px;
}

.of-frame--video .of-frame__screen {
	height: 100%;
}

.of-frame__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 10px 30px rgba(11, 16, 32, 0.25);
	transform: translate(-50%, -50%);
}

.of-frame__play::after {
	position: absolute;
	top: 50%;
	left: 54%;
	border-top: 9px solid transparent;
	border-bottom: 9px solid transparent;
	border-left: 14px solid #6C5CE7;
	transform: translate(-50%, -50%);
	content: "";
}

/* No frame: the image fills the stage. */
.of-frame--none {
	width: calc(100% + 56px);
	height: calc(100% + 56px);
	margin: -56px -28px 0;
	box-shadow: none;
}

.of-frame--none .of-frame__screen {
	height: 100%;
}

/* ---------- Drawn sample screens (no image yet) ---------- */
.of-mock {
	display: grid;
	gap: 10px;
	align-content: start;
	height: 100%;
	padding: 16px;
	background: linear-gradient(180deg, #FFFFFF 0%, #F4F5FB 100%);
}

.of-mock i {
	display: block;
	height: 12px;
	border-radius: 6px;
	background: #E6E8F2;
}

.of-mock i:first-child {
	width: 55%;
	height: 22px;
	background: var(--of-gradient, linear-gradient(135deg, #6C5CE7 0%, #00C2FF 100%));
	opacity: 0.85;
}

.of-mock i:nth-child(2) { width: 85%; }
.of-mock i:nth-child(3) { width: 70%; }

.of-mock i:nth-child(4) {
	height: 64px;
	margin-top: 6px;
	border-radius: 10px;
	background: linear-gradient(135deg, rgba(108, 92, 231, 0.18), rgba(0, 194, 255, 0.18));
}

.of-mock--none {
	padding-top: 56px; /* stay clear of the tags */
	place-content: center;
	justify-items: center;
	background:
		radial-gradient(50% 50% at 50% 45%, rgba(108, 92, 231, 0.28), transparent 70%),
		linear-gradient(135deg, #FFFFFF, #EEF0FA);
}

.of-mock--none i:first-child {
	width: 72px;
	height: 72px;
	border-radius: 22px;
}

.of-mock--none i:nth-child(n+2) { width: 120px; }
.of-mock--none i:nth-child(4) { display: none; }

.of-mock--video {
	background: linear-gradient(135deg, #1A1F38, #2B2F55);
}

.of-mock--video i { background: rgba(255, 255, 255, 0.12); }
.of-mock--video i:nth-child(4) { display: none; }

/* ---------- Hover and focus (computers only) ---------- */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	a.of-work-card:hover,
	a.of-work-card:focus-visible {
		border-color: rgba(108, 92, 231, 0.35);
		transform: translate3d(0, -4px, 0);
		box-shadow: var(--of-glow, 0 20px 60px rgba(108, 92, 231, 0.18));
	}

	a.of-work-card:hover .of-frame,
	a.of-work-card:focus-visible .of-frame {
		transform: translate3d(0, -6px, 0);
	}

	a.of-work-card:hover .of-frame__screen img,
	a.of-work-card:focus-visible .of-frame__screen img {
		transform: scale(1.04);
	}

	a.of-work-card:hover .of-work-card__overlay,
	a.of-work-card:focus-visible .of-work-card__overlay {
		opacity: 0.35;
	}

	a.of-work-card:hover .of-work-card__arrow,
	a.of-work-card:focus-visible .of-work-card__arrow {
		opacity: 1;
		transform: none;
	}
}

a.of-work-card:focus-visible {
	outline: 3px solid var(--of-color-violet, #6C5CE7);
	outline-offset: 3px;
}

/* Arrow always visible where there is no hover (touch screens). */
@media (hover: none) {
	.of-work-card__arrow {
		opacity: 1;
		transform: none;
	}
}

/* Staggered reveal (classes added by the Effects module, below the first screen only). */
.of-work .of-work-item.of-reveal-in {
	transition-delay: calc(var(--i, 0) * 60ms);
}

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
	.of-work { --of-work-row: 240px; }

	.of-work--bento .of-work__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.of-work--bento .of-work-item--large { grid-column: span 6; }
	.of-work--bento .of-work-item--tall  { grid-column: span 3; grid-row: span 1; } /* avoids an empty hole next to it */
	.of-work--bento .of-work-item--wide  { grid-column: span 6; }
	.of-work--bento .of-work-item--std   { grid-column: span 3; }

	.of-work--grid .of-work__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Phone: Bento becomes a swipe row, Grid one column ---------- */
@media (max-width: 767px) {
	.of-work { --of-work-gap: 16px; }

	.of-work--bento .of-work__grid {
		display: flex;
		gap: var(--of-work-gap);
		margin-inline: -16px;
		padding: 4px 16px 12px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: 16px;
		scrollbar-width: none;
	}

	.of-work--bento .of-work__grid::-webkit-scrollbar { display: none; }

	.of-work--bento .of-work-item {
		flex: 0 0 85%;
		height: 400px;
		scroll-snap-align: start;
	}

	.of-work--grid .of-work__grid { grid-template-columns: 1fr; }

	.of-work-card__stage { padding: 52px 20px 0; }
	.of-frame--none { width: calc(100% + 40px); height: calc(100% + 52px); margin: -52px -20px 0; }
}

@media (prefers-reduced-motion: reduce) {
	.of-work-card,
	.of-frame,
	.of-frame__screen img,
	.of-work-card__overlay,
	.of-work-card__arrow {
		transition: none;
	}
}

/* Verified project result (shown only when the owner ticked it). */
.of-work-card__result {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin-top: 6px;
	color: var(--of-color-text, #0B1020);
	font-size: 0.9375rem;
	font-weight: 600;
}

.of-work-card__result::before {
	content: "";
	flex: none;
	width: 10px;
	height: 10px;
	margin-top: 0.4em;
	border-radius: 50%;
	background: var(--of-gradient-strong, linear-gradient(135deg, #6C5CE7 0%, #2F6FE4 100%));
}
