/* Clotbust Review — minimal reader-friendly CSS.
   Goal: do not interfere with the user's reading flow.
   WJC-style <details> blocks render as soft cards. */

:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #666;
  --rule: #e3e3e3;
  --accent: #2c5282;
  --details-bg: #f3f5f8;
  --details-open-bg: #ffffff;
  --code-bg: #f5f5f0;
  --max-width: 800px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --fg: #e6e6e6;
    --muted: #9a9a9a;
    --rule: #2a2d30;
    --accent: #7ab7ff;
    --details-bg: #1f2226;
    --details-open-bg: #1a1d20;
    --code-bg: #202327;
  }
}

* { box-sizing: border-box; }

html {
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
}
.site-header .container {
  display: flex; justify-content: space-between; align-items: center;
  max-width: var(--max-width);
}
.site-title {
  font-weight: 700; color: var(--fg); text-decoration: none; font-size: 1.15rem;
}
.site-nav a { color: var(--muted); text-decoration: none; margin-left: 1rem; font-size: 0.95rem; }
.site-nav a:hover { color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3rem;
  margin-top: 4rem;
  color: var(--muted); font-size: 0.875rem;
}
.site-footer a { color: var(--accent); }

/* Post list (home + term) */
.post-list { list-style: none; padding: 0; margin: 2rem 0; }
.post-list li { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: none; }
.post-list h2 { margin: 0 0 0.4rem; font-size: 1.35rem; }
.post-list h2 a { color: var(--fg); text-decoration: none; }
.post-list h2 a:hover { color: var(--accent); }
.post-list .meta { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0; }
.post-list .summary { margin: 0.5rem 0 0; }

.tag {
  display: inline-block; background: var(--details-bg);
  color: var(--muted); font-size: 0.8rem; padding: 0.1rem 0.5rem;
  border-radius: 3px; text-decoration: none; margin: 0 0.15rem;
}
.tag:hover { background: var(--accent); color: #fff; }

/* Post header + body */
.post-header { margin: 2.5rem 0 1.5rem; }
.post-header h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 0.5rem; }
.post-header .meta { color: var(--muted); font-size: 0.9rem; margin: 0; }
.post-header .meta a { color: var(--muted); }
.hero { margin: 1rem 0 2rem; }
.hero img { width: 100%; height: auto; border-radius: 4px; display: block; max-width: 100%; }
.hero figcaption { font-size: 0.825rem; color: var(--muted); margin-top: 0.5rem; }

.post-body { max-width: 100%; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 { overflow-wrap: break-word; word-wrap: break-word; }
.post-body h1 { font-size: 1.6rem; line-height: 1.25; margin-top: 0; }
.post-body h2 { font-size: 1.4rem; margin-top: 2.5rem; }
.post-body h3 { font-size: 1.15rem; margin-top: 2rem; }
.post-body p { margin: 1rem 0; overflow-wrap: break-word; word-wrap: break-word; }
.post-body ul, .post-body ol {
  margin: 1rem 0; padding-left: 1.5rem;
  max-width: 100%; overflow-wrap: break-word;
}
.post-body li { margin: 0.4rem 0; overflow-wrap: break-word; word-wrap: break-word; }
.post-body li > strong,
.post-body li > code,
.post-body li > a { overflow-wrap: anywhere; }
.post-body blockquote {
  border-left: 3px solid var(--accent); margin: 1.25rem 0; padding: 0.25rem 1rem;
  color: var(--muted); overflow-wrap: break-word;
}
.post-body code { background: var(--code-bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.9em; overflow-wrap: anywhere; }
.post-body pre {
  background: var(--code-bg); padding: 1rem; border-radius: 4px;
  overflow-x: auto; max-width: 100%; white-space: pre-wrap; word-wrap: break-word;
}
.post-body table {
  border-collapse: collapse; width: 100%; max-width: 100%; margin: 1rem 0;
  font-size: 0.95rem; table-layout: fixed;
}
.post-body table th, .post-body table td {
  border: 1px solid var(--rule); padding: 0.5rem; text-align: left;
  overflow-wrap: break-word; word-wrap: break-word;
}
.post-body table th { background: var(--details-bg); }
.post-body hr { border: none; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* WJC-style collapsible details blocks. */
.post-body details {
  background: var(--details-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0;
  margin: 1rem 0;
  transition: background 0.15s ease;
  max-width: 100%;
}
.post-body details[open] {
  background: var(--details-open-bg);
}
.post-body details summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  list-style: none;
  position: relative;
}
.post-body details summary::-webkit-details-marker { display: none; }
.post-body details summary::before {
  content: "▸"; display: inline-block; margin-right: 0.5rem; color: var(--muted);
  transition: transform 0.15s ease;
}
.post-body details[open] summary::before { transform: rotate(90deg); }
.post-body details[open] summary { border-bottom: 1px solid var(--rule); }
.post-body details > *:not(summary):not(ul):not(ol) {
  padding: 0 1.5rem;
  max-width: 100%;
  overflow-wrap: break-word;
  box-sizing: border-box;
}
/* Lists inside details — explicit margin-left (not padding-left) so the
   bullet glyph sits inside the dropdown window, not at the column edge.
   With list-style-position: outside, the bullet renders at the ul's
   left edge and the text wraps in the ul's content area — putting the
   bullet at ul_left_edge = (column + 1.5rem) means the visible bullet
   is 1.5rem from the dropdown's left edge, matching the summary text's
   indent. */
.post-body details > ul,
.post-body details > ol {
  margin: 0.5rem 0 0.5rem 1.5rem;
  padding-left: 0;
  list-style-position: outside;
}
.post-body details ul ul,
.post-body details ol ol {
  margin-left: 1.5rem;
}
.post-body details li {
  margin: 0.4rem 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
/* Inside the dropdown, also pad figures and paragraphs uniformly. */
.post-body details figure {
  margin: 1rem 0;
  max-width: 100%;
}
.post-body details figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}
.post-body details figure figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* Figure lightbox: zoomable figures + native <dialog> preview. */
.post-body figure.zoomable,
.post-body figure.hero.zoomable {
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.post-body figure.zoomable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.post-body figure.zoomable img {
  cursor: zoom-in;
}

/* Native <dialog> styled as a centered modal */
dialog.figure-dialog {
  position: fixed;
  inset: 0;
  width: min(95vw, 1200px);
  max-height: 95vh;
  margin: auto;
  padding: 1rem;
  background: var(--details-open-bg, #ffffff);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  overflow: auto;
}
dialog.figure-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}
dialog.figure-dialog img.figure-dialog-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto 1rem;
  border-radius: 4px;
}
dialog.figure-dialog figcaption.figure-dialog-caption {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.5rem;
  padding: 0 1rem;
  line-height: 1.5;
}
dialog.figure-dialog .figure-dialog-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  font-size: 1.5rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
dialog.figure-dialog .figure-dialog-close:hover {
  background: var(--details-bg);
}
@media (max-width: 640px) {
  dialog.figure-dialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* Comments */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.comments h2 { font-size: 1.2rem; margin-top: 0; }
.comments-note { color: var(--muted); font-size: 0.875rem; }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; margin: 2rem 0; }
.pagination .page-info { color: var(--muted); font-size: 0.9rem; }

/* Empty state */
.empty { color: var(--muted); font-style: italic; }

/* See-more link on home */
.see-more { margin: 2rem 0; }

/* Figures block */
.post-body figure { margin: 1.5rem 0; max-width: 100%; }
.post-body figure img { max-width: 100%; height: auto; border-radius: 4px; display: block; }
.post-body figure figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }

/* Responsive — narrower on small viewports. */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .container { padding: 0 1rem; }
  .post-header h1 { font-size: 1.6rem; }
  .post-body h1 { font-size: 1.35rem; }
  .post-body h2 { font-size: 1.2rem; }
  .site-header .container { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .site-nav a { margin-left: 0; margin-right: 1rem; }
}

/* Wider on very wide viewports, but still capped for readability. */
@media (min-width: 1400px) {
  :root { --max-width: 880px; }
}
