@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Quicksand:wght@300;400;500;600;700&display=swap');

:root {
  --paper: #fafaf8;
  --ink: #1a1a1a;
  --gray: #4a4a4a;
  --wash: #f1f1ec;
  --hand: 'Caveat', 'Quicksand', "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --body: 'Quicksand', "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --line: 1.6px solid var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.07'/></svg>");
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.75;
  font-weight: 400;
}

menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

a {
  color: var(--ink);
}

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

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.45rem 1.1rem;
}

.brand {
  position: relative;
  z-index: 36;
  font-family: var(--hand);
  font-size: 1.55rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
  padding: 0.35rem 0;
  transform: rotate(-0.9deg);
}

.menu-wrap > summary {
  position: relative;
  z-index: 36;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.45rem 0.95rem;
  border: var(--line);
  border-radius: 16px 10px 18px 9px;
  background: var(--paper);
  font-size: 1rem;
  cursor: pointer;
  list-style: none;
  transform: rotate(0.7deg);
}

.menu-wrap > summary::-webkit-details-marker {
  display: none;
}

.menu-wrap > summary::before {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  margin-top: 1px;
  background: var(--ink);
  box-shadow: 0 6px 0 var(--ink), 0 -6px 0 var(--ink);
}

.menu-wrap > menu {
  position: fixed;
  z-index: 35;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 88px 1.4rem 2.5rem;
  background: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.08'/></svg>");
  overflow-y: auto;
  border-bottom: 2px solid var(--ink);
}

.menu-wrap > menu > li > a {
  display: block;
  padding: 0.7rem 0.2rem;
  min-height: 48px;
  font-family: var(--hand);
  font-size: 1.6rem;
  line-height: 1.4;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1.5px dashed var(--gray);
}

.menu-wrap > menu > li > a:hover {
  padding-left: 0.7rem;
  text-decoration: underline;
  text-underline-offset: 5px;
}

.strip {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.3rem 1.1rem 0.4rem;
  border-top: 1.5px dashed #d8d8d0;
  scrollbar-width: thin;
}

.strip a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.3rem 0.7rem;
  font-size: 0.95rem;
  color: var(--gray);
  text-decoration: none;
  border: 1.4px solid transparent;
  border-radius: 12px 8px 14px 7px;
}

.strip a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* ---------- hero ---------- */

.hero {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 70vh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.1rem 2.6rem;
  border-bottom: 2px solid var(--ink);
}

.hero h1 {
  margin: 0;
  max-width: 15em;
  font-family: var(--hand);
  font-size: clamp(2.5rem, 9.5vw, 6rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-align: right;
  transform: rotate(-1.2deg);
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 2.4rem;
  align-items: start;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.4rem 1.1rem 3rem;
}

.side {
  position: sticky;
  top: 160px;
  border-left: 3px solid var(--ink);
  padding: 0.2rem 0 0.2rem 0.9rem;
}

.side h2 {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 2px solid var(--ink);
  width: 64px;
  margin: 0.45rem 0 1rem;
}

.toc a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0.35rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--gray);
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

div {
  min-width: 0;
  max-width: 66ch;
}

div > article {
  padding-bottom: 2rem;
  scroll-margin-top: 150px;
}

div > article + article {
  margin-top: 1.6rem;
  padding-top: 2rem;
  border-top: 1.5px dashed #cfcfc6;
}

div h2 {
  margin: 0 0 0.2rem;
  font-family: var(--hand);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.01em;
}

div h3 {
  margin: 1.8rem 0 0.4rem;
  font-size: 1.2rem;
  line-height: 1.4;
  font-weight: 700;
}

div p {
  margin: 0 0 1rem;
}

div ul,
div ol {
  margin: 0 0 1rem;
  padding-left: 1.3rem;
}

div li {
  margin: 0.35rem 0;
}

div a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

div img {
  max-width: 100%;
  height: auto;
  border: var(--line);
  border-radius: 6px;
  transform: rotate(-0.5deg);
}

div blockquote {
  margin: 1.4rem 0;
  padding: 0.7rem 1rem;
  background: var(--wash);
  border-left: 5px solid var(--ink);
  border-radius: 0 16px 12px 0;
}

div blockquote p:last-child {
  margin-bottom: 0;
}

div table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.98rem;
}

div th,
div td {
  border: 1.5px solid var(--ink);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

div th {
  background: var(--wash);
}

div code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--wash);
  padding: 0.1em 0.3em;
}

/* ---------- footer ---------- */

footer {
  margin-top: 2rem;
  padding: 1.6rem 1.1rem 1.2rem;
  border-top: 2px solid var(--ink);
  background: #f4f4ef;
}

.fgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.2rem;
  max-width: 1080px;
  margin: 0 auto;
}

footer dl {
  margin: 0;
  min-width: 0;
}

footer dt {
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--gray);
}

footer dd {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

footer dd a {
  display: flex;
  align-items: center;
  min-height: 40px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1.4px solid transparent;
}

footer dd a:hover {
  border-bottom-color: var(--ink);
}

.copy {
  max-width: 1080px;
  margin: 1.1rem auto 0;
  padding-top: 0.75rem;
  border-top: 1.4px dashed #cfcfc6;
  font-size: 0.85rem;
  color: var(--gray);
}

/* ---------- reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(14px) rotate(-0.35deg);
}

.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s steps(4, end), transform 0.5s cubic-bezier(0.2, 0.8, 0.25, 1);
}

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

  .reveal,
  .reveal.in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- narrow ---------- */

@media (max-width: 820px) {
  body {
    font-size: 16.5px;
  }

  .mast {
    padding: 0.4rem 0.9rem;
  }

  .brand {
    font-size: 1.3rem;
  }

  .hero {
    min-height: 62vh;
    padding: 1.6rem 0.9rem 2rem;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.4rem;
    padding: 1.6rem 0.9rem 2rem;
  }

  .side {
    position: static;
    border-left: 0;
    border-bottom: 1.5px dashed #cfcfc6;
    padding: 0 0 0.8rem;
  }

  .side hr {
    margin: 0.4rem 0 0.6rem;
  }

  .toc {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0 1rem;
  }

  div > article {
    scroll-margin-top: 130px;
  }

  footer {
    padding: 1.2rem 0.9rem 1rem;
  }

  .fgrid {
    gap: 0.6rem 0.8rem;
  }

  footer dd,
  footer dt {
    font-size: 0.85rem;
  }
}

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