@import url("../fonts/maple-mono-nf-cn.css");

:root {
  --font: "Maple Mono NF CN", ui-monospace, Menlo, Consolas, sans-serif;
}

* { box-sizing: border-box; }

html {
  /* 关掉手机 Safari 的自动文字放大（webkit 的"可读性"启发式），
     它会在某些排版下把文字渲染得比 CSS 指定的字号更大，挤爆本来够用的
     flex 布局，导致换行时机跟其它浏览器（包括桌面 Chrome、iOS 上的
     第三方浏览器）不一致——缩小页面缩放能绕开也是因为这个启发式跟着缩放变化。 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.25s;
  animation-timing-function: ease;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.site-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  row-gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 44px 24px 20px;
}

.brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.brand:hover { opacity: 0.55; }

.search-form {
  position: relative;
  flex: 1;
  min-width: 140px;
}

.search-hint {
  position: absolute;
  top: 100%;
  left: 2px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.search-hint.visible {
  opacity: 1;
  transform: translateY(0);
}

.search-form input[type="search"] {
  width: 100%;
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 2px;
  transition: border-color 0.2s ease;
}

.search-form input[type="search"]::placeholder {
  color: var(--muted);
}

.search-form input[type="search"]:hover,
.search-form input[type="search"]:focus {
  border-color: var(--fg);
  outline: none;
}

.search-form input[type="search"].shake {
  animation: shake 0.4s ease;
  border-color: var(--accent);
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}

.width-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.width-toggle:hover {
  border-color: var(--fg);
  color: var(--fg);
}

.width-toggle[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* 小屏幕本来就没有多余宽度可以展开，按钮就不用占地方了 */
@media (max-width: 900px) {
  .width-toggle {
    display: none;
  }
}

html.wide .site-header,
html.wide .content,
html.wide .site-footer {
  max-width: min(1200px, 94vw);
}

.theme-picker {
  position: relative;
  flex-shrink: 0;
}

.theme-trigger {
  display: inline-flex;
  align-items: center;
  position: relative;
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 28px 6px 14px;
  font-size: 13px;
  color: var(--muted);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.theme-trigger::-webkit-details-marker { display: none; }
.theme-trigger::marker { content: ""; }

.theme-trigger::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.theme-picker:hover .theme-trigger,
.theme-picker[open] .theme-trigger {
  border-color: var(--fg);
  color: var(--fg);
}

.theme-picker[open] .theme-trigger::after {
  transform: translateY(-35%) rotate(-135deg);
}

.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 130px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 10;
  animation: menu-in 0.15s ease both;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.theme-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.theme-option:hover {
  background: var(--code-bg);
}

.theme-menu li[aria-selected="true"] .theme-option {
  color: var(--accent);
  font-weight: 600;
}

.content {
  width: 100%;
  flex: 1 0 auto;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 24px 48px;
  animation: fade-in 0.6s ease both;
}

.site-footer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-sep {
  opacity: 0.5;
}

.footer-logout-form {
  display: inline;
  margin-left: auto;
}

.footer-logout-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  color: #e5484d;
  text-decoration: underline;
  cursor: pointer;
}

#footer-brand {
  -webkit-tap-highlight-color: transparent;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.page-list li {
  border-bottom: 1px solid var(--border);
}

.page-list li:first-child {
  border-top: 1px solid var(--border);
}

.page-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 2px 4px;
  text-decoration: none;
  color: var(--fg);
}

.item-snippet {
  margin: 0 0 20px;
  padding: 0 2px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.item-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 1;
  gap: 16px;
  min-width: 0;
}

.item-title {
  font-size: 17px;
  transition: transform 0.25s ease, color 0.25s ease;
}

.item-date {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 752px) {
  .item-title {
    font-size: 15px;
  }

  .item-date {
    font-size: 12px;
  }

  .item-snippet {
    font-size: 13px;
  }
}

.item-arrow {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  color: var(--accent);
}

.page-list a:hover .item-title {
  transform: translateX(4px);
  color: var(--accent);
}

.page-list a:hover .item-arrow {
  opacity: 1;
  transform: translateX(0);
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.not-found {
  text-align: center;
  padding: 80px 0;
}

.not-found-code {
  font-size: 72px;
  font-weight: 700;
  color: var(--border);
  margin: 0 0 8px;
  letter-spacing: 0.05em;
}

.not-found-text {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 15px;
}

.not-found .back-link {
  margin-bottom: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
  color: var(--fg);
  transform: translateX(-2px);
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.article-nav-prev,
.article-nav-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 48%;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.2s ease;
}

.article-nav-next {
  text-align: right;
  margin-left: auto;
}

.article-nav-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.article-nav-title {
  font-size: 15px;
  transition: color 0.2s ease;
}

.article-nav-prev:hover .article-nav-title,
.article-nav-next:hover .article-nav-title {
  color: var(--accent);
}

.article-nav-prev:hover {
  transform: translateX(-2px);
}

.article-nav-next:hover {
  transform: translateX(2px);
}

.meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 32px;
}

.prose h1 { font-size: 28px; line-height: 1.35; margin: 0 0 8px; }
.prose h2 { font-size: 21px; margin-top: 44px; margin-bottom: 12px; }
.prose h3 { font-size: 17px; margin-top: 32px; margin-bottom: 8px; }
.prose p, .prose li { font-size: 16.5px; }
.prose ul, .prose ol { padding-left: 22px; }

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
}

.prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

.prose a:hover {
  text-decoration-color: var(--accent);
  color: var(--accent);
}

code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "Maple Mono NF CN", "SF Mono", Menlo, Consolas, monospace;
}

pre {
  background: var(--code-bg);
  padding: 18px 20px;
  border-radius: 8px;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

.code-block {
  position: relative;
  margin: 20px 0;
}

.code-block pre {
  margin: 0;
}

.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

.code-block[data-lang] pre {
  padding-top: 34px;
}

/* 代码块的高亮配色在服务端就渲染成了浅色/深色两份，切换主题时只靠这两条规则
   切换显示哪一份，不用等整页刷新、也不需要引入客户端语法高亮库。 */
.code-dark {
  display: none;
}

html[data-scheme="dark"] .code-light {
  display: none;
}

html[data-scheme="dark"] .code-dark {
  display: block;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.code-block:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
  transform: translateY(0);
}

.copy-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

blockquote {
  margin: 24px 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.prose input[type="checkbox"] {
  margin-right: 8px;
}

.admin-login {
  max-width: 320px;
  margin: 60px auto;
  text-align: center;
}

.admin-login h1 {
  font-size: 20px;
  margin: 0 0 24px;
}

.admin-login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-login input[type="password"] {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
}

.admin-login button,
.admin-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.admin-login button:hover,
.admin-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.admin-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.admin-btn-primary:hover {
  opacity: 0.9;
  color: var(--bg);
}

/* 原生的文件选择框在不同浏览器/系统下长得完全不一样，没法跟站点的
   主题配色统一，所以视觉上把它隐藏掉，改用一个套 .admin-btn 样式的
   <label for="..."> 来触发它——点这个 label 等价于点原生输入框，
   但外观完全由 CSS 控制，跟每个主题的其它按钮长得一样。 */
.admin-file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-file-name {
  font-size: 12px;
  color: var(--muted);
}

.admin-image-status {
  font-size: 12px;
  color: var(--muted);
}

.admin-error {
  color: var(--accent);
  font-size: 13px;
  margin: 0 0 12px;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.admin-bar h1 {
  font-size: 20px;
  margin: 0;
}

.admin-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-import-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-btn-ghost {
  color: var(--muted);
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.admin-empty {
  color: var(--muted);
  font-size: 14px;
}

.admin-row-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.admin-row-title {
  font-size: 15px;
}

.admin-row-slug {
  font-size: 12px;
  color: var(--muted);
}

.admin-row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.admin-row-actions a {
  color: var(--fg);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.admin-row-actions a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.admin-danger {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.admin-danger:hover {
  color: #e5484d;
}

.admin-edit-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.admin-field input,
.admin-field textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.admin-edit-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}
