/* Custom CSS for DACH KONSTRUKT Website */

/* Performance optimizations */
* {
    box-sizing: border-box;
}

/* Improve font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Reduce motion for users who prefer it */
@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;
    }
}

/* Focus styles for better accessibility */
*:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* Better focus for interactive elements */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .text-gray-300 {
        color: #ffffff !important;
    }
    .text-gray-400 {
        color: #e5e5e5 !important;
    }
}

/* Accessibility Utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus\:not-sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

.skip-link {
    transform: translateY(-100%);
    transition: transform 0.3s;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Image loading optimization */
img {
    height: auto;
    max-width: 100%;
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Smooth scrolling and base styles */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
}

/* Custom animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Animation classes */
.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.8s ease-out forwards;
}

.animate-pulse-slow {
    animation: pulse 3s ease-in-out infinite;
}

/* Custom hover effects */
.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Loading animation */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Custom gradient backgrounds */
.gradient-primary {
    background: linear-gradient(135deg, #000000 0%, #1f2937 50%, #000000 100%);
}

.gradient-secondary {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 50%, #dc2626 100%);
}

/* Hero section particles effect */
.hero-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-particles::before,
.hero-particles::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    opacity: 0.1;
    animation: float 6s ease-in-out infinite;
}

.hero-particles::before {
    background: radial-gradient(circle, #dc2626, transparent);
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.hero-particles::after {
    background: radial-gradient(circle, #dc2626, transparent);
    top: 60%;
    right: 10%;
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-20px) rotate(5deg);
    }
    50% {
        transform: translateY(-10px) rotate(-3deg);
    }
    75% {
        transform: translateY(-15px) rotate(3deg);
    }
}

/* Portfolio grid masonry layout */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    align-items: start;
}

.portfolio-item {
    break-inside: avoid;
    opacity: 1;
    transform: scale(1);
    transition: all 0.5s ease;
}

.portfolio-item.filtered-out {
    opacity: 0;
    transform: scale(0.8);
    height: 0;
    margin: 0;
    overflow: hidden;
}

/* Custom form styles */
.form-input {
    transition: all 0.3s ease;
    position: relative;
}

.form-input:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    border-color: #dc2626;
}

.form-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input.success {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #dc2626;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b91c1c;
}

/* Navigation improvements - Fully Responsive */
nav {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s ease;
}

/* Mobile/Desktop navigation visibility control */
.mobile-menu-button {
    display: block;
}

.desktop-navigation {
    display: none;
}

.mobile-menu-container {
    display: block;
}

/* Show desktop navigation only on screens 1200px and above */
@media (min-width: 1200px) {
    .mobile-menu-button {
        display: none !important;
    }
    
    .desktop-navigation {
        display: flex !important;
    }
    
    .mobile-menu-container {
        display: none !important;
    }
}

/* Ensure mobile menu button is always visible on smaller screens */
@media (max-width: 1199px) {
    .mobile-menu-button {
        display: block !important;
    }
    
    .desktop-navigation {
        display: none !important;
    }
}

/* Extra safety for very small screens */
@media (max-width: 768px) {
    .mobile-menu-button {
        display: block !important;
        position: relative;
        z-index: 51;
    }
}

/* Hamburger icon specific fixes */
.hamburger-icon {
    display: block !important;
    width: 24px;
    height: 20px;
    position: relative;
}

/* Navigation background transitions */
nav.scrolled {
    background: rgba(0, 0, 0, 0.98);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.nav-link {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #dc2626;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

/* Hamburger Menu Animation - Fixed for ultra-wide phones */
.hamburger-icon {
    display: flex !important;
    width: 24px;
    height: 20px;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    cursor: pointer;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background-color: white;
    transition: all 0.3s ease;
    border-radius: 1px;
    display: block;
    position: relative;
    flex-shrink: 0;
}

/* Remove absolute positioning that was causing issues */
.hamburger-line:nth-child(1),
.hamburger-line:nth-child(2),
.hamburger-line:nth-child(3) {
    position: relative;
    top: auto;
}

/* Hamburger animation when active */
.hamburger-active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile menu improvements */
#mobile-menu {
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0 0 12px 12px;
    margin: 0 -1rem;
    padding: 0 1rem;
}

#mobile-menu a {
    position: relative;
    transition: all 0.3s ease;
}

#mobile-menu a:hover {
    transform: translateX(4px);
}

#mobile-menu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.1), transparent);
    transition: width 0.3s ease;
    transform: translateY(-50%);
    border-radius: 4px;
}

#mobile-menu a:hover::before {
    width: 100%;
}

/* Responsive breakpoints */
@media (max-width: 475px) {
    .xs\:flex {
        display: flex !important;
    }
    
    .xs\:hidden {
        display: none !important;
    }
    
    /* Ultra-narrow screens - prevent hamburger cutoff */
    nav .container {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    /* Adjust navbar layout for very narrow screens */
    nav .flex.items-center.justify-between {
        gap: 8px;
    }
    
    /* Ensure hamburger button doesn't get squeezed */
    #mobile-menu-btn {
        flex-shrink: 0 !important;
        margin-left: auto;
    }
    
    /* Make CTA button more compact */
    .bg-secondary {
        padding-left: 8px !important;
        padding-right: 8px !important;
        font-size: 12px !important;
    }
}

/* Touch-friendly sizing for mobile */
@media (max-width: 768px) {
    #mobile-menu a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    #mobile-menu-btn {
        min-height: 48px;
        min-width: 48px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 52;
    }
    
    .hamburger-icon {
        width: 26px;
        height: 22px;
    }
}

/* Samsung Galaxy S8+ and ultra-wide phones fix */
@media screen and (max-width: 414px) and (min-height: 736px),
       screen and (max-width: 360px) and (min-height: 740px),
       screen and (device-width: 360px) and (device-height: 740px),
       screen and (device-width: 414px) and (device-height: 736px) {
    
    /* Force hamburger menu button to be fully visible */
    #mobile-menu-btn {
        display: flex !important;
        position: relative;
        z-index: 999;
        min-width: 52px;
        min-height: 52px;
        padding: 12px;
        margin-right: 4px;
        flex-shrink: 0;
    }
    
    .hamburger-icon {
        width: 28px;
        height: 24px;
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
    }
    
    .hamburger-line {
        width: 100% !important;
        height: 3px !important;
        background-color: white !important;
        position: static !important;
        display: block !important;
        border-radius: 2px;
    }
    
    /* Ensure navbar doesn't overflow on narrow screens */
    nav .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Adjust logo size for narrow screens */
    nav .w-10 {
        width: 2rem !important;
        height: 2rem !important;
    }
    
    nav .sm\:w-12 {
        width: 2rem !important;
        height: 2rem !important;
    }
}

/* Additional fix for Galaxy S8+ in landscape */
@media screen and (max-height: 414px) and (min-width: 736px) and (orientation: landscape) {
    #mobile-menu-btn {
        display: flex !important;
        min-width: 48px;
        min-height: 48px;
    }
    
    .hamburger-icon {
        width: 24px;
        height: 20px;
    }
}

/* Force visibility on all touch devices and ultra-wide phones */
@media (pointer: coarse) {
    .mobile-menu-button {
        display: flex !important;
    }
}

/* Ultra-wide phone detection (aspect ratio > 2:1) */
@media screen and (max-aspect-ratio: 1/2) {
    .mobile-menu-button {
        display: flex !important;
    }
    
    .desktop-navigation {
        display: none !important;
    }
    
    #mobile-menu-btn {
        min-width: 50px;
        min-height: 50px;
    }
}

/* Very narrow screens (Galaxy S8+, iPhone X series, etc.) */
@media screen and (max-width: 414px) {
    .mobile-menu-button {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Prevent logo from taking too much space */
    nav .flex.items-center.space-x-2 {
        flex-shrink: 1;
        min-width: 0;
    }
    
    /* Ensure CTA button doesn't push hamburger off screen */
    nav .flex.items-center.space-x-2.sm\:space-x-4 {
        flex-wrap: nowrap;
        gap: 8px;
    }
}

/* Enhanced navbar scroll effects */
.navbar-scrolled {
    background: rgba(0, 0, 0, 0.98) !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
}

/* Additional responsive utilities */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    /* Tablet specific styles */
    nav .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (min-width: 1024px) {
    /* Desktop specific styles */
    .nav-link:focus {
        outline: none;
        background-color: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }
}

/* High DPI displays optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hamburger-line {
        height: 1.5px;
    }
}

/* Landscape phone optimizations */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #mobile-menu {
        max-height: 250px;
        overflow-y: auto;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    nav {
        background: rgba(0, 0, 0, 0.98);
    }
}

/* Improve button tap targets for mobile */
@media (pointer: coarse) {
    .nav-link,
    #mobile-menu a {
        padding: 0.75rem 1rem;
    }
    
    #mobile-menu-btn {
        padding: 0.75rem;
    }
}

/* Focus improvements for keyboard navigation */
.nav-link:focus-visible,
#mobile-menu-btn:focus-visible,
#mobile-menu a:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
    background-color: rgba(220, 38, 38, 0.1);
    border-radius: 6px;
}

/* Smooth animations preference */
@media (prefers-reduced-motion: no-preference) {
    nav {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .hamburger-line {
        transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
}

/* Print styles - hide navigation */
@media print {
    nav {
        display: none !important;
    }
}

/* CSS-only fallback for hamburger menu visibility */
@media (max-width: 1199px) {
    /* Force mobile menu button visibility */
    button[id="mobile-menu-btn"] {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Force desktop navigation to hide */
    .desktop-navigation {
        display: none !important;
    }
}

/* No-JavaScript fallback */
.no-js .mobile-menu-button {
    display: block !important;
}

.no-js .desktop-navigation {
    display: none !important;
}

@media (min-width: 1200px) {
    .no-js .desktop-navigation {
        display: flex !important;
    }
    
    .no-js .mobile-menu-button {
        display: none !important;
    }
}

/* Button enhancements */
.btn-primary {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: all 0.6s ease;
    transform: translate(-50%, -50%);
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

/* Card hover effects */
.service-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.1), transparent);
    transition: left 0.6s ease;
}

.service-card:hover::before {
    left: 100%;
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Testimonial cards */
.testimonial-card {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(220, 38, 38, 0.1);
}

.testimonial-card::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 20px;
    font-size: 60px;
    color: #dc2626;
    opacity: 0.3;
    font-family: serif;
    line-height: 1;
}

/* Mobile menu animations */
.mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-menu.active {
    max-height: 300px;
}

/* Portfolio filter buttons */
.portfolio-filter {
    position: relative;
    transition: all 0.3s ease;
}

.portfolio-filter.active {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.3);
}

/* FAQ accordion */
.faq-question .fa-chevron-down {
    transition: transform 0.3s ease;
}

.faq-question.active .fa-chevron-down {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.faq-answer:not(.hidden) {
    max-height: 500px;
    padding: 1.5rem;
    padding-top: 0;
}

/* Override Tailwind's hidden class for FAQ answers */
.faq-answer.hidden {
    display: block !important;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Loading states */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Custom utilities */
.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.backdrop-blur-strong {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Image overlay effects */
.image-overlay {
    position: relative;
    overflow: hidden;
}

.image-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(220, 38, 38, 0.8), rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.image-overlay:hover::before {
    opacity: 1;
}

.image-overlay .overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
}

.image-overlay:hover .overlay-content {
    opacity: 1;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-particles::before,
    .hero-particles::after {
        width: 200px;
        height: 200px;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    a {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-primary {
        background-color: #000000 !important;
    }
    
    .bg-secondary {
        background-color: #ff0000 !important;
    }
    
    .text-gray-600 {
        color: #000000 !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hero-particles::before,
    .hero-particles::after {
        animation: none;
    }
}

/* Focus styles for accessibility */
.focus-visible:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* Custom selection */
::selection {
    background-color: #dc2626;
    color: white;
}

::-moz-selection {
    background-color: #dc2626;
    color: white;
}
