@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;500;600;700&display=swap');

:root {
  --ink: #000000;
  --paper: #ffffff;
  --u: 8px;
  --edge: clamp(16px, 3.4vw, 48px);
  --sans: "Noto Sans TC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Noto Serif TC", Georgia, "Songti TC", serif;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

img { display: block; max-width: 100%; height: auto; }
a { color: var(--ink); }
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
p { margin: 0 0 1em; }

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

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0;
  padding: 0 var(--edge);
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 6px 14px 6px 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
  text-decoration: none;
}
.mark img { width: 44px; height: 44px; object-fit: cover; }

.site-head nav {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-head nav::-webkit-scrollbar { display: none; }

.site-head nav p {
  display: flex;
  align-items: stretch;
  margin: 0;
  min-height: 56px;
}

.site-head nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  font-size: 16px;
  white-space: nowrap;
  text-decoration: none;
  border-left: 1px solid var(--ink);
}
.site-head nav a:last-child { border-right: 1px solid var(--ink); }
.site-head nav a:hover,
.site-head nav a:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.find-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 8px 12px;
  padding-left: 12px;
  border-left: 1px solid var(--ink);
}
.find-form input {
  width: clamp(88px, 13vw, 170px);
  min-width: 0;
  padding: 8px 8px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.find-form button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}
.find-form button:hover { background: var(--paper); color: var(--ink); }

/* ---------- 主体网格 ---------- */
main {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
}

main > article {
  grid-column: 1 / span 8;
  min-width: 0;
  padding-bottom: calc(var(--u) * 6);
}

main > aside {
  grid-column: 10 / span 3;
  align-self: start;
  position: sticky;
  top: 65px;
  max-height: calc(100vh - 65px);
  overflow: auto;
  padding: calc(var(--u) * 4) var(--edge) calc(var(--u) * 6) 20px;
  border-left: 1px solid var(--ink);
}

/* ---------- 首屏 ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: calc(var(--u) * 4);
  padding: calc(var(--u) * 8) var(--edge) calc(var(--u) * 5);
  text-align: center;
}

.hero h1 {
  max-width: 15em;
  font-size: clamp(2rem, 6vw, 4.6rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
  animation: rise 0.7s ease both;
}

.hero-img {
  width: 100%;
  max-width: 760px;
  max-height: 44vh;
  object-fit: cover;
  border: 1px solid var(--ink);
  border-radius: 18px;
  animation: rise 0.7s 0.08s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 正文章节 ---------- */
main > article > div { scroll-margin-top: 96px; }

main > article > div:not(.hero) {
  margin: 0 var(--edge) calc(var(--u) * 3);
  padding: clamp(20px, 3vw, 40px);
  border: 1px solid var(--ink);
  border-radius: 18px;
  transition: background-color 0.25s ease;
}
main > article > div:not(.hero):hover { background: #f6f6f6; }

article h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
article h3 { margin-top: calc(var(--u) * 3); font-size: clamp(1.2rem, 2vw, 1.5rem); }
article h2 + hr,
article h3 + hr {
  margin: 10px 0 18px;
  border: 0;
  border-top: 1px solid var(--ink);
}

article a {
  text-underline-offset: 4px;
  transition: background-color 0.18s ease, color 0.18s ease;
}
article a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }

article ul,
article ol { padding-left: 1.3em; }
article li { margin: 0.3em 0; }

article blockquote {
  margin: calc(var(--u) * 2) 0;
  padding-left: 16px;
  border-left: 3px solid var(--ink);
  font-family: var(--serif);
}

article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
article th,
article td {
  padding: 8px 10px;
  border: 1px solid var(--ink);
  text-align: left;
}

article code,
article pre {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px;
}

/* ---------- 侧栏 ---------- */
aside h2 { font-size: clamp(1.2rem, 1.6vw, 1.45rem); }
aside hr {
  margin: 10px 0 16px;
  border: 0;
  border-top: 1px solid var(--ink);
}
aside ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: idx;
}
aside li {
  counter-increment: idx;
  border-top: 1px solid var(--ink);
}
aside li:last-child { border-bottom: 1px solid var(--ink); }
aside a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 11px 0;
  font-size: 16px;
  text-decoration: none;
}
aside a::before {
  content: counter(idx, decimal-leading-zero);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.08em;
}
aside a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 页脚 ---------- */
.site-foot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 0.9fr) auto;
  gap: calc(var(--u) * 3) calc(var(--u) * 2);
  align-items: start;
  padding: calc(var(--u) * 4) var(--edge);
  border-top: 1px solid var(--ink);
}

.site-foot nav p {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
}
.site-foot nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px 0 0;
  font-size: 16px;
  text-decoration: none;
}
.site-foot nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

.sub-form {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--ink);
}
.sub-form input {
  flex: 1 1 110px;
  min-width: 0;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.sub-form button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}
.sub-form button:hover { background: var(--paper); color: var(--ink); border-left-color: var(--ink); }

.foot-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}
.copy { margin: 0; font-size: 16px; }
.to-top {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}
.to-top:hover { background: var(--ink); color: var(--paper); }

/* ---------- 滚动显现 ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* ---------- 断点 ---------- */
@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  main > article { grid-column: 1; }
  main > aside {
    grid-column: 1;
    position: static;
    max-height: none;
    padding: calc(var(--u) * 4) var(--edge);
    border-left: 0;
    border-top: 1px solid var(--ink);
  }
  main > article > div:not(.hero) { margin-bottom: calc(var(--u) * 2); }
  .hero {
    min-height: auto;
    padding: calc(var(--u) * 7) var(--edge) calc(var(--u) * 4);
  }
  .hero-img { max-height: 36vh; }
}

@media (max-width: 860px) {
  .site-head {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
  .find-form {
    grid-column: 1 / -1;
    margin: 0;
    padding: 6px 0;
    border-left: 0;
    border-top: 1px solid var(--ink);
  }
  .find-form input { flex: 1 1 auto; width: auto; }
  .site-foot { grid-template-columns: 1fr; gap: calc(var(--u) * 2); }
  .foot-end {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .hero h1,
  .hero-img { animation: none; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
