/* ========================================
   Tilth Apps — Design System
   ======================================== */

:root {
    /* Earth palette */
    --soil:        #2C2417;
    --loam:        #3D3226;
    --bark:        #5C4A3A;
    --clay:        #8B7355;
    --sand:        #B8A68E;
    --wheat:       #D4C5AA;
    --parchment:   #EDE6D8;
    --cream:       #F6F1E7;
    --milk:        #FDFAF3;

    /* Accent — muted sage green */
    --sprout:      #6B7F5E;
    --leaf:        #4A5E3C;
    --moss:        #3A4A2F;

    /* Functional */
    --text:        var(--soil);
    --text-mid:    var(--bark);
    --text-light:  var(--clay);
    --bg:          var(--milk);
    --bg-subtle:   var(--cream);
    --border:      var(--wheat);
    --border-light: var(--parchment);

    /* Type scale */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body:    'DM Sans', -apple-system, sans-serif;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.375rem;
    --text-2xl:  1.75rem;
    --text-3xl:  2.5rem;
    --text-4xl:  3.5rem;
    --text-5xl:  4.5rem;

    /* Spacing */
    --space-xs:  0.5rem;
    --space-sm:  0.75rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 5rem;
    --space-4xl: 8rem;

    /* Layout */
    --max-width: 72rem;
    --gutter:    clamp(1.5rem, 5vw, 3rem);

    /* Motion */
    --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration:  0.6s;
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

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

/* Grain overlay */
.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

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

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

strong {
    font-weight: 600;
}

em {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
}

/* ========================================
   Navigation
   ======================================== */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--gutter);
    background: linear-gradient(to bottom, var(--bg) 60%, transparent);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: opacity 0.3s ease;
}

.nav-logo:hover {
    opacity: 0.7;
}

.nav-logo-icon {
    width: 28px;
    height: 28px;
    color: var(--text);
}

.nav-links {
    display: flex;
    gap: var(--space-xl);
}

.nav-links a {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-mid);
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: var(--text);
}

/* ========================================
   Hero
   ======================================== */

.hero {
    position: relative;
    min-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-4xl) var(--gutter) var(--space-3xl);
    max-width: var(--max-width);
    margin: 0 auto;
}

.hero-eyebrow {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sprout);
    margin-bottom: var(--space-lg);
    animation: fadeUp 0.8s var(--ease-out) 0.1s both;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, var(--text-5xl));
    font-weight: 300;
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: var(--text);
    margin-bottom: var(--space-xl);
    animation: fadeUp 0.8s var(--ease-out) 0.2s both;
}

.hero-title em {
    font-weight: 300;
    font-style: italic;
    color: var(--bark);
}

.hero-subtitle {
    max-width: 32rem;
    font-size: var(--text-lg);
    line-height: 1.7;
    color: var(--text-mid);
    animation: fadeUp 0.8s var(--ease-out) 0.35s both;
}

.hero-decoration {
    position: absolute;
    bottom: 0;
    left: var(--gutter);
    right: var(--gutter);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    animation: fadeUp 0.8s var(--ease-out) 0.5s both;
}

.hero-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.hero-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sprout);
}

/* ========================================
   Sections — Shared
   ======================================== */

.section-header {
    margin-bottom: var(--space-2xl);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--duration) var(--ease-out),
                transform var(--duration) var(--ease-out);
}

.section-header.in-view {
    opacity: 1;
    transform: translateY(0);
}

.section-label {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sprout);
    margin-bottom: var(--space-sm);
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, var(--text-3xl));
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text);
}

/* ========================================
   Apps Section
   ======================================== */

.apps {
    padding: var(--space-3xl) var(--gutter) var(--space-4xl);
    max-width: var(--max-width);
    margin: 0 auto;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
    gap: var(--space-lg);
}

.app-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-2xl);
    background: var(--cream);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    transition: transform 0.4s var(--ease-out),
                box-shadow 0.4s var(--ease-out),
                border-color 0.4s ease;
    cursor: default;

    /* Reveal animation */
    opacity: 0;
    transform: translateY(24px);
}

.app-card.in-view {
    opacity: 1;
    transform: translateY(0);
    transition: opacity var(--duration) var(--ease-out),
                transform var(--duration) var(--ease-out),
                box-shadow 0.4s var(--ease-out),
                border-color 0.4s ease;
}

.app-card.in-view:nth-child(2) {
    transition-delay: 0.1s;
}

a.app-card {
    cursor: pointer;
}

a.app-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(44, 36, 23, 0.08);
    border-color: var(--wheat);
}

a.app-card:hover .app-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

.app-card-icon svg {
    width: 56px;
    height: 56px;
    color: var(--bark);
}

.app-card-icon--placeholder svg {
    color: var(--sand);
}

.app-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.app-card-name {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.app-card-tagline {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--sprout);
}

.app-card-description {
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    line-height: 1.7;
    color: var(--text-mid);
}

.app-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-md);
    padding: 6px 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--bark);
    background: var(--parchment);
    border-radius: 100px;
    width: fit-content;
}

.app-card-badge svg {
    width: 12px;
    height: 12px;
    display: inline;
}

.app-card-badge--live {
    color: var(--leaf);
    background: rgba(74, 94, 60, 0.1);
}

.app-card-arrow {
    position: absolute;
    top: var(--space-2xl);
    right: var(--space-2xl);
    color: var(--clay);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.3s ease, transform 0.3s var(--ease-out);
}

.app-card--coming-soon {
    background: transparent;
    border-style: dashed;
    border-color: var(--border);
}

/* ========================================
   About Section
   ======================================== */

.about {
    padding: var(--space-3xl) var(--gutter) var(--space-4xl);
    background: var(--cream);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.about-content {
    max-width: 38rem;
    margin: 0 auto;

    /* Reveal */
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--duration) var(--ease-out),
                transform var(--duration) var(--ease-out);
}

.about-content.in-view {
    opacity: 1;
    transform: translateY(0);
}

.about-content .section-label {
    margin-bottom: var(--space-sm);
}

.about-content .section-title {
    margin-bottom: var(--space-xl);
}

.about-content p {
    color: var(--text-mid);
    line-height: 1.8;
    margin-bottom: var(--space-md);
}

.about-content p:last-child {
    margin-bottom: 0;
}

.about-content strong {
    color: var(--text);
    font-weight: 600;
}

/* ========================================
   Footer
   ======================================== */

.footer {
    padding: var(--space-3xl) var(--gutter) var(--space-2xl);
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-mid);
}

.footer-logo {
    width: 22px;
    height: 22px;
    color: var(--clay);
}

.footer-links {
    display: flex;
    gap: var(--space-xl);
}

.footer-links a {
    font-size: var(--text-sm);
    color: var(--text-light);
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--text);
}

.footer-copy p {
    font-size: var(--text-xs);
    color: var(--sand);
}

/* ========================================
   Legal Pages (shared)
   ======================================== */

.legal-page {
    padding: var(--space-4xl) var(--gutter) var(--space-3xl);
    max-width: 48rem;
    margin: 0 auto;
}

.legal-page .hero-eyebrow {
    margin-bottom: var(--space-sm);
}

.legal-page h1 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, var(--text-3xl));
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: var(--space-xs);
    animation: fadeUp 0.8s var(--ease-out) 0.15s both;
}

.legal-updated {
    font-size: var(--text-sm);
    color: var(--text-light);
    margin-bottom: var(--space-3xl);
    animation: fadeUp 0.8s var(--ease-out) 0.25s both;
}

.legal-body {
    animation: fadeUp 0.8s var(--ease-out) 0.35s both;
}

.legal-body h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    color: var(--text);
}

.legal-body h3 {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 600;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    color: var(--text);
}

.legal-body p {
    color: var(--text-mid);
    line-height: 1.8;
    margin-bottom: var(--space-md);
}

.legal-body ul, .legal-body ol {
    color: var(--text-mid);
    line-height: 1.8;
    margin-bottom: var(--space-md);
    padding-left: var(--space-xl);
}

.legal-body li {
    margin-bottom: var(--space-xs);
}

.legal-body a {
    color: var(--sprout);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-body a:hover {
    color: var(--leaf);
}

.legal-body strong {
    color: var(--text);
    font-weight: 600;
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 640px) {
    .hero {
        min-height: 70vh;
        padding-top: 7rem;
    }

    .nav-links {
        gap: var(--space-lg);
    }

    .app-card {
        padding: var(--space-xl);
    }

    .footer-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-links {
        flex-direction: column;
        gap: var(--space-sm);
    }
}

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

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
