/* Modern CSS optimizations and improvements for Alien101 site */

/* CSS Variables for easier theming and consistency */
:root {
    --primary-color: #5e42a6;
    --accent-color: #b74e91;
    --text-dark: #1a1a1a;
    --text-medium: #2d2d2d;
    --text-light: #666;
    --bg-light: #f5f5f5;
    --bg-dark: #1a1d20;
    --link-color: #c84e6d;
    --link-hover: #e27689;
    --transition-speed: 0.3s;
    --shadow-subtle: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 16px rgba(0,0,0,0.15);
}

/* HIGH CONTRAST COLOR IMPROVEMENTS */

/* Improve body text contrast and font - Playful artist style */
body {
    color: var(--text-dark);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Improve paragraph text readability - Playful artist style */
p {
    color: #000 !important;
    line-height: 1.5;
    font-weight: 400 !important;
    font-size: 1.0625rem !important;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Improve heading contrast - Playful artist style */
h1, h2, h3, h4, h5, h6 {
    color: #000 !important;
    font-weight: 700 !important;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Improve link visibility and contrast */
a {
    color: var(--link-color) !important;
    text-decoration: none;
    border-bottom: 1px solid rgba(200, 78, 109, 0.3);
}

a:hover {
    color: var(--link-hover) !important;
    border-bottom-color: var(--link-hover);
}

/* Header/sidebar improvements */
#header {
    background: var(--bg-dark) !important;
}

#header #logo h1 {
    color: #fff !important;
    font-weight: 700;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

#header #logo p {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.75em;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Navigation link improvements - Playful artist style */
#nav a {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

#nav a:hover,
#nav a.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1);
}

#nav a span {
    color: rgba(255, 255, 255, 0.85);
}

/* Button text readability improvements - Playful artist style */
.button {
    color: #fff !important;
    font-weight: 700 !important;
    background-color: #6d1a32 !important;
    background-image: none !important;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.button:hover {
    color: #fff !important;
    background-color: #4d1224 !important;
}

/* Section backgrounds for better contrast */
section.one {
    background-color: #fff;
}

section.two {
    background-color: #f8f8f8;
}

section.three {
    background-color: #fff;
}

section.four {
    background-color: #f8f8f8;
}

/* Dark section text improvements */
section.dark {
    color: #fff !important;
}

section.dark h2,
section.dark h3,
section.dark p {
    color: #fff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Dark section button styles removed to restore original */

/* Portfolio item text improvements */
.item h3 {
    color: var(--text-dark) !important;
    font-weight: 600;
    font-size: 1.1em;
}

/* Form element improvements */
input[type="text"],
input[type="email"],
textarea {
    color: var(--text-dark) !important;
    background: #fff;
    border: 2px solid #ddd;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
    border-color: var(--link-color);
    color: var(--text-dark) !important;
}

label {
    color: var(--text-medium) !important;
    font-weight: 600;
}

/* Social icons contrast */
.icons a {
    color: rgba(255, 255, 255, 0.75) !important;
    background: rgba(255, 255, 255, 0.1);
    width: 3em;
    height: 3em;
    line-height: 3em;
    border-radius: 50%;
    display: inline-block;
}

.icons a:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.2);
}

/* Footer improvements */
#footer {
    background: var(--bg-dark);
    color: rgba(255, 255, 255, 0.7);
}

#footer .copyright {
    color: rgba(255, 255, 255, 0.6);
}

/* Improve text over images */
.cover header h2 {
    font-size: 3em;
    font-weight: 700;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

/* Accessibility: ensure minimum contrast ratios */
/* WCAG AA requires 4.5:1 for normal text, 3:1 for large text */

/* Override default text colors for better readability - Playful artist style */
#main section p,
#main section li {
    color: #000 !important;
    font-weight: 400 !important;
    font-size: 1.0625rem !important;
    line-height: 1.5;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Ensure links in content are visible */
#main section a {
    color: var(--link-color) !important;
    font-weight: 500;
}

/* Improve code/pre blocks if any */
code, pre {
    background: #f4f4f4;
    color: var(--text-dark);
    border: 1px solid #ddd;
}

/* Blockquote improvements */
blockquote {
    border-left: 4px solid var(--link-color);
    color: var(--text-medium);
}

/* List improvements */
ul li, ol li {
    color: #000 !important;
}

/* Table improvements if any */
table th {
    color: var(--text-dark);
    font-weight: 600;
    background: #f8f8f8;
}

table td {
    color: var(--text-medium);
}

/* Improve contrast for the cover section overlay */
#top.cover {
    position: relative;
}

#top.cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

#top.cover .container {
    position: relative;
    z-index: 2;
}

/* Ensure proper text contrast on darker sections */
section.dark,
section.cover {
    position: relative;
}

section.dark::after,
section.cover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 0;
}

section.dark .container,
section.cover .container {
    position: relative;
    z-index: 1;
}

/* Modern font loading with fallback */
@supports (font-display: swap) {
    @font-face {
        font-family: 'Source Sans Pro';
        font-display: swap;
    }
}

/* Smooth scrolling for modern browsers */
html {
    scroll-behavior: smooth;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Improved image loading performance */
img {
    content-visibility: auto;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src]) {
    opacity: 1;
}

/* Better focus indicators for accessibility */
a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Portfolio item enhancements */
.item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.item img {
    transition: transform var(--transition-speed) ease, filter var(--transition-speed) ease;
}

.item:hover img {
    transform: scale(1.05);
}

/* Button animation styles removed to restore original */

/* Navigation improvements */
#nav a {
    position: relative;
    transition: all var(--transition-speed) ease;
}

#nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width var(--transition-speed) ease;
}

#nav a:hover::after,
#nav a.active::after {
    width: 100%;
}

/* Section animations */
section {
    will-change: opacity, transform;
}

/* Video embed container improvements */
iframe {
    border-radius: 8px;
    box-shadow: var(--shadow-subtle);
}

/* Form enhancements */
form input,
form textarea {
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

form input:focus,
form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(94, 66, 166, 0.1);
}

form button[type="submit"] {
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

form button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Social icons hover effects */
.icons a {
    transition: all var(--transition-speed) ease;
}

.icons a:hover {
    transform: scale(1.2) rotate(5deg);
}

/* Performance: Use contain for isolated elements */
#header {
    contain: layout style;
}

.item {
    contain: layout paint;
}

/* Dark mode support (if user prefers) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if desired */
}

/* Loading optimization for above-the-fold content */
.header,
#top {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* Improve text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Responsive image improvements */
.image.fit {
    position: relative;
    overflow: hidden;
}

.image.fit img {
    display: block;
    width: 100%;
    height: auto;
}

/* Add subtle animations to headers */
h1, h2, h3 {
    transition: color var(--transition-speed) ease;
}

/* Improve link hover states */
a {
    transition: color var(--transition-speed) ease, border-bottom-color var(--transition-speed) ease;
}

/* Add loading skeleton for images (optional) */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

.image-loading {
    background: linear-gradient(to right, #eff1f3 4%, #e2e2e2 25%, #eff1f3 36%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

/* WebP background image support */
.webp .section-bg {
    background-image: url('/img/banner.webp');
}

.no-webp .section-bg {
    background-image: url('/img/banner.png');
}

/* Optimize paint performance */
* {
    box-sizing: border-box;
}

/* Add visual feedback for clickable items */
.item,
.button,
a {
    -webkit-tap-highlight-color: rgba(94, 66, 166, 0.2);
}

/* Improve contrast for better accessibility */
.label {
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Add GPU acceleration to animated elements */
.item,
.button,
#nav a {
    transform: translateZ(0);
    backface-visibility: hidden;
}
