/* ===== Mobile-First Optimizations ===== */
/* Touch & Accessibility Improvements for iOS and Android */

/* ===== Touch Optimizations ===== */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Prevent text selection on interactive elements */
button, a, .btn, .preset, .color-input {
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection on content */
p, h1, h2, h3, h4, h5, h6, li, span {
    -webkit-user-select: text;
    user-select: text;
}

/* ===== Safe Area Support (iPhone X+, Android notch) ===== */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.navbar {
    padding-top: calc(20px + env(safe-area-inset-top));
}

.footer {
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
}

/* ===== Minimum Touch Target Size (44x44px for iOS, 48x48px for Android) ===== */
.btn,
.nav-links a,
.mobile-nav-links a,
.mobile-menu-btn,
.preset,
.color-input,
.preview-btn,
.reset-btn,
.social-links a,
.modal-close,
.scroll-indicator {
    min-height: 44px;
    min-width: 44px;
}

/* ===== Improved Touch States ===== */
.btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.benefit-card:active,
.project-card:active {
    transform: scale(0.98);
}

.preset:active {
    transform: scale(1.15);
}

/* ===== Mobile Navigation Improvements ===== */
.mobile-menu-btn {
    width: 48px;
    height: 48px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn span {
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.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(6px, -6px);
}

/* ===== Smooth Scrolling ===== */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar on mobile but keep functionality */
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* ===== Form Elements for Mobile ===== */
input, button, select, textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
}

.color-input {
    width: 60px;
    height: 50px;
    border-radius: 10px;
    cursor: pointer;
}

/* ===== Mobile-Specific Media Queries ===== */

/* Large phones and small tablets */
@media (max-width: 768px) {
    /* Navigation */
    .mobile-menu-btn {
        display: flex;
    }
    
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 999;
        padding: calc(100px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        justify-content: center;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-menu.active {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-nav-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }
    
    .mobile-nav-links a {
        font-size: 1.5rem;
        font-weight: 600;
        padding: 12px 24px;
        border-radius: 12px;
        transition: all 0.3s ease;
        width: 100%;
        text-align: center;
        max-width: 300px;
    }
    
    .mobile-nav-links a:active {
        background: rgba(59, 130, 246, 0.2);
    }
    
    .mobile-nav-links .btn {
        margin-top: 20px;
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
    
    /* Hero adjustments */
    .hero {
        min-height: calc(100vh - env(safe-area-inset-top));
        padding-top: calc(80px + env(safe-area-inset-top));
    }
    
    .hero-scroll {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    /* Feature points hidden on mobile */
    .totem-features {
        display: none;
    }
    
    /* Better touch on cards */
    .benefit-card,
    .project-card {
        cursor: pointer;
    }
    
    /* Safe area horizontal para secções projetos e vídeos (notch) */
    .projects .container,
    .tech-action .container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    
    /* Customizer mobile improvements */
    .customizer-container {
        gap: 30px;
    }
    
    .customizer-preview {
        position: relative;
        top: 0;
    }
    
    .preview-wrapper {
        padding: 40px 20px 30px;
        min-height: 380px;
        border-radius: 20px;
    }
    
    /* Color presets larger for touch */
    .color-presets {
        gap: 12px;
    }
    
    .color-presets .preset {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }
    
    /* Control groups spacing */
    .control-group {
        margin-bottom: 32px;
    }
    
    /* Modal improvements */
    .modal-content {
        margin: 16px;
        max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overflow-y: auto;
    }
    
    /* CTA section */
    .cta-section {
        padding: 60px 0;
    }
    
    .cta-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Small phones */
@media (max-width: 480px) {
    /* Typography scaling */
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .section-description {
        font-size: 0.95rem;
    }
    
    /* Buttons */
    .btn {
        padding: 14px 20px;
        font-size: 0.95rem;
    }
    
    .btn-lg {
        padding: 16px 24px;
        font-size: 1rem;
    }
    
    /* Stats */
    .hero-stats {
        gap: 20px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Benefits */
    .benefit-card {
        padding: 20px 16px;
    }
    
    .benefit-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .benefit-card h3 {
        font-size: 1.1rem;
    }
    
    .benefit-card p {
        font-size: 0.9rem;
    }
    
    /* Projects */
    .project-info h3 {
        font-size: 1rem;
    }
    
    /* Customizer */
    .control-label {
        font-size: 0.9rem;
    }
    
    .color-picker-wrapper {
        flex-wrap: wrap;
    }
    
    .color-value {
        flex: 1 1 100%;
        margin-top: 8px;
    }
    
    .customizer-cta .btn {
        font-size: 0.95rem;
    }
    
    .cta-note {
        font-size: 0.8rem;
    }
    
    /* Specs */
    .spec-category {
        padding: 20px 16px;
    }
    
    .spec-list li {
        font-size: 0.85rem;
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    
    .spec-list li strong {
        font-size: 0.9rem;
    }
    
    /* Footer */
    .footer {
        padding: 40px 0 20px;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .hero-title {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.35rem;
    }
    
    .hero-cta {
        gap: 10px;
    }
    
    .hero-cta .btn {
        width: 100%;
    }
}

/* ===== Landscape Mode ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 0 60px;
    }
    
    .hero-visual {
        display: none;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
    }
    
    .mobile-menu {
        padding-top: 80px;
        overflow-y: auto;
    }
    
    .mobile-nav-links {
        gap: 16px;
    }
    
    .mobile-nav-links a {
        font-size: 1.2rem;
        padding: 10px 20px;
    }
}

/* ===== Dark Mode / OLED Optimization ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-dark: #000000;
        --bg-darker: #000000;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid white;
    }
    
    .project-card,
    .benefit-card,
    .spec-category {
        border-width: 2px;
    }
}

/* ===== iOS Specific Fixes ===== */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS 100vh issue */
    .hero {
        min-height: -webkit-fill-available;
    }
    
    .mobile-menu {
        height: -webkit-fill-available;
    }
    
    /* Fix for iOS input zoom */
    input[type="color"] {
        font-size: 16px;
    }
}

/* ===== Android Specific ===== */
@supports not (-webkit-touch-callout: none) {
    /* Android-specific styles if needed */
    .color-input {
        border: 2px solid rgba(255, 255, 255, 0.1);
    }
}

/* ===== Print Styles ===== */
@media print {
    .navbar,
    .mobile-menu,
    .hero-scroll,
    .customizer,
    .cta-section,
    .footer {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .hero {
        min-height: auto;
        padding: 20px;
    }
}

/* ===== Hero Refresh: mobile ===== */
@media (max-width: 768px) {
    .hero {
        min-height: auto;
        padding: calc(108px + env(safe-area-inset-top)) 0 64px;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 42px;
        text-align: left;
    }

    .hero-title {
        font-size: clamp(2.15rem, 9vw, 3.25rem);
    }

    .hero-description {
        margin-left: 0;
        margin-right: 0;
    }

    .hero-cta {
        justify-content: flex-start;
    }

    .hero-cta .btn {
        width: 100%;
    }

    .hero-visual {
        order: initial;
    }

    .hero-media-frame {
        min-height: 370px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2rem, 10.5vw, 2.65rem);
        line-height: 1.05;
    }

    .hero-description {
        font-size: 0.98rem;
        line-height: 1.65;
    }

    .hero-badge {
        font-size: 0.68rem;
        letter-spacing: 0.06em;
    }

    .hero-trust {
        align-items: flex-start;
        font-size: 0.82rem;
    }

    .hero-sectors {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .hero-media-topline {
        align-items: flex-start;
        font-size: 0.66rem;
    }

    .hero-media-frame {
        min-height: 330px;
        padding: 24px;
    }

    .media-placeholder-copy strong {
        font-size: 1.45rem;
    }

    .media-placeholder-copy p {
        font-size: 0.84rem;
    }
}

@media (max-width: 360px) {
    .hero-title {
        font-size: 1.9rem;
    }

    .hero-sectors {
        grid-template-columns: 1fr;
    }
}

/* ===== Authority and Positioning: mobile ===== */
@media (max-width: 600px) {
    .authority {
        padding: 68px 0;
    }

    .authority-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .authority-copy {
        padding: 0;
        border-left: 0;
    }

    .authority-lead {
        font-size: 1rem;
    }

    .authority-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .authority-card {
        min-height: auto;
        padding: 24px;
    }

    .authority-card::before {
        left: 24px;
    }

    .authority-card-icon {
        width: 44px;
        height: 44px;
        margin-bottom: 22px;
    }

    .authority-card h3 {
        font-size: 1.12rem;
    }

    .authority-closing {
        margin-top: 24px;
        padding: 24px;
    }

    .authority-link {
        width: 100%;
        justify-content: space-between;
    }
}

/* ===== Technology in Action: mobile ===== */
@media (max-width: 600px) {
    .tech-action {
        padding: 68px 0;
    }

    .tech-action-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .tech-action-intro {
        padding: 0;
        border-left: 0;
    }

    .tech-action-intro p {
        font-size: 0.95rem;
    }

    .tech-action-grid {
        gap: 12px;
    }

    .tech-action-card {
        grid-template-columns: minmax(128px, 0.72fr) minmax(0, 1fr);
        border-radius: 15px;
    }

    .tech-action-content {
        padding: 20px 18px;
    }

    .tech-action-kicker {
        align-items: flex-start;
        margin-bottom: 12px;
        font-size: 0.6rem;
        line-height: 1.45;
    }

    .tech-action-content h3 {
        margin-bottom: 9px;
        font-size: 1rem;
    }

    .tech-action-content p {
        font-size: 0.77rem;
        line-height: 1.52;
    }

    .tech-video-label {
        top: 10px;
        left: 10px;
        padding: 5px 7px;
        font-size: 0.55rem;
    }

    .tech-video-play {
        width: 44px;
        height: 44px;
    }

    .tech-action-closing {
        margin-top: 22px;
        padding: 22px;
    }

    .tech-action-link {
        width: 100%;
        justify-content: space-between;
        white-space: normal;
    }
}

/* ===== Risks and Problems: mobile ===== */
@media (max-width: 600px) {
    .risks {
        padding: 68px 0;
        background-size: 44px 44px, 44px 44px, auto, auto;
    }

    .risks-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .risks-intro {
        padding: 0;
        border-left: 0;
        font-size: 0.95rem;
    }

    .risks-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .risk-card {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        column-gap: 16px;
        align-items: start;
        min-height: auto;
        padding: 20px;
    }

    .risk-card-top {
        grid-column: 1;
        grid-row: 1 / span 2;
        margin-bottom: 0;
    }

    .risk-icon {
        width: 42px;
        height: 42px;
    }

    .risk-index {
        display: none;
    }

    .risk-card h3 {
        grid-column: 2;
        margin: 1px 0 8px;
        font-size: 1.08rem;
    }

    .risk-card p {
        grid-column: 2;
        font-size: 0.86rem;
    }

    .risks-transition {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 22px;
        padding: 22px;
    }

    .risks-transition-mark {
        width: 42px;
        height: 42px;
    }

    .risks-link {
        grid-column: auto;
        width: 100%;
        justify-content: space-between;
        white-space: normal;
    }
}

/* ===== Integrated Solutions: mobile ===== */
@media (max-width: 600px) {
    .integrated-solutions {
        padding: 68px 0;
    }

    .integrated-solutions-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .integrated-solutions-intro {
        padding: 0;
        border-left: 0;
        font-size: 0.95rem;
    }

    .solution-groups {
        gap: 14px;
    }

    .solution-group {
        gap: 14px;
        padding: 18px;
    }

    .solution-group-heading {
        align-items: flex-start;
        padding: 2px 0 8px;
    }

    .solution-group-grid {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .integrated-solution-card,
    .integrated-solution-card:last-child:nth-child(3) {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        column-gap: 14px;
        min-height: auto;
        padding: 19px;
        grid-column: auto;
    }

    .integrated-solution-icon {
        grid-column: 1;
        grid-row: 1 / span 3;
        width: 42px;
        height: 42px;
        margin-bottom: 0;
    }

    .integrated-solution-card h4,
    .integrated-solution-card p,
    .solution-application {
        grid-column: 2;
    }

    .integrated-solution-card h4 {
        margin: 1px 0 7px;
        font-size: 1rem;
    }

    .integrated-solution-card p {
        margin-bottom: 11px;
        font-size: 0.82rem;
    }

    .solution-application {
        padding-top: 10px;
        font-size: 0.69rem;
    }

    .integrated-solutions-closing {
        margin-top: 22px;
        padding: 22px;
    }

    .integrated-solutions-closing .btn {
        width: 100%;
    }
}

/* ===== How We Work: mobile ===== */
@media (max-width: 600px) {
    .work-process {
        padding: 68px 0;
    }

    .work-process-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .work-process-intro {
        padding: 0;
        border-left: 0;
        font-size: 0.95rem;
    }

    .work-process-steps {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .work-process-step {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        column-gap: 16px;
        min-height: auto;
        padding: 20px;
    }

    .work-process-marker {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 0;
    }

    .work-process-marker span {
        width: 42px;
        height: 42px;
        box-shadow: none;
    }

    .work-process-marker i {
        display: none;
    }

    .work-process-content {
        grid-column: 2;
    }

    .work-process-kicker {
        margin-bottom: 6px;
        font-size: 0.62rem;
    }

    .work-process-content h3 {
        margin-bottom: 8px;
        font-size: 1.08rem;
    }

    .work-process-content p {
        font-size: 0.85rem;
    }

    .work-process-closing {
        margin-top: 22px;
        padding: 22px;
    }

    .work-process-link {
        width: 100%;
        justify-content: space-between;
        white-space: normal;
    }
}

/* ===== Projects and Cases: mobile ===== */
@media (max-width: 600px) {
    .project-cases {
        padding: 68px 0;
    }

    .project-cases-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .project-cases-intro {
        padding: 0;
        border-left: 0;
        font-size: 0.95rem;
    }

    .project-cases-grid {
        gap: 12px;
    }

    .case-media {
        height: 240px;
    }

    .case-content {
        padding: 22px;
    }

    .case-meta {
        gap: 10px;
        margin-bottom: 18px;
    }

    .case-environment {
        font-size: 1rem;
    }

    .case-details {
        gap: 12px;
    }

    .case-details > div {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 13px;
    }

    .case-details .case-result {
        padding: 14px;
    }

    .project-cases-note {
        margin-top: 22px;
        padding: 22px;
    }

    .project-cases-link {
        width: 100%;
        justify-content: space-between;
        white-space: normal;
    }
}

/* ===== Security Applications Map: mobile ===== */
@media (max-width: 980px) {
    .security-map-shell {
        grid-template-columns: 1fr;
    }

    .security-map-stage {
        border-right: 0;
        border-bottom: 1px solid rgba(125, 166, 220, 0.14);
    }

    .security-map-details {
        display: grid;
        grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
    }

    .security-map-placeholder {
        height: 320px;
        min-height: 320px;
        border-right: 1px solid rgba(125, 166, 220, 0.14);
        border-bottom: 0;
    }
}

@media (max-width: 640px) {
    .map-section {
        padding: 68px 0;
    }

    .map-section-header {
        margin-bottom: 30px;
        text-align: left;
    }

    .map-section-header .section-title {
        font-size: clamp(2rem, 9.5vw, 2.55rem);
    }

    .map-section-header .section-description {
        margin-left: 0;
        font-size: 0.95rem;
    }

    .security-map-shell {
        min-height: 0;
        border-radius: 18px;
    }

    .security-map-toolbar {
        min-height: 72px;
        padding: 15px 16px;
    }

    .security-map-toolbar-hint {
        max-width: 90px;
        text-align: right;
    }

    .security-map-canvas {
        min-height: 390px;
    }

    .security-map-point {
        width: 54px;
        height: 54px;
    }

    .security-map-axis {
        display: none;
    }

    .security-map-legend {
        flex-wrap: wrap;
        gap: 10px 18px;
        padding: 15px 16px;
    }

    .security-map-legend .security-map-legend-note {
        width: 100%;
        margin-left: 0;
    }

    .security-map-details {
        display: flex;
    }

    .security-map-placeholder {
        flex-basis: 220px;
        height: 220px;
        min-height: 220px;
        border-right: 0;
        border-bottom: 1px solid rgba(125, 166, 220, 0.14);
    }

    .security-map-details-body {
        padding: 24px 20px;
    }

    .security-map-details-list {
        margin: 22px 0 24px;
    }

    .security-map-cta {
        white-space: normal;
    }
}

@media (max-width: 380px) {
    .security-map-toolbar-hint i {
        display: none;
    }

    .security-map-canvas {
        min-height: 350px;
    }

    .security-map-point {
        width: 50px;
        height: 50px;
    }
}
