/* ============================================================
   Inkwell — public blog (v2)
   Requires assets/tokens.css FIRST (shared tokens + dual theme),
   so the blog and the notes app stay visually identical.
   Reading measure is user-adjustable via --read-w.
   ============================================================ */

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16.5px/1.72 var(--sans);
  min-height: 100%; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: 2px; }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-sm);
}

/* the measure every band shares */
.wrap, .site-header, main, .site-footer {
  width: 100%; margin-inline: auto;
  max-width: min(var(--read-w), 100% - 32px);
}

/* ---------- header ---------- */
.site-header {
  padding: 46px 0 14px;
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
}
.site-title {
  font-size: 29px; font-weight: 800; text-decoration: none; color: var(--fg);
  letter-spacing: -.3px; transition: color var(--t);
}
.site-title:hover { color: var(--accent); }
.site-title .logo { color: var(--accent); }
.tagline { color: var(--fg-dim); font-size: 14px; }

/* header controls (theme toggle) — injected by blog.js */
.site-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.site-tools button {
  background: transparent; color: var(--fg-dim); border: 1px solid transparent;
  border-radius: var(--r); padding: 5px 9px; cursor: pointer; font: inherit; font-size: 14px;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.site-tools button:hover { background: var(--bg3); color: var(--fg); border-color: var(--border); }

main { padding: 20px 0; flex: 1; }
.loading, .empty { color: var(--fg-dim); text-align: center; margin-top: 70px; }

/* ---------- post list ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px 26px; margin-bottom: 18px;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.card:hover {
  border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--sh-2);
}
.card h2 { margin: 0 0 5px; font-size: 21px; letter-spacing: -.2px; }
.card h2 a { text-decoration: none; color: var(--fg); transition: color var(--t); }
.card h2 a:hover { color: var(--accent); }
.meta { color: var(--fg-dim); font-size: 13px; margin-bottom: 9px; }
.tag {
  color: var(--accent); background: var(--accent-soft); border-radius: 12px;
  padding: 1.5px 9px; font-size: 12px;
}
.excerpt { margin: 0; color: var(--fg-dim); font-size: 14.5px; }

/* ---------- single post ---------- */
.post .back {
  display: inline-block; margin-bottom: 20px; text-decoration: none; font-size: 14px;
  color: var(--fg-dim); transition: color var(--t);
}
.post .back:hover { color: var(--accent); }
.post h1 { font-size: 35px; margin: 0 0 8px; line-height: 1.22; letter-spacing: -.6px; }
.post .content { margin-top: 28px; }

/* ---------- rendered markdown ---------- */
.content > *:first-child { margin-top: 0; }
.content h1, .content h2, .content h3 {
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
  margin-top: 2em; margin-bottom: .6em; letter-spacing: -.2px; font-weight: 650;
}
.content h3 { border-bottom: none; }
.content h4, .content h5, .content h6 { margin-top: 1.6em; margin-bottom: .5em; font-weight: 650; }
.content blockquote {
  margin: 1.1em 0; padding: 8px 18px; border-left: 3px solid var(--accent);
  color: var(--fg-dim); background: var(--accent-soft); border-radius: 0 var(--r) var(--r) 0;
}
.content blockquote > *:first-child { margin-top: 0; }
.content blockquote > *:last-child { margin-bottom: 0; }
.content pre {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.6;
}
:root[data-theme="light"] .content pre { background: #f6f7f9; }
.content code {
  font-family: var(--mono); background: var(--bg3); padding: 1.5px 6px;
  border-radius: var(--r-sm); font-size: .89em;
}
.content pre code { background: none; padding: 0; }
.content table { border-collapse: collapse; margin: 16px 0; display: block; overflow-x: auto; max-width: 100%; }
.content th, .content td { border: 1px solid var(--border); padding: 7px 14px; }
.content th { background: var(--bg3); font-weight: 650; text-align: left; }
.content tr:nth-child(even) { background: var(--bg2); }
.content img { max-width: 100%; border-radius: var(--r-lg); }
.content hr { border: none; border-top: 1px solid var(--border); margin: 30px 0; }
.content input[type="checkbox"] { accent-color: var(--accent2); margin-right: 4px; }
.content ul, .content ol { padding-left: 1.5em; }
.content li { margin: .28em 0; }

/* ---------- reading-width handle (NEW) ---------- */
/* Pinned to the right edge of the centred measure; drag widens symmetrically. */
#readResize {
  position: fixed; top: 0; bottom: 0; width: 12px; z-index: 20; cursor: col-resize;
  left: calc(50% + min(var(--read-w), 100% - 32px) / 2 - 6px);
}
#readResize::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 3px; height: 46px; margin: -23px 0 0 -1.5px; border-radius: 3px;
  background: var(--border); transition: background var(--t), height var(--t);
}
#readResize:hover::before, #readResize:focus-visible::before {
  background: var(--accent); height: 76px; margin-top: -38px;
}
#readResize.dragging::before { background: var(--accent); }
body.rw-resizing { cursor: col-resize; user-select: none; }
body.rw-resizing * { cursor: col-resize !important; }

/* ---------- footer ---------- */
.site-footer {
  padding: 34px 0 44px; color: var(--fg-dim); font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-top: 1px solid var(--border-soft); margin-top: 30px;
}
.admin-link { text-decoration: none; opacity: .4; font-size: 15px; transition: opacity var(--t); }
.admin-link:hover { opacity: 1; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); background-clip: content-box; }

/* ---------- small screens ---------- */
@media (max-width: 780px) {
  body { font-size: 16px; }
  .site-header { padding-top: 30px; }
  .post h1 { font-size: 28px; }
  #readResize { display: none; }   /* no room to spare; measure is already fluid */
}
@media (pointer: coarse) {
  #readResize { width: 20px; left: calc(50% + min(var(--read-w), 100% - 32px) / 2 - 10px); }
}
