{% extends "base.html" %}
{% block footer %}{% endblock %}
{% block extra_head %}
<link rel="stylesheet" href="/static/css/landing.css">
<link rel="stylesheet" href="/static/css/news.css">
{% endblock %}
{% block content %}
<div class="landing">
    <section class="landing-hero">
        <h1>Devplace.net &mdash; The Developer <span>Social Network</span></h1>
        <p>Track industry shifts. Discover bold releases. Share what you're building in an open, uncensored environment.</p>
        <a href="/auth/signup" class="landing-cta"><span class="icon">&#x2728;</span>Join DevPlace Free</a>

        <div class="landing-features">
            <div class="landing-feature">
                <div class="landing-feature-icon">&#x1F511;</div>
                <h3>100% Free Forever</h3>
            </div>
            <div class="landing-feature">
                <div class="landing-feature-icon">&#x1F6AB;</div>
                <h3>Zero Ads</h3>
            </div>
            <div class="landing-feature">
                <div class="landing-feature-icon">&#x1F4AD;</div>
                <h3>No Censorship</h3>
            </div>
            <div class="landing-feature">
                <div class="landing-feature-icon">&#x1F4B3;</div>
                <h3>No Payments</h3>
            </div>
        </div>

        <div class="landing-auth-link">
            Already have an account? <a href="/auth/login">Log In</a>
        </div>
    </section>

    {% if landing_posts %}
    <section class="landing-section">
        <div class="landing-section-header">
            <h2>Latest Posts</h2>
            <a href="/feed" class="landing-section-link">Browse all posts &rarr;</a>
        </div>
        <div class="landing-posts-grid">
            {% for item in landing_posts %}
            <article class="landing-post-card">
                <div class="landing-post-header">
                    {% set _user = item.author %}
                    {% set _size = 28 %}
                    {% set _size_class = "sm" %}
                    {% include "_avatar_link.html" %}
                    <div class="landing-post-author-wrap">
                        <a href="/profile/{{ item.author['username'] }}" class="landing-post-author">{{ item.author['username'] }}</a>
                        <span class="landing-post-time">{{ item.time_ago }}</span>
                    </div>
                    <span class="badge badge-{{ item.post['topic'] }}">{{ item.post['topic'] }}</span>
                </div>
                {% if item.post.get('title') %}
                <h3 class="landing-post-title">
                    <a href="/posts/{{ item.slug }}">{{ item.post['title'] }}</a>
                </h3>
                {% endif %}
                <div class="landing-post-content rendered-content" data-render>{{ item.post['content'][:200] }}{% if item.post['content']|length > 200 %}...{% endif %}</div>
                <div class="landing-post-footer">
                    <span class="landing-post-stat">+{{ item.stars }}</span>
                    <span class="landing-post-stat">&#x1F4AC; {{ item.comment_count }}</span>
                    <a href="/posts/{{ item.slug }}" class="landing-post-open">Open &rarr;</a>
                </div>
            </article>
            {% endfor %}
        </div>
    </section>
    {% endif %}

    {% if landing_articles %}
    <section class="landing-section">
        <div class="landing-section-header">
            <h2>Developer News</h2>
            <a href="/news" class="landing-section-link">View all news &rarr;</a>
        </div>
        <div class="news-grid">
            {% for item in landing_articles %}
            <article class="news-card">
                {% if item.image_url %}
                <div class="news-card-image">
                    <img src="{{ item.image_url }}" alt="" loading="lazy" class="image-fallback">
                </div>
                {% endif %}
                <div class="news-card-body">
                    <div class="news-card-meta">
                        <span class="news-source">{{ item.source_name }}</span>
                        {% if item.grade >= 9 %}
                        <span class="news-grade news-grade-top">Grade {{ item.grade }}</span>
                        {% elif item.grade >= 7 %}
                        <span class="news-grade news-grade-high">Grade {{ item.grade }}</span>
                        {% else %}
                        <span class="news-grade">Grade {{ item.grade }}</span>
                        {% endif %}
                        <span class="news-time">{{ item.time_ago }}</span>
                    </div>
                    <h3 class="news-card-title">
                        <a href="/news/{{ item.slug or item.uid }}">{{ item.title }}</a>
                    </h3>
                    {% if item.description %}
                    <p class="news-card-desc">{{ item.description[:250] }}{% if item.description|length > 250 %}...{% endif %}</p>
                    {% endif %}
                    <a href="{{ item.url }}" target="_blank" rel="noopener" class="news-read-link">
                        Read on {{ item.source_name }} &#x2197;
                    </a>
                </div>
            </article>
            {% endfor %}
        </div>
    </section>
    {% endif %}

    <footer class="landing-footer">
        <p>&copy; DevPlace &mdash; The Developer Social Network</p>
        <div class="landing-footer-links">
            <a href="/feed"><span class="icon">&#x1F4DD;</span>Posts</a>
            <a href="/news"><span class="icon">&#x1F4F0;</span>News</a>
            <a href="/projects"><span class="icon">&#x1F680;</span>Projects</a>
            <a href="/auth/login"><span class="icon">&#x1F511;</span>Login</a>
            <a href="/auth/signup"><span class="icon">&#x2728;</span>Sign Up</a>
            <a href="/bugs"><span class="icon">&#x1F41B;</span> Bug Report</a>
        </div>
    </footer>
</div>
{% endblock %}