/* --- GLOBAL VARIABLES --- */
:root {
    /* === DARK MODE === */
    --bg-color: #0c1b33;
    --text-primary: #FFFFFF;
    --text-secondary: #B8B8B8;
    --accent-color: #4A9EFF;
    --border-color: #2A3F5F;

    /* Pattern Color - near-invisible paper texture */
    --pattern-color: rgba(0, 31, 63, 0.05);

    /* Dimensions */
    --container-width: 1000px;
    --header-height: 70px;
    --font-ui: 'Inter', sans-serif;
    --font-data: 'JetBrains Mono', monospace;
}

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.1s ease, color 0.1s ease;
}

/* --- BACKGROUND LAYER --- */
.bg-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: -1;
}

.bg-pattern {
    z-index: -2;
}

/* --- LAYOUT UTILITIES --- */
main {
    flex: 1;
    padding-top: calc(var(--header-height) + 2rem);
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

/* --- HEADER --- */
nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-height);
    /* Stripe-like Glass Effect */
    background: rgba(12, 27, 51, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(74, 158, 255, 0.1);
    transition: all 0.3s ease;
}

.nav-inner {
    height: 100%;
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1200px; margin: 0 auto; padding: 0 2rem;
}

.logo {
    display: flex; align-items: center; gap: 0.75rem;
    text-decoration: none;
}

.logo span {
    color: #FFFFFF;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.nav-links { display: flex; align-items: center; gap: 0.5rem; }
.nav-links a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    transition: all 0.2s ease;
}
.nav-links a:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}
.nav-links a.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary) !important;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.15s;
    border: 1px solid rgba(74, 158, 255, 0.3);
}
.nav-btn:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

@media (max-width: 768px) {
    .nav-links { display: none; }
}

/* --- TYPOGRAPHY --- */
h1 { font-size: 3rem; line-height: 1.1; margin-bottom: 1.5rem; letter-spacing: -0.03em; color: var(--accent-color); scroll-margin-top: 80px; }
h2 { font-size: 2rem; margin-bottom: 1rem; margin-top: 0; letter-spacing: -0.02em; color: var(--accent-color); scroll-margin-top: 80px; }
h3 { font-size: 1.5rem; margin-bottom: 0.75rem; letter-spacing: -0.01em; color: var(--accent-color); scroll-margin-top: 80px; }
h4 { scroll-margin-top: 80px; }
section { scroll-margin-top: 80px; }
p { margin-bottom: 1.5rem; color: var(--text-secondary); }
.mono { font-family: var(--font-data); }

/* --- BUTTONS --- */
.btn-primary {
    display: inline-block;
    background: var(--accent-color);
    color: #FFFFFF;
    padding: 0.875rem 2rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: #003366;
}

.btn-secondary {
    display: inline-block;
    background: transparent;
    color: var(--accent-color);
    padding: 0.875rem 2rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border: 2px solid var(--accent-color);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--accent-color);
    color: #FFFFFF;
}

.btn-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.1s;
    margin-top: auto;
}

.btn-link:hover {
    color: #003366;
}

/* --- SIDEBAR NAVIGATION (SHARED) --- */
.sidebar-layout-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 0.5rem;
    position: relative;
}

.page-nav {
    position: sticky;
    top: 100px;
    padding-top: 5rem;
}

.page-nav-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(74, 158, 255, 0.15);
    border-radius: 8px;
    padding: 1rem 0.75rem;
}

.page-nav-list {
    list-style: none;
    position: relative;
    padding-left: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.page-nav-item { margin-bottom: 0; }

.page-nav-link {
    display: block;
    padding: 0.35rem 0 0.35rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
    line-height: 1.4;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.page-nav-link:hover {
    color: #FFFFFF;
    padding-left: 1.75rem;
}

.page-nav-link.active {
    color: var(--accent-color);
    font-weight: 600;
    border-left-color: var(--accent-color);
    background: linear-gradient(90deg, rgba(74, 158, 255, 0.1) 0%, transparent 100%);
}

@media (max-width: 1200px) {
    .page-nav { display: none; }
    .sidebar-layout-grid { grid-template-columns: 1fr; padding: 0 2rem; }
}

/* --- INTERACTIVE CARD EFFECTS --- */
/* Stripe-inspired lift and shadow on hover for interactive cards */
.industry-card,
.resource-card {
    position: relative;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s cubic-bezier(0.165, 0.84, 0.44, 1),
                box-shadow 0.2s ease,
                border-color 0.2s ease,
                background 0.2s ease;
}

.industry-card:hover,
.resource-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

/* Animate arrows/links inside cards */
.industry-card .btn-link,
.resource-card .btn-download {
    transition: transform 0.2s ease;
}

.industry-card:hover .btn-link,
.resource-card:hover .btn-download {
    transform: translateX(5px);
}

/* --- FOOTER --- */
footer {
    margin-top: auto;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.footer-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 2rem;
}

.footer-offices {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.footer-office strong {
    color: var(--text-primary);
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.footer-legal {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.6;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.footer-legal p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.footer-links a {
    color: var(--text-secondary); text-decoration: none; margin-left: 2rem;
    transition: color 0.1s;
}
.footer-links a:hover { color: var(--accent-color); }

@media (max-width: 1024px) {
    .footer-offices {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .footer-offices {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .footer-offices {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */

/* Hamburger Button (hidden on desktop) */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    z-index: 1001;
    position: relative;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

/* Hamburger Icon */
.hamburger-icon {
    width: 24px;
    height: 2px;
    background-color: #FFFFFF;
    position: relative;
    display: block;
    transition: background-color 0.3s ease;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 24px;
    height: 2px;
    background-color: #FFFFFF;
    transition: all 0.3s ease;
}

.hamburger-icon::before { top: -8px; }
.hamburger-icon::after { top: 8px; }

/* Active State (X animation) */
.mobile-menu-toggle.active .hamburger-icon {
    background-color: transparent;
}

.mobile-menu-toggle.active .hamburger-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

/* Mobile Overlay (hidden on desktop) */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: rgba(12, 27, 51, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Nav Links */
.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.mobile-nav-link {
    font-size: 1.5rem;
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 600;
    padding: 1rem 2rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
    background: rgba(74, 158, 255, 0.1);
    color: var(--accent-color);
}

.mobile-nav-link:active {
    transform: scale(0.98);
}

/* ============================================
   MOBILE RESPONSIVENESS - PHASE 1
   ============================================ */

/* Tablet Breakpoint */
@media (max-width: 992px) {
    .container {
        padding: 0 1.5rem;
        max-width: 100%;
    }
}

/* Mobile Breakpoint */
@media (max-width: 768px) {
    /* Show mobile menu, hide desktop nav */
    .nav-links {
        display: none !important; /* Override page-specific styles */
    }

    .mobile-menu-toggle {
        display: flex;
    }

    /* Reduce backdrop blur for performance */
    nav,
    .mobile-nav-overlay {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    /* Container & Spacing */
    section {
        padding: 2.5rem 0;
    }

    main {
        padding-top: calc(var(--header-height) + 1rem);
    }

    /* Typography Scaling */
    h1 {
        font-size: 2rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    body {
        font-size: 0.9375rem;
    }

    /* Parallax Disable (Index Page) */
    .parallax-bg {
        position: static !important;
        height: auto !important;
        background-attachment: scroll !important;
        transform: none !important;
        max-width: 100% !important;
    }

    .parallax-section {
        min-height: auto !important;
        padding: 3rem 0;
    }

    /* Index Page Footer Fix */
    body main {
        margin-bottom: 0;
    }

    body footer {
        position: static !important;
    }
}

/* Small Mobile Breakpoint */
@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    section {
        padding: 2rem 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.35rem;
    }
}

/* ============================================
   TOUCH DEVICE INTERACTIONS
   ============================================ */

/* Disable hover effects on touch-only devices */
@media (hover: none) {
    .industry-card:hover,
    .resource-card:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    .industry-card:active,
    .resource-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

@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;
    }

    .parallax-bg {
        background-attachment: scroll !important;
    }
}

/* ============================================
   MOBILE RESPONSIVENESS - PHASE 2
   ============================================ */

/* PRIORITY 1: Critical Fixes */
@media (max-width: 768px) {
    /* iOS Form Zoom Prevention (Contact Page) */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea,
    .form-input,
    .form-textarea {
        font-size: 16px !important; /* Must be 16px minimum to prevent iOS zoom */
    }

    /* Contact Form Layout */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .btn-submit,
    .btn-primary {
        width: 100%;
        text-align: center;
    }

    /* Table Horizontal Scroll (Solutions & Index Pages) */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .comparison-table,
    .specs-table {
        min-width: 600px; /* Force scroll on narrow screens */
    }

    /* Add scroll indicator */
    .table-wrapper::after {
        content: '← Scroll for more →';
        display: block;
        text-align: center;
        font-size: 0.8125rem;
        color: var(--text-secondary);
        margin-top: 0.5rem;
        font-style: italic;
    }

    /* ÜberCAP/ÜberTime Cards - Show description by default on mobile */
    .uber-product-card .uber-product-overlay {
        opacity: 0; /* Hide title-only view on mobile */
    }

    .uber-product-card .uber-product-hover {
        opacity: 1; /* Always show full description on mobile */
        position: absolute; /* Keep absolute positioning */
        width: 100%;
        height: 100%;
        padding: 1.5rem; /* Increase padding for better mobile readability */
    }

    /* Stack ÜberCAP/ÜberTime side-by-side into vertical */
    .uber-products-row,
    section > div[style*="grid-template-columns: 1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    .uber-product-card {
        max-width: 100%;
        height: 300px;
    }
}

/* PRIORITY 2: Layout Stacking */
@media (max-width: 768px) {
    /* Index: Hero & Product Showcase */
    .product-showcase {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }

    .product-showcase.reverse {
        direction: ltr;
    }

    .product-image {
        order: -1; /* Image on top */
    }

    .product-text h2,
    .product-text h3 {
        text-align: center;
    }

    /* Solutions: Solution Blocks - Force vertical stack */
    .solution-block,
    .solution-block:nth-child(even) {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    .solution-block:nth-child(even) .solution-content {
        order: 1 !important;
    }

    .solution-block:nth-child(even) .solution-visual {
        order: 2 !important;
    }

    .solution-visual {
        min-height: 200px;
        padding: 1.5rem;
    }

    /* Stack stats rows vertically */
    .stat-row,
    .stats-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    /* Technology & Company: Architecture/Content Grids */
    .arch-container,
    .timing-layout {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    /* Reduce padding on diagram containers for mobile */
    .timing-box {
        padding: 0 !important;
    }

    /* Remove section padding on mobile to maximize space for diagrams */
    #sdci,
    #architecture,
    #precision-time {
        padding: 3rem 0 !important;
    }

    /* Ensure images fill container better */
    .timing-box img,
    .arch-container img,
    .arch-container svg {
        max-width: 100%;
        height: auto;
        display: block;
    }

    /* Reduce gap between stacked elements */
    .arch-container {
        gap: 1rem !important;
    }

    /* Company: Leadership Grid */
    .team-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .team-card {
        max-width: 400px;
        margin: 0 auto;
    }

    /* Resources: Resource Grid */
    .resource-grid {
        grid-template-columns: 1fr;
    }

    /* Feature Grid (Solutions Page) */
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

/* PRIORITY 3: Sidebar Navigation Conversion */
@media (max-width: 992px) {
    /* Convert vertical sidebar to horizontal sticky tabs */
    .sidebar-layout-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .page-nav-container {
        position: sticky;
        top: var(--header-height);
        background: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        border-radius: 0;
        margin: 0 -1.5rem;
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 10;
    }

    .page-nav {
        position: static;
        padding-top: 0;
    }

    .page-nav-list {
        display: flex;
        flex-direction: row;
        border-left: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-left: 0;
        white-space: nowrap;
        padding: 0 1.5rem;
    }

    .page-nav-item {
        flex: 0 0 auto;
    }

    .page-nav-link {
        padding: 1rem 1.5rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        background: none;
        margin-left: 0;
    }

    .page-nav-link:hover {
        padding-left: 1.5rem; /* No slide animation */
        background: rgba(255, 255, 255, 0.04);
    }

    .page-nav-link.active {
        border-bottom-color: var(--accent-color);
        border-left-color: transparent;
        background: none;
    }

    .content-column {
        width: 100%;
    }
}

/* PRIORITY 4: Chart Switcher & Benchmark Viewer */
@media (max-width: 768px) {
    .benchmark-viewer {
        grid-template-columns: 1fr;
    }

    .chart-nav {
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 1rem;
    }

    .chart-nav-item {
        flex: 0 0 auto;
        width: auto;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* Tablet-specific adjustments */
@media (max-width: 1024px) {
    .team-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small mobile refinements */
@media (max-width: 480px) {
    .btn-primary,
    .btn-secondary {
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

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

    .metric-value {
        font-size: 2.5rem;
    }
}
