/**
 * Amitry Project Showcase - Frontend styles
 *
 * Architecture:
 * - All sizing/spacing driven by CSS custom properties set inline by PHP
 * - Theme-resilient: every selector is namespaced under .apshow-showcase
 * - No `all: revert`, no `!important` unless explicitly required
 * - Container queries used where appropriate so grid responds to its own width
 */

/* ============================================================
 * Root design tokens (overridable by theme via CSS vars)
 * ============================================================ */
.apshow-showcase {
	/* Defaults. PHP sets --apshow-columns, --apshow-gap etc. inline. */
	--apshow-columns: 1;
	--apshow-columns-tablet: 1;
	--apshow-columns-mobile: 1;
	--apshow-gap: 32px;
	--apshow-hover-duration: 6s;
	--apshow-hover-easing: ease-in-out;

	/* Frame design tokens. */
	--apshow-frame-radius: 12px;
	--apshow-frame-bg: #e8e8ed;
	--apshow-frame-border: #d1d1d6;
	--apshow-frame-chrome-height: 36px;
	--apshow-frame-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.5) inset;

	/* Traffic light colors. */
	--apshow-dot-close: #ff5f57;
	--apshow-dot-min: #febc2e;
	--apshow-dot-max: #28c840;
	--apshow-dot-size: 12px;

	/* URL bar. */
	--apshow-urlbar-bg: #ffffff;
	--apshow-urlbar-color: #6e6e73;
	--apshow-urlbar-radius: 6px;

	/* Viewport (where the screenshot lives). */
	--apshow-viewport-bg: #ffffff;
	--apshow-viewport-aspect: 16 / 10;

	/* Typography (inherits from theme by default; user-overridable via inspector). */
	--apshow-heading-size: 1.25rem;
	--apshow-heading-color: inherit;
	--apshow-heading-weight: 600;
	--apshow-description-size: 0.95rem;
	--apshow-description-color: inherit;
	--apshow-description-weight: 400;
	--apshow-cta-size: 0.95rem;
	--apshow-cta-weight: 500;
	--apshow-icon-size: 1.4rem;

	/* CTA. */
	--apshow-accent: #1d4ed8;
	--apshow-accent-contrast: #ffffff;
	--apshow-cta-radius: 6px;
	--apshow-cta-padding: 0.6em 1.2em;

	/* Reset for our subtree only. */
	box-sizing: border-box;
}

.apshow-showcase *,
.apshow-showcase *::before,
.apshow-showcase *::after {
	box-sizing: border-box;
}

/* ============================================================
 * Grid layout
 * ============================================================ */
.apshow-showcase__grid {
	display: grid;
	gap: var(--apshow-gap);
	grid-template-columns: repeat(var(--apshow-columns), minmax(0, 1fr));
}

@media (max-width: 1024px) {
	.apshow-showcase__grid {
		grid-template-columns: repeat(var(--apshow-columns-tablet), minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.apshow-showcase__grid {
		grid-template-columns: repeat(var(--apshow-columns-mobile), minmax(0, 1fr));
	}
}

/* Single layout: only one column. */
.apshow-showcase--single .apshow-showcase__grid {
	grid-template-columns: minmax(0, 1fr);
}

/* ============================================================
 * Item card
 * ============================================================ */
.apshow-item {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	min-width: 0; /* allow grid items to shrink */
}

.apshow-item__content {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.apshow-item__header {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.apshow-item__icon.dashicons {
	width: var(--apshow-icon-size);
	height: var(--apshow-icon-size);
	font-size: var(--apshow-icon-size);
	color: var(--apshow-accent);
	line-height: 1;
}

/* Heading: be specific enough to win over theme/block-theme h3 rules
 * (Block themes often set color on h1..h6 via :where(...) which has low
 * specificity but still beats the default :root cascade for inherited values).
 */
.apshow-showcase .apshow-item__heading {
	margin: 0;
	font-size: var(--apshow-heading-size);
	color: var(--apshow-heading-color);
	font-weight: var(--apshow-heading-weight);
	line-height: 1.3;
}

.apshow-showcase .apshow-item__description {
	margin: 0;
	font-size: var(--apshow-description-size);
	color: var(--apshow-description-color);
	font-weight: var(--apshow-description-weight);
	line-height: 1.5;
	opacity: 0.85;
}

/* ============================================================
 * Safari frame
 * ============================================================ */
.apshow-frame {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--apshow-frame-bg);
	border: 1px solid var(--apshow-frame-border);
	border-radius: var(--apshow-frame-radius);
	overflow: hidden;
	box-shadow: var(--apshow-frame-shadow);
}

.apshow-frame__chrome {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 12px;
	height: var(--apshow-frame-chrome-height);
	padding: 0 12px;
	background: linear-gradient(180deg, #f5f5f7 0%, #e8e8ed 100%);
	border-bottom: 1px solid var(--apshow-frame-border);
}

.apshow-frame__traffic {
	display: flex;
	align-items: center;
	gap: 6px;
}

.apshow-frame__dot {
	width: var(--apshow-dot-size);
	height: var(--apshow-dot-size);
	border-radius: 50%;
	display: inline-block;
}

.apshow-frame__dot--close { background: var(--apshow-dot-close); }
.apshow-frame__dot--min   { background: var(--apshow-dot-min); }
.apshow-frame__dot--max   { background: var(--apshow-dot-max); }

.apshow-frame__urlbar {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	height: calc(var(--apshow-frame-chrome-height) - 14px);
	padding: 0 10px;
	background: var(--apshow-urlbar-bg);
	border-radius: var(--apshow-urlbar-radius);
	font-size: 12px;
	color: var(--apshow-urlbar-color);
	box-shadow: 0 0 0 1px var(--apshow-frame-border) inset;
}

.apshow-frame__url {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

.apshow-frame__chrome-spacer {
	width: calc(var(--apshow-dot-size) * 3 + 12px); /* mirrors traffic light width for centering */
}

/* Viewport: fixed-aspect window that crops the long screenshot. */
.apshow-frame__viewport {
	position: relative;
	width: 100%;
	aspect-ratio: var(--apshow-viewport-aspect);
	background: var(--apshow-viewport-bg);
	overflow: hidden;
}

.apshow-frame__image {
	display: block;
	width: 100%;
	height: auto; /* image keeps natural aspect, gets translated by JS */
	max-width: none;
	transform: translateY(0);
	will-change: transform;
	user-select: none;
	-webkit-user-drag: none;
	/* Quality hints for browser when scaling large source images down. */
	image-rendering: -webkit-optimize-contrast;
	image-rendering: auto;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

.apshow-frame__placeholder {
	position: absolute;
	inset: 0;
	background:
		linear-gradient(135deg, rgba(0, 0, 0, 0.04) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.04) 50%, rgba(0, 0, 0, 0.04) 75%, transparent 75%, transparent),
		var(--apshow-viewport-bg);
	background-size: 20px 20px;
}

/* ============================================================
 * CTA
 * ============================================================ */
.apshow-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	padding: var(--apshow-cta-padding);
	border-radius: var(--apshow-cta-radius);
	font-size: var(--apshow-cta-size);
	font-weight: var(--apshow-cta-weight);
	text-decoration: none;
	line-height: 1.2;
	transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.apshow-cta:hover {
	transform: translateY(-1px);
}

.apshow-cta--solid {
	background: var(--apshow-accent);
	color: var(--apshow-cta-color, var(--apshow-accent-contrast));
	border: 1px solid var(--apshow-accent);
}

.apshow-cta--solid:hover {
	filter: brightness(1.05);
	color: var(--apshow-cta-color, var(--apshow-accent-contrast));
}

.apshow-cta--outline {
	background: transparent;
	color: var(--apshow-cta-color, var(--apshow-accent));
	border: 1px solid currentColor;
}

.apshow-cta--outline:hover {
	background: var(--apshow-cta-color, var(--apshow-accent));
	color: var(--apshow-accent-contrast);
}

.apshow-cta--ghost {
	background: transparent;
	color: var(--apshow-cta-color, var(--apshow-accent));
	border: 1px solid transparent;
	padding-left: 0;
	padding-right: 0;
}

.apshow-cta--ghost:hover {
	color: var(--apshow-cta-color, var(--apshow-accent));
	text-decoration: underline;
	text-underline-offset: 4px;
}

/* ============================================================
 * Accessibility: respect reduced motion
 * The JS also checks this, but CSS fallback if JS fails.
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
	.apshow-frame__image {
		transition: none;
	}
}
