/* ================================================================
   Site Name — global styles
   ================================================================ */

:root {
  color-scheme: light dark;
  --bg: #fff;
  --text: #111;
  --muted: #666;
  --faint: #8a8a8a;
  --border: #e5e5e5;
  --border-strong: #cfcfcf;
  --inverse: #fff;
  --code-bg: #1e1e1e;
  --code-text: #f1f1f1;
  --content-width: 720px;
  --shell-width: 1060px;
  --radius: 0;

  /* Theme changes animate smoothly without delaying interaction. */
  background-color: var(--bg);
  color: var(--text);
  transition: background-color .3s ease-in-out, color .3s ease-in-out, border-color .3s ease-in-out;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --text: #111;
  --muted: #666;
  --faint: #8a8a8a;
  --border: #e5e5e5;
  --border-strong: #cfcfcf;
  --inverse: #fff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111;
  --text: #e5e5e5;
  --muted: #999;
  --faint: #777;
  --border: #333;
  --border-strong: #4a4a4a;
  --inverse: #111;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #111;
    --text: #e5e5e5;
    --muted: #999;
    --faint: #777;
    --border: #333;
    --border-strong: #4a4a4a;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.menu-open { overflow: hidden; }

img { max-width: 100%; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .15s ease;
}

.skip-link:focus { transform: translateY(0); }

.shell {
  width: min(calc(100% - 32px), var(--shell-width));
  margin-inline: auto;
}

.page-space { padding-block: 64px 96px; }

.site-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-name {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.menu-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.menu-toggle span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 1px;
  background: currentColor;
  transform: translate(-50%, -50%) translateY(-6px);
  transition: transform .3s ease-in-out, opacity .3s ease-in-out;
}

.menu-toggle span:nth-child(2) {
  transform: translate(-50%, -50%);
}

.menu-toggle span:nth-child(3) {
  transform: translate(-50%, -50%) translateY(6px);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translate(-50%, -50%) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: translate(-50%, -50%) scaleX(.6);
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.site-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.site-nav .nav-item {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-size: .88rem;
  line-height: 1.2;
}

.site-nav .nav-item:hover,
.site-nav .nav-item[aria-current="page"] {
  color: var(--text);
}

.site-nav .nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-nav .theme-toggle [hidden] {
  display: none;
}

body.menu-open .site-nav {
  display: flex;
  position: fixed;
  inset: 68px 0 0 0;
  min-height: calc(100vh - 68px);
  padding: 24px 16px 40px;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

body.menu-open .site-nav .nav-item {
  width: 100%;
  min-height: 52px;
  justify-content: flex-start;
  gap: 14px;
  padding-inline: 16px;
  border-bottom: 1px solid transparent;
}

body.menu-open .site-nav .nav-item:hover,
body.menu-open .site-nav .nav-item[aria-current="page"] {
  border-bottom-color: var(--border);
}

.intro {
  max-width: 640px;
  margin-bottom: 48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.18;
  letter-spacing: -.03em;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(2.1rem, 7vw, 4.25rem);
}

.intro-copy {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: .01em;
}

.result-count {
  color: var(--faint);
  font-size: .82rem;
}

.post-list { margin-top: 12px; }

.post-card {
  display: block;
  padding: 24px 0 26px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.post-card:first-child {
  border-top: 1px solid var(--border);
}

.post-card-title {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 650;
}

.post-card-summary {
  margin: 0 0 14px;
  color: var(--muted);
}

.post-card-date {
  color: var(--faint);
  font-size: .8rem;
}

.post-card-tags {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
}

.tag-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inline-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.inline-tag {
  color: var(--muted);
  font-size: .8rem;
}

.post-card mark {
  background: var(--text);
  color: var(--bg);
  padding: 0 .12em;
}

.status-box {
  padding: 24px 0;
  margin-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.status-box a { text-underline-offset: 3px; }

.text-link-button {
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--faint);
  font-size: .78rem;
}

.footer-inner p { margin: 0; }

.footer-inner a { text-underline-offset: 3px; }

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.social-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.article-wrap {
  max-width: var(--content-width);
  margin-inline: auto;
}

.article-status { color: var(--muted); }

.article-header { margin-bottom: 44px; }

.article-header h1 {
  font-size: clamp(2.25rem, 8vw, 4rem);
  margin-bottom: 16px;
}

.article-summary {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1.05rem;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--faint);
  font-size: .82rem;
}

.article-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.article-tag { color: var(--muted); }

.article-content { font-size: 1rem; }

.article-content > *:first-child { margin-top: 0; }

.article-content h2 {
  margin: 2.3em 0 .65em;
  font-size: 1.65rem;
}

.article-content h3 {
  margin: 2em 0 .6em;
  font-size: 1.3rem;
}

.article-content h4 {
  margin: 1.6em 0 .5em;
  font-size: 1.05rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content table {
  margin: 0 0 1.25em;
}

.article-content ul,
.article-content ol {
  padding-left: 1.3rem;
}

.article-content li + li { margin-top: .35em; }

.article-content a { text-underline-offset: 3px; }

.article-content blockquote {
  margin-left: 0;
  padding-left: 18px;
  border-left: 2px solid var(--border-strong);
  color: var(--muted);
}

.article-content hr {
  margin: 2.6em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.article-content img {
  display: block;
  height: auto;
  margin: 1.8em auto;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.article-content th,
.article-content td {
  padding: 9px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-content th { font-weight: 650; }

.article-content :not(pre) > code {
  padding: .15em .35em;
  background: var(--border);
  font-size: .9em;
}

.code-wrap {
  position: relative;
  margin: 1.5em 0 1.7em;
}

.code-wrap pre {
  margin: 0;
  padding: 52px 84px 18px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--code-bg);
  color: var(--code-text);
}

.code-wrap pre code {
  display: block;
  min-width: max-content;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .84rem;
  line-height: 1.65;
}

.code-lang {
  position: absolute;
  top: 8px;
  left: 10px;
  color: #aaa;
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.copy-code {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 64px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #555;
  background: #2d2d2d;
  color: #eee;
  cursor: pointer;
}

.copy-code:hover { border-color: #888; }

.post-back {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-bottom: 36px;
  color: var(--muted);
  text-decoration: none;
}

.post-back:hover { color: var(--text); }

.prose { max-width: var(--content-width); }

.narrow-prose { max-width: 680px; }

.prose h1 { margin-bottom: 24px; }

.prose h2 {
  margin-top: 2.2em;
  font-size: 1.55rem;
}

.prose p { margin: 0 0 1.3em; }

.prose .muted { color: var(--muted); }

.search-main {
  min-height: calc(100vh - 145px);
}

.search-hero {
  max-width: 820px;
  margin-bottom: 56px;
}

.search-field-large {
  min-height: 70px;
}

.search-field-large input {
  min-height: 68px;
  font-size: clamp(1rem, 4vw, 2rem);
}

.search-hint {
  margin: 12px 0 0;
  color: var(--faint);
  font-size: .84rem;
}

.empty-page {
  min-height: calc(100vh - 145px);
  display: grid;
  place-items: center;
  text-align: center;
}

.empty-page section {
  width: min(100%, 540px);
}

.empty-page h1 {
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 8vw, 4rem);
}

.error-code {
  margin: 0 0 10px;
  color: var(--faint);
  font-size: .8rem;
  letter-spacing: .16em;
}

.empty-page p:not(.error-code) {
  margin: 0 0 18px;
  color: var(--muted);
}

.text-link { text-underline-offset: 3px; }

@media (min-width: 640px) {
  .shell {
    width: min(calc(100% - 56px), var(--shell-width));
  }

  .page-space { padding-block: 80px 112px; }

  .menu-toggle { display: none; }

  .site-nav { display: flex; }

  .site-nav .nav-item {
    padding-inline: 10px;
  }

  .post-card { padding-block: 28px; }

  .post-card-title { font-size: 1.45rem; }
}

@media (min-width: 1024px) {
  .shell {
    width: min(calc(100% - 80px), var(--shell-width));
  }

  .page-space { padding-block: 100px 128px; }

  .article-content { font-size: 1.05rem; }
}

@media (max-width: 639px) {
  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 18px;
  }

  .code-wrap pre {
    padding-right: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  :root,
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
