/*
Theme Name: Hiqjj Journal
Theme URI: https://www.hiqjj.org/
Description: Clean, content-first dev journal for Hiqjj. System fonts, light and dark mode, no external requests.
Version: 1.0.0
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: hiqjj-journal
*/

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #6b6f76;
  --faint: #9a9ea5;
  --line: #e7e4dd;
  --accent: #b4690e;
  --accent-ink: #8a4f08;
  --mark: #e8a317;
  --mark-ink: #1d1f23;
  --tag-bg: #f2efe8;
  --code-bg: #f4f2ed;
  --pre-bg: #1e2127;
  --pre-text: #e6e6e6;
  --focus: #2f6fed;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --w: 720px;
  --w-wide: 960px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1b1e23;
    --text: #e8e6e1;
    --muted: #a3a7ad;
    --faint: #767a81;
    --line: #2a2e35;
    --accent: #f0b04a;
    --accent-ink: #f6c877;
    --mark: #f0b04a;
    --mark-ink: #14161a;
    --tag-bg: #23272e;
    --code-bg: #23272e;
    --pre-bg: #0f1114;
    --pre-text: #e6e6e6;
    --focus: #8ab4ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video, iframe { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--mark) 35%, transparent); }

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 20px; }
.screen-reader-text, .skip-link:not(:focus) {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { max-width: var(--w-wide); display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; font-size: 18px; flex-shrink: 0; }
.brand:hover { color: var(--text); }
.mark { color: var(--mark); display: block; flex-shrink: 0; }
.site-nav { flex: 1; min-width: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav-list::-webkit-scrollbar { display: none; }
.nav-list a {
  display: block; padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500;
}
.nav-list a:hover { color: var(--text); background: var(--tag-bg); }
.nav-list .current-menu-item > a { color: var(--text); }
.nav-members a { color: var(--accent-ink); }
.search input {
  width: 160px; height: 34px; padding: 0 12px;
  font: 14px var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  transition: width .2s, border-color .2s;
}
.search input:focus { width: 220px; outline: none; border-color: var(--accent); }

/* ---------- Home intro ---------- */
.intro { padding: 64px 0 40px; }
.intro h1 { font-size: clamp(30px, 5vw, 40px); line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 14px; font-weight: 750; }
.intro p { color: var(--muted); font-size: 18px; margin: 0 0 24px; max-width: 34em; }
.topic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.topic-list .tag span { color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }

.section-label, .kicker {
  font: 600 12px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
}
.section-label { margin: 0 0 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.kicker { margin: 0 0 14px; }
.kicker a { color: var(--accent-ink); text-decoration: none; }

/* ---------- Post list ---------- */
.post-list { list-style: none; margin: 0 0 40px; padding: 0; }
.post-row { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.post-date { font: 13px/1.9 var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.post-title { font-size: 20px; line-height: 1.35; letter-spacing: -0.012em; margin: 0 0 6px; font-weight: 650; }
.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { color: var(--accent-ink); }
.post-excerpt { margin: 0 0 10px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; font-size: 13px; color: var(--faint); }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--tag-bg); color: var(--muted); font-size: 13px; line-height: 1.5; text-decoration: none; font-weight: 500;
}
a.tag:hover { color: var(--text); }

.list-header { padding: 56px 0 24px; }
.list-header h1 { font-size: clamp(28px, 4.5vw, 36px); letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
.list-desc { color: var(--muted); margin-top: 10px; }
.empty { color: var(--muted); padding: 32px 0; }

.pagination { margin: 0 0 64px; }
.pagination .nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination .page-numbers { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); font-size: 14px; }
.pagination .current { color: var(--text); border-color: var(--text); }

/* ---------- Article ---------- */
.article-header { padding-top: 56px; padding-bottom: 8px; }
.article-title { font-size: clamp(30px, 5.2vw, 44px); line-height: 1.12; letter-spacing: -0.028em; margin: 0 0 16px; font-weight: 750; text-wrap: balance; }
.article-meta { margin: 0 0 32px; color: var(--faint); font-size: 14px; }
.article-cover { max-width: var(--w-wide); margin: 0 auto 40px; }
.article-cover img { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--line); }

.prose { font-size: 18px; line-height: 1.75; overflow-wrap: break-word; }
.prose > * { margin-top: 0; margin-bottom: 1.25em; }
.prose h2 { font-size: 1.45em; line-height: 1.3; letter-spacing: -0.015em; margin: 2em 0 .7em; font-weight: 700; }
.prose h3 { font-size: 1.18em; line-height: 1.35; margin: 1.8em 0 .6em; font-weight: 650; }
.prose h4 { font-size: 1em; margin: 1.6em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--faint); }
.prose blockquote, .prose .wp-block-quote {
  margin-left: 0; padding: 2px 0 2px 20px; border-left: 3px solid var(--mark); color: var(--muted); font-style: normal;
}
.prose hr, .prose .wp-block-separator { border: 0; border-top: 1px solid var(--line); margin: 2.5em auto; width: 100%; }
.prose img, .prose .wp-block-image img { border-radius: 10px; border: 1px solid var(--line); }
.prose figure { margin-left: 0; margin-right: 0; }
.prose figcaption, .prose .wp-element-caption { font-size: 14px; color: var(--faint); text-align: center; margin-top: 8px; }
.prose .alignwide { width: min(var(--w-wide) - 40px, calc(100vw - 40px)); max-width: none; margin-left: 50%; transform: translateX(-50%); }
.prose .alignfull { width: 100vw; margin-left: calc(50% - 50vw); max-width: none; }
.prose .alignfull img { border-radius: 0; border-left: 0; border-right: 0; }

.prose code, .prose kbd {
  font: .86em var(--mono); background: var(--code-bg); padding: .15em .4em; border-radius: 5px;
}
.prose pre, .prose .wp-block-code {
  font: 14.5px/1.6 var(--mono); background: var(--pre-bg); color: var(--pre-text);
  padding: 18px 20px; border-radius: 10px; overflow-x: auto; tab-size: 4;
  border: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
}
.prose pre code, .prose .wp-block-code code { background: none; padding: 0; font-size: inherit; color: inherit; border-radius: 0; }

.prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; }

.article-footer { padding-top: 16px; padding-bottom: 8px; }
.article-footer > .post-meta { margin-bottom: 28px; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid var(--line); padding-top: 24px; margin-bottom: 24px; }
.post-nav a {
  display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; line-height: 1.4; background: var(--surface);
}
.post-nav a:hover { border-color: var(--accent); }
.post-nav a span { display: block; font: 500 12px var(--mono); color: var(--faint); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.post-nav .next { text-align: right; grid-column: 2; }

/* ---------- Comments ---------- */
.comments { border-top: 1px solid var(--line); padding: 32px 0 64px; }
.comments-title, .comment-reply-title { font-size: 20px; margin: 0 0 16px; letter-spacing: -0.01em; }
.comment-reply-title small { font-size: 14px; font-weight: 400; margin-left: 8px; }
.comment-list, .comment-list .children { list-style: none; margin: 0 0 32px; padding: 0; }
.comment-list .children { padding-left: 24px; border-left: 2px solid var(--line); margin: 12px 0 0; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 14px; margin-bottom: 6px; }
.comment-author { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.comment-author .avatar { border-radius: 50%; }
.comment-author .says { display: none; }
.comment-metadata a { color: var(--faint); text-decoration: none; font-size: 13px; }
.comment-content p { margin: .4em 0; }
.reply a { font-size: 13px; }
.comment-notes, .logged-in-as { font-size: 14px; color: var(--muted); }
.comment-form { display: grid; gap: 14px; }
.comment-form p { margin: 0; }
.comment-form .form-submit { order: 99; }
.comment-form .required { color: var(--accent); }
.cf-turnstile { margin: 0 !important; min-height: 65px; }
.comment-form label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form textarea, .search-inline input {
  width: 100%; padding: 10px 12px; font: 16px var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.comment-form input:focus, .comment-form textarea:focus, .search-inline input:focus { outline: none; border-color: var(--accent); }
.comment-form-cookies-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.comment-form-cookies-consent label { font-weight: 400; margin: 0; }
.btn, .comment-form .submit {
  appearance: none; border: 0; cursor: pointer;
  background: var(--text); color: var(--bg); font: 600 15px var(--sans);
  padding: 10px 18px; border-radius: 8px;
}
.btn:hover, .comment-form .submit:hover { background: var(--accent-ink); color: #fff; }
.search-inline { display: flex; gap: 8px; margin-top: 20px; max-width: 420px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; }
.footer-inner { max-width: var(--w-wide); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 24px; padding-bottom: 32px; font-size: 14px; color: var(--faint); }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .header-inner { height: auto; flex-wrap: wrap; gap: 8px 12px; padding-top: 10px; padding-bottom: 8px; }
  .brand { order: 1; }
  .search { order: 2; margin-left: auto; }
  .search input, .search input:focus { width: 140px; }
  .site-nav { order: 3; flex-basis: 100%; margin: 0 -10px; }
  .intro { padding: 40px 0 28px; }
  .post-row { grid-template-columns: 1fr; gap: 4px; padding: 20px 0; }
  .post-date { order: -1; padding: 0; }
  .prose { font-size: 17px; }
  .prose pre, .prose .wp-block-code { margin-left: -20px; margin-right: -20px; border-radius: 0; border-left: 0; border-right: 0; font-size: 13.5px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { grid-column: 1; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

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