/* pages.css — shared components for section/index pages (blog, perch, references,
 * scratch, search). Load after style.css (and blog.css where an article is present).
 *
 * Markup contract (see the generator in scripts/build_blog.py):
 *
 *   <html lang="en" class="wide">
 *   <a class="back-link" href="/">Muninn</a>  <muninn-search trigger="text"></muninn-search>
 *   <header class="page-head">
 *     <p class="eyebrow">Blog · 115 posts</p>
 *     <h1>Title</h1>  <p class="lede">…</p>
 *     <div class="page-tools"><a class="chip" href="/feed.xml">Atom feed</a>
 *       <input class="filter" type="search" hidden …>   (a script un-hides it)
 *       <p class="filter-status" role="status" aria-live="polite"></p></div>
 *   </header>
 *   <article class="feature">            the newest entry, set larger; same children as an entry
 *     <div class="entry-art">…</div><div class="entry-body"><time class="entry-date">…</time>
 *       <h2 class="entry-title"><a href="…">Title</a></h2><p class="entry-desc">…</p></div></article>
 *   <section class="year-group"><h2 class="year">2026<small>41 posts</small></h2>
 *     <ol class="entries">
 *       <li class="entry"><time class="entry-date">Oct 2</time>
 *         <div class="entry-body"><h3 class="entry-title"><a href="…">Title</a></h3><p class="entry-desc">…</p></div>
 *         <div class="entry-art"><img …> | <span class="sigil" style="--a:30;--b:60;--c:15"></span></div></li>
 *   <footer>…</footer>
 */

html.wide { max-width: 70rem; }

/* ── Page head ───────────────────────────────────────────────────────────── */
.page-head {
  position: relative;
  padding: 1.6rem 0 2.2rem;
  border-bottom: 1px solid var(--line);
}
.page-head::after {
  /* registration mark, printed off to one side */
  content: "";
  position: absolute;
  top: 2.4rem;
  right: 0;
  width: 64px;
  height: 64px;
  opacity: 0.85;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 17px, var(--coral) 17.5px 19px, transparent 19.5px),
    linear-gradient(var(--coral), var(--coral)) 50% 50% / 1.5px 100% no-repeat,
    linear-gradient(var(--coral), var(--coral)) 50% 50% / 100% 1.5px no-repeat;
  pointer-events: none;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 0.9rem;
  font-family: var(--f-mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage-ink);
}
.eyebrow::before { content: ""; width: 1.7rem; height: 5px; background: var(--sage); }
.page-head h1 {
  margin: 0;
  font-size: clamp(2.7rem, 1.5rem + 5.6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: -0.032em;
  overflow-wrap: anywhere; /* titles and summaries are generated; one long token must not widen the page */
}
.lede {
  max-width: 38rem;
  margin: 1.1rem 0 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(1.15rem, 1rem + 0.8vw, 1.55rem);
  line-height: 1.38;
  color: var(--fg-2);
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.page-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 0.9rem;
  margin-top: 1.5rem;
}
.chip {
  display: inline-block;
  padding: 0.38rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { background: var(--head); border-color: var(--head); color: var(--bg); text-decoration: none; }
.filter {
  flex: 1 1 15rem;
  max-width: 24rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-family: var(--f-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}
.filter::placeholder { color: var(--fg-3); }
.filter:focus-visible { border-color: var(--coral); outline-offset: 2px; }

/* ── Year groups and entries ─────────────────────────────────────────────── */
.year-group {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0 1.6rem;
  margin-top: 2.6rem;
}
.year {
  position: sticky;
  top: 1.4rem;
  align-self: start;
  margin: 0;
  font-family: var(--f-display);
  font-size: 2.1rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--head);
}
.year small {
  display: block;
  margin-top: 0.45rem;
  font-family: var(--f-mono);
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.entries { list-style: none; margin: 0; padding: 0; }
.entry {
  position: relative;
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 9.5rem;
  gap: 0 1.4rem;
  margin: 0;
  padding: 1.3rem 0;
  border-top: 1px solid var(--line);
}
.entry:first-child { border-top-color: var(--head); border-top-width: 2px; }
.entry-body { min-width: 0; }
.entry-date {
  padding-top: 0.45rem;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}
.entry-title {
  margin: 0 0 0.4rem;
  font-family: var(--f-display);
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.42rem);
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--head);
  overflow-wrap: anywhere;
}
.entry-title a {
  color: inherit;
  text-decoration: none;
  background: linear-gradient(var(--coral), var(--coral)) 0 100% / 0 2px no-repeat;
  transition: background-size 0.28s ease;
}
.entry-title a::after { content: ""; position: absolute; inset: 0; } /* whole row is the target */
.entry:hover .entry-title a, .entry-title a:focus-visible { background-size: 100% 2px; }
.entry-desc {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.52;
  color: var(--fg-2);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-art {
  align-self: start;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-2);
}
.entry-art img {
  background: var(--plate);
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  border-radius: 0;
  mix-blend-mode: normal;
  transition: transform 0.6s ease;
}
.entry:hover .entry-art img { transform: scale(1.045); }

/* Feature: the newest entry, set larger */
.feature {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 2rem;
  margin-top: 2.2rem;
  padding-bottom: 2.4rem;
  border-bottom: 1px solid var(--line);
}
.feature .entry-art { aspect-ratio: 16 / 8; } /* wider than tall: a procedural sigil at poster scale reads as a placeholder */
.feature .entry-date { padding: 0 0 0.7rem; }
.feature .entry-title { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.6rem); line-height: 1.08; margin-bottom: 0.7rem; }
.feature .entry-desc { font-size: 1.02rem; -webkit-line-clamp: 5; }
.feature .entry-body { align-self: center; }
.feature .entry-title a::after { content: ""; position: absolute; inset: 0; }

/* Entries hidden by the filter box */
.entry[hidden], .feature[hidden], .year-group[hidden] { display: none; }
.filter-status { margin: 1.2rem 0 0; font-family: var(--f-mono); font-size: 0.74rem; letter-spacing: 0.03em; color: var(--fg-3); min-height: 1.2em; }
.page-tools .filter-status { margin: 0; min-height: 0; } /* inside the tools row: no space until it has text */

/* ── Sigil: a deterministic three-ink overprint standing in for a missing image.
      Set --a, --b, --c to integers 0-100 (the generator hashes the slug). ───── */
.sigil {
  --a: 30; --b: 60; --c: 15;
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at calc(var(--a) * 1%) calc(var(--b) * 1%), var(--coral) 0 calc(14% + var(--c) * 0.12%), transparent calc(14.6% + var(--c) * 0.12%)),
    radial-gradient(circle at calc(var(--b) * 1%) calc(var(--c) * 1%), var(--indigo) 0 calc(9% + var(--a) * 0.08%), transparent calc(9.6% + var(--a) * 0.08%)),
    radial-gradient(circle at calc(var(--c) * 1%) calc(var(--a) * 1%), var(--sage) 0 calc(11% + var(--b) * 0.09%), transparent calc(11.6% + var(--b) * 0.09%)),
    radial-gradient(circle at calc(100% - var(--a) * 1%) calc(100% - var(--c) * 1%), var(--indigo) 0 2.4%, transparent 2.9%),
    radial-gradient(circle at calc(100% - var(--b) * 1%) calc(var(--a) * 1%), var(--coral) 0 1.8%, transparent 2.3%),
    linear-gradient(calc(var(--c) * 3deg + 20deg), transparent calc(50% - 0.8px), var(--indigo) calc(50% - 0.8px) calc(50% + 0.8px), transparent calc(50% + 0.8px)),
    var(--bg-2);
  background-blend-mode: multiply, multiply, multiply, normal, normal, normal, normal;
}
.sigil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grain);
  opacity: 0.9;
  mix-blend-mode: multiply;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sigil { background-blend-mode: screen, screen, screen, normal, normal, normal, normal; }
  :root:not([data-theme="light"]) .sigil::after { mix-blend-mode: screen; }
}

/* ── Sister-site note, footers ───────────────────────────────────────────── */
.sister-blog {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--fg-2);
}

/* ── Narrow screens ──────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .feature { grid-template-columns: 1fr; gap: 1.1rem; }
  .year-group { grid-template-columns: 1fr; margin-top: 2rem; }
  .year { position: static; display: flex; align-items: baseline; gap: 0.8rem; margin-bottom: 0.6rem; }
  .year small { margin-top: 0; }
  .page-head::after { width: 40px; height: 40px; top: 0.9rem; }
}
@media (max-width: 620px) {
  .entry { grid-template-columns: minmax(0, 1fr) 6.2rem; gap: 0 1rem; }
  .entry > .entry-date { grid-column: 1 / -1; padding: 0 0 0.35rem; }
  .entry > .entry-art { grid-column: 2; grid-row: 2; }
  .entry > .entry-body { grid-column: 1; grid-row: 2; }
  .entry-desc { -webkit-line-clamp: 4; }
  .feature .entry-desc { -webkit-line-clamp: 6; }
}
/* iOS Safari zooms the page when a field under 16px takes focus, and does not zoom back */
@media (max-width: 760px) {
  .filter { font-size: max(16px, 0.78rem); }
}
@media (max-width: 700px) {
  .chip { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .entry-art img, .entry-title a, .chip { transition: none; }
}
