/**
 * ASLAN4U - Professional Mobile Styles
 * Optimized for touch devices and mobile experience
 */

/* ============================================
   MOBILE BASE (< 768px)
   ============================================ */

/* Safe Area for notched devices */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .mobile-nav {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Prevent text resize on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Fix text overflow on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, blockquote {
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
        -webkit-hyphens: auto;
    }

    /* Prevent horizontal scroll */
    .container, .container-narrow, section, article, main {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* Touch-friendly tap targets (minimum 44x44px) */
@media (max-width: 768px) {
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improved touch feedback */
    a:active, button:active {
        opacity: 0.7;
        transform: scale(0.98);
    }

    /* Prevent double-tap zoom */
    * {
        touch-action: manipulation;
    }
}

/* ============================================
   MOBILE HEADER
   ============================================ */
@media (max-width: 768px) {
    :root {
        --header-height: 64px;
    }

    .header {
        height: var(--header-height);
    }

    .header-inner {
        padding: 0 1rem;
    }

    .logo {
        gap: 0.75rem; /* Mehr Abstand zwischen Icon und Text */
    }

    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0; /* Icon nicht schrumpfen */
    }

    .logo-text {
        font-size: 0.95rem;
        letter-spacing: 0.01em;
    }

    .logo-text .version {
        font-size: 0.7rem;
        margin-left: 0.25rem;
        opacity: 0.7;
    }

    /* Hide desktop nav */
    .nav-links {
        display: none;
    }

    .lang-toggle {
        display: none;
    }

    .mode-toggle {
        display: none;
    }

    /* FIX: Hamburger mit 3 Strichen */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column; /* FIX: Striche untereinander! */
        align-items: center;
        justify-content: center;
        gap: 5px; /* FIX: Abstand zwischen Strichen */
        width: 44px;
        height: 44px;
        padding: 8px;
        background: transparent;
        border: none;
        cursor: pointer;
    }

    .mobile-menu-btn span {
        display: block;
        width: 22px;
        height: 2px;
        background: var(--gray-700);
        border-radius: 1px;
        transition: all 0.3s ease;
    }

    .privat-mode .mobile-menu-btn span {
        background: var(--gray-300);
    }

    /* Hamburger Animation beim Öffnen */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
}

/* ============================================
   MOBILE NAVIGATION (Full Screen Overlay)
   ============================================ */
@media (max-width: 768px) {
    .mobile-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--white);
        z-index: 999;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }

    .privat-mode .mobile-nav {
        background: var(--gray-50);
    }

    .mobile-nav.open {
        transform: translateX(0);
    }

    .mobile-nav-links {
        list-style: none;
        padding: 1rem;
        flex: 1;
    }

    .mobile-nav-links li {
        margin-bottom: 0.25rem;
    }

    .mobile-nav-links a {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.25rem;
        font-size: 1.1rem;
        font-weight: 500;
        color: var(--gray-700);
        border-radius: var(--radius-lg);
        transition: all 0.2s ease;
    }

    .privat-mode .mobile-nav-links a {
        color: var(--gray-300);
    }

    .mobile-nav-links a:hover,
    .mobile-nav-links a.active {
        background: var(--gray-100);
        color: var(--primary);
    }

    .privat-mode .mobile-nav-links a:hover,
    .privat-mode .mobile-nav-links a.active {
        background: var(--gray-200);
    }

    .mobile-nav-links a i {
        width: 24px;
        text-align: center;
        font-size: 1.1rem;
    }

    .mobile-nav-divider {
        height: 1px;
        background: var(--gray-200);
        margin: 1rem 0;
    }

    .mobile-nav-label {
        padding: 0.75rem 1.25rem;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--primary);
    }

    .mobile-toggles {
        padding: 1.5rem;
        border-top: 1px solid var(--gray-200);
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        background: var(--gray-50);
    }

    .privat-mode .mobile-toggles {
        background: var(--gray-100);
        border-color: var(--gray-300);
    }

    .mobile-toggles .btn {
        justify-content: center;
        padding: 0.875rem 1rem;
    }
}

/* ============================================
   MOBILE HERO - FIX: CTAs above the fold sichtbar
   ============================================ */
@media (max-width: 768px) {
    .hero {
        min-height: auto; /* Nicht mehr volle Höhe erzwingen */
        padding: 1.5rem 0 2rem;
    }

    .hero-content {
        gap: 1.25rem; /* Reduziert für mehr Platz */
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-text {
        order: 2; /* Text nach Bild */
        text-align: center;
    }

    .hero-text h1 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .hero-description,
    .hero-pitch {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }

    /* FIX: CTAs müssen above the fold sichtbar sein! */
    .hero-ctas {
        flex-direction: column;
        gap: 0.625rem;
        width: 100%;
        margin-top: 0.5rem;
    }

    .hero-ctas .btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }

    .hero-image {
        order: 1; /* Bild zuerst */
        max-width: 160px; /* Kompakter */
        margin: 0 auto;
    }

    .hero-image img {
        width: 100%;
        height: auto;
        max-height: none; /* Keine Beschränkung - Bild komplett zeigen */
        object-fit: contain;
        object-position: center top; /* Kopf nicht abschneiden */
        border-radius: var(--radius-lg);
    }

    /* Hero Status Badge kompakter */
    .hero-status-badge {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        margin: 0.5rem 0;
    }

    .hero-status-badge i {
        font-size: 0.9rem;
    }
}

/* ============================================
   MOBILE PAGE HEADER
   ============================================ */
@media (max-width: 768px) {
    .page-header {
        padding-top: calc(var(--header-height) + 1.5rem);
        padding-bottom: 1.5rem;
    }

    .page-header .container {
        padding: 0 1rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    .page-header .breadcrumb {
        font-size: 0.8rem;
        display: inline-flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE */
        padding-bottom: 0.25rem;
        max-width: 100%;
    }

    .page-header .breadcrumb::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .page-header .breadcrumb a,
    .page-header .breadcrumb span,
    .page-header .breadcrumb i {
        flex-shrink: 0;
        white-space: nowrap !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none !important;
    }
}

/* ============================================
   MOBILE SECTIONS
   ============================================ */
@media (max-width: 768px) {
    .section {
        padding: 3rem 0;
    }

    .container {
        padding: 0 1.25rem;
        max-width: 100%;
        overflow-x: hidden;
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
    }
}

/* ============================================
   MOBILE TEXT FIXES (Specific Elements)
   ============================================ */
@media (max-width: 768px) {
    /* Hero subtitle tags - einheitliches Design */
    .hero-subtitle {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .hero-subtitle span {
        white-space: nowrap;
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
        background: rgba(230, 126, 34, 0.15);
        border: 1px solid rgba(230, 126, 34, 0.3);
        border-radius: 50px;
        color: var(--primary);
        font-weight: 500;
    }

    .hero-subtitle span.hero-tag-highlight {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
    }

    .privat-mode .hero-subtitle span {
        background: rgba(230, 126, 34, 0.2);
        border-color: rgba(230, 126, 34, 0.4);
    }

    .privat-mode .hero-subtitle span.hero-tag-highlight {
        background: var(--primary);
        color: white;
    }

    /* Home Header - Mobile Layout */
    .home-header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .home-header-image {
        width: 100px;
        height: 100px;
    }

    .home-header-text h1 {
        font-size: 1.5rem;
    }

    .home-header-text .page-subtitle {
        font-size: 0.9rem;
    }

    .home-header-tags {
        justify-content: center;
    }

    .home-header-tags span {
        font-size: 0.7rem;
        padding: 0.25rem 0.6rem;
    }

    /* Home Intro - Mobile */
    .home-intro {
        padding: 1.5rem 0;
    }

    .home-intro .hero-pitch {
        font-size: 0.95rem;
    }

    .home-intro .hero-ctas {
        flex-direction: column;
    }

    .home-intro .hero-ctas .btn {
        width: 100%;
        justify-content: center;
    }

    /* CV Timeline text */
    .timeline-content h3,
    .timeline-content h4 {
        font-size: 1rem;
        line-height: 1.4;
    }

    .timeline-content p {
        font-size: 0.9rem;
    }

    /* Quote blocks */
    blockquote {
        padding: 1rem;
        font-size: 0.95rem;
    }

    blockquote p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    /* Stats row - ensure all visible */
    .stats-row, .stats-grid, .project-stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
    }

    .stat-item, .stat {
        min-width: 0;
        text-align: center;
        padding: 0.25rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.6rem;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .project-stats .stat-label {
        font-size: 0.55rem;
    }

    /* Page content text */
    .page-content p,
    .content p,
    article p {
        font-size: 0.95rem;
        line-height: 1.7;
        padding-right: 0;
    }

    /* Privat page headers */
    .privat-header h1,
    .lab-header h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    /* === SPECIFIC MOBILE FIXES === */

    /* Homepage Hero Tags - professional stacked layout */
    .hero-subtitle {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        max-width: 100%;
        margin-top: 0.5rem;
    }

    .hero-subtitle span {
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-secondary);
        letter-spacing: 0.02em;
    }

    /* Remove bullet separators on mobile */
    .hero-subtitle span:not(:last-child)::after {
        content: none;
    }

    /* Highlighted tag (AI Engineering) - make it stand out */
    .hero-tag-highlight {
        font-size: 0.85rem !important;
        padding: 0.5rem 1rem !important;
        margin-top: 0.5rem;
        background: var(--primary);
        color: white !important;
        border-radius: 20px;
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
    }

    /* Hero Status Badge - full width */
    .hero-status-badge {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem 1rem;
        max-width: 100%;
    }

    .hero-status-badge span {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* CV Status Banner - fix text overflow */
    .status-banner {
        padding: 1.5rem 0;
    }

    .status-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 0 0.5rem;
    }

    .status-text {
        max-width: 100%;
    }

    .status-text h3 {
        font-size: 1.1rem;
        line-height: 1.3;
        word-wrap: break-word;
    }

    .status-text p {
        font-size: 0.85rem;
        line-height: 1.5;
        word-wrap: break-word;
    }

    .status-badge {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .status-badge span {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }

    /* Contact Page Text */
    .contact-intro,
    .form-intro,
    .contact-form p,
    .form-section p {
        font-size: 0.9rem;
        line-height: 1.6;
        padding-right: 0;
        margin-right: 0;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Force container padding on contact */
    .contact-section .container,
    .contact-form {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

/* ============================================
   MOBILE CARDS & GRIDS
   ============================================ */
@media (max-width: 768px) {
    /* Project Cards */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .project-card {
        border-radius: var(--radius-lg);
    }

    .project-image {
        aspect-ratio: 16/10;
    }

    .project-content {
        padding: 1.25rem;
    }

    .project-title {
        font-size: 1.1rem;
    }

    .project-desc {
        font-size: 0.9rem;
        -webkit-line-clamp: 3;
    }

    /* Gallery Grid */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* Console/Game Grids */
    .consoles-grid {
        grid-template-columns: 1fr;
    }

    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .game-card {
        border-radius: var(--radius);
    }

    .game-info {
        padding: 0.75rem;
    }

    .game-info h3 {
        font-size: 0.85rem;
    }
}

/* ============================================
   MOBILE BUTTONS
   ============================================ */
@media (max-width: 768px) {
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }

    .btn-lg {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }

    /* Stack buttons on mobile */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }
}

/* ============================================
   MOBILE FORMS
   ============================================ */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.875rem 1rem;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* ============================================
   MOBILE FILTER TABS
   ============================================ */
@media (max-width: 768px) {
    .filter-tabs {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0.5rem 0;
        margin: 0 -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-tab {
        flex-shrink: 0;
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* ============================================
   MOBILE STATS
   ============================================ */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }
}

/* ============================================
   MOBILE FOOTER
   ============================================ */
@media (max-width: 768px) {
    .footer {
        padding: 3rem 0 2rem;
    }

    .footer-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem 1rem !important;
        text-align: left !important;
    }

    /* Brand: full width, centered */
    .footer-brand {
        grid-column: 1 / -1 !important;
        text-align: center !important;
    }

    /* Contact: full width, centered */
    .footer-contact {
        grid-column: 1 / -1 !important;
        text-align: center !important;
        padding-top: 1rem;
        border-top: 1px solid var(--gray-200);
    }

    /* Nav & Expertise: side by side */
    .footer-nav h4,
    .footer-expertise h4 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .footer-links li {
        margin-bottom: 0.35rem;
    }

    .footer-links a {
        font-size: 0.85rem;
    }

    .footer-links {
        justify-content: flex-start;
    }

    .social-links {
        justify-content: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ============================================
   MOBILE UTILITIES
   ============================================ */
@media (max-width: 768px) {
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Full width on mobile */
    .full-mobile {
        width: 100% !important;
    }

    /* Text alignment */
    .text-center-mobile {
        text-align: center !important;
    }

    /* Reduced spacing */
    .gap-mobile-sm {
        gap: 1rem !important;
    }
}

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

/* ============================================
   LANDSCAPE MODE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 4rem 0;
    }

    .mobile-nav {
        overflow-y: auto;
    }
}

/* ============================================
   SMALL PHONES (< 375px)
   ============================================ */
@media (max-width: 374px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 0 0.75rem;
    }

    .hero-text h1 {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.75rem 1.25rem;
    }
}

/* ============================================
   PULL TO REFRESH INDICATOR (iOS style)
   ============================================ */
.pull-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.85rem;
    transition: transform 0.3s ease;
}

.pull-refresh.visible {
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   INSTALL PROMPT (PWA)
   ============================================ */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gray-900);
    color: white;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    display: none;
    align-items: center;
    gap: 1rem;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.install-prompt.show {
    display: flex;
}

.install-prompt-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.install-prompt-text {
    flex: 1;
}

.install-prompt-text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.install-prompt-text span {
    font-size: 0.85rem;
    opacity: 0.8;
}

.install-prompt-actions {
    display: flex;
    gap: 0.5rem;
}

.install-prompt .btn-install {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
}

.install-prompt .btn-dismiss {
    background: transparent;
    color: var(--gray-400);
    border: none;
    padding: 0.5rem;
    font-size: 1.25rem;
}

/* ============================================
   WHATSAPP FLOATING BUTTON - MOBILE
   FIX: Button weiter unten um Überlappung zu vermeiden
   ============================================ */
@media (max-width: 768px) {
    .whatsapp-float {
        bottom: 24px;  /* Näher am unteren Rand */
        right: 16px;
        z-index: 999;  /* Unter Header aber über Content */
    }

    .whatsapp-btn {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    }

    /* Tooltip auf Mobile ausblenden */
    .whatsapp-tooltip {
        display: none !important;
    }

    /* Puls-Animation kleiner */
    .whatsapp-btn::before {
        animation: whatsappPulseMobile 2.5s infinite;
    }

    @keyframes whatsappPulseMobile {
        0% { transform: scale(1); opacity: 0.8; }
        100% { transform: scale(1.3); opacity: 0; }
    }

    /* FIX: WhatsApp im Hero-Bereich ausblenden um Überlappung zu vermeiden */
    .hero .whatsapp-float,
    .hero ~ .whatsapp-float {
        /* Button bleibt sichtbar, aber am unteren Rand */
    }
}

/* Cookie Button - FIX: weiter nach unten */
@media (max-width: 768px) {
    .cookie-settings-btn {
        bottom: 24px;  /* Gleiche Höhe wie WhatsApp */
        left: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
        z-index: 998;
        opacity: 0.7;  /* Weniger aufdringlich */
    }

    .cookie-settings-btn:hover {
        opacity: 1;
    }
}
