/*
Theme Name: Aching Notes
Theme URI: https://aching.cn
Author: sisthy
Description: A calm field-notes theme for technical writing and reproducible work.
Version: 0.2.1
Requires at least: 6.6
Tested up to: 7.0
Text Domain: aching-notes
*/

:root {
  color-scheme: light;
  --ink: #18211f;
  --ink-soft: #35413d;
  --muted: #5e6a66;
  --line: rgba(30, 48, 43, 0.14);
  --line-strong: rgba(30, 48, 43, 0.24);
  --paper: #eef3ef;
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --blue: #2864b8;
  --cyan: #0f7f8c;
  --green: #28755d;
  --orange: #a95f22;
  --code-bg: #15201e;
  --code-ink: #dbe8e3;
  --shadow: 0 22px 58px rgba(30, 48, 43, 0.11);
  --shadow-small: 0 10px 30px rgba(30, 48, 43, 0.07);
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(30, 48, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 48, 43, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 78% 0%, rgba(15, 127, 140, 0.09), transparent 33rem),
    var(--paper);
  background-size: 40px 40px, 40px 40px, auto, auto;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(40, 100, 184, 0.2);
}

a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--cyan);
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

button,
input,
textarea,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(40, 100, 184, 0.42);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 8px 13px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
}

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

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(238, 243, 239, 0.86);
  backdrop-filter: blur(20px) saturate(130%);
}

.admin-bar .site-header {
  top: 32px;
}

.header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 36px;
  width: min(calc(100% - 40px), 1180px);
  min-height: 76px;
  margin: 0 auto;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  line-height: 1.1;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--glass-strong);
  color: var(--green);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

.site-brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.primary-nav {
  min-width: 0;
}

.primary-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-menu a {
  display: block;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.primary-menu a:hover,
.primary-menu .current-menu-item > a,
.primary-menu .current-cat > a {
  background: rgba(255, 255, 255, 0.65);
  color: var(--blue);
}

.home-link {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.home-link span {
  color: var(--cyan);
}

.site-main {
  width: min(calc(100% - 40px), 1180px);
  margin: 0 auto;
  padding: 72px 0 38px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: clamp(32px, 5vw, 68px);
  align-items: start;
}

.content-primary {
  min-width: 0;
}

.index-head,
.archive-head {
  max-width: 840px;
  margin: 0 0 52px;
}

.eyebrow,
.rail-label {
  margin: 0 0 14px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
}

.page-title {
  max-width: 820px;
  margin: 0;
  font-size: clamp(40px, 6vw, 68px);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1.06;
}

.page-title span {
  color: var(--blue);
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.035em;
}

.archive-title {
  font-size: clamp(38px, 5vw, 60px);
}

.archive-title .page-title {
  font-size: inherit;
}

.page-lead {
  max-width: 700px;
  margin: 23px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.85;
}

.page-lead p {
  margin: 0;
}

.post-list {
  display: grid;
  gap: 14px;
}

.post-card {
  position: relative;
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 25px 27px;
  background: var(--glass);
  box-shadow: var(--shadow-small);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.post-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(var(--cyan), var(--blue));
  content: "";
  opacity: 0;
  transition: opacity 160ms ease;
}

.post-card:hover {
  border-color: rgba(40, 100, 184, 0.3);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.post-card:hover::after {
  opacity: 1;
}

.post-date {
  position: relative;
  padding-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
}

.post-date span {
  display: block;
  width: 34px;
  height: 1px;
  margin-top: 14px;
  background: var(--orange);
}

.post-title {
  max-width: 680px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(23px, 2.8vw, 31px);
  font-weight: 740;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.post-title a {
  color: var(--ink);
  text-decoration: none;
}

.post-title a:hover {
  color: var(--blue);
}

.post-summary {
  display: -webkit-box;
  max-width: 700px;
  margin: 12px 0 0;
  overflow: hidden;
  color: var(--ink-soft);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.post-meta a,
.rail-pills a {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.post-meta .more-link {
  margin-left: auto;
  border-color: transparent;
  background: transparent;
  color: var(--blue);
}

.context-rail {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 13px;
}

.rail-block {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 19px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-small);
}

.rail-intro {
  border-left: 3px solid var(--green);
}

.rail-intro p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.75;
}

.rail-block h2 {
  margin: 0 0 13px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.rail-list a {
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  text-decoration: none;
}

.rail-list time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.rail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rail-pills a:hover {
  border-color: rgba(40, 100, 184, 0.35);
  color: var(--blue);
}

.rail-pills span {
  color: var(--orange);
}

.single-grid {
  grid-template-columns: minmax(0, 800px) 250px;
  justify-content: space-between;
}

.single-layout {
  min-width: 0;
}

.page-layout {
  max-width: 800px;
  margin: 0 auto;
}

.single-header {
  margin-bottom: 40px;
  padding-bottom: 31px;
  border-bottom: 1px solid var(--line);
}

.single-title {
  max-width: 790px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(38px, 5.4vw, 58px);
  font-weight: 760;
  letter-spacing: -0.047em;
  line-height: 1.12;
}

.single-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-top: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.single-terms {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.single-terms a {
  color: var(--green);
  text-decoration: none;
}

.meta-divider {
  color: var(--orange);
}

.entry-content {
  max-width: 760px;
  overflow-wrap: break-word;
  color: var(--ink);
  font-size: 17.5px;
  line-height: 1.88;
}

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

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4 {
  scroll-margin-top: 110px;
  color: var(--ink);
  font-weight: 730;
  letter-spacing: -0.025em;
  line-height: 1.32;
}

.entry-content h2 {
  position: relative;
  margin: 2.5em 0 0.8em;
  padding-top: 0.8em;
  border-top: 1px solid var(--line);
  font-size: clamp(27px, 4vw, 33px);
}

.entry-content h2::before {
  position: absolute;
  top: -1px;
  left: 0;
  width: 48px;
  height: 2px;
  background: var(--cyan);
  content: "";
}

.entry-content h3 {
  margin: 2em 0 0.7em;
  font-size: clamp(21px, 3vw, 25px);
}

.entry-content h4 {
  margin: 1.8em 0 0.6em;
  font-size: 19px;
}

.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote,
.entry-content table,
.entry-content figure {
  margin-top: 0;
  margin-bottom: 1.25em;
}

.entry-content li + li {
  margin-top: 0.35em;
}

.entry-content strong {
  color: #0f1816;
}

.entry-content hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.entry-content blockquote {
  margin-left: 0;
  border-left: 3px solid var(--orange);
  border-radius: 0 8px 8px 0;
  padding: 13px 18px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-soft);
}

.entry-content blockquote > :last-child {
  margin-bottom: 0;
}

.entry-content code {
  border: 1px solid rgba(40, 100, 184, 0.12);
  border-radius: 4px;
  padding: 0.12em 0.34em;
  background: rgba(40, 100, 184, 0.07);
  color: #174b88;
  font-family: var(--mono);
  font-size: 0.88em;
  overflow-wrap: normal;
}

.code-shell {
  position: relative;
  max-width: 100%;
  margin: 1.5em 0;
}

.entry-content pre {
  max-width: 100%;
  margin: 0;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 22px 18px;
  background: var(--code-bg);
  color: var(--code-ink);
  box-shadow: 0 16px 38px rgba(15, 27, 24, 0.16);
  overscroll-behavior-x: contain;
  tab-size: 2;
}

.entry-content pre code {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1.72;
  white-space: pre;
}

.copy-code {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  min-width: 54px;
  border: 1px solid rgba(219, 232, 227, 0.2);
  border-radius: 5px;
  padding: 4px 8px;
  background: rgba(21, 32, 30, 0.88);
  color: #bfd0ca;
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}

.copy-code:hover {
  border-color: rgba(219, 232, 227, 0.45);
  color: #fff;
}

.entry-content table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}

.entry-content th,
.entry-content td {
  min-width: 120px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}

.entry-content th {
  background: rgba(40, 117, 93, 0.08);
  font-weight: 750;
}

.entry-content figure {
  max-width: 100%;
}

.entry-content figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.entry-content .alignwide {
  width: min(900px, calc(100vw - 40px));
  max-width: none;
}

.article-map {
  position: sticky;
  top: 112px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 5px 0 8px 24px;
}

.article-map[hidden],
.mobile-toc[hidden] {
  display: none;
}

.map-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  overflow: hidden;
}

.map-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(var(--cyan), var(--blue));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 100ms linear;
}

.toc-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list a {
  display: block;
  overflow: hidden;
  padding: 5px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  text-overflow: ellipsis;
}

.toc-list a:hover,
.toc-list a.is-active {
  color: var(--blue);
}

.toc-list a.is-active {
  font-weight: 760;
}

.toc-depth-3 {
  padding-left: 14px;
}

.back-to-top {
  display: inline-block;
  margin-top: 18px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.mobile-toc {
  display: none;
}

.nav-links,
.post-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 48px;
}

.nav-links {
  align-items: center;
}

.nav-links .page-numbers,
.post-navigation a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  background: var(--glass);
  color: var(--ink-soft);
  font-size: 12px;
  text-decoration: none;
}

.nav-links .current {
  border-color: var(--green);
  color: var(--green);
}

.post-navigation a {
  display: grid;
  min-width: 180px;
  max-width: 360px;
  gap: 2px;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.post-navigation a span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.empty-state {
  max-width: 800px;
  min-height: 45vh;
  padding-top: 8vh;
}

.return-link {
  display: inline-block;
  margin-top: 25px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin-top: 84px;
  border-top: 1px solid var(--line);
  padding: 24px 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.site-footer span:nth-child(2) {
  margin-right: auto;
}

.site-footer a {
  color: var(--ink-soft);
  text-decoration: none;
}

@media (max-width: 960px) {
  .header-inner {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 20px;
  }

  .home-link {
    display: none;
  }

  .primary-menu {
    justify-content: flex-end;
  }

  .content-grid,
  .single-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .context-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 38px;
  }

  .rail-intro {
    grid-column: 1 / -1;
  }

  .article-map {
    display: none;
  }

  .mobile-toc {
    display: block;
    margin: 0 0 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.55);
  }

  .mobile-toc summary {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    color: var(--green);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
  }

  .mobile-toc nav {
    padding: 0 0 14px;
  }

  .toc-list a {
    font-size: 13px;
  }
}

@media (max-width: 700px) {
  .admin-bar .site-header {
    top: 0;
  }

  .site-header {
    position: relative;
  }

  .header-inner {
    display: block;
    width: min(calc(100% - 28px), 1180px);
    padding: 15px 0 10px;
  }

  .site-brand {
    margin-bottom: 12px;
  }

  .site-brand small {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .primary-nav {
    width: calc(100vw - 14px);
    margin-left: -7px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .primary-menu {
    width: max-content;
    justify-content: flex-start;
    padding: 0 7px;
  }

  .primary-menu a {
    padding: 6px 8px;
    font-size: 12px;
  }

  .site-main {
    width: min(calc(100% - 28px), 1180px);
    padding-top: 44px;
  }

  .index-head,
  .archive-head {
    margin-bottom: 35px;
  }

  .page-title {
    font-size: clamp(34px, 10.5vw, 46px);
    letter-spacing: -0.045em;
  }

  .page-lead {
    margin-top: 18px;
    font-size: 15.5px;
  }

  .post-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 20px;
  }

  .post-date {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .post-date span {
    width: 25px;
    margin: 0;
  }

  .post-title {
    font-size: 23px;
  }

  .post-summary {
    font-size: 14px;
    -webkit-line-clamp: 4;
  }

  .post-meta .more-link {
    flex-basis: 100%;
    margin: 4px 0 0;
    padding-left: 0;
  }

  .context-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail-intro {
    grid-column: auto;
  }

  .single-header {
    margin-bottom: 29px;
    padding-bottom: 24px;
  }

  .single-title {
    font-size: clamp(32px, 9.5vw, 42px);
    letter-spacing: -0.04em;
  }

  .entry-content {
    font-size: 16.5px;
    line-height: 1.82;
  }

  .entry-content h2 {
    font-size: 26px;
  }

  .entry-content h3 {
    font-size: 21px;
  }

  .entry-content pre {
    margin-right: 0;
    padding: 20px 14px;
  }

  .entry-content pre code {
    font-size: 12px;
  }

  .post-navigation {
    display: grid;
  }

  .post-navigation a {
    max-width: none;
  }

  .site-footer {
    display: grid;
    margin-top: 58px;
  }
}

@media (max-width: 360px) {
  .site-main {
    width: calc(100% - 20px);
  }

  .post-card {
    padding: 17px;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .site-header,
  .article-map,
  .mobile-toc,
  .post-navigation,
  .site-footer,
  .copy-code {
    display: none !important;
  }

  .site-main,
  .entry-content,
  .single-layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .entry-content a {
    color: #000;
    text-decoration: underline;
  }

  .entry-content pre {
    border: 1px solid #bbb;
    background: #f5f5f5;
    color: #000;
    white-space: pre-wrap;
  }
}
