@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Montserrat:wght@700&display=swap');

:root {
    --forest-deep: #1c3d3d;
    --forest-teal: #008080;
    --forest-light: #f0f4f4;
    --forest-mist: rgba(255, 255, 255, 0.2);
    --accent-gold: #c5a059;
    --text-dark: #1a1a1a;
    --text-white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--forest-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'Montserrat', sans-serif;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--forest-deep) 0%, var(--forest-teal) 30%, var(--forest-light) 60%);
    position: relative;
    padding-bottom: 80px;
}

header {
    padding: 40px 20px 20px;
    color: var(--text-white);
    text-align: center;
}

.logo-container {
    margin-bottom: 20px;
}

.logo-text {
    font-size: 2.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    margin: 0;
}

.tagline {
    font-size: 0.9rem;
    opacity: 0.8;
    font-weight: 300;
}

/* Trail Selector */
.trail-selector {
    display: flex;
    overflow-x: auto;
    padding: 10px 20px;
    gap: 15px;
    scrollbar-width: none;
}

.trail-selector::-webkit-scrollbar {
    display: none;
}

.trail-pill {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--forest-mist);
    color: var(--text-white);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.trail-pill.active {
    background: var(--text-white);
    color: var(--forest-deep);
    font-weight: 600;
}

/* Dashboard Card */
.dashboard {
    padding: 20px;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.score-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 5px solid var(--forest-teal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--forest-deep);
}

.score-info h3 {
    font-size: 1.1rem;
    color: var(--forest-deep);
}

.score-label {
    font-size: 0.8rem;
    color: var(--forest-teal);
    font-weight: 600;
    text-transform: uppercase;
}

.sensor-status {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.sensor-status.live {
    background: rgba(0, 128, 128, 0.12);
    color: var(--forest-teal);
    border: 1px solid rgba(0, 128, 128, 0.25);
}

.sensor-status.baseline {
    background: rgba(100, 100, 100, 0.08);
    color: #666;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Map Focused View */
.map-container-focused {
    height: 50vh;
    width: 100%;
    background: #e0e0e0;
    border-radius: 0 0 32px 32px;
    margin-bottom: -32px; /* Pull the dashboard cards up over the map bottom */
    border: none;
    z-index: 1;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* Google Maps Setup & Fallback Card */
.map-placeholder {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: radial-gradient(circle at center, #274844 0%, #153230 100%);
    color: var(--text-white);
    border-radius: inherit;
    box-sizing: border-box;
}

.map-placeholder-badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.map-placeholder h3 {
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 4px;
}

.map-placeholder-coords {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 14px;
}

.map-placeholder-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 18px;
    border-radius: 16px;
    max-width: 400px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.map-placeholder-card p {
    margin-bottom: 8px;
}

.code-pill {
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.72rem;
    word-break: break-all;
    margin: 6px 0;
    color: #e0f2f1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-security-note {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 8px;
}

.map-infowindow {
    font-family: 'Inter', sans-serif;
    color: var(--forest-deep);
    padding: 2px;
    line-height: 1.35;
}

.map-infowindow strong {
    font-size: 0.95rem;
    display: block;
    margin-bottom: 2px;
}

.dashboard {
    padding: 0 20px 20px;
    position: relative;
    z-index: 2;
}

/* Biotic/Abiotic Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    padding: 12px;
    background: rgba(0,0,0,0.03);
    border-radius: 12px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #666;
    display: block;
}

.stat-value {
    font-weight: 600;
    color: var(--forest-deep);
    font-size: 0.9rem;
}

/* Social Feed */
.social-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.source-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.3px;
}

.source-walkersurvey { background: var(--forest-teal); }
.source-soundscapelog { background: #2e7d32; }
.source-noisealert { background: #d97706; }
.source-fieldsurvey { background: #0f766e; }
.source-researchstation { background: #334155; }
.source-trailnote { background: #0d9488; }
.source-reddit { background: #ff4500; }
.source-alltrails { background: #42b72a; }
.source-nextdoor { background: #00b1a0; }

#social-feed {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 128, 128, 0.3) transparent;
}

#social-feed::-webkit-scrollbar {
    width: 5px;
}

#social-feed::-webkit-scrollbar-thumb {
    background: rgba(0, 128, 128, 0.3);
    border-radius: 4px;
}

.survey-study-header {
    margin-bottom: 12px;
}

.survey-study-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 128, 128, 0.08);
    border: 1px solid rgba(0, 128, 128, 0.2);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--forest-deep);
}

.survey-count-pill {
    background: var(--forest-teal);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
}

.feed-item {
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 10px 0;
    transition: background 0.2s ease;
}

.feed-item.feed-alert {
    border-left: 2px solid #d97706;
    padding-left: 8px;
    margin-bottom: 4px;
}

.feed-item.feed-praise {
    border-left: 2px solid #2e7d32;
    padding-left: 8px;
    margin-bottom: 4px;
}

.feed-item.feed-info {
    border-left: 2px solid var(--forest-teal);
    padding-left: 8px;
    margin-bottom: 4px;
}

.feed-item:last-child { border-bottom: none; }

.feed-text {
    font-size: 0.85rem;
    margin: 5px 0;
    font-style: italic;
    line-height: 1.4;
    color: #2c3e50;
}

.feed-meta {
    font-size: 0.7rem;
    color: #64748b;
}

.ttb-blog-list {
    display: flex;
    flex-direction: column;
}

.ttb-blog-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 12px 0;
}

.ttb-blog-card:last-child { border-bottom: none; }

.ttb-blog-card-media {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
}

.ttb-blog-card-media img { width: 100%; height: 100%; object-fit: cover; }

.ttb-blog-card-date {
    font-size: 0.7rem;
    color: #888;
}

.ttb-blog-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--forest-deep);
    margin: 2px 0 4px;
}

.ttb-blog-card-excerpt {
    font-size: 0.8rem;
    color: #555;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ttb-blog-card-link {
    font-size: 0.75rem;
    color: var(--forest-teal);
    font-style: italic;
}

.ttb-blog-empty { font-size: 0.85rem; color: #888; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.5s ease forwards;
}

/* Desktop/Tablet Split View */
@media (min-width: 800px) {
    .app-container {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    header {
        position: relative;
        z-index: 10;
        background: var(--forest-deep);
        padding: 20px;
    }

    .dashboard-layout {
        display: grid !important;
        grid-template-columns: 1fr 400px !important;
        flex: 1;
        overflow: hidden;
    }

    .map-container-focused {
        height: 100%;
        border-radius: 0;
        margin-bottom: 0;
    }

    .dashboard {
        height: 100%;
        overflow-y: auto;
        background: var(--forest-light);
        padding: 20px;
        box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    }

    .glass-card {
        background: white;
        margin-bottom: 30px;
    }
}

/* Mobile Stack View (Default) */
@media (max-width: 799px) {
    .dashboard-layout {
        display: flex !important;
        flex-direction: column !important;
        overflow-y: auto;
    }
    .map-container-focused {
        height: 40vh !important;
        flex-shrink: 0;
        border-radius: 0;
    }
    .dashboard {
        padding: 20px;
        position: relative;
        z-index: 2;
        margin-top: -20px;
    }
}


/* ---- TTB ECOSYSTEM CONNECTION ---- */
.ttb-eco-header { background: #2d4a3e; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; position: relative; z-index: 20; }
.eco-brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.eco-nav-links, .eco-nav-actions { display: flex; align-items: center; gap: 14px; }
.eco-nav-links a, .eco-login { color: rgba(255,255,255,0.78); text-decoration: none; font-size: 0.88rem; }
.eco-nav-links a:hover, .eco-login:hover { color: #fff; }
.eco-join { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.28); color: #fff; border-radius: 999px; padding: 8px 14px; text-decoration: none; font-size: 0.86rem; font-weight: 700; }
.eco-login { border: 1px solid rgba(255,255,255,0.28); border-radius: 999px; padding: 8px 14px; }
.ttb-ecosystem-footer { background: #f0ede0; color: #333; padding: 22px 20px; border-top: 1px solid #d5d2c5; }
.eco-footer-brand { max-width: 1100px; margin: 0 auto 16px; }
.eco-footer-brand strong { display: block; color: #111; font-size: 0.92rem; }
.eco-footer-brand span { display: block; color: #888; font-size: 0.78rem; margin-top: 2px; }
.eco-sites { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 14px; }
.eco-site { color: #333; text-decoration: none; line-height: 1.25; }
.eco-site strong { display: block; font-size: 0.82rem; }
.eco-site span { display: block; font-size: 0.7rem; color: #888; }
.eco-site.is-active { opacity: 0.48; pointer-events: none; }
@media (max-width: 760px) { .ttb-eco-header { align-items: flex-start; flex-wrap: wrap; } .eco-nav-links { order: 3; width: 100%; flex-wrap: wrap; } .eco-nav-actions { gap: 8px; } .eco-join, .eco-login { padding: 7px 10px; } .eco-sites { grid-template-columns: 1fr 1fr; } }
