{#
    Page profil publique — GET /@{username}.

    Rendue par ShowUserProfileAction. Variables :
      - profile    : sortie de PublicUserSummarySerializer
                     (username, displayName, bio, avatarUrl, hasAvatar,
                      isVerified, level, displayTitle?)
      - mediaCount : total des médias publiés de l'utilisateur
      - medias     : première page des médias publiés
                     (id, name, url, blurHash, width, height, orientation)

    SEO : page HORS sitemap (aucun provider ne l'énumère) mais INDEXABLE
    (meta robots index, follow). Le <head> est construit ici car titre et
    métadonnées sont dynamiques (dérivés du profil) — le partial statique
    partials/page-meta.twig ne convient pas.

    Style : feuille inline minimale (le projet n'a pas de CSS partagé ; cf.
    landing.twig / explorer.twig). À extraire vers un asset le jour où une
    charte graphique commune existe.
#}
<!doctype html>
<html lang="{{ locale|default('fr-FR') }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>{{ profile.displayName }} (@{{ profile.username }}) — Hydrogen</title>
    {% if profile.bio %}
        <meta name="description" content="{{ profile.bio }}">
    {% endif %}
    <meta name="robots" content="index, follow">
    <link rel="canonical" href="{{ app_url }}/@{{ profile.username }}">

    <meta property="og:type" content="profile">
    <meta property="og:title" content="{{ profile.displayName }} (@{{ profile.username }})">
    {% if profile.bio %}
        <meta property="og:description" content="{{ profile.bio }}">
    {% endif %}
    {% if profile.hasAvatar %}
        <meta property="og:image" content="{{ profile.avatarUrl }}">
    {% endif %}
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="{{ profile.displayName }} (@{{ profile.username }})">
    {% if profile.bio %}
        <meta name="twitter:description" content="{{ profile.bio }}">
    {% endif %}
    {% if profile.hasAvatar %}
        <meta name="twitter:image" content="{{ profile.avatarUrl }}">
    {% endif %}

    <style>
        :root {
            --bg: #f9fafb;
            --card: #ffffff;
            --text: #1f2937;
            --muted: #6b7280;
            --border: #e5e7eb;
            --accent: #2563eb;
        }
        * { box-sizing: border-box; }
        body {
            margin: 0;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            color: var(--text);
            background: var(--bg);
            line-height: 1.5;
        }
        main { max-width: 960px; margin: 0 auto; padding: 32px 16px; }

        .profile-header {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            background: var(--card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 32px 24px;
            margin-bottom: 32px;
        }
        .profile-avatar {
            width: 128px;
            height: 128px;
            border-radius: 50%;
            object-fit: cover;
            margin-bottom: 16px;
        }
        .profile-name {
            font-size: 24px;
            margin: 0 0 4px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .profile-verified { color: var(--accent); font-size: 18px; }
        .profile-handle { color: var(--muted); margin: 0 0 12px; }
        .profile-level { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
        .profile-bio { max-width: 520px; margin: 0; }

        .profile-media h2 {
            font-size: 18px;
            border-bottom: 1px solid var(--border);
            padding-bottom: 8px;
            margin-bottom: 16px;
        }
        .profile-media-empty { color: var(--muted); }

        .media-grid {
            list-style: none;
            padding: 0;
            margin: 0;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
            gap: 8px;
        }
        .media-grid-item {
            position: relative;
            aspect-ratio: 1 / 1;
            overflow: hidden;
            border-radius: 8px;
            background: var(--border);
        }
        .media-grid-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            transition: transform 0.2s ease;
        }
        .media-grid-item a:hover img { transform: scale(1.04); }
    </style>
</head>
<body>
    <main>
        <header class="profile-header">
            {% if profile.hasAvatar %}
                <img class="profile-avatar" src="{{ profile.avatarUrl }}"
                     alt="{{ profile.displayName }}" width="128" height="128">
            {% endif %}

            <h1 class="profile-name">
                {{ profile.displayName }}
                {% if profile.isVerified %}
                    <span class="profile-verified" title="{{ trans('pages.profile.verified') }}" aria-label="{{ trans('pages.profile.verified') }}">✔</span>
                {% endif %}
            </h1>

            <p class="profile-handle">@{{ profile.username }}</p>

            <p class="profile-level">
                {{ trans('pages.profile.level', { level: profile.level }) }}
                {% if profile.displayTitle %}
                    — {{ profile.displayTitle }}
                {% endif %}
            </p>

            {% if profile.bio %}
                <p class="profile-bio">{{ profile.bio }}</p>
            {% endif %}
        </header>

        <section class="profile-media">
            <h2>{{ trans('pages.profile.mediaHeading', { count: mediaCount }) }}</h2>

            {% if medias is empty %}
                <p class="profile-media-empty">{{ trans('pages.profile.noMedia') }}</p>
            {% else %}
                <ul class="media-grid">
                    {% for media in medias %}
                        <li class="media-grid-item media-grid-item--{{ media.orientation }}">
                            <a href="{{ media.url }}">
                                <img src="{{ media.url }}"
                                     alt="{{ media.name|default('') }}"
                                     loading="lazy"
                                     {% if media.width %}width="{{ media.width }}"{% endif %}
                                     {% if media.height %}height="{{ media.height }}"{% endif %}>
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            {% endif %}
        </section>
    </main>

    {% include 'partials/cookie-consent.twig' %}
</body>
</html>
