/* ---------------------------------------------------------------------------
   Allmogens — an archive of Swedish folk literature.

   The material is 19th-century printed matter, so the design borrows from it:
   warm paper stock, deep ink, hairline rules, oldstyle figures, and a colophon
   at the foot of every text. The accent is Falu red — the pigment on Swedish
   cottages — which does the contextual work no generic accent colour could.
   --------------------------------------------------------------------------- */

:root {
  --paper:        #f2ece1;
  --paper-sunk:   #e8e0d2;
  --paper-raised: #f8f4ec;
  --ink:          #191512;
  --ink-soft:     #4a4038;
  --ink-faint:    #7d7267;
  --rule:         #cdc2b0;
  --falu:         #8c3520;
  --falu-bright:  #a8412a;
  --pine:         #3d4f41;

  --display: "Bodoni Moda", "Didot", Georgia, serif;
  --body:    "Spectral", Georgia, "Times New Roman", serif;
  --mono:    ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 34rem;      /* ~68 characters, the readable line for long prose */
  --gutter:  clamp(1.25rem, 5vw, 4rem);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #16130f;
    --paper-sunk:   #100e0b;
    --paper-raised: #1e1a15;
    --ink:          #ece3d5;
    --ink-soft:     #c0b4a3;
    --ink-faint:    #8b8073;
    --rule:         #3a332a;
    --falu:         #c8563a;
    --falu-bright:  #dd6a4c;
    --pine:         #8fa892;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.15rem);
  line-height: 1.72;
  font-feature-settings: "onum" 1, "kern" 1, "liga" 1;
  text-rendering: optimizeLegibility;
}

/* ── typography ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 1.5rem + 3vw, 3.9rem); font-weight: 700; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1.1vw, 2rem); }
h3 { font-size: 1.2rem; }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
a:hover { color: var(--falu-bright); text-decoration-color: currentColor; }

p { margin: 0 0 1.15em; }
blockquote {
  margin: 1.6em 0;
  padding-left: 1.4rem;
  border-left: 2px solid var(--falu);
  color: var(--ink-soft);
  font-style: italic;
}
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
img { max-width: 100%; height: auto; }

/* Metadata labels: letterspaced small caps, the way a colophon sets them. */
.label {
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ── shell ──────────────────────────────────────────────────────────────── */

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 var(--gutter); }

.skip {
  position: absolute; left: -9999px;
  background: var(--falu); color: var(--paper); padding: 0.6rem 1rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 99; }

.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0 1.2rem;
  margin-bottom: 3rem;
}
.masthead__inner {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem;
  align-items: baseline; justify-content: space-between;
}
.masthead__title {
  font-family: var(--display);
  font-size: 1.5rem; font-weight: 700; letter-spacing: 0.02em;
  text-decoration: none;
}
.masthead__motto { font-style: italic; color: var(--ink-faint); font-size: 0.92rem; }
.nav { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.nav a {
  text-decoration: none;
  font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] {
  border-bottom-color: var(--falu);
  color: var(--falu-bright);
}

.foot {
  margin-top: 6rem;
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3.5rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* ── home ───────────────────────────────────────────────────────────────── */

.hero { padding: 1rem 0 3rem; max-width: 46rem; }
.hero p { font-size: 1.2rem; color: var(--ink-soft); max-width: var(--measure); }

/* Asymmetric: the section cards break the grid rather than sitting in a
   tidy 4-up row, which would read as a generic template. */
.decks { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
@media (min-width: 46rem) { .decks { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 68rem) { .decks { grid-template-columns: repeat(4, 1fr); } }

.deck {
  background: var(--paper-raised);
  padding: 1.8rem 1.5rem 1.6rem;
  text-decoration: none;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: background 160ms ease;
}
.deck:hover { background: var(--paper-sunk); color: inherit; }
.deck__n {
  font-family: var(--display);
  font-size: 2.6rem; line-height: 1; font-weight: 400;
  color: var(--falu);
}
.deck__name { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.deck__desc { font-size: 0.88rem; color: var(--ink-faint); }

/* ── archive listings ───────────────────────────────────────────────────── */

.page-head { margin-bottom: 2.5rem; max-width: var(--measure); }
.page-head p { color: var(--ink-soft); }

.items { list-style: none; margin: 0; padding: 0; }
.item {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
  display: grid; gap: 0.35rem;
}
.item:last-child { border-bottom: 1px solid var(--rule); }
.item__title { font-family: var(--display); font-size: 1.3rem; font-weight: 600; margin: 0; }
.item__title a { text-decoration: none; }
.item__title a:hover { text-decoration: underline; }
.item__meta { font-size: 0.84rem; color: var(--ink-faint); }
.item__meta > * + *::before { content: " · "; }
.item__ingress { color: var(--ink-soft); margin: 0.2rem 0 0; max-width: var(--measure); }

/* Books carry more structured data, so they list with their imprint. */
.item--bok { grid-template-columns: 1fr; }
.imprint { font-size: 0.84rem; color: var(--ink-faint); font-variant-numeric: oldstyle-nums; }
.formats { display: flex; gap: 0.7rem; margin-top: 0.35rem; }
.formats a {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  text-decoration: none; border: 1px solid var(--rule); padding: 0.2rem 0.55rem;
}
.formats a:hover { border-color: var(--falu); color: var(--falu-bright); }

/* Poems list tighter — they are short and the title carries the weight. */
.items--verse .item { padding: 1rem 0; }

/* ── single page ────────────────────────────────────────────────────────── */

.article { max-width: var(--measure); margin: 0 auto; }
.article__head { margin-bottom: 2.5rem; }
.article__ingress {
  font-size: 1.18rem; color: var(--ink-soft); font-style: italic;
  margin-top: 0.8rem;
}
.article__byline { margin-top: 1.2rem; font-size: 0.9rem; color: var(--ink-faint); }
.article__byline a { font-weight: 600; }

.prose > p:first-of-type::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 3.6em;
  line-height: 0.82;
  padding: 0.06em 0.09em 0 0;
  color: var(--falu);
}
.prose { font-size: 1.06em; }
.prose h2 { margin-top: 2.2em; }

/* Verse must keep its own line breaks; never justify or re-wrap it. */
.prose--verse { font-size: 1.08em; }
.prose--verse > p:first-of-type::first-letter { float: none; font-size: inherit; color: inherit; padding: 0; }

/* The provenance block is a colophon: where the text came from, who digitised
   it, under what licence. For a republishing archive this is the point. */
.colophon {
  margin-top: 3.5rem;
  padding-top: 1.4rem;
  border-top: 2px solid var(--ink);
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.colophon dl { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1.2rem; margin: 0.8rem 0 0; }
.colophon dt { color: var(--ink-faint); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; padding-top: 0.28em; }
.colophon dd { margin: 0; }

.terms { margin-top: 2.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.terms a {
  font-size: 0.76rem; text-decoration: none;
  border: 1px solid var(--rule); padding: 0.15rem 0.6rem; border-radius: 2px;
}
.terms a:hover { border-color: var(--falu); color: var(--falu-bright); }

/* ── author archive ─────────────────────────────────────────────────────── */

.author-head {
  display: grid; gap: 2rem; align-items: start;
  margin-bottom: 3rem; padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 42rem) {
  .author-head { grid-template-columns: 12rem 1fr; gap: 3rem; }
}
.portrait {
  width: 100%; max-width: 12rem; aspect-ratio: 1;
  object-fit: cover;
  filter: grayscale(1) contrast(1.06);
  border: 1px solid var(--rule);
}
.author-bio { max-width: var(--measure); }
.author-bio p:last-child { margin-bottom: 0; }

.author-group { margin-top: 3rem; }
.author-group > h2 {
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint);
  font-family: var(--body);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* Author index: portraits in a dense grid, names beneath. */
.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
.roster a { text-decoration: none; display: block; }
.roster img { width: 100%; aspect-ratio: 1; object-fit: cover; filter: grayscale(1) contrast(1.06);
  border: 1px solid var(--rule); margin-bottom: 0.6rem; }
.roster .noimg { width: 100%; aspect-ratio: 1; border: 1px solid var(--rule);
  background: var(--paper-sunk); display: grid; place-items: center; margin-bottom: 0.6rem;
  font-family: var(--display); font-size: 2rem; color: var(--ink-faint); }
.roster__name { font-family: var(--display); font-weight: 600; font-size: 0.98rem; line-height: 1.25; }
.roster__count { font-size: 0.78rem; color: var(--ink-faint); }
.roster a:hover .roster__name { color: var(--falu-bright); }

/* ── standalone pages ───────────────────────────────────────────────────── */

/* The pull-quote is the one place a portrait appears outside an author
   archive, so it borrows the same grayscale treatment to stay of a piece. */
.pullquote {
  margin: 3.5rem 0 0;
  padding: 2rem 0 0;
  border-top: 2px solid var(--ink);
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 40rem) {
  .pullquote { grid-template-columns: 8rem 1fr; gap: 2rem; align-items: start; }
}
.pullquote__portrait {
  width: 100%; max-width: 8rem; aspect-ratio: 1;
  object-fit: cover; object-position: 50% 35%;
  filter: grayscale(1) contrast(1.06);
  border: 1px solid var(--rule);
}
/* Set in the text face, not the display face. Bodoni is a didone: its
   horizontal strokes are hairlines, so at reading sizes an en dash thins below
   one device pixel and vanishes entirely -- and a hundred words of it is tiring
   besides. The quote stays distinct through size, measure and the rule above
   it rather than through a second typeface. */
.pullquote__text {
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--body);
  font-size: 1.1rem;
  line-height: 1.66;
  font-style: normal;
  color: var(--ink);
  text-wrap: pretty;
}
.pullquote__text::before { content: "”"; margin-left: -0.42em; }
.pullquote__by {
  margin-top: 1rem;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
}
.pullquote__by a { color: inherit; }
.pullquote__role::before { content: " · "; }

/* Live counts, so the About page cannot go stale as the archive changes. */
.tally {
  margin-top: 3.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  display: flex; flex-wrap: wrap; gap: 1.75rem;
}
.tally a { text-decoration: none; display: flex; align-items: baseline; gap: 0.4rem; }
.tally__n { font-family: var(--display); font-size: 1.5rem; color: var(--falu); }
.tally__label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.tally a:hover .tally__label { color: var(--falu-bright); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
