/* ==========================================================================
   leinonen.ninja — Margin Notes stylesheet
   Zen / space-first · serif body · monospace metadata · restrained accent
   --------------------------------------------------------------------------
   Self-hosted fonts (EB Garamond, Fraunces, JetBrains Mono)
   ========================================================================== */

/* ---------- Self-hosted Fonts ---------- */
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/eb-garamond-400.woff2') format('woff2');
}
@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/eb-garamond-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/eb-garamond-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('./fonts/fraunces-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/fraunces-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/fraunces-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/fraunces-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/fraunces-600.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-500.woff2') format('woff2');
}

/* ---------- Tokens ---------- */
:root {
  --accent:   #6d4463;                /* plum. swap for rust #a85a2c, ochre #b5873a, pine #3f6b4a, ink #2f4858 */
  --ink:      #1a1a17;
  --ink-70:   rgba(26, 26, 23, 0.70);
  --ink-50:   rgba(26, 26, 23, 0.50);
  --ink-30:   rgba(26, 26, 23, 0.30);
  --ink-15:   rgba(26, 26, 23, 0.15);
  --ink-08:   rgba(26, 26, 23, 0.08);
  --paper:    #f6f3ec;

  --serif-display: 'Fraunces', Georgia, serif;
  --serif-body:    'EB Garamond', Georgia, serif;
  --mono:          'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --gutter:     200px;   /* width of the left margin meta column */
  --gap:        24px;
  --max:        960px;   /* total content max-width */
  --pad-x:      56px;
  --pad-y:      72px;
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img, svg { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--ink-15); margin: 48px 0; }
::selection { background: var(--accent); color: var(--paper); }

/* ---------- Page wrapper ---------- */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--pad-y) var(--pad-x) 120px;
}

/* ---------- Masthead ---------- */
.site-header {
  display: grid;
  grid-template-columns: var(--gutter) 1fr auto;
  align-items: baseline;
  gap: var(--gap);
  margin-bottom: 96px;
}
.site-header .brand {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.site-header .brand .dot { color: var(--accent); }
.site-header .brand .tagline {
  display: block;
  color: var(--ink-50);
  margin-top: 4px;
}
.site-header .rule { height: 1px; background: var(--ink-15); }
.site-header nav {
  display: flex;
  gap: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-70);
}
.site-header nav a.active { color: var(--ink); }
.site-header nav a.active::before { content: "→ "; color: var(--accent); }
.header-search { display: flex; align-items: baseline; }
.header-search input {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-70);
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-15);
  outline: none;
  padding: 0 0 2px;
  width: 100px;
}
.header-search input::placeholder { color: var(--ink-30); }
.header-search input:focus { border-bottom-color: var(--ink-50); color: var(--ink); }

/* ---------- Promo / announcement strip (optional) ---------- */
.promo {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  padding: 18px 0 28px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--ink-15);
}
.promo .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.promo .meta .date {
  display: block;
  color: var(--ink-50);
  margin-top: 4px;
}
.promo .headline {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.promo .headline em { color: var(--accent); font-style: italic; }

/* ---------- Post list (home, tag archives) ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list > li {
  padding: 56px 0;
  border-bottom: 1px solid var(--ink-15);
}
article.post-preview {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
}
article.post-preview:last-of-type,
.post-list > li:last-of-type {
  border-bottom: none;
}
.post-preview .margin-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
  letter-spacing: 0.03em;
  padding-top: 10px;
}
.post-preview .margin-meta .num { color: var(--accent); font-weight: 500; }
.post-preview .margin-meta time,
.post-preview .margin-meta .readtime {
  display: block;
  color: var(--ink-70);
  margin-top: 6px;
}
.post-preview .margin-meta .tags {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.post-preview .margin-meta .tags a { color: var(--ink-70); }
.post-preview .margin-meta .tags a::before {
  content: "# ";
  color: var(--ink-30);
}
.post-preview h2 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.post-preview h2 a:hover { color: var(--accent); }
.post-preview p {
  color: var(--ink-70);
  font-size: 16.5px;
  line-height: 1.65;
  margin: 0 0 12px;
  max-width: 58ch;
}
.post-preview .readmore,
a.readmore {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.post-preview .readmore::after,
a.readmore::after { content: " ↗"; }

/* ---------- Pagination ---------- */
.pagination {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-top: 56px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-70);
}
.pagination .meta { color: var(--ink-50); }
.pagination .pages { display: flex; gap: 16px; flex-wrap: wrap; }
.pagination .pages a,
.pagination .pages .current { color: var(--ink-70); }
.pagination .pages .current { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-top: 96px;
  padding-top: 20px;
  border-top: 1px solid var(--ink-15);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
}

/* ==========================================================================
   Post detail
   ========================================================================== */
article.post {}
article.post .lede {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-bottom: 56px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--ink-15);
}
article.post .lede .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
  letter-spacing: 0.03em;
}
article.post .lede .meta .label { color: var(--accent); display: block; }
article.post .lede .meta time,
article.post .lede .meta .readtime {
  color: var(--ink-70);
  margin-top: 6px;
  display: block;
}
article.post .lede .meta .tags {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
article.post .lede .meta .tags a { color: var(--ink-70); }
article.post .lede .meta .tags a::before {
  content: "# ";
  color: var(--ink-30);
}
article.post h1 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 48px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  max-width: 22ch;
}
article.post .standfirst {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 300;
  font-size: 20px;
  line-height: 1.4;
  color: var(--ink-70);
  margin: 0;
  max-width: 38ch;
}
article.post .post-body {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
}
article.post .post-body > aside {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-50);
  letter-spacing: 0.04em;
}

/* long-form typography inside the content column */
article.post .content { max-width: 58ch; }
article.post .content > * { max-width: 58ch; }
article.post .content p { margin: 0 0 20px; }
article.post .content h2,
article.post .content h3 {
  font-family: var(--serif-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 44px 0 14px;
}
article.post .content h2 { font-size: 26px; }
article.post .content h3 { font-size: 22px; }
article.post .content blockquote {
  margin: 32px 0;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--ink-70);
  max-width: 52ch;
}
article.post .content ul,
article.post .content ol { padding-left: 1.25em; margin: 0 0 20px; }
article.post .content li { margin: 4px 0; }
article.post .content a { color: var(--accent); border-bottom: 1px solid currentColor; }
article.post .content hr { margin: 56px auto; width: 40%; }
article.post .content img {
  margin: 32px 0;
  border-radius: 2px;
  max-width: 100%;
}
article.post .content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--ink-08);
  padding: 2px 6px;
  border-radius: 3px;
}
article.post .content pre {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  background: #edeae0;
  color: var(--ink);
  padding: 20px 24px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 28px 0;
  max-width: 100%;
  border: 1px solid var(--ink-15);
}
article.post .content pre code { background: transparent; padding: 0; color: inherit; text-shadow: none; }
article.post .content code[class*="language-"],
article.post .content pre[class*="language-"] { text-shadow: none; }
article.post .content .token.operator,
article.post .content .token.entity,
article.post .content .token.url { background: transparent; }

/* post actions (like button) */
.post-actions {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--ink-15);
}

.post-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--ink-15);
}

.back-to-top {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-70);
  letter-spacing: 0.03em;
  text-decoration: none;
}
.back-to-top:hover { color: var(--ink); }

/* ==========================================================================
   About page (and other static pages)
   ========================================================================== */
.about-page {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
}
.about-page aside {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
}
.about-page aside dt {
  color: var(--ink);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.about-page aside dd {
  color: var(--ink-70);
  margin: 0 0 18px;
}
.about-page .lead {
  font-family: var(--serif-display);
  font-weight: 300;
  font-style: italic;
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 0 0 40px;
  max-width: 28ch;
}
.about-page h1 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 36px;
  letter-spacing: -0.02em;
  margin: 0 0 32px;
}
.about-page p { margin: 0 0 18px; max-width: 58ch; }
.about-page .content > * { max-width: 58ch; }
.about-page .content p { margin: 0 0 20px; }
.about-page .content h2,
.about-page .content h3 {
  font-family: var(--serif-display);
  font-weight: 400;
  margin: 36px 0 12px;
}
.about-page .content a { color: var(--accent); border-bottom: 1px solid currentColor; }
.about-page .content blockquote {
  margin: 24px 0;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--ink-70);
}
.about-page .content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--ink-08);
  padding: 2px 6px;
  border-radius: 3px;
}
.about-page .content pre {
  font-family: var(--mono);
  font-size: 13.5px;
  background: #edeae0;
  color: var(--ink);
  padding: 20px 24px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 28px 0;
  border: 1px solid var(--ink-15);
}
.about-page .content pre code { background: transparent; padding: 0; color: inherit; text-shadow: none; }
.about-page .content code[class*="language-"],
.about-page .content pre[class*="language-"] { text-shadow: none; }
.about-page .content .token.operator,
.about-page .content .token.entity,
.about-page .content .token.url { background: transparent; }

/* ==========================================================================
   Tags index
   ========================================================================== */
.tags-page {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
}
.tags-page aside {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
}
.tag-list { list-style: none; margin: 0; padding: 0; }
.tag-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  padding: 14px 0;
  border-bottom: 1px solid var(--ink-08);
  align-items: baseline;
}
.tag-list .tag {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-70);
}
.tag-list .tag::before { content: "# "; color: var(--ink-30); }
.tag-list li:hover .tag { color: var(--accent); }
.tag-list .count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-50);
}

/* Tag posts page heading */
.tag-posts-heading {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-bottom: 8px;
}
.tag-posts-heading h1 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 32px;
  letter-spacing: -0.02em;
  margin: 0;
}
.tag-posts-back {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-top: 48px;
}
.tag-posts-back a {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-70);
}

/* Search page heading */
.search-heading {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: var(--gap);
  margin-bottom: 8px;
}
.search-refine input {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--ink-70);
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-15);
  outline: none;
  padding: 0 0 4px;
  width: 100%;
}
.search-refine input:focus { border-bottom-color: var(--ink-50); color: var(--ink); }

/* ==========================================================================
   Mobile — stack the gutter column beneath the content
   ========================================================================== */
@media (max-width: 720px) {
  :root {
    --pad-x: 22px;
    --pad-y: 48px;
  }

  .site-header,
  .promo,
  article.post-preview,
  .pagination,
  .site-footer,
  article.post .lede,
  article.post .post-body,
  .about-page,
  .tags-page,
  .tag-posts-heading,
  .tag-posts-back,
  .search-heading {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .site-header { margin-bottom: 36px; }
  .site-header .rule { display: none; }
  .site-header nav { justify-content: flex-start; }

  .promo .meta {
    display: flex;
    justify-content: space-between;
  }
  .promo .meta .date { margin-top: 0; }
  .promo .headline { font-size: 26px; }

  .post-list > li { padding: 32px 0; }

  .post-preview .margin-meta {
    padding-top: 0;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 14px;
  }
  .post-preview .margin-meta .num { margin-right: 8px; }
  .post-preview .margin-meta time,
  .post-preview .margin-meta .readtime { margin-top: 0; display: inline; }
  .post-preview .margin-meta .tags {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0;
    flex-basis: 100%;
  }
  .post-preview h2 { font-size: 24px; }

  article.post h1 { font-size: 32px; }
  article.post .standfirst { font-size: 17px; }
  article.post .lede .meta {
    display: flex;
    gap: 12px;
    justify-content: space-between;
  }
  article.post .lede .meta time,
  article.post .lede .meta .readtime { margin-top: 0; }

  .about-page .lead { font-size: 22px; }

  .tag-list li { grid-template-columns: 1fr auto; }
}

/* ==========================================================================
   Print — strip nav, make it read-ready
   ========================================================================== */
@media print {
  :root { --paper: #fff; }
  .site-header nav,
  .pagination,
  .site-footer,
  article.post .post-body > aside { display: none; }
  article.post .post-body,
  article.post .lede,
  .post-list > li,
  article.post-preview { grid-template-columns: 1fr; }
  body { font-size: 12pt; }
}

/* ==========================================================================
   Admin navbar (shown on public pages when logged in)
   ========================================================================== */
.admin-navbar {
    background: #000000;
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.admin-navbar-content {
    max-width: var(--max);
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 12px;
}
.admin-navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.admin-nav-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s ease;
    font-family: var(--mono);
}
.admin-nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.admin-logout-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--mono);
}
.admin-logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}
@media (max-width: 768px) {
    .admin-navbar-content { padding: 10px 16px; flex-direction: column; gap: 8px; }
    .admin-navbar-right { gap: 12px; }
    .admin-nav-link, .admin-logout-btn { font-size: 13px; padding: 4px 8px; }
}

/* ==========================================================================
   Edit button (shown on public pages when logged in)
   ========================================================================== */
.post-header, .page-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 4px;
}
.edit-btn {
    background: var(--accent);
    color: var(--paper);
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 3px;
    font-size: 11px;
    font-family: var(--mono);
    letter-spacing: 0.04em;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}
.edit-btn:hover {
    opacity: 0.8;
    color: var(--paper);
}

/* ==========================================================================
   Like button
   ========================================================================== */
.like-button {
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
}
.like-btn {
    background: none;
    border: 1px solid var(--ink-15);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink-70);
    transition: all 0.2s ease;
    font-family: var(--mono);
    position: relative;
    overflow: hidden;
}
.like-btn:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
    transform: translateY(-1px);
}
.like-btn:active { transform: translateY(0); }
.heart-icon {
    width: 18px;
    height: 18px;
    transition: all 0.2s ease;
    color: currentColor;
}
.heart-icon.filled {
    color: #ff6b6b;
    animation: heartBeat 0.3s ease-in-out;
}
.like-button.liked .like-btn {
    border-color: #ff6b6b;
    color: #ff6b6b;
}
.like-count {
    font-weight: 500;
    font-size: 13px;
    min-width: 20px;
    text-align: center;
}
@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.like-btn.htmx-request { opacity: 0.7; cursor: not-allowed; }
.like-btn.htmx-request::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 16px; height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
