@font-face {
  font-family: "Instrument Serif";
  src: url("./instrument-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #faf9f7;
  --ink: #272823;
  --quiet: #64635e;
  --rule: #dbd8d1;
  --gutter: clamp(1.5rem, 3.7vw, 4.5rem);
  --masthead-size: 5rem;
  --serif: "Instrument Serif", "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", SimSun, Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #625d48; outline-offset: 5px; }
button { font: inherit; }

.visually-hidden, .skip:not(:focus) {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
  width: 1px;
  height: 1px;
}

.skip:focus {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.6rem 0.85rem;
  background: var(--paper);
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 5;
  height: var(--masthead-size);
  margin-bottom: calc(-1 * var(--masthead-size));
  padding-inline: var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none;
}

.wordmark {
  font: 400 2.22rem/1 var(--serif);
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.masthead .wordmark {
  justify-self: start;
  pointer-events: auto;
  filter: drop-shadow(0 1px 8px #faf9f7);
}
.nav-shell { grid-column: 2; pointer-events: auto; }
.nav-shell:has(.gooey-nav) .nav-fallback { display: none; }
.nav-shell .gooey-nav { --gn-y: 0.61rem; --gn-x: 1.05rem; }
.nav-shell .gooey-nav__list { flex-wrap: nowrap; }
.nav-fallback {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(246, 245, 242, 0.92);
  border: 1px solid rgba(39, 40, 35, 0.1);
  border-radius: 999px;
  font-size: 0.875rem;
}
.nav-fallback a {
  padding: 0.61rem 1.05rem;
  border-radius: 999px;
  white-space: nowrap;
}
.nav-fallback [aria-current] { color: #fff; background: var(--ink); }

.colophon nav {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 3.1vw, 3.25rem);
  font-size: 0.875rem;
}
.colophon nav a, .quiet-link {
  padding-block: 0.75rem;
  color: var(--quiet);
  transition: color 180ms;
}
.colophon nav a:hover, .quiet-link:hover { color: var(--ink); }

.hero { position: relative; }
.cloth-stage {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  height: 100vh;
  height: 100svh;
  min-height: 19rem;
  background: radial-gradient(ellipse at 42% 28%, #eeede9, #e5e3de 70%, #dddcd5);
}

.cloth-stage canvas, .cloth-input, .cloth-still, .cloth-still picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cloth-stage canvas { display: block; pointer-events: none; opacity: 0; }
.cloth-input {
  display: none;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.is-grabbed .cloth-input { cursor: grabbing; }
.is-live canvas { opacity: 1; }
.is-live .cloth-input { display: block; }
.is-live .cloth-still { display: none; }

.cloth-still { pointer-events: none; }
.cloth-still picture { z-index: 1; }
.cloth-still img { width: 100%; height: 100%; display: block; object-fit: contain; }

.stage-controls {
  position: absolute;
  z-index: 1;
  inset: auto var(--gutter) max(0.3rem, env(safe-area-inset-bottom)) var(--gutter);
  pointer-events: none;
  min-height: 3.7rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  color: var(--quiet);
  font-size: 0.875rem;
}

.cloth-caption {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}

.caption-dot {
  width: 0.48rem;
  height: 0.48rem;
  flex: none;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.hero:has(.is-grabbed) .caption-dot { background: currentColor; }
.index-link {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  color: var(--ink);
}
.index-link::after {
  content: "";
  display: block;
  height: 0.35rem;
  width: 0.35rem;
  margin-top: -0.18rem;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}

.reset {
  pointer-events: auto;
  justify-self: end;
  min-height: 2.75rem;
  padding: 0.35rem 0.3rem;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.reset:disabled { visibility: hidden; }
.reset:hover { color: var(--ink); }

.writing {
  width: min(82rem, calc(100% - 2 * var(--gutter)));
  margin: 5.6rem auto 5rem;
  scroll-margin-top: calc(var(--masthead-size) + 0.5rem);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.75rem;
}
.section-head h2 {
  margin: 0;
  font: 400 clamp(1.9rem, 3.4vw, 3.2rem)/1.2 var(--serif);
  letter-spacing: -0.055em;
}

.writing-actions { display: flex; align-items: center; gap: clamp(0.65rem, 2vw, 1.6rem); }
.quiet-link, .wall-toggle { font-size: 0.875rem; white-space: nowrap; }
.wall-toggle {
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  color: var(--quiet);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}
.wall-toggle:hover { color: var(--ink); background: #eeece6; }

.article-wall { position: relative; }
.article-wall [data-wall-mount] { display: none; }
.article-wall.is-drifting:not(:has(.posts:focus-within)) [data-wall-mount] {
  display: block;
  height: clamp(30rem, 69svh, 46rem);
  background: radial-gradient(ellipse at 50% 40%, #efede8 0%, transparent 75%);
}
.article-wall.is-drifting .posts:not(:focus-within) {
  position: absolute;
  inset: 0 auto auto 0;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
}
.posts {
  list-style: none;
  padding: 1.35rem 0 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 1rem;
}
.post-card {
  position: relative;
  min-width: 0;
  min-height: 9.6rem;
  height: 100%;
  padding: clamp(0.8rem, 1.6vw, 1.4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
  overflow: hidden;
  border: 1px solid #f5f3ee;
  border-radius: 0.8rem;
  background: #eae7df;
  box-shadow: 0 0.32rem 1rem rgb(45 38 22 / 0.08);
}
.post-card[data-tone="1"] { background: #e5e6df; }
.post-card[data-tone="2"] { background: #eeebe4; }
.post-card[data-tone="3"] { background: #e9e5e2; }
.post-card[data-tone="4"] { background: #e6e3d8; }
.post-card--cover {
  color: #fff;
  background: #57534b;
}
.post-card--cover::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(170deg, #1d1c19b3, #1d1c1940 46%, #1d1c19bf);
}
.post-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-meta {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 0.38rem;
  align-items: baseline;
  color: #514e47;
  font-size: 0.74rem;
}
.post-date { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.post-title {
  position: relative;
  z-index: 2;
  font: 400 clamp(1.17rem, 1.75vw, 1.64rem)/1.28 var(--serif);
  overflow-wrap: anywhere;
}
.post-card--cover .post-meta { color: #fff; }
.editorial-drift .post-card {
  position: absolute;
  min-height: 0;
  height: auto;
}
.editorial-drift .post-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.empty { color: var(--quiet); }

.colophon {
  margin-inline: var(--gutter);
  min-height: 6rem;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.colophon .wordmark { font-size: 1.8rem; }

@media (max-width: 680px) {
  :root { --gutter: 1rem; --masthead-size: 4.15rem; }
  .masthead .wordmark { font-size: 1.82rem; }
  .nav-shell .gooey-nav { --gn-x: 0.85rem; --gn-y: 0.6rem; }
  .nav-fallback a { padding-inline: 0.85rem; }
  .stage-controls { min-height: 3.15rem; gap: 0.65rem; }
  .cloth-caption { gap: 0.35rem; }
  .writing { margin-block: 4.85rem 3rem; }
  .article-wall.is-drifting:not(:has(.posts:focus-within)) [data-wall-mount] { height: clamp(25rem, 64svh, 34rem); }
  .posts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
  .post-card { min-height: 8rem; }
  .colophon nav { gap: clamp(0.65rem, 3vw, 1.25rem); }
}

@media (max-width: 535px) {
  .masthead .wordmark { display: none; }
}

@media (max-width: 360px) {
  .stage-controls { font-size: 0.8rem; }
  .post-meta { font-size: 0.6875rem; }
}

@media (max-height: 510px) and (orientation: landscape) {
  :root { --masthead-size: 3.6rem; }
  .stage-controls { min-height: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
