/* ---------- Fonts ----------
   Self-hosted, latin subset. All SIL Open Font License 1.1,
   license texts next to the files in /assets/fonts/. */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader.woff2") format("woff2");
  font-weight: 400 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 400 600; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400 500; font-style: normal; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #121212;
  --bg-raised: #1a1a1a;
  --bg-glow: #2a0d07;
  --fg: #e8e4df;
  --muted: #8f8a85;
  --accent: #d0402a;
  --line: #2a2a2a;
  --sans: "Schibsted Grotesk", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1180px;
  --narrow: 680px;
  --gutter: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f0ec;
    --bg-raised: #ebe6e0;
    --bg-glow: #f2d9d2;
    --fg: #1b1b1b;
    --muted: #6b6560;
    --accent: #a3220f;
    --line: #ddd6cf;
    color-scheme: light;
  }
}
@media (min-width: 720px) { :root { --gutter: 32px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0; font-weight: 550; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 10; background: var(--bg); padding: 6px 10px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

.eyebrow {
  font: 13px/1 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.eyebrow a { text-decoration: none; color: inherit; }
.lead { font-size: 19px; color: var(--muted); max-width: 46ch; margin: 14px 0 0; }
.lead p { margin: 0; }
.meta { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.empty { color: var(--muted); }

/* ---------- Header / footer ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  /* full-width bar, content aligned with .wrap */
  padding: 16px max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; border-radius: 50%; image-rendering: pixelated; background: #ebebeb; }
.brand span { white-space: nowrap; }
.site-header nav { display: flex; gap: 20px; font-size: 15px; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--fg); }
.site-header nav a[aria-current] { box-shadow: 0 2px 0 var(--accent); }
@media (max-width: 480px) { .brand span { display: none; } }

.site-footer {
  max-width: var(--wrap);
  width: 100%;
  margin: 96px auto 0;
  padding: 32px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}
.site-footer p { margin: 0; }
.site-footer p a { text-decoration: none; }
.site-footer p a:hover { color: var(--accent); }

.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pills a {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--fg);
  font-size: 14px;
  transition: border-color .2s, color .2s;
}
.pills a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Home ---------- */
.hero {
  padding: 56px 0 72px;
  display: grid;
  gap: 32px;
  align-items: center;
}
@media (min-width: 720px) { .hero { grid-template-columns: auto 1fr; gap: 48px; padding: 88px 0 104px; } }
.hero picture { display: block; }
.hero .avatar {
  width: 168px; height: 168px;
  border-radius: 50%;
  image-rendering: pixelated;
  background: #ebebeb;
  border: 3px solid var(--fg);
  box-shadow: 0 0 0 8px var(--bg), 0 0 0 9px var(--line), 0 0 120px 30px var(--bg-glow);
}
.hero h1 { font-size: clamp(38px, 7vw, 64px); }
.hero .lead { max-width: 52ch; }

.section { padding: 32px 0 24px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: 26px; }
.section-head a { font-size: 15px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.section-head a:hover { color: var(--accent); }

/* ---------- Page heads ---------- */
.page-head { padding: 48px 0 40px; }
.page-head h1 { font-size: clamp(34px, 6vw, 52px); }

/* ---------- Albums ---------- */
.album-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.album-grid a { display: block; text-decoration: none; }
.album-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-raised);
  transition: transform .4s cubic-bezier(.2,.7,.2,1), filter .4s;
}
.album-grid a:hover img { transform: scale(1.015); filter: brightness(1.05); }
.album-title { display: block; margin-top: 12px; font-weight: 600; font-size: 18px; }
.album-meta { display: block; color: var(--muted); font-size: 14px; }

/* ---------- Gallery (justified rows via flex-grow by aspect ratio) ---------- */
.gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gallery li {
  flex-grow: calc(var(--ratio) * 100);
  flex-basis: calc(var(--ratio) * 260px);
  aspect-ratio: var(--ratio);
}
.gallery::after { content: ""; flex-grow: 999; }
@media (max-width: 600px) { .gallery li { flex-basis: calc(var(--ratio) * 160px); } }
.gallery a { display: block; height: 100%; overflow: hidden; border-radius: 4px; background: var(--bg-raised); cursor: zoom-in; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.gallery a:hover img { transform: scale(1.02); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 8, 8, .96);
  color: #e8e4df;
  display: grid;
  grid-template-rows: 1fr auto;
  opacity: 0;
  transition: opacity .2s;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }
.lightbox figure { margin: 0; display: grid; place-items: center; padding: 56px 16px 8px; min-height: 0; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); width: auto; height: auto; object-fit: contain; }
.lightbox figcaption { padding: 8px 16px 20px; text-align: center; font-size: 14px; color: #bdb7b1; min-height: 52px; }
.lightbox figcaption .exif { display: block; font: 12px/1.6 var(--mono); color: #8f8a85; }
.lightbox button {
  position: absolute;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 12px;
  opacity: .7;
}
.lightbox button:hover { opacity: 1; }
.lightbox .lb-close { top: 8px; right: 8px; font-size: 28px; line-height: 1; }
.lightbox .lb-prev, .lightbox .lb-next { top: 50%; transform: translateY(-50%); font-size: 36px; }
.lightbox .lb-prev { left: 4px; }
.lightbox .lb-next { right: 4px; }
.lightbox .lb-count { position: absolute; top: 20px; left: 20px; font: 12px var(--mono); color: #8f8a85; }
@media (hover: none) { .lightbox .lb-prev, .lightbox .lb-next { display: none; } }
body.lb-lock { overflow: hidden; }

/* ---------- Writing ---------- */
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.post-list a {
  display: grid;
  gap: 2px 32px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
@media (min-width: 720px) { .post-list a { grid-template-columns: 130px 1fr; } .post-list .excerpt { grid-column: 2; } }
.post-list time { color: var(--muted); font: 13px/2 var(--mono); }
.post-list .title { font-size: 21px; font-weight: 550; letter-spacing: -.01em; }
.post-list .excerpt { color: var(--muted); font-size: 16px; }
.post-list a:hover .title { color: var(--accent); }
.post-list .tags { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font: 12px/1.6 var(--mono); margin-top: 6px; }
@media (min-width: 720px) { .post-list .tags { grid-column: 2; } }

.tag-filter { margin: 0 0 28px; }
.tag-filter small { color: var(--muted); font: 11px var(--mono); margin-left: 4px; }
.tag-filter a[aria-current] { border-color: var(--accent); color: var(--accent); }
.tag-filter a[aria-current] small { color: inherit; }
.post-tags { margin-top: 18px; }
.post-tags a { padding: 4px 12px; font: 13px var(--mono); color: var(--muted); }

.post-head { padding: 48px 0 32px; }
.post-head h1 { font-size: clamp(32px, 6vw, 48px); }
.post-cover { margin: 0 0 40px; }
.post-cover img { border-radius: 6px; }

.prose { font: 450 19.5px/1.75 var(--serif); }
.prose strong, .prose b { font-weight: 600; }
.prose > * { margin: 0 0 1.2em; }
.prose h2, .prose h3 { font-family: var(--sans); margin: 1.8em 0 .6em; }
.prose h2 { font-size: 26px; }
.prose h3 { font-size: 21px; }
.prose blockquote { margin-left: 0; padding-left: 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose img { border-radius: 4px; margin: 0 auto; }
.prose figure { margin: 2em 0; }
.prose figcaption { font: 14px/1.5 var(--sans); color: var(--muted); text-align: center; margin-top: 10px; }
.prose hr { border: 0; text-align: center; margin: 2.4em 0; }
.prose hr::before { content: "* * *"; color: var(--muted); letter-spacing: .6em; }
.prose code { font: .85em var(--mono); background: var(--bg-raised); padding: 2px 5px; border-radius: 4px; }
.prose pre { background: var(--bg-raised); padding: 16px; border-radius: 6px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }

.legal { max-width: var(--narrow); padding-bottom: 48px; font-size: 18px; }
.legal section > h2:first-child, .legal > p:first-child { margin-top: 0; }
.legal h2 { font-size: 21px; }
.legal-translation { margin-top: 64px; padding-top: 8px; border-top: 1px solid var(--line); }
.placeholder { background: var(--bg-glow); color: var(--accent); padding: 0 4px; border-radius: 3px; font: .85em var(--mono); }

.button {
  display: inline-block; padding: 10px 20px; border-radius: 999px;
  background: var(--fg); color: var(--bg); font: 600 16px var(--sans);
  text-decoration: none; transition: background .2s;
}
.button:hover { background: var(--accent); color: var(--bg); }
.contact-cta small { font: 14px var(--mono); color: var(--muted); }
.contact-cta small a { text-decoration: none; color: inherit; }

.post-nav { display: flex; justify-content: space-between; gap: 24px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.post-nav a { text-decoration: none; max-width: 48%; font-weight: 600; }
.post-nav a.next { text-align: right; margin-left: auto; }
.post-nav small { display: block; font: 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 400; }

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