/* Theme toggle — icon by default, expands on hover/focus */
.theme-switch {
	position: fixed;
	bottom: max(4.75rem, env(safe-area-inset-bottom, 0px));
	right: 0;
	z-index: 1000;
	display: flex;
	flex-direction: row-reverse;
	align-items: center;
	gap: 0.5rem;
	font-family: var(--font-mono, ui-monospace, monospace);
}
.theme-switch__trigger {
	width: 44px;
	height: 40px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--line);
	border-right: none;
	border-radius: 999px 0 0 999px;
	background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
	color: var(--text);
	cursor: pointer;
	padding: 0;
	transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.theme-switch__trigger:hover {
	color: var(--accent);
	border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.theme-switch__trigger:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
}
.theme-switch__trigger svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.theme-switch__panel {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	max-width: 0;
	opacity: 0;
	overflow: hidden;
	pointer-events: none;
	white-space: nowrap;
	border: 0 solid var(--line);
	border-radius: 999px;
	padding: 0;
	background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
	transition:
		max-width 0.35s cubic-bezier(0.22, 1, 0.36, 1),
		opacity 0.25s ease,
		padding 0.35s cubic-bezier(0.22, 1, 0.36, 1),
		border-width 0.2s ease;
}
.theme-switch:hover .theme-switch__panel,
.theme-switch.is-open .theme-switch__panel {
	max-width: 240px;
	opacity: 1;
	pointer-events: auto;
	padding: 0.55rem 0.85rem;
	border-width: 1px;
}
.theme-switch__label {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	transition: color 0.25s ease;
	white-space: nowrap;
	user-select: none;
	cursor: pointer;
}
.theme-switch__label.is-active {
	color: var(--accent);
	font-weight: 600;
}
.theme-switch__control {
	appearance: none;
	-webkit-appearance: none;
	flex-shrink: 0;
	width: 44px;
	height: 24px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--bg-form-field, var(--bg-panel));
	cursor: pointer;
	position: relative;
	transition: border-color 0.25s ease, background 0.25s ease;
}
.theme-switch__control:hover {
	border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.theme-switch__control:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
}
.theme-switch__track {
	display: block;
	width: 100%;
	height: 100%;
	position: relative;
}
.theme-switch__thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--text-muted);
	transition: transform 0.25s ease, background 0.25s ease;
}
.theme-switch__control[aria-checked="true"] .theme-switch__thumb {
	transform: translateX(20px);
	background: var(--accent);
}
.theme-switch__control[aria-checked="true"] {
	border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

/* Dark mode — lift icon and switch off the page background */
html:not([data-theme="light"]) .theme-switch__trigger {
	border-color: rgba(255, 255, 255, 0.22);
	background: rgba(58, 58, 72, 0.96);
	color: #d4d4de;
}
html:not([data-theme="light"]) .theme-switch__trigger:hover {
	background: rgba(68, 68, 84, 0.96);
	border-color: color-mix(in srgb, var(--accent) 40%, rgba(255, 255, 255, 0.28));
}
html:not([data-theme="light"]) .theme-switch__panel {
	border-color: rgba(255, 255, 255, 0.14);
	background: rgba(28, 28, 36, 0.92);
}
html:not([data-theme="light"]) .theme-switch__control {
	background: #454558;
	border-color: rgba(255, 255, 255, 0.22);
}
html:not([data-theme="light"]) .theme-switch__control:hover {
	background: #525266;
	border-color: color-mix(in srgb, var(--accent) 40%, rgba(255, 255, 255, 0.28));
}

/* Light mode palette */
html[data-theme="light"] {
	color-scheme: light;
	--bg-deep: #f4f4f6;
	--bg-panel: #ffffff;
	--bg-elevated: #ffffff;
	--bg-form-surface: #ececf0;
	--bg-form-field: #ffffff;
	--line-form: rgba(0, 0, 0, 0.12);
	--line: rgba(0, 0, 0, 0.08);
	--text: #12121a;
	--text-muted: #5c5c6a;
	--accent: #0891b2;
	--accent-dim: rgba(8, 145, 178, 0.14);
	--accent-glow: rgba(8, 145, 178, 0.32);
}

html[data-theme="light"] #cursor-glow {
	mix-blend-mode: normal;
	background: radial-gradient(circle, var(--accent-glow) 0%, transparent 68%);
}

html[data-theme="light"] .btn:not(.btn--ghost) {
	color: #fff;
}

html[data-theme="light"] body:hover #cursor-glow {
	opacity: 0.35;
}

html[data-theme="light"] .atmosphere {
	background:
		linear-gradient(165deg, transparent 40%, rgba(8, 145, 178, 0.04) 100%),
		repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 80px),
		repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 80px);
	opacity: 0.5;
}

html[data-theme="light"] .site-nav {
	background: linear-gradient(
		to bottom,
		color-mix(in srgb, var(--bg-deep) 94%, transparent) 0%,
		color-mix(in srgb, var(--bg-deep) 82%, transparent) 55%,
		transparent 100%
	);
}

@supports not (background: color-mix(in srgb, black 50%, white)) {
	html[data-theme="light"] .site-nav {
		background: linear-gradient(
			to bottom,
			rgba(244, 244, 246, 0.94) 0%,
			rgba(244, 244, 246, 0.78) 50%,
			transparent 100%
		);
	}
}

html[data-theme="light"] .nav-burger {
	background: rgba(255, 255, 255, 0.85);
}

/* Mobile nav: logo + icons share one grid row, vertically centered */
@media (max-width: 719px) {
	.site-nav {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-rows: auto auto;
		align-items: center;
		column-gap: 1rem;
		row-gap: 0;
	}
	.site-nav .brand {
		grid-column: 1;
		grid-row: 1;
		display: flex;
		align-items: center;
		min-height: 40px;
		line-height: 1;
	}
	.site-nav-end {
		grid-column: 2;
		grid-row: 1;
		margin-left: 0;
	}
	.site-nav-panel {
		grid-column: 1 / -1;
		grid-row: 2;
		flex: none;
		order: unset;
		width: 100%;
	}
}

html[data-theme="light"] .hero::before {
	background:
		repeating-linear-gradient(
			-22deg,
			transparent 0 18px,
			rgba(8, 145, 178, 0.06) 18px,
			rgba(8, 145, 178, 0.06) 19px
		),
		radial-gradient(circle, rgba(0, 0, 0, 0.06) 1px, transparent 1.35px),
		repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 48px),
		repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 48px),
		radial-gradient(
			circle at 94% 36%,
			transparent 0,
			transparent 200px,
			rgba(8, 145, 178, 0.12) 200px,
			rgba(8, 145, 178, 0.12) 203px,
			transparent 204px
		),
		radial-gradient(ellipse 120% 80% at 8% -8%, rgba(8, 145, 178, 0.15), transparent 52%),
		linear-gradient(172deg, #e8ecf0 0%, var(--bg-deep) 50%, var(--bg-deep) 100%);
}

html[data-theme="light"] .services::before {
	background:
		repeating-linear-gradient(
			-22deg,
			transparent 0 18px,
			rgba(8, 145, 178, 0.05) 18px,
			rgba(8, 145, 178, 0.05) 19px
		),
		radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1.35px),
		repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px 48px),
		repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px 48px),
		radial-gradient(ellipse 110% 95% at 16% 0%, rgba(8, 145, 178, 0.08), transparent 50%),
		linear-gradient(180deg, rgba(232, 236, 240, 0.65) 0%, transparent 90%);
}

html[data-theme="light"] .service-card:hover {
	border-color: rgba(8, 145, 178, 0.35);
}

html[data-theme="light"] .portfolio-block__media {
	background: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .theme-switch__trigger,
html[data-theme="light"] .theme-switch__panel {
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@media (prefers-reduced-motion: reduce) {
	.theme-switch__panel,
	.theme-switch__control,
	.theme-switch__thumb,
	.theme-switch__label,
	.theme-switch__trigger {
		transition: none;
	}
}

.site-footer {
	padding: 2rem clamp(20px, 4vw, 48px) 3rem;
	border-top: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.85rem;
	font-size: 0.78rem;
	color: var(--text-muted);
	text-align: center;
}

.site-footer__legal {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.5rem 1.5rem;
	width: 100%;
}

.site-footer__legal a {
	font-size: 0.75rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.site-footer__meta {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	gap: 1rem;
}

.site-footer a,
.site-footer a:visited {
	color: var(--accent);
	text-decoration: none;
}

.site-footer a:hover {
	text-decoration: underline;
}

/* Avoid low-contrast browser-default purple for visited links in dark mode */
.hint a,
.hint a:visited,
.checkout-legal a,
.checkout-legal a:visited {
	color: var(--accent);
	text-decoration: none;
}

.hint a:hover,
.checkout-legal a:hover {
	text-decoration: underline;
}

@media (max-width: 639px) {
	.site-footer {
		padding-left: max(1rem, env(safe-area-inset-left, 0px));
		padding-right: max(1rem, env(safe-area-inset-right, 0px));
		padding-bottom: max(5rem, calc(env(safe-area-inset-bottom, 0px) + 4.5rem));
		gap: 1rem;
	}

	.site-footer__legal {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: center;
		gap: 0.75rem;
		margin-bottom: 1.25rem;
	}

	.site-footer__legal a {
		display: block;
		width: 100%;
		text-align: center;
	}

	.site-footer__meta {
		flex-direction: column;
		flex-wrap: nowrap;
		justify-content: center;
		align-items: center;
		gap: 0.6rem;
	}

	.site-footer__meta > span {
		display: block;
		width: 100%;
		max-width: 22rem;
		text-align: center;
		line-height: 1.45;
	}
}
