/* ===================================
   Useful Software Limited - Stylesheet
   Modern, performant CSS inspired by Mapbox
   =================================== */

/* === CSS Custom Properties === */
:root {
    /* Colors - Darker Green Palette (25% darker) */
    --color-primary: #5fa869;
    --color-primary-dark: #3d9a53;
    --color-secondary: #2d9a47;
    --color-accent: #1e8b3c;
    --color-text: #0d0d0d;
    --color-text-light: #2d3b3e;
    --color-text-lighter: #4a5b61;
    --color-bg: #f5f5f5;
    --color-bg-alt: #b8f5c5;
    --color-border: #7ecb95;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;

    /* Typography */
    --font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;
    --font-size-5xl: 3rem;

    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent text size adjustment on iOS orientation change */
    -webkit-text-size-adjust: 100%;
    /* Safe area insets for iPhone notch/Dynamic Island */
    padding-top: env(safe-area-inset-top);
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    /* iOS touch optimization */
    -webkit-tap-highlight-color: rgba(95, 168, 105, 0.2);
    -webkit-touch-callout: none;
    /* Prevent menu overflow scrolling */
}

body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* === Container === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* === Navigation === */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: all var(--transition-base);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.nav-logo {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.nav-link {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text);
    transition: color var(--transition-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: width var(--transition-base);
}

.nav-link:hover {
    color: var(--color-primary);
}

.nav-link:hover::after {
    width: 100%;
}

.nav-cta {
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-cta::after {
    display: none;
}

.nav-cta:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* === Hamburger Menu === */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    /* Ensure minimum touch target size */
    min-width: 44px;
    min-height: 44px;
    align-items: center;
}

.hamburger span {
    width: 28px;
    height: 3px;
    background: var(--color-text);
    border-radius: 3px;
    transition: all var(--transition-base);
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* === Hero Section === */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-container {
    position: relative;
    z-index: 1;
    max-width: 900px;
}

.hero-title {
    font-size: var(--font-size-5xl);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    animation: fadeInUp 0.8s var(--transition-base);
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    font-weight: 400;
    line-height: 1.5;
    margin-bottom: var(--spacing-lg);
    opacity: 0.95;
    animation: fadeInUp 0.8s var(--transition-base) 0.2s both;
}

.hero-cta {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeInUp 0.8s var(--transition-base) 0.4s both;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    font-size: var(--font-size-base);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 2px solid transparent;
    will-change: transform;
    /* Ensure minimum touch target size */
    min-height: 44px;
}

.btn-primary {
    background: white;
    color: #1e6b2f;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent;
    color: white;
    border-color: white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: var(--font-size-lg);
}

/* === Features Section === */
.features {
    padding: var(--spacing-xl) 0;
    background: var(--color-bg);
}

.section-title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.section-subtitle {
    font-size: var(--font-size-lg);
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: var(--spacing-lg);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.feature-card {
    padding: var(--spacing-md);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    cursor: default;
    display: block;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-primary);
}

.feature-card-link {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.feature-card-link:hover {
    transform: translateY(-8px) scale(1.02);
}

.feature-card-link:active {
    transform: translateY(-4px) scale(1.01);
}

.feature-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-md);
    color: white;
    transition: transform var(--transition-base);
}

.feature-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.feature-card:hover .feature-icon {
    transform: scale(1.1) rotate(5deg);
}

.feature-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.feature-description {
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text-light);
}

/* === About Section === */
.about {
    padding: var(--spacing-xl) 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    text-align: center;
}

.about .section-title {
    color: white;
}

.about-container {
    max-width: 800px;
}

.about-text {
    font-size: var(--font-size-lg);
    line-height: 1.8;
    color: white;
    opacity: 0.95;
    margin-top: var(--spacing-md);
}

/* === Footer === */
.footer {
    background: var(--color-text);
    color: white;
    padding: var(--spacing-xl) 0 var(--spacing-md);
}

.footer-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    align-items: start;
}

.footer-section {
    opacity: 0.95;
}

.footer-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.footer-text {
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

.footer-heading {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: var(--spacing-md);
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

/* === Animations === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Responsive Design === */

/* Touch device optimization - remove hover effects on touch devices */
@media (hover: none) {
    .feature-card:hover {
        transform: none;
    }

    .nav-link:hover::after {
        width: 0;
    }

    .btn:hover {
        transform: none;
    }

    /* Use active states for touch feedback instead */
    .feature-card:active {
        transform: scale(0.98);
    }
}

/* Tablet landscape and below (768px) */
@media (max-width: 768px) {
    :root {
        --font-size-5xl: 2.25rem;
        --font-size-4xl: 1.875rem;
        --font-size-3xl: 1.5rem;
        --spacing-xl: 3rem;
    }

    .container {
        padding: 0 var(--spacing-sm);
    }

    .hero {
        min-height: 90vh;
        padding: var(--spacing-lg) var(--spacing-sm);
    }

    .hero-title {
        font-size: var(--font-size-4xl);
    }

    .hero-subtitle {
        font-size: var(--font-size-lg);
    }

    .hero-cta {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

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

    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .features {
        padding: var(--spacing-lg) 0;
    }

    .about {
        padding: var(--spacing-lg) 0;
    }

    .about-text {
        font-size: var(--font-size-base);
    }

    .footer {
        padding: var(--spacing-lg) 0 var(--spacing-md);
    }
}

/* Mobile landscape and below (600px) - Hamburger menu activation */
@media (max-width: 600px) {
    .hamburger {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        right: -100%;
        width: 280px;
        height: calc(100vh - 70px);
        background: white;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: var(--spacing-md);
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        transition: right var(--transition-base);
        z-index: 999;
        overflow-y: auto;
        /* Safe area insets for iPhone */
        padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid var(--color-border);
    }

    .nav-link {
        display: block;
        padding: var(--spacing-sm);
        font-size: var(--font-size-lg);
        /* Minimum touch target */
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-link::after {
        display: none;
    }

    .nav-cta {
        margin-top: var(--spacing-sm);
        text-align: center;
        border-radius: var(--radius-md);
    }

    .nav-cta::after {
        display: none;
    }
}

/* Mobile portrait - iPhone 12/13/14 and similar (390px) */
@media (max-width: 480px) {
    :root {
        --font-size-5xl: 2rem;
        --font-size-4xl: 1.75rem;
        --font-size-3xl: 1.375rem;
        --font-size-2xl: 1.25rem;
        --spacing-xl: 2.5rem;
        --spacing-lg: 2rem;
    }

    .nav-container {
        height: 60px;
    }

    .nav {
        /* Account for safe area on iPhone */
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .nav-logo {
        font-size: var(--font-size-lg);
    }

    .nav-menu {
        top: 60px;
        height: calc(100vh - 60px);
        width: 100%;
        right: -100%;
    }

    .hero {
        min-height: calc(100vh - 60px);
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .hero-title {
        font-size: var(--font-size-4xl);
        margin-bottom: var(--spacing-sm);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
        margin-bottom: var(--spacing-md);
    }

    .feature-card {
        padding: var(--spacing-sm);
    }

    .feature-icon {
        width: 56px;
        height: 56px;
    }

    .feature-icon svg {
        width: 40px;
        height: 40px;
    }

    .btn-large {
        padding: 0.875rem 2rem;
        font-size: var(--font-size-base);
    }
}

/* Very small phones - iPhone SE (375px and below) */
@media (max-width: 375px) {
    :root {
        --font-size-5xl: 1.75rem;
        --font-size-4xl: 1.5rem;
        --spacing-md: 1.5rem;
    }

    .container {
        padding: 0 1rem;
    }

    .hero-title {
        font-size: var(--font-size-3xl);
    }

    .section-title {
        font-size: var(--font-size-3xl);
    }

    .feature-title {
        font-size: var(--font-size-lg);
    }

    .feature-description {
        font-size: var(--font-size-sm);
    }
}

/* Landscape orientation optimization for phones */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: var(--spacing-lg) var(--spacing-sm);
    }

    .hero-title {
        font-size: var(--font-size-3xl);
        margin-bottom: var(--spacing-xs);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
        margin-bottom: var(--spacing-sm);
    }

    .hero-cta {
        flex-direction: row;
        gap: var(--spacing-sm);
    }

    .btn {
        width: auto;
        padding: 0.625rem 1.5rem;
        font-size: var(--font-size-sm);
    }
}

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

/* GPU acceleration for animations */
.feature-card,
.btn,
.nav-cta {
    transform: translateZ(0);
    backface-visibility: hidden;
}
