{{- define "main" }}
{{- $isZh := eq .Lang "zh" }}
{{- $polarsteps := .Params.polarsteps_url | default "https://www.polarsteps.com/cubxxw" }}

{{- $travelTags := slice "travel" "Travel" "Adventure" "旅行" "Exploration" "探索" "hiking" "Hiking" }}
{{- $travelPages := slice }}
{{- range .Site.RegularPages }}
  {{- if and (not .Params.Draft) (.Params.tags) }}
    {{- if gt (len (intersect .Params.tags $travelTags)) 0 }}
      {{- $travelPages = $travelPages | append . }}
    {{- end }}
  {{- end }}
{{- end }}
{{- $travelPages = sort $travelPages "Date" "desc" }}
{{- $articleCount := len $travelPages }}

{{- $allTags := slice }}
{{- range $travelPages }}
  {{- range .Params.tags }}{{- $allTags = $allTags | append . }}{{- end }}
{{- end }}
{{- $uniqueTags := $allTags | uniq }}

<div class="eitr-page">

  {{/* ── Hero ── */}}
  <header class="eitr-hero">
    <div class="eitr-hero__bg">
      <div class="eitr-hero__grid"></div>
      <div class="eitr-hero__orb eitr-hero__orb--1"></div>
      <div class="eitr-hero__orb eitr-hero__orb--2"></div>
      <svg class="eitr-hero__compass" viewBox="0 0 200 200" fill="none" aria-hidden="true">
        <circle cx="100" cy="100" r="90" stroke="rgba(255,255,255,0.06)" stroke-width="1"/>
        <circle cx="100" cy="100" r="65" stroke="rgba(255,255,255,0.05)" stroke-width="1"/>
        <circle cx="100" cy="100" r="40" stroke="rgba(255,255,255,0.05)" stroke-width="1"/>
        <line x1="100" y1="10" x2="100" y2="190" stroke="rgba(255,255,255,0.05)" stroke-width="1"/>
        <line x1="10" y1="100" x2="190" y2="100" stroke="rgba(255,255,255,0.05)" stroke-width="1"/>
        <polygon points="100,18 104,94 100,106 96,94" fill="rgba(255,255,255,0.55)"/>
        <polygon points="100,182 104,106 100,94 96,106" fill="rgba(255,255,255,0.18)"/>
        <polygon points="18,100 94,96 106,100 94,104" fill="rgba(255,255,255,0.18)"/>
        <polygon points="182,100 106,96 94,100 106,104" fill="rgba(255,255,255,0.12)"/>
        <circle cx="100" cy="100" r="5" fill="rgba(255,255,255,0.65)"/>
        <text x="100" y="9" text-anchor="middle" fill="rgba(255,255,255,0.6)" font-size="9" font-family="sans-serif">N</text>
        <text x="100" y="197" text-anchor="middle" fill="rgba(255,255,255,0.35)" font-size="9" font-family="sans-serif">S</text>
        <text x="197" y="104" text-anchor="middle" fill="rgba(255,255,255,0.35)" font-size="9" font-family="sans-serif">E</text>
        <text x="3" y="104" text-anchor="middle" fill="rgba(255,255,255,0.35)" font-size="9" font-family="sans-serif">W</text>
      </svg>
    </div>
    <div class="eitr-hero__content">
      <div class="eitr-hero__badge">
        <span class="eitr-hero__dot"></span>
        {{ if $isZh }}数字游民 · 探险者{{ else }}Digital Nomad · Explorer{{ end }}
      </div>
      <h1 class="eitr-hero__title">
        {{- if $isZh }}
        <span class="eitr-hero__line1">探索世界</span>
        <span class="eitr-hero__line2">记录足迹</span>
        {{- else }}
        <span class="eitr-hero__line1">Explore the World</span>
        <span class="eitr-hero__line2">Leave Footprints</span>
        {{- end }}
      </h1>
      <p class="eitr-hero__sub">
        {{ if $isZh }}一步一个脚印，记录旅途中的真实故事与深度感悟{{ else }}One step at a time — real stories and deep reflections from the road{{ end }}
      </p>
      <div class="eitr-hero__actions">
        <a href="#eitr-stories" class="eitr-btn eitr-btn--primary">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>
          {{ if $isZh }}旅行故事{{ else }}Travel Stories{{ end }}
        </a>
        <a href="{{ $polarsteps }}" target="_blank" rel="noopener noreferrer" class="eitr-btn eitr-btn--ghost">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
          {{ if $isZh }}Polarsteps 地图{{ else }}Polarsteps Map{{ end }}
        </a>
      </div>
    </div>
    <div class="eitr-hero__scroll" aria-hidden="true">
      <div class="eitr-hero__scroll-line"></div>
    </div>
  </header>

  {{/* ── Stats ── */}}
  {{- if gt $articleCount 0 }}
  <section class="eitr-stats">
    <div class="eitr-stat">
      <span class="eitr-stat__num">{{ $articleCount }}</span>
      <span class="eitr-stat__label">{{ if $isZh }}旅行故事{{ else }}Stories{{ end }}</span>
    </div>
    <div class="eitr-stat__divider"></div>
    <div class="eitr-stat">
      <span class="eitr-stat__num">{{ len $uniqueTags }}</span>
      <span class="eitr-stat__label">{{ if $isZh }}探索主题{{ else }}Topics{{ end }}</span>
    </div>
    <div class="eitr-stat__divider"></div>
    {{- $startYear := now.Year }}
    {{- if $travelPages }}
    {{- $startYear = (index (sort $travelPages "Date" "asc") 0).Date.Year }}
    {{- end }}
    {{- $years := sub now.Year $startYear }}{{- if lt $years 1 }}{{- $years = 1 }}{{- end }}
    <div class="eitr-stat">
      <span class="eitr-stat__num">{{ $years }}+</span>
      <span class="eitr-stat__label">{{ if $isZh }}旅行年数{{ else }}Years{{ end }}</span>
    </div>
    <div class="eitr-stat__divider"></div>
    <div class="eitr-stat">
      <span class="eitr-stat__num">∞</span>
      <span class="eitr-stat__label">{{ if $isZh }}探索可能{{ else }}Possibilities{{ end }}</span>
    </div>
  </section>
  {{- end }}

  {{/* ── Travel Stories ── */}}
  <section id="eitr-stories" class="eitr-stories">
    <div class="eitr-section-header">
      <div class="eitr-section-eyebrow">
        <span class="eitr-dot"></span>
        {{ if $isZh }}来自路上{{ else }}From the Road{{ end }}
      </div>
      <h2 class="eitr-section-title">{{ if $isZh }}旅行故事与记录{{ else }}Travel Stories & Journals{{ end }}</h2>
      <p class="eitr-section-desc">{{ if $isZh }}深度记录、真实感悟和实用指南{{ else }}Deep dives, honest reflections, and practical guides{{ end }}</p>
    </div>

    {{- if gt $articleCount 0 }}
    <div class="eitr-grid">
      {{- range $i, $p := $travelPages }}
      <article class="eitr-card {{ if eq $i 0 }}eitr-card--featured{{ end }}{{ if not $p.Params.cover.image }} eitr-card--no-img{{ end }}">
        {{- with $p.Params.cover.image }}
        <div class="eitr-card__img-wrap">
          <img src="{{ . }}" alt="{{ $p.Title }}" loading="lazy" class="eitr-card__img">
          <div class="eitr-card__img-scrim"></div>
        </div>
        {{- end }}
        <div class="eitr-card__body">
          <div class="eitr-card__meta">
            <time class="eitr-date">{{ if $isZh }}{{ $p.Date.Format "2006 年 1 月 2 日" }}{{ else }}{{ $p.Date.Format "Jan 2, 2006" }}{{ end }}</time>
            {{- with $p.Params.tags }}
            <div class="eitr-card__tags">
              {{- range first 2 . }}<span class="eitr-tag">{{ . }}</span>{{- end }}
            </div>
            {{- end }}
          </div>
          <h3 class="eitr-card__title">
            <a href="{{ $p.Permalink }}">{{ $p.Title }}</a>
          </h3>
          <p class="eitr-card__excerpt">
            {{- with $p.Description }}{{ . | plainify | htmlUnescape | truncate 120 }}
            {{- else }}{{ $p.Summary | plainify | htmlUnescape | truncate 120 }}
            {{- end }}
          </p>
          <a href="{{ $p.Permalink }}" class="eitr-cta">
            {{ if $isZh }}阅读全文{{ else }}Read Story{{ end }}
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>
          </a>
        </div>
        <a class="eitr-card__cover" href="{{ $p.Permalink }}" aria-label="{{ $p.Title }}"></a>
      </article>
      {{- end }}
    </div>
    {{- else }}
    <div class="eitr-empty">
      <svg width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
      <p>{{ if $isZh }}旅行故事即将到来…{{ else }}Travel stories coming soon…{{ end }}</p>
      <a href="{{ $polarsteps }}" target="_blank" rel="noopener noreferrer" class="eitr-btn eitr-btn--outline">
        {{ if $isZh }}先去 Polarsteps 看看{{ else }}See Polarsteps for now{{ end }}
      </a>
    </div>
    {{- end }}
  </section>

  {{/* ── Philosophy ── */}}
  <section class="eitr-philosophy">
    <blockquote class="eitr-philosophy__quote">
      {{- if $isZh }}旅行不是逃离生活，而是让生活不会逃离你
      {{- else }}Travel is not an escape from life — it's so life doesn't escape from you
      {{- end }}
    </blockquote>
    <div class="eitr-philosophy__cards">
      <div class="eitr-philo-card">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
        <h3>{{ if $isZh }}真实连接{{ else }}Real Connection{{ end }}</h3>
        <p>{{ if $isZh }}与当地文化深度交流，而非走马观花{{ else }}Deep cultural exchange, not just sightseeing{{ end }}</p>
      </div>
      <div class="eitr-philo-card">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M1 6v16l7-4 8 4 7-4V2l-7 4-8-4-7 4z"/><line x1="8" y1="2" x2="8" y2="18"/><line x1="16" y1="6" x2="16" y2="22"/></svg>
        <h3>{{ if $isZh }}慢旅行{{ else }}Slow Travel{{ end }}</h3>
        <p>{{ if $isZh }}驻留体验，不赶打卡，感受每个地方的节奏{{ else }}Stay longer, skip checklists, feel each place's rhythm{{ end }}</p>
      </div>
      <div class="eitr-philo-card">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
        <h3>{{ if $isZh }}数字游民{{ else }}Digital Nomad{{ end }}</h3>
        <p>{{ if $isZh }}代码与旅途并行，世界是我的办公室{{ else }}Code and travel in parallel — the world is my office{{ end }}</p>
      </div>
    </div>
  </section>

  {{/* ── Connect ── */}}
  <section class="eitr-connect">
    <h2 class="eitr-connect__title">{{ if $isZh }}一起出发？{{ else }}Travel Together?{{ end }}</h2>
    <p class="eitr-connect__desc">
      {{ if $isZh }}分享旅行技巧、交流冒险故事，或者讨论数字游民生活{{ else }}Share travel tips, exchange adventure stories, or discuss the nomad life{{ end }}
    </p>
    <div class="eitr-connect__links">
      {{- with .Site.Params.socialIcons }}
        {{- range . }}
          {{- if or (eq .name "twitter") (eq .name "github") (eq .name "email") }}
          <a href="{{ .url }}" {{ if ne .name "email" }}target="_blank" rel="noopener noreferrer"{{ end }} class="eitr-social">{{ .name }}</a>
          {{- end }}
        {{- end }}
      {{- else }}
      <a href="https://twitter.com/cubxxw" target="_blank" rel="noopener noreferrer" class="eitr-social">Twitter / X</a>
      <a href="https://github.com/cubxxw" target="_blank" rel="noopener noreferrer" class="eitr-social">GitHub</a>
      {{- end }}
    </div>
  </section>

</div>
{{- end }}
