/* ------------------------------------------------------------------ *
 * Matti — a calm, warm personal blog.
 * Warm paper, a serif for titles, quiet colour used with restraint.
 * ------------------------------------------------------------------ */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-wght-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

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

:root {
  /* Warm paper, soft ink */
  --paper:    #faf6ef;
  --paper-2:  #f2ebdd;   /* tinted cards (thoughts) */
  --ink:      #2b2620;
  --ink-soft: #574f44;
  --muted:    #938a79;
  --faint:    #b8ae9b;
  --line:     #e6ddca;

  /* Quiet colour */
  --accent:   #b0532a;   /* terracotta — links, titles on hover */
  --accent-2: #6f7a56;   /* sage — secondary marks, "reading" */

  --color-code-bg: #efe8d8;

  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono:  "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  --reading-width: 40rem;
}

html {
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
li { list-style: none; }
button { font: inherit; background: none; border: 0; color: inherit; cursor: pointer; }
strong, b { font-weight: 600; }

small { font-size: .85rem; color: var(--muted); }

::selection { background: var(--accent); color: #fff; }

/* Serif titles */
.serif,
.brand,
.page-title,
.article-title,
.entry-title,
.thought-title,
.book-title,
.text h2,
.text h3 {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-weight: 500;
  letter-spacing: -0.005em;
}

/* ------------------------------------------------------------------ *
 * Layout — sidebar + reading column
 * ------------------------------------------------------------------ */

/* The content is a single column, centred in the page like a feed.
   On narrow/medium screens the nav stacks on top of the centred column.
   On wide screens a symmetric grid puts the nav in the left margin while
   keeping the reading column dead-centre in the viewport. */
.layout {
  max-width: 43rem;            /* reading column + padding */
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.main { min-width: 0; }
.wrap { width: 100%; max-width: var(--reading-width); }

@media screen and (min-width: 80rem) {
  .layout {
    /* spacer | nav | gap | content | gap | (phantom nav) | spacer
       The mirrored right-hand columns keep the content column centred
       in the viewport, with the nav sitting in the left margin. */
    display: grid;
    grid-template-columns: 1fr 12rem 2.5rem minmax(0, 40rem) 2.5rem 12rem 1fr;
    max-width: none;
    padding: 5rem 1.5rem 7rem;
  }
  .sidebar { grid-column: 2; }
  .main     { grid-column: 4; }
}

/* ------------------------------------------------------------------ *
 * Sidebar
 * ------------------------------------------------------------------ */

.sidebar { margin-bottom: 3rem; }

/* Wide screens: nav sits in the left margin, sticky as you scroll. */
@media screen and (min-width: 80rem) {
  .sidebar {
    position: sticky;
    top: 5rem;
    align-self: start;
    margin-bottom: 0;
  }
}

.brand {
  display: inline-block;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: .35rem;
}

.brand-tagline {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
  margin-bottom: 1.75rem;
  max-width: 12rem;
}

.nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 1.25rem; }

.nav a {
  color: var(--muted);
  padding: .15rem 0;
  width: fit-content;
  transition: color .15s ease;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current] {
  color: var(--ink);
  font-weight: 500;
  box-shadow: inset 0 -2px 0 var(--accent);
}

@media screen and (min-width: 80rem) {
  .nav { flex-direction: column; gap: .2rem; }
}

.sidebar-social { display: flex; gap: 1rem; margin-top: 1.5rem; }
.sidebar-social a { color: var(--faint); transition: color .15s ease; }
.sidebar-social a:hover { color: var(--accent); }
.sidebar-social svg { width: 1.05rem; height: 1.05rem; display: block; }

@media screen and (min-width: 80rem) {
  .sidebar-social { margin-top: 2rem; }
}

/* ------------------------------------------------------------------ *
 * Page head
 * ------------------------------------------------------------------ */

.page-head { margin-bottom: 3rem; max-width: var(--reading-width); }

.page-title {
  font-size: 2rem;
  line-height: 1.15;
}
.page-lead {
  color: var(--muted);
  margin-top: .6rem;
  font-size: 1.05rem;
}
.page-lead a { color: var(--accent); }

/* ------------------------------------------------------------------ *
 * Home feed — one quiet stream of journal entries.
 * Short and mid-length posts read in full; only long ones fold away.
 * No boxes — the rhythm comes from space and hairlines.
 * ------------------------------------------------------------------ */

.feed {
  display: flex;
  flex-direction: column;
  max-width: var(--reading-width);
}

.post {
  padding: 2.75rem 0;
  border-top: 1px solid var(--line);
}
.post:first-child { border-top: 0; padding-top: 0; }

.post-date {
  display: inline-block;
  font-size: .82rem;
  letter-spacing: .02em;
  color: var(--accent-2);
  margin-bottom: .4rem;
}
.post-date:hover { color: var(--accent); }

.post-title {
  font-size: 1.6rem;
  line-height: 1.18;
}
.post-title a:hover { color: var(--accent); }

.post-body {
  margin-top: 1rem;
  font-size: 1.06rem;
  line-height: 1.72;
}
.post-body > :last-child { margin-bottom: 0; }

.post-lead { color: var(--ink-soft); }

.more {
  display: inline-block;
  margin-top: 1rem;
  font-size: .95rem;
  color: var(--accent);
}
.more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ *
 * Single post
 * ------------------------------------------------------------------ */

.article { max-width: var(--reading-width); }
.article-head { margin-bottom: 2.5rem; }
.article-meta {
  display: block;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: .9rem;
}
.article-title {
  font-size: 2.2rem;
  font-weight: 560;
  line-height: 1.12;
}
.article-subtitle {
  color: var(--ink-soft);
  font-size: 1.15rem;
  margin-top: .7rem;
  line-height: 1.4;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}
.article-cover { margin: 0 0 2.5rem; }
.article-cover img { border-radius: 4px; }

.article-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--muted);
  font-size: .85rem;
}
.article-tags { display: flex; gap: .6rem; flex-wrap: wrap; }
.article-tags a { color: var(--accent-2); }
.article-tags a:hover { color: var(--accent); }

.prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: .9rem;
}
.prevnext a { color: var(--muted); }
.prevnext a:hover { color: var(--accent); }

/* ------------------------------------------------------------------ *
 * Library — cover grid
 * ------------------------------------------------------------------ */

.library-group { margin-bottom: 3.5rem; }
.library-group > h2 {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-2);
  margin-bottom: 1.5rem;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 2rem 1.75rem;
}

.book { display: flex; flex-direction: column; }
.book-cover {
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper-2);
  box-shadow: 0 1px 2px rgba(43, 38, 32, .12), 0 8px 18px rgba(43, 38, 32, .10);
  transition: transform .18s ease, box-shadow .18s ease;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book:hover .book-cover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(43, 38, 32, .14), 0 14px 26px rgba(43, 38, 32, .16);
}
.book-meta { margin-top: .7rem; }
.book-title { font-size: 1rem; line-height: 1.25; }
.book-author { color: var(--muted); font-size: .85rem; margin-top: .1rem; }
.book-note {
  color: var(--ink-soft);
  font-size: .85rem;
  margin-top: .4rem;
  font-family: var(--font-serif);
  font-style: italic;
}

/* ------------------------------------------------------------------ *
 * Long-form text (blocks / kirbytext)
 * ------------------------------------------------------------------ */

.text { max-width: var(--reading-width); }
.text > :first-child { margin-top: 0; }
.text > :last-child { margin-bottom: 0; }

.text p, .text ul, .text ol { margin-bottom: 1.4rem; }

.text a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(176, 83, 42, .35);
  text-underline-offset: 2px;
  transition: text-decoration-color .15s ease;
}
.text a:hover { text-decoration-color: var(--accent); }

.text h2 { font-size: 1.4rem; margin: 2.75rem 0 1rem; line-height: 1.25; }
.text h3 { font-size: 1.15rem; margin: 2rem 0 .75rem; }

.text ul, .text ol { margin-left: 1.1rem; }
.text ul > li { list-style: disc; }
.text ol > li { list-style: decimal; }
.text li { margin-bottom: .35rem; }
.text li p { margin-bottom: 0; }
.text ul ul, .text ul ol, .text ol ul, .text ol ol { margin-bottom: 0; }

.text blockquote {
  border-left: 2px solid var(--accent-2);
  padding-left: 1.25rem;
  margin: 2rem 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.2rem;
  line-height: 1.45;
}
.text blockquote footer {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: .85rem;
  margin-top: .5rem;
  color: var(--muted);
}

.text code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--color-code-bg);
  padding: .1rem .35rem;
  border-radius: 3px;
}
.text pre {
  margin: 2rem 0;
  background: #2b2620;
  color: #f2ebdd;
  padding: 1.25rem 1.4rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.6;
}
.text pre code { padding: 0; background: none; font-size: 1em; }

.text figure { margin: 2.5rem 0; }
.text figure img { border-radius: 4px; }
.text figcaption { padding-top: .6rem; color: var(--muted); font-size: .88rem; }

.text hr { border: 0; height: 1px; background: var(--line); margin: 3rem 0; }

.img, .video {
  position: relative;
  display: block;
  --w: 1; --h: 1;
  padding-bottom: calc(100% / var(--w) * var(--h));
  background: var(--paper-2);
  border-radius: 4px;
  overflow: hidden;
}
.img img, .video iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border: 0;
}

/* ------------------------------------------------------------------ *
 * Pagination & colophon
 * ------------------------------------------------------------------ */

.pagination {
  display: flex;
  gap: 1.5rem;
  margin-top: 3rem;
  font-size: .9rem;
  color: var(--muted);
}
.pagination a:hover { color: var(--accent); }

.colophon {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: .82rem;
  max-width: var(--reading-width);
}
.colophon a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); }
.colophon a:hover { color: var(--accent); }
