{% extends "base.html" %}

{% block title %}{{ index.title }}{% endblock %}

{% block extra_css %}
.avis-layout {
  max-width: var(--layout-max-width);
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* Hero */
.hero {
  border-bottom: 3px solid var(--color-primary);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.hero__title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  line-height: 1.1;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}
.hero__summary {
  font-size: 1.1rem;
  color: var(--color-muted);
  max-width: 60ch;
}
.hero__meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.5rem;
}

/* Featured + sidebar grid */
.avis-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.featured-list { display: flex; flex-direction: column; gap: 1rem; }
.featured-item {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1rem;
}
.featured-item__title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}
.featured-item__summary {
  font-size: 0.9rem;
  color: var(--color-muted);
}

/* Sidebar */
.sidebar {
  border-left: 2px solid var(--color-accent);
  padding-left: 1rem;
}
.sidebar__heading {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 1rem;
}

/* Stream */
.stream { border-top: 2px solid var(--color-primary); padding-top: 1rem; }
.stream__heading {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 1rem;
}
.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}
.stream-item__title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--color-primary);
}
.stream-item__meta {
  font-size: 0.8rem;
  color: var(--color-muted);
}

@media (max-width: 768px) {
  .avis-grid { grid-template-columns: 1fr; }
  .sidebar { border-left: none; border-top: 2px solid var(--color-accent); padding-left: 0; padding-top: 1rem; }
  .hero__title { font-size: 1.75rem; }
}
{% endblock %}

{% block content %}
<div class="avis-layout">
  {% if index.hero %}
  <div class="hero">
    <h2 class="hero__title"><a href="{{ base_url }}/{{ index.hero.short_id }}">{{ index.hero.title }}</a></h2>
    {% if index.hero.summary %}
    <p class="hero__summary">{{ index.hero.summary }}</p>
    {% endif %}
    <div class="hero__meta">{{ index.hero.published_at_short }}</div>
  </div>
  {% endif %}

  {% if index.featured | length > 0 or index.stream | length > 0 %}
  <div class="avis-grid">
    <div class="featured-list">
      {% for item in index.featured %}
      <div class="featured-item">
        <h3 class="featured-item__title"><a href="{{ base_url }}/{{ item.short_id }}">{{ item.title }}</a></h3>
        {% if item.summary %}
        <p class="featured-item__summary">{{ item.summary }}</p>
        {% endif %}
      </div>
      {% endfor %}
    </div>
    <aside class="sidebar">
      <div class="sidebar__heading">Siste nytt</div>
      {% for item in index.stream %}
      {% if loop.index <= 5 %}
      <div style="margin-bottom: 0.75rem;">
        <a href="{{ base_url }}/{{ item.short_id }}" style="font-size: 0.9rem;">{{ item.title }}</a>
        <div style="font-size: 0.75rem; color: var(--color-muted);">{{ item.published_at_short }}</div>
      </div>
      {% endif %}
      {% endfor %}
    </aside>
  </div>
  {% endif %}

  {% if index.stream | length > 5 %}
  <section class="stream">
    <div class="stream__heading">Flere saker</div>
    <div class="stream-grid">
      {% for item in index.stream %}
      {% if loop.index > 5 %}
      <div class="stream-item">
        <h4 class="stream-item__title"><a href="{{ base_url }}/{{ item.short_id }}">{{ item.title }}</a></h4>
        <div class="stream-item__meta">{{ item.published_at_short }}</div>
      </div>
      {% endif %}
      {% endfor %}
    </div>
  </section>
  {% endif %}
</div>
{% endblock %}
