@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ========== Variables ========== */
:root {
	--color-bg: #10161b;
	--color-text: #FDFDFD;
	--color-paragraph: #A8A8A8;
	--color-link: #AABECF;
	--color-accent: #3DADFF;
	--color-button: #004475;
	--color-button-alpha: #00447570;
	--color-white: #FFFFFF;
	--ease-cubic: cubic-bezier(0.4, 0.0, 0.2, 1);
	--ease-default: 0.4s ease-in-out;
	
	/* Spacing system */
	--space-xs: 8px;
	--space-sm: 16px;
	--space-md: 24px;
	--space-lg: clamp(24px, 3vw, 32px);
	--space-xl: clamp(28px, 4vw, 40px);
	--space-2xl: clamp(40px, 6vw, 64px);
	
	/* Typography scale */
	--text-xs: 12px;
	--text-sm: 14px;
	--text-base: 16px;
	--text-lg: clamp(18px, 2.5vw + 0.5rem, 20px);
	--text-xl: clamp(20px, 3vw + 0.5rem, 24px);
	--text-2xl: clamp(28px, 5vw + 1rem, 40px);
	
	/* Border radius system */
	--radius-none: 0;
	--radius-sm: 4px;
	--radius-md: 6px;
	--radius-lg: 12px;
	--radius-xl: 18px;
	--radius-full: 50%;
	
	/* Duration system */
	--duration-fast: 0.2s;
	--duration-normal: 0.3s;
	--duration-slow: 0.4s;
	--duration-slower: 0.5s;
	--duration-page: 0.6s;
	
	/* Shadow system */
	--shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.3);
	--shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
	--shadow-focus: 0 0 0 3px rgba(61, 173, 255, 0.1);
	
	/* Z-index scale */
	--z-base: 1;
	--z-elevated: 10;
	--z-overlay: 99999;

	/* Page fade */
	--fade-duration: var(--duration-page);
	--fade-delay: 100ms;

	/* Gallery shimmer */
	--shimmer-color: rgba(255, 255, 255, 0.1);
	--shimmer-duration: 1.2s;
	--shimmer-delay-start: 1.8;
	--shimmer-delay-step: 0.02;
}

/* ========== Reset & Base ========== */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	background: var(--color-bg);
	color: var(--color-text);
	font-size: var(--text-sm);
	font-family: 'Roboto', sans-serif;
	line-height: 1.5;
	overflow-wrap: break-word;
}

img, video {
	max-width: 100%;
	height: auto;
	display: block;
}

/* ========== Layout Components ========== */
.body-main {
	background: url('images/topbarbg.png') repeat-x;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-2xl);
}

/* ========== Header ========== */
.header-main,
.header-main-horizontal {
	background: url(images/glow.png) no-repeat center top scroll;
	background-size: min(1072px, 100%) auto;
	width: 100%;
	display: flex;
	align-items: center;
	gap: var(--space-xl);
}

.header-main {
	flex-direction: column;
	padding-top: var(--space-2xl);
}

.header-main-horizontal {
	flex-direction: row;
	justify-content: space-between;
	max-width: 982px;
	padding: var(--space-lg) var(--space-sm);
	border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-logo { width: 128px; }
.header-logo-horizontal { width: 64px; }

.header-links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
}

/* ========== Gallery Grid ========== */
.gallery-main {	
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0;
	max-width: 1200px;
	width: 100%;
	flex: 1;
	justify-content: center;
}

.gallery-item {
	position: relative;
	aspect-ratio: 4/3;
	transition: transform var(--duration-normal) var(--ease-cubic), box-shadow var(--duration-normal) var(--ease-cubic), border-radius var(--duration-normal) var(--ease-cubic);
	z-index: var(--z-base);
	border-radius: var(--radius-none);
}

.gallery-item:hover {
	transform: scale(1.05);
	z-index: var(--z-elevated);
	box-shadow: var(--shadow-lg);
	border-radius: var(--radius-lg);
}

.gallery-item:focus-within {
	outline: 3px solid var(--color-accent);
	outline-offset: 4px;
	z-index: var(--z-elevated);
	transition: outline var(--duration-fast) ease;
}

.gallery-view {
	width: 100%;
	height: 100%;
	position: relative;
	overflow: hidden;
	cursor: pointer;
	border-radius: inherit;
	transition: border-radius var(--duration-normal) var(--ease-cubic);
}

.gallery-view img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--duration-page) var(--ease-cubic);
}

.gallery-mask {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	backdrop-filter: blur(4px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	opacity: 0;
	transition: opacity var(--duration-slow) var(--ease-cubic), backdrop-filter var(--duration-slow) var(--ease-cubic);
	z-index: var(--z-base);
	border-radius: inherit;
}

.gallery-view h2,
.gallery-view h3 {
	color: white;
	text-align: center;
	padding: 0 var(--space-xl);
	transform: translateY(0);
}

.gallery-view h2 {
	font-size: var(--text-lg);
	font-weight: 500;
	opacity: 0;
	transform: translateY(-20px);
	transition: transform var(--duration-slower) var(--ease-cubic), opacity var(--duration-slower) var(--ease-cubic);
}

.gallery-view h3 {
	font-size: var(--text-sm);
	font-weight: 400;
	font-style: italic;
	opacity: 0;
	transform: translateY(20px);
	margin-top: var(--space-xs);
	transition: transform var(--duration-slower) var(--ease-cubic) 0.1s, opacity var(--duration-slower) var(--ease-cubic) 0.1s;
}

/* Hover Effects (pointer devices only) */
@media (hover: hover) {
	.gallery-item:hover img {
		transform: scale(1.2);
	}

	.gallery-item:hover .gallery-mask {
		opacity: 1;
		backdrop-filter: blur(6px);
	}

	.gallery-item:hover h2 {
		opacity: 1;
		transform: translateY(0);
	}

	.gallery-item:hover h3 {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Focus effects (keyboard navigation, always active) */
.gallery-item:focus-within img {
	transform: scale(1.2);
}

.gallery-item:focus-within .gallery-mask {
	opacity: 1;
	backdrop-filter: blur(6px);
}

.gallery-item:focus-within h2 {
	opacity: 1;
	transform: translateY(0);
}

.gallery-item:focus-within h3 {
	opacity: 1;
	transform: translateY(0);
}

/* ========== Work Pages ========== */
.work-main {
	display: flex;
	flex-direction: column;
	max-width: 982px;
	width: 100%;
	gap: var(--space-sm);
	padding: 0 var(--space-sm);
	flex: 1;
}

.textbox {
	width: 100%;
}

.textbox a {
    font-size: var(--text-base);
    line-height: 1.375;
    font-weight: 400;
    text-decoration: underline;
}

.gallerybox {
	font-size: var(--text-xs);
	color: var(--color-paragraph);
	width: 100%;
}

.gallerybox-footer {
	background: url(images/bar.png) no-repeat center top scroll;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-top: 10px;
	gap: var(--space-xs);
	font-size: var(--text-sm);
}

.gallerybox-footer p {
    margin: 0;	
}

.gallerybox-footer p,
.gallerybox-footer a {
    font-size: var(--text-sm);
}

.gallerybox-footer a {
    text-align: right;
}

.gallerybox-gif {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}

.gallerybox-gif video:first-child {
	grid-column: 1 / -1;
}

.gallerybox-gif--grid video:first-child {
	grid-column: auto;
}

.gallerybox-gif--stack {
	grid-template-columns: 1fr;
}

/* ========== Typography ========== */
h1 {
	font-size: var(--text-2xl);
	font-weight: 400;
	margin-bottom: var(--space-sm);
}

h2 {
	font-size: var(--text-xl);
	font-weight: 400;
	margin-top: var(--space-lg);
	margin-bottom: var(--space-xs);
}

h3 {
	font-size: var(--text-xl);
	font-weight: 400;
	margin-bottom: var(--space-xs);
}

h4 {
	font-size: var(--text-lg);
	font-weight: 400;
	margin-top: var(--space-md);
	margin-bottom: var(--space-xs);
}

p {
	font-size: var(--text-base);
	line-height: 1.375;
	color: var(--color-paragraph);
	margin-bottom: var(--space-sm);
}

strong, b {
	font-weight: 500;
	color: var(--color-text);
}

ul, ol {
	color: var(--color-paragraph);
	padding-left: var(--space-sm);
	margin-bottom: var(--space-sm);
}

li {
	margin-bottom: var(--space-xs);
}

/* ========== Links & Buttons ========== */
a {
	font-size: var(--text-base);
	font-weight: 300;
	color: var(--color-link);
	text-decoration: none;
	transition: color var(--ease-default);
}

a:hover {
	color: var(--color-accent);
}

a:focus {
	outline: 2px solid var(--color-link);
	outline-offset: 2px;
}

.link-main,
.link-selected {
	position: relative;
	padding: 12px 20px;
	min-height: 44px;
	border-radius: var(--radius-none) var(--radius-none) var(--radius-xl) var(--radius-none);
	overflow: hidden;
	display: inline-flex;
	align-items: center;
}

.link-selected {
	background: var(--color-button);
	color: white;
	box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

.link-main {
	isolation: isolate;
}

.link-main::before {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--color-button-alpha);
	transform: translateX(101%);
	transition: transform var(--duration-normal) var(--ease-cubic);
	z-index: -1;
}

.link-main:hover {
	color: white;
}

.link-main:hover::before {
	transform: translateX(0);
}

/* ========== Forms ========== */
.input-group {
	position: relative;
	margin-bottom: var(--space-sm);
}

.input-field {
	width: 100%;
	padding: 14px;
	border: 2px solid var(--color-link);
	border-radius: var(--radius-md);
	background: white;
	color: black;
	font-size: var(--text-base);
	transition: border-color var(--ease-default), box-shadow var(--ease-default);
}

.input-field:focus {
	outline: none;
	border-color: var(--color-accent);
	box-shadow: var(--shadow-focus);
}

.input-field.error {
	border-color: #ff6b6b;
	animation: shake var(--duration-slower) ease-in-out;
}

button {
	width: 100%;
	padding: 14px var(--space-md);
	background: var(--color-button);
	color: white;
	border: none;
	border-radius: var(--radius-md);
	font-size: var(--text-base);
	font-weight: 500;
	cursor: pointer;
	transition: all var(--ease-default);
}

button:hover:not(:disabled) {
	background: var(--color-accent);
	transform: translateY(-1px);
}

button:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

button:focus {
	outline: 2px solid var(--color-accent);
	outline-offset: 2px;
}

/* ========== Messages ========== */
#msg {
	font-size: var(--text-sm);
	min-height: 20px;
	margin-top: var(--space-xs);
	padding: var(--space-xs);
	border-radius: var(--radius-sm);
	transition: all var(--ease-default);
}

.message-error { 
	color: #ff6b6b; 
	background: rgba(255, 107, 107, 0.1); 
}

.message-success { 
	color: #51cf66; 
	background: rgba(81, 207, 102, 0.1); 
}

.message-loading { 
	color: var(--color-accent); 
	background: rgba(61, 173, 255, 0.1); 
}

/* ========== Footer ========== */
.footer-main {
	width: 100%;
	padding: var(--space-sm) 0;
	background: var(--color-accent);
	display: flex;
	justify-content: center;
	align-items: center;
}

.footer-main p {
	font-size: var(--text-sm);
	color: var(--color-bg);
	margin: 0;
}

/* ========== Animations ========== */
@keyframes shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-5px); }
	75% { transform: translateX(5px); }
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

.spinner {
	border: 2px solid transparent;
	border-top-color: currentColor;
	border-radius: var(--radius-full);
	width: 16px;
	height: 16px;
	animation: spin 1s linear infinite;
	display: inline-block;
}

.fade {
	opacity: 1;
	transition: opacity var(--duration-page) ease;
}

.fade.hidden {
	opacity: 0;
}

/* ========== Page Fade In/Out ========== */
.page-fade-in {
	opacity: 0;
	transition: opacity var(--fade-duration) ease;
}

.page-fade-in.loaded {
	opacity: 1;
}

.page-fade-in.fade-out {
	opacity: 0;
}

/* ========== Responsive Design ========== */
@media (max-width: 1024px) {
	.gallery-main {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 768px) and (min-width: 481px) {
	.header-main-horizontal {
		padding-left: var(--space-sm);
		padding-right: var(--space-sm);
	}
}

@media (max-width: 768px) {
	.gallery-main {
		grid-template-columns: 1fr;
	}

	.header-main-horizontal {
		flex-direction: column;
		padding-top: var(--space-lg);
		gap: var(--space-md);
	}

	.work-main {
		padding: 0;
	}

	.textbox {
		padding: 0 var(--space-sm);
	}

	.gallerybox-gif {
		grid-template-columns: 1fr;
	}

	.gallerybox-footer {
		padding-left: var(--space-sm);
		padding-right: var(--space-sm);
	}
}

@media (max-width: 480px) {
	.header-logo {
		width: 88px;
	}

	.header-links {
		flex-direction: row;
		gap: 0;
	}

	.link-main,
	.link-selected {
		padding: 12px 12px;
		font-size: var(--text-sm);
	}
}

/* ========== Utility Classes ========== */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

.skip-link:focus {
	position: fixed;
	top: var(--space-xs);
	left: var(--space-xs);
	width: auto;
	height: auto;
	padding: var(--space-xs) var(--space-sm);
	margin: 0;
	overflow: visible;
	clip: auto;
	white-space: normal;
	background: var(--color-accent);
	color: var(--color-bg);
	font-weight: 500;
	z-index: var(--z-overlay);
	border-radius: var(--radius-md);
}

/* ========== Gallery Shimmer Effect ========== */
.gallery-view::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--shimmer-color),
        transparent
    );
    z-index: 2;
    pointer-events: none;
    animation-name: shimmer;
    animation-duration: var(--shimmer-duration);
    animation-timing-function: ease-out;
    animation-delay: var(--shimmer-delay);
    animation-fill-mode: forwards;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; opacity: 0; }
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.page-fade-in {
		opacity: 1;
	}

	.gallery-view::before {
		animation: none;
	}
}