/**
 * Grafline – Global Styles
 * Design tokens (CSS custom properties), base reset, and typography.
 * Enhanced with improved shadows, spacing, and animation curves.
 * FULLY RESPONSIVE across all devices.
 */

/* ============================================
   DESIGN TOKENS
   ============================================ */

:root {
	/* Brand Colors — Grafline Red */
	--grafline-primary: #ff2a13;
	--grafline-primary-dark: #d80f0f;
	--grafline-primary-light: #fef2f2;
	--grafline-secondary: #1d1d1f;
	--grafline-secondary-dark: #0a0a0a;
	--grafline-accent: #f5f5f7;
	--grafline-text: #1d1d1f;
	--grafline-text-light: #6b7280;
	--grafline-bg: #ffffff;
	--grafline-bg-light: #f9fafb;
	--grafline-border: #e5e7eb;

	/* Spacing - Improved rhythm */
	--spacing-xs: 0.5rem;
	--spacing-sm: 1rem;
	--spacing-md: 1.5rem;
	--spacing-lg: 2.5rem;
	--spacing-xl: 4rem;
	--spacing-2xl: 6rem;

	/* Typography - Enhanced scale */
	--font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--font-size-xs: 0.75rem;
	--font-size-sm: 0.875rem;
	--font-size-base: 1rem;
	--font-size-lg: 1.125rem;
	--font-size-xl: 1.25rem;
	--font-size-2xl: 1.5rem;
	--font-size-3xl: 1.875rem;
	--font-size-4xl: 2.5rem;
	--font-size-5xl: 3rem;

	/* Shadows - Refined elevation system */
	--shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
	--shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
	--shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
	--shadow-lg: 0 10px 20px -5px rgba(0, 0, 0, 0.1), 0 4px 8px -4px rgba(0, 0, 0, 0.06);
	--shadow-xl: 0 20px 30px -10px rgba(0, 0, 0, 0.12), 0 8px 12px -6px rgba(0, 0, 0, 0.08);
	--shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

	/* Border Radius */
	--radius-sm: 0.375rem;
	--radius-md: 0.5rem;
	--radius-lg: 0.75rem;
	--radius-xl: 1rem;
	--radius-2xl: 1.5rem;
	--radius-full: 9999px;

	/* Animation curves */
	--ease-in-out-smooth: cubic-bezier(0.4, 0, 0.2, 1);
	--ease-out-smooth: cubic-bezier(0, 0, 0.2, 1);
	--ease-in-smooth: cubic-bezier(0.4, 0, 1, 1);
	--ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   BASE RESET & TYPOGRAPHY
   ============================================ */

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

/* Prevent any element from exceeding viewport */
img, video, iframe, embed, object, table, pre {
	max-width: 100%;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	font-family: var(--font-family);
	font-size: var(--font-size-base);
	line-height: 1.65;
	color: var(--grafline-text);
	background: var(--grafline-bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
	font-weight: 700;
	line-height: 1.25;
	color: var(--grafline-text);
	margin-bottom: 0.75em;
	letter-spacing: -0.02em;
}

h1 { 
	font-size: var(--font-size-5xl);
	font-weight: 800;
	letter-spacing: -0.03em;
}
h2 { 
	font-size: var(--font-size-3xl);
	font-weight: 700;
}
h3 { 
	font-size: var(--font-size-xl);
	font-weight: 600;
}

p {
	margin-bottom: 1em;
	line-height: 1.7;
}

a {
	color: var(--grafline-primary);
	text-decoration: none;
	transition: color 0.2s var(--ease-out-smooth);
}

a:hover {
	color: var(--grafline-primary-dark);
}

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

/* ============================================
   LAYOUT
   ============================================ */

.container {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	padding-top: 0;
	padding-bottom: 0;
	padding-left: max(clamp(1rem, 4vw, 4rem), env(safe-area-inset-left, 0px));
	padding-right: max(clamp(1rem, 4vw, 4rem), env(safe-area-inset-right, 0px));
	box-sizing: border-box;
}

.container--narrow {
	max-width: 1000px;
}

.container--tight {
	max-width: 800px;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

*:focus-visible {
	outline: 2px solid var(--grafline-primary);
	outline-offset: 3px;
	border-radius: 2px;
}

.skip-to-content {
	position: absolute;
	top: -40px;
	left: 0;
	background: var(--grafline-primary);
	color: #fff;
	padding: 0.5rem 1rem;
	text-decoration: none;
	z-index: 10000;
	transition: top 0.2s;
}

.skip-to-content:focus {
	top: 0;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.hidden { display: none !important; }

/* ============================================
   SCROLL REVEAL ANIMATIONS - Enhanced
   ============================================ */

.reveal {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.5s var(--ease-out-smooth), transform 0.5s var(--ease-out-smooth);
}

.reveal.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.reveal--delay-1 { transition-delay: 0.1s; }
.reveal--delay-2 { transition-delay: 0.2s; }
.reveal--delay-3 { transition-delay: 0.3s; }
.reveal--delay-4 { transition-delay: 0.4s; }

.reveal--scale {
	opacity: 0;
	transform: scale(0.96);
	transition: opacity 0.45s var(--ease-out-smooth), transform 0.5s var(--ease-spring);
}

.reveal--scale.is-visible {
	opacity: 1;
	transform: scale(1);
}

.reveal--left {
	opacity: 0;
	transform: translateX(-32px);
	transition: opacity 0.5s var(--ease-out-smooth), transform 0.5s var(--ease-out-smooth);
}

.reveal--left.is-visible {
	opacity: 1;
	transform: translateX(0);
}

.reveal--right {
	opacity: 0;
	transform: translateX(32px);
	transition: opacity 0.5s var(--ease-out-smooth), transform 0.5s var(--ease-out-smooth);
}

.reveal--right.is-visible {
	opacity: 1;
	transform: translateX(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;
	}

	.reveal,
	.reveal--scale,
	.reveal--left,
	.reveal--right {
		opacity: 1 !important;
		transform: none !important;
	}
}

/* ============================================
   RESPONSIVE TYPOGRAPHY & SPACING
   ============================================ */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
	:root {
		--spacing-xl: 3rem;
		--spacing-2xl: 4.5rem;
		--font-size-4xl: 2.25rem;
		--font-size-5xl: 2.75rem;
	}
}

/* Mobile: < 768px */
@media (max-width: 768px) {
	:root {
		--spacing-lg: 2rem;
		--spacing-xl: 2.5rem;
		--spacing-2xl: 3.5rem;
		--font-size-3xl: 1.625rem;
		--font-size-4xl: 2rem;
		--font-size-5xl: 2.25rem;
	}
	
	body {
		font-size: var(--font-size-base);
		line-height: 1.7;
	}
	
	h1 { 
		font-size: var(--font-size-4xl); 
		line-height: 1.2;
	}
	h2 { 
		font-size: var(--font-size-2xl);
		line-height: 1.3;
	}
	h3 { 
		font-size: var(--font-size-lg);
	}
	
	.container {
		padding-left: max(1rem, env(safe-area-inset-left, 0px));
		padding-right: max(1rem, env(safe-area-inset-right, 0px));
	}
}

/* Small mobile: < 480px */
@media (max-width: 480px) {
	:root {
		--spacing-md: 1.25rem;
		--spacing-lg: 1.75rem;
		--spacing-xl: 2rem;
		--spacing-2xl: 3rem;
		--font-size-2xl: 1.375rem;
		--font-size-3xl: 1.5rem;
		--font-size-4xl: 1.75rem;
		--font-size-5xl: 2rem;
	}
	
	h1 { 
		font-size: var(--font-size-4xl);
	}
	h2 { 
		font-size: var(--font-size-2xl);
	}
	
	.container {
		padding-left: max(1rem, env(safe-area-inset-left, 0px));
		padding-right: max(1rem, env(safe-area-inset-right, 0px));
	}
}

/* ============================================
   MOBILE / TOUCH OPTIMIZATION (SEO & CWV)
   ============================================ */

/* Fix mobile scrolling: ensure document and main content can scroll with momentum on iOS */
@media (max-width: 1024px) {
	html {
		-webkit-overflow-scrolling: touch;
		overflow-y: auto;
	}
	body {
		overflow-x: hidden;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
	#page,
	main {
		min-height: 0;
		overflow: visible;
	}
}

/* Prevent iOS zoom on focus when input font-size < 16px */
@media (max-width: 768px) {
	input[type="text"],
	input[type="email"],
	input[type="tel"],
	input[type="number"],
	input[type="search"],
	input[type="url"],
	select,
	textarea {
		font-size: max(16px, 1rem);
	}
}

/* Touch: better tap highlight and scroll */
@media (pointer: coarse) {
	* {
		-webkit-tap-highlight-color: rgba(255, 42, 19, 0.12);
	}
	/* Allow smooth scroll on focus for keyboard/screen reader */
	main:focus {
		outline: none;
	}
}

/* Ensure interactive elements have at least 44px touch target where possible */
@media (max-width: 768px) {
	button:not(.menu-toggle),
	.btn,
	input[type="submit"],
	input[type="button"] {
		min-height: 44px;
		padding-top: 0.5rem;
		padding-bottom: 0.5rem;
	}

	a {
		overflow-wrap: anywhere;
	}
}
