/* ==========================================================
   CH NET GUARD — Mobile / Touch (Phase 3)
   ----------------------------------------------------------
   Loaded after legal.css. Houses:
     - The hamburger button (.nav-burger)
     - The full-screen overlay menu (.mobile-menu)
     - Touch tilt / tap-feedback overrides for service cards
     - Mobile-tuned reveal timings (shorter, snappier)
   ========================================================== */

/* ----------------------------------------------------------
   HAMBURGER BUTTON
   Visible on mobile, hidden above 1024px (where .nav-links shows)
   ---------------------------------------------------------- */
.nav-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;             /* 44px tap target — Apple HIG / WCAG */
    margin-left: 6px;
    padding: 0;
    background: rgba(8, 10, 18, 0.55);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--d-base) var(--ease-out),
                border-color var(--d-base) var(--ease-out),
                transform var(--d-base) var(--ease-out);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    flex-shrink: 0;
}
.nav-burger:hover,
.nav-burger:focus-visible {
    background: rgba(15, 181, 164, 0.10);
    border-color: var(--accent-teal);
    outline: none;
}
.nav-burger-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transform-origin: center;
    transition: transform 300ms var(--ease-out),
                opacity   200ms var(--ease-out);
}
/* Hamburger → X morph when the menu is open */
.nav-burger.is-active .nav-burger-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-burger.is-active .nav-burger-bar:nth-child(2) {
    opacity: 0;
}
.nav-burger.is-active .nav-burger-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Show hamburger only on narrow viewports */
@media (min-width: 1024px) {
    .nav-burger { display: none; }
}

/* Hide the desktop quote button when the hamburger is showing — saves space.
   The mobile menu has its own larger CTA inside. */
@media (max-width: 1023px) {
    .nav-quote-btn { display: none; }
}
/* On very small phones, also drop the office-flags strip — already done at
   <768 by the existing CSS, but make the burger more prominent. */
@media (max-width: 480px) {
    .nav-right { gap: 8px; }
}

/* ----------------------------------------------------------
   MOBILE FULL-SCREEN OVERLAY MENU
   ---------------------------------------------------------- */
.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 9500;          /* above nav (which has its own z), below toast/banner */
    display: flex;
    flex-direction: column;
    padding: 32px 28px 36px;
    background: rgba(3, 4, 10, 0.985);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 350ms var(--ease-out);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
}
.mobile-menu.is-open {
    opacity: 1;
    pointer-events: auto;
}
.mobile-menu[hidden] { display: none !important; }

/* Lock body scroll while open — JS handles the scroll-position save/restore */
html.mobile-menu-open,
html.mobile-menu-open body {
    overflow: hidden;
}
html.mobile-menu-open body {
    position: fixed;
    width: 100%;
}

/* Animated background layers */
.mobile-menu-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.mobile-menu-glow {
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.4;
    animation: mm-glow-drift 18s ease-in-out infinite alternate;
}
.mobile-menu-glow--teal {
    background: radial-gradient(circle, rgba(15, 181, 164, 0.45), transparent 60%);
    top: -120px;
    right: -120px;
}
.mobile-menu-glow--gold {
    background: radial-gradient(circle, rgba(201, 162, 39, 0.32), transparent 60%);
    bottom: -120px;
    left: -160px;
    animation-direction: alternate-reverse;
    animation-duration: 22s;
}
@keyframes mm-glow-drift {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(40px, 30px); }
    100% { transform: translate(-20px, 60px); }
}

.mobile-menu-grid {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg,  rgba(255,255,255,0.015) 0 1px, transparent 1px 60px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 60px);
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 90%);
}

/* All overlay content sits above the bg layer */
.mobile-menu > *:not(.mobile-menu-bg) {
    position: relative;
    z-index: 1;
}

/* Close (X) button — top right */
.mobile-menu-close {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(8, 10, 18, 0.65);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    z-index: 2;
    transition: background var(--d-base) var(--ease-out),
                border-color var(--d-base) var(--ease-out),
                transform var(--d-base) var(--ease-out);
    padding: 0;
}
.mobile-menu-close:hover,
.mobile-menu-close:focus-visible {
    background: rgba(15, 181, 164, 0.12);
    border-color: var(--accent-teal);
    transform: rotate(90deg);
    outline: none;
}
.mobile-menu-close-bar {
    position: absolute;
    top: 50%; left: 50%;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transform-origin: center;
}
.mobile-menu-close-bar:nth-child(1) { transform: translate(-50%, -50%) rotate(45deg); }
.mobile-menu-close-bar:nth-child(2) { transform: translate(-50%, -50%) rotate(-45deg); }

/* Brand strip inside the overlay */
.mobile-menu-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    margin-top: 6px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 18px;
}
.mobile-menu-brand-text { letter-spacing: 0.02em; color: var(--text-primary); }

/* Eyebrow */
.mobile-menu-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    margin: 0 0 24px;
}
.mobile-menu-eyebrow .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent-teal);
    box-shadow: 0 0 10px var(--accent-teal);
}

/* The big stacked links */
.mobile-menu-links {
    list-style: none;
    margin: 0 0 32px;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.mobile-menu-links li {
    border-bottom: 1px solid var(--border-soft);
}
.mobile-menu-links li:first-child { border-top: 1px solid var(--border-soft); }

.mobile-menu-links a {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 22px 4px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.6rem, 7vw, 2.4rem);
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--d-base) var(--ease-out),
                padding-left var(--d-base) var(--ease-out);
}
.mobile-menu-links a:hover,
.mobile-menu-links a:focus-visible {
    color: var(--accent-teal-2);
    padding-left: 12px;
    outline: none;
}
.mobile-menu-link-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    letter-spacing: 0.1em;
    align-self: center;
    width: 24px;
}
.mobile-menu-link-text {
    flex: 1;
    line-height: 1;
}
.mobile-menu-link-arrow {
    align-self: center;
    font-size: 14px;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity var(--d-base) var(--ease-out),
                transform var(--d-base) var(--ease-out),
                color    var(--d-base) var(--ease-out);
}
.mobile-menu-links a:hover .mobile-menu-link-arrow,
.mobile-menu-links a:focus-visible .mobile-menu-link-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent-teal-2);
}

/* CTA inside the overlay — full-width primary button */
.mobile-menu-cta { margin-bottom: auto; }
.mobile-menu-quote {
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 16px 20px;
}

/* Footer block at the bottom */
.mobile-menu-footer {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
    text-align: center;
}
.mobile-menu-flags {
    display: inline-flex;
    gap: 12px;
    font-size: 22px;
    margin-bottom: 10px;
    filter: grayscale(15%);
    opacity: 0.95;
}
.mobile-menu-tagline {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 16px;
}
.mobile-menu-legal {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.mobile-menu-legal a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--d-base) var(--ease-out);
}
.mobile-menu-legal a:hover { color: var(--accent-teal-2); }

/* iOS safe-area insets so the overlay clears the notch / home indicator */
@supports (padding: env(safe-area-inset-top)) {
    .mobile-menu {
        padding-top:    calc(32px + env(safe-area-inset-top));
        padding-bottom: calc(36px + env(safe-area-inset-bottom));
    }
    .mobile-menu-close {
        top: calc(22px + env(safe-area-inset-top));
    }
}

/* ----------------------------------------------------------
   SERVICE CARDS — TOUCH MODE OVERRIDES
   The card itself is now transformed by JS (scroll-driven tilt),
   so we restore the underlying transition that would otherwise
   fight it, and add tap-press feedback on the inner element.
   ---------------------------------------------------------- */
html.is-touch .service-card {
    /* JS sets transform inline; keep transitions only for non-transform props */
    transition: box-shadow 250ms var(--ease-out),
                border-color 250ms var(--ease-out);
    will-change: transform;
}
html.is-touch .service-card .card-inner {
    transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
html.is-touch .service-card .card-inner.is-pressed {
    transform: scale(0.97);
}

/* On reduced-motion, drop all scroll-tilt so JS effectively no-ops */
html.is-touch.is-reduced-motion .service-card { transform: none !important; }

/* ----------------------------------------------------------
   MOBILE-TUNED SCROLL REVEALS
   Shorter durations and smaller travel feel snappier on small
   screens where the user is scrolling fast with a thumb.
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    [data-reveal] {
        transform: translateY(20px);             /* was 36px */
        transition: opacity 600ms var(--ease-out),
                    transform 600ms var(--ease-out);
        transition-delay: var(--reveal-delay, 0ms);
    }
    [data-reveal].is-visible {
        transform: translateY(0);
    }
}

/* Slightly less generous stagger on mobile — main.js sets the delay,
   but we cap the effective max via CSS clamp on transition-delay.
   This stops the last item in a long list from feeling laggy. */
@media (max-width: 768px) {
    [data-section-reveal] [data-reveal] {
        /* No-op for inline styles set by JS; the global 600ms duration
           keeps things tight regardless of the per-element delay. */
    }
}

/* ----------------------------------------------------------
   REDUCED MOTION
   The mobile menu must still appear and dismiss — just instantly.
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu { transition: opacity 1ms; }
    .mobile-menu-glow { animation: none; }
    .nav-burger-bar { transition: none; }
    .mobile-menu-close { transition: background 1ms, border-color 1ms; }
}

/* ==========================================================
   LANGUAGE SWITCHER (Phase 5)
   3 small flag-buttons in the nav: IT / SE / GB.
   Active state highlighted with the brand teal.
   ========================================================== */
.lang-switcher {
    display: none;                    /* hidden on very small screens */
    align-items: center;
    gap: 4px;
    padding: 2px;
    background: rgba(8, 10, 18, 0.55);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
@media (min-width: 640px) {
    .lang-switcher { display: inline-flex; }
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    transition: background var(--d-base) var(--ease-out),
                color var(--d-base) var(--ease-out),
                transform var(--d-base) var(--ease-out);
    line-height: 1;
}
.lang-btn:hover,
.lang-btn:focus-visible {
    color: var(--text-primary);
    background: rgba(15, 181, 164, 0.10);
    outline: none;
}
.lang-btn.is-active {
    color: var(--accent-teal-2);
    background: rgba(15, 181, 164, 0.18);
    border: 1px solid rgba(15, 181, 164, 0.35);
    padding: 4px 9px;          /* compensate for border */
}
.lang-flag {
    font-size: 14px;
    line-height: 1;
    filter: grayscale(8%);
}
.lang-code {
    font-weight: 600;
}

/* On really narrow phones the switcher squishes the burger — show flags only */
@media (max-width: 380px) {
    .lang-code { display: none; }
    .lang-btn { padding: 6px; }
    .lang-btn.is-active { padding: 5px; }
}
