/* Global Reset & Base Styles */
@import 'variables.css';

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: var(--line-height-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    line-height: var(--line-height-heading);
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    /* Common in industrial/surveying themes */
    letter-spacing: 0.5px;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 600;
    border-bottom: 2px solid var(--color-accent);
    display: inline-block;
    padding-bottom: 0.5rem;
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 600;
    text-transform: none;
}

p {
    margin-bottom: var(--spacing-md);
    max-width: 70ch;
}

/* Utilities */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* Premium Gradient Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 2rem;
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--gradient-btn);
    color: white;
    box-shadow: var(--shadow-md);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: transparent;
    border: 2px solid var(--color-accent);
    color: var(--color-accent);
}

.btn-secondary:hover {
    background: var(--gradient-btn);
    color: white;
    border-color: var(--color-accent);
}

.section {
    padding: var(--spacing-xl) 0;
}

.bg-light {
    background-color: var(--color-bg-light);
}

.bg-primary {
    background-color: #2C2C2C;
    border-top: 1px solid var(--color-border);
}

.text-center {
    text-align: center;
}

.text-accent {
    color: var(--color-accent);
    font-weight: 600;
}

/* Header & Nav */
.site-header {
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #1A1A1A;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    padding: 8px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.site-header a,
.site-header .nav-link,
.site-header .nav-links a {
    color: #FFFFFF !important;
}

.site-header .nav-cta {
    color: #1A1A1A !important;
}

/* Override topo-bg for header */
.site-header.topo-bg {
    background-color: #1A1A1A;
    z-index: 1000;
}

.nav-links {
    z-index: 10001;
}

.site-header.topo-bg::before {
    display: none;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo img {
    height: 90px;
    width: auto;
    object-fit: contain;
}

/* Fallback/Legacy if needed, though we are replacing with img */
.logo span {
    display: none;
}

.nav-links {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    height: 100%;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.9rem;
    color: #3A3A3A;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-accent);
}

/* Services Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown > a {
    cursor: pointer;
}

.nav-dropdown > a::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    margin-left: 6px;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

.nav-dropdown:hover > a::after {
    transform: rotate(-135deg);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem 0;
    min-width: 520px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    columns: 2;
    column-gap: 0;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
    color: #ccc;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    break-inside: avoid;
    height: auto;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-accent);
}

.nav-dropdown-menu .dropdown-view-all {
    column-span: all;
    text-align: center;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid #333;
    color: var(--color-accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
}

/* Mobile Menu */
.mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
}

.mobile-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background-color: #3A3A3A;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Hamburger to X animation */
.mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Body scroll lock when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Footer */
.site-footer {
    background-color: #2C2C2C;
    border-top: 5px solid var(--color-accent);
    color: #aaa;
    padding: var(--spacing-2xl) 0 var(--spacing-lg);
}

.footer-credit {
    text-align: center;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid #444;
    font-size: 0.75rem;
    color: #777;
}

.footer-credit a {
    color: var(--color-accent);
    font-weight: 600;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.footer-col h4 {
    color: white;
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #444;
    display: inline-block;
}

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

.footer-links a:hover {
    color: var(--color-accent);
    padding-left: 5px;
}

/* Bold all footer text */
.site-footer,
.site-footer p,
.site-footer li,
.site-footer a,
.footer-links li,
.footer-links a,
.footer-col p {
    font-weight: 700;
}

/* Footer Logo - Full Name Centered */
.site-footer .logo {
    display: block;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1.3;
}

.site-footer .logo span {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: var(--color-accent);
    margin-top: 0.25rem;
}

.site-footer .logo img {
    display: none;
}

/* Footer Social Row - Horizontal Centered */
.footer-social-row {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0 0;
    margin-top: 1.5rem;
    border-top: 1px solid #444;
}

.footer-social-row .social-links {
    display: flex !important;
    flex-direction: row !important;
    gap: 1.25rem;
    justify-content: center;
    align-items: center;
}

.footer-social-row .social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #ccc;
    transition: all 0.3s ease;
}

.footer-social-row .social-links a:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
    transform: translateY(-3px);
    padding-left: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .site-header {
        height: 70px;
        z-index: 10001;
        position: sticky;
        top: 0;
    }

    .logo img {
        height: 50px;
    }

    .nav-links {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        background-color: #000000 !important;
        flex-direction: column;
        padding: 100px 2rem 2rem;
        gap: 0;
        z-index: 10001;
        /* Above toggle? No, toggle is 10002 */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-links.open {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* Mobile dropdown */
    .nav-dropdown {
        position: static;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .nav-dropdown > a {
        font-size: 1.5rem !important;
        padding: 1.25rem 0 !important;
        min-height: 54px !important;
        display: flex !important;
        align-items: center !important;
        border-bottom: 1px solid #333 !important;
        width: 100% !important;
        color: #ffffff !important;
        font-weight: 700 !important;
        opacity: 1 !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
    }

    .nav-dropdown > a::after {
        content: '' !important;
        display: inline-block !important;
        width: 8px !important;
        height: 8px !important;
        border-right: 2px solid var(--color-accent) !important;
        border-bottom: 2px solid var(--color-accent) !important;
        transform: rotate(45deg) !important;
        margin-left: auto !important;
        margin-bottom: 2px !important;
        transition: transform 0.2s ease !important;
    }

    .nav-dropdown.mobile-expanded > a::after {
        transform: rotate(-135deg) !important;
    }

    .nav-dropdown-menu {
        position: static !important;
        transform: none !important;
        display: none !important;
        min-width: 0 !important;
        width: 100% !important;
        columns: unset !important;
        background: rgba(255, 255, 255, 0.03) !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0.25rem 0 0.25rem 1.5rem !important;
        margin: 0 !important;
    }

    .nav-dropdown-menu.mobile-open {
        display: block !important;
    }

    .nav-links .nav-dropdown-menu a {
        font-size: 1rem !important;
        font-weight: 500 !important;
        padding: 0.6rem 0 !important;
        min-height: 0 !important;
        height: auto !important;
        border-bottom: 1px solid #222 !important;
        text-transform: none !important;
        color: #ccc !important;
        text-shadow: none !important;
        display: block !important;
    }

    .nav-links .nav-dropdown-menu a:hover,
    .nav-links .nav-dropdown-menu a:active {
        color: var(--color-accent) !important;
        padding-left: 0 !important;
        background: transparent !important;
    }

    .nav-links .nav-dropdown-menu .dropdown-view-all {
        text-align: left;
        border-top: 1px solid #444 !important;
        border-bottom: none !important;
        padding-top: 0.75rem !important;
        margin-top: 0.25rem;
        color: var(--color-accent) !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        font-size: 0.85rem !important;
    }

    .nav-links a {
        font-size: 1.5rem !important;
        /* Larger text */
        padding: 1.25rem 0;
        min-height: 54px;
        /* Larger touch target */
        display: flex;
        align-items: center;
        border-bottom: 1px solid #333;
        width: 100%;
        color: #ffffff !important;
        /* Force white */
        font-weight: 700 !important;
        opacity: 1 !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
        /* Contrast boost */
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .nav-links a:hover,
    .nav-links a:active {
        color: var(--color-accent) !important;
        padding-left: 10px;
        background: rgba(255, 255, 255, 0.05);
    }

    .nav-links .btn.btn-pill {
        margin-left: 0 !important;
        margin-top: 1.5rem;
        width: 80%;
        max-width: 260px;
        align-self: center;
        justify-content: center;
        font-size: 0.9rem;
        padding: 0.85rem 1.5rem;
        background: var(--gradient-btn) !important;
        color: white !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    }

    .mobile-toggle {
        display: flex;
        z-index: 10002;
        /* Top of stack */
        background: rgba(0, 0, 0, 0.5);
        /* Background for better visibility */
        border-radius: 4px;
        touch-action: manipulation;
        /* Improve touch response */
    }

    /* Thicker hamburger lines for visibility */
    .mobile-toggle span {
        height: 3px;
        width: 30px;
        background-color: white !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    }

    /* Footer mobile adjustments */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }

    .footer-col h4 {
        display: block;
        text-align: center;
    }

    .footer-links {
        text-align: center;
    }

    .footer-links a {
        display: inline-block;
        min-height: 44px;
        line-height: 44px;
        padding: 0 0.5rem;
    }

    /* Section padding reduction */
    .section {
        padding: 3rem 0;
    }

    /* Button touch optimization */
    .btn {
        min-height: 48px;
        padding: 1rem 1.5rem;
    }

    .btn-pill {
        padding: 1rem 2rem;
    }
}

/* Service Card Global Style (for services page) */
.service-card {
    background: white;
    color: black;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    border: 1px solid #eee;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
}

.service-card h3 {
    font-size: 1.25rem;
    color: black;
    margin-bottom: var(--spacing-xs);
    border-bottom: none;
}

.service-card p {
    flex-grow: 1;
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 1.5rem;
}

/* Image responsiveness and mobile-friendly photo handling */
/* Ensure images scale, and use object-fit where a fixed height is desired */
img,
picture,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Cards with fixed-height images (team, service previews) */
.team-card img,
.service-card img,
.service-card-premium img,
.content-card img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    object-position: center center;
    display: block;
    border-radius: 6px 6px 0 0;
}

/* Smaller devices: reduce image heights for better layout and balance */
@media (max-width: 900px) {

    .team-card img,
    .service-card img,
    .service-card-premium img,
    .content-card img {
        height: 240px;
    }
}

@media (max-width: 480px) {

    .team-card img,
    .service-card img,
    .service-card-premium img,
    .content-card img {
        height: 160px;
    }

    /* Make headings and text more compact on very small screens */
    h1 {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }

    h2 {
        font-size: clamp(1.25rem, 5vw, 1.75rem);
    }

    /* Make quick nav and icon circles smaller */
    .icon-circle {
        width: 64px;
        height: 64px;
        font-size: 1.2rem;
    }

    .quick-nav {
        gap: 1rem;
    }

    /* Ensure container paddings stay reasonable */
    .container {
        padding: 0 1rem;
    }
}

/* Utility: responsive-cover to apply object-fit where needed */
.responsive-cover {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Modifier for team photos that need a shorter crop */
.team-card.team-card--short img {
    height: 220px;
    object-position: top center;
}

@media (max-width: 900px) {
    .team-card.team-card--short img {
        height: 160px;
    }
}

@media (max-width: 480px) {
    .team-card.team-card--short img {
        height: 110px;
    }
}

/* ==========================================================
   ENHANCED MOBILE OPTIMIZATIONS
   ========================================================== */

/* Extra small devices (320px) */
@media (max-width: 375px) {
    .container {
        padding: 0 0.75rem;
    }

    h1 {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    .btn {
        font-size: 0.85rem;
        padding: 0.9rem 1.2rem;
    }

    .btn-pill {
        padding: 0.9rem 1.5rem;
        letter-spacing: 1px;
    }

    .nav-links {
        padding: 80px 1.5rem 1.5rem;
    }

    .nav-links a {
        font-size: 1.1rem;
    }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .site-footer {
        padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
    }

    .floating-cta {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .nav-links {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {

    /* Disable hover effects on touch devices */
    .service-card:hover,
    .service-card-premium:hover,
    .service-detail-card:hover {
        transform: none;
    }

    /* Ensure all interactive elements have adequate touch targets */
    a,
    button,
    input,
    select,
    textarea {
        min-height: 44px;
    }

    /* Active state for touch feedback */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .service-card:active,
    .service-card-premium:active {
        transform: scale(0.99);
    }
}

/* Form inputs mobile optimization */
@media (max-width: 768px) {

    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .reveal-stagger>* {
        opacity: 1;
        transform: none;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {

    .hero-premium,
    .hero-parallax,
    .services-hero,
    .contact-hero {
        min-height: 100vh;
        padding: 60px 0 2rem;
    }

    .nav-links {
        padding-top: 70px;
    }

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

/* Print optimization */
@media print {

    .site-header,
    .floating-cta,
    .mobile-toggle {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: black;
        background: white;
    }
}