/*
Theme Name: Show Me China Life
Theme URI:
Author: Show Me China
Description: A Chinese-first notebook theme for everyday notes, technology, and photographs.
Version: 2.1.5
Requires at least: 6.7
Requires PHP: 8.1
Text Domain: show-me-china-life
*/

:root {
  color-scheme: light;
  --paper: #f7f8f2;
  --surface: #ffffff;
  --ink: #24352b;
  --muted: #657269;
  --rule: #dce2d7;
  --accent: #315c48;
  --accent-soft: #eaf0e5;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --site-width: 1120px;
  --reading-width: 760px;
  --gutter: clamp(20px, 4vw, 40px);
}

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

html {
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

::selection {
  color: var(--ink);
  background: #dae7d3;
}

.site-shell {
  width: min(calc(100% - (var(--gutter) * 2)), var(--site-width));
  margin-inline: auto;
}

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

.screen-reader-text:focus {
  z-index: 100000;
  top: 12px;
  left: 12px;
  width: auto;
  height: auto;
  padding: 10px 18px;
  margin: 0;
  clip: auto;
  color: var(--surface);
  background: var(--accent);
}

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
}

.site-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  grid-row: span 2;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.site-wordmark {
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.5;
  text-decoration: none;
}

.brand-caption {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 24px;
  font-size: 14px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: 6px;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
}

.site-nav a[aria-current="page"],
.site-nav .is-active {
  color: var(--accent);
  font-weight: 700;
}

.site-nav .nav-write {
  min-height: 38px;
  padding: 5px 15px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--surface);
  background: var(--accent);
  font-weight: 600;
}

.site-nav .nav-write:hover {
  background: #254b39;
}

.notebook-intro {
  margin-block: 32px;
  padding: 28px 32px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: linear-gradient(110deg, #eef3e8, #fafbf7);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.notebook-intro h1,
.list-header h1 {
  margin: 0 0 12px;
  font-size: clamp(27px, 3.2vw, 36px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.notebook-intro > p:last-child,
.list-header > p:last-child {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.notebook-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px;
  align-items: start;
  padding-bottom: 64px;
}

.notebook-main,
.notebook-sidebar {
  min-width: 0;
}

.list-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding-block: 0 14px;
  border-bottom: 1px solid var(--rule);
}

.list-toolbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.list-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
}

.filter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0 2px;
  padding: 0;
  list-style: none;
}

.filter-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 3px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.filter-link:hover {
  background: #eff2e9;
}

.filter-link.is-active,
.filter-link[aria-current="page"] {
  border-color: #d5e0ce;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.entry-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.entry-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}

.entry-card + .entry-card {
  margin-top: 16px;
}

.entry-copy {
  flex: 1;
  min-width: 0;
}

.entry-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.entry-meta a {
  color: var(--accent);
  text-decoration: none;
}

.entry-title {
  margin: 9px 0 8px;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.entry-title a {
  text-decoration: none;
}

.entry-title a:hover {
  text-decoration: underline;
}

.entry-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.entry-read {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  margin-top: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.entry-image {
  display: flex;
  flex: 0 0 160px;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 110px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
}

.entry-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.notebook-sidebar {
  padding-left: 24px;
  border-left: 1px solid var(--rule);
}

.sidebar-section + .sidebar-section {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}

.sidebar-section h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-section p,
.sidebar-section li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.sidebar-section p {
  margin: 0 0 12px;
}

.sidebar-section p:last-child {
  margin-bottom: 0;
}

.sidebar-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-section li + li {
  margin-top: 6px;
}

.sidebar-section a {
  text-decoration: none;
}

.sidebar-section a:hover {
  text-decoration: underline;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-form > label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.search-field {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #c8d2c3;
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
}

.search-field::placeholder {
  color: #747e73;
}

.search-submit {
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--surface);
  background: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.search-submit:hover {
  background: #254b39;
}

.month-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.month-list a {
  flex: 1;
  padding-block: 2px;
  color: var(--ink);
}

.sidebar-note {
  padding: 14px 15px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #eff3e9;
  font-size: 13px;
}

.sidebar-note p {
  font-size: 12px;
}

.empty-state {
  padding: 38px 0;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 20px;
}

.empty-state p {
  margin: 0 0 16px;
}

.empty-state .search-form {
  max-width: 420px;
}

.list-header {
  padding-block: 40px 28px;
}

.article-shell {
  padding-block: 28px 0;
}

.article-header {
  width: min(calc(100% - (var(--gutter) * 2)), var(--reading-width));
  margin: 0 auto 28px;
}

.article-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.article-title {
  margin: 12px 0 16px;
  font-size: clamp(27px, 3.4vw, 38px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.article-lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.article-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 16px;
  color: var(--accent);
  font-size: 13px;
}

.article-featured {
  width: min(calc(100% - (var(--gutter) * 2)), var(--reading-width));
  margin: 0 auto 28px;
}

.article-featured img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.article-body {
  width: min(calc(100% - (var(--gutter) * 2)), var(--reading-width));
  margin-inline: auto;
  font-size: 17px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

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

.article-body p {
  margin-block: 1.2em;
}

.article-body :where(h2, h3, h4, h5, h6) {
  margin-top: 2em;
  margin-bottom: 0.7em;
  color: var(--ink);
  font-weight: 680;
  line-height: 1.55;
  scroll-margin-top: 24px;
}

.article-body h2 {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
  font-size: 25px;
}

.article-body h3 {
  font-size: 21px;
}

.article-body h4 {
  font-size: 18px;
}

.article-body :where(ul, ol) {
  padding-left: 1.5em;
}

.article-body li + li {
  margin-top: 0.35em;
}

.article-body a {
  color: var(--accent);
}

.article-body blockquote {
  margin-inline: 0;
  padding: 1px 20px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--accent-soft);
}

.article-body code,
.article-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.article-body :not(pre) > code {
  padding: 2px 5px;
  border-radius: 3px;
  background: #e9eee3;
}

.article-body pre {
  max-width: 100%;
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #eff2e9;
  line-height: 1.7;
  white-space: pre;
  overflow-wrap: normal;
}

.article-body pre code {
  padding: 0;
  font-size: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
}

.article-body .wp-block-table,
.article-body > table {
  max-width: 100%;
  overflow-x: auto;
}

.article-body > table {
  display: block;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.article-body :where(th, td) {
  padding: 10px 12px;
  border: 1px solid var(--rule);
  text-align: left;
}

.article-body th {
  background: var(--accent-soft);
  font-weight: 600;
}

.article-body hr {
  margin-block: 32px;
  border: 0;
  border-top: 1px solid var(--rule);
}

.article-body :where(.wp-block-image, .wp-block-gallery, .wp-block-cover, .alignwide, .alignfull) {
  max-width: 100%;
  margin-block: 24px;
  margin-inline: 0;
}

.article-body .wp-block-image img {
  height: auto;
  border-radius: 5px;
}

.article-body .wp-block-gallery img {
  border-radius: 5px;
}

.article-body .wp-block-gallery figure.wp-block-image img {
  height: auto;
  object-fit: contain;
}

/* Match core's cropped-gallery specificity while retaining complete screenshots. */
.article-body .wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) {
  align-self: flex-start;
}

.article-body .wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) img {
  flex: 0 0 auto;
  height: auto;
  object-fit: contain;
}

/* Older notes used image covers for screenshots. Keep the complete image
   and put the accompanying words below it instead of over the screenshot. */
.article-body .wp-block-cover:has(> img.wp-block-cover__image-background, > .smc-cover-original > img.wp-block-cover__image-background) {
  display: block;
  min-height: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.article-body .wp-block-cover > img.wp-block-cover__image-background,
.article-body .wp-block-cover > .smc-cover-original > img.wp-block-cover__image-background {
  position: relative;
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 5px;
}

.article-body .wp-block-cover:has(> img.wp-block-cover__image-background, > .smc-cover-original > img.wp-block-cover__image-background) > .wp-block-cover__background {
  display: none;
}

.article-body .wp-block-cover:has(> img.wp-block-cover__image-background, > .smc-cover-original > img.wp-block-cover__image-background) > .wp-block-cover__inner-container {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.article-body .wp-block-cover:has(> img.wp-block-cover__image-background, > .smc-cover-original > img.wp-block-cover__image-background) > .wp-block-cover__inner-container p {
  margin: 0;
  color: inherit;
  /* Saved Cover captions may carry WordPress's important large-font preset. */
  font-size: inherit !important;
}

.article-body .smc-cover-original {
  display: block;
  color: var(--accent);
  text-decoration: none;
}

.smc-cover-original img {
  cursor: zoom-in;
}

.smc-cover-original__label {
  display: block;
  padding-block: 8px;
  font-size: 13px;
  text-align: right;
}

.article-body :where(figcaption, .wp-element-caption) {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
}

.toc {
  margin-bottom: 28px;
  padding: 13px 18px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #eff3e9;
  font-size: 14px;
}

.toc summary {
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.toc .toc-list {
  margin: 12px 0 3px;
  padding-left: 20px;
}

.toc .toc-list li {
  margin-top: 5px;
}

.toc .toc-item--nested {
  margin-left: 16px;
  font-size: 13px;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.article-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  width: min(calc(100% - (var(--gutter) * 2)), var(--reading-width));
  margin: 44px auto 56px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.article-navigation a {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  line-height: 1.8;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.article-navigation__next a {
  justify-content: flex-end;
  text-align: right;
}

.pagination,
.pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pagination {
  margin-top: 28px;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding-inline: 12px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--surface);
  font-size: 13px;
  text-decoration: none;
}

.pagination .current {
  border-color: var(--accent);
  color: var(--surface);
  background: var(--accent);
}

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

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-block: 20px 26px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  text-decoration: none;
}

@media (max-width: 960px) {
  .notebook-layout {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 28px;
  }

  .notebook-sidebar {
    padding-left: 20px;
  }

  .entry-card {
    gap: 20px;
  }

  .entry-image {
    flex-basis: 128px;
    width: 128px;
    height: 100px;
  }
}

@media (max-width: 760px) {
  :root {
    --gutter: 20px;
  }

  .site-header__inner {
    flex-wrap: wrap;
    gap: 10px;
    padding-block: 16px 10px;
  }

  .site-brand {
    column-gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .site-wordmark {
    font-size: 15px;
  }

  .site-nav {
    width: 100%;
    gap: 8px 12px;
    font-size: 13px;
  }

  .site-nav .nav-write {
    margin-left: auto;
  }

  .notebook-intro {
    margin-block: 24px;
    padding: 22px;
  }

  .notebook-intro h1,
  .list-header h1 {
    font-size: 28px;
  }

  .notebook-intro > p:last-child {
    font-size: 14px;
  }

  .notebook-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-bottom: 40px;
  }

  .notebook-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    padding: 24px 0 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .sidebar-section + .sidebar-section {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar-section.sidebar-note {
    padding: 14px 15px;
    border: 1px solid var(--rule);
  }

  .entry-card {
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
  }

  .entry-title {
    font-size: 19px;
  }

  .entry-summary {
    font-size: 13px;
  }

  .entry-image {
    flex-basis: 88px;
    width: 88px;
    height: 80px;
    margin-top: 28px;
  }

  .article-shell {
    padding-top: 16px;
  }

  .article-back {
    margin-bottom: 12px;
  }

  .article-title {
    font-size: 28px;
  }

  .article-body {
    font-size: 16px;
  }

  .article-body h2 {
    font-size: 23px;
  }

  .article-body h3 {
    font-size: 20px;
  }

  .article-body pre {
    padding: 14px;
  }

  .article-navigation {
    gap: 16px;
    margin-block: 32px 40px;
  }
}

@media (max-width: 420px) {
  :root {
    --gutter: 16px;
  }

  .site-nav {
    gap: 8px 8px;
  }

  .site-nav .nav-write {
    padding-inline: 11px;
  }

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

  .entry-card {
    gap: 12px;
    padding: 16px;
  }

  .entry-title {
    font-size: 18px;
  }

  .article-navigation {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .article-navigation__next a {
    justify-content: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
