/* Shengjie Jin — shared styles.
   The world: a literary quarterly's interior. Cream leaves with a fine paper tooth, laid on an
   oltremare desk printed like a solid on uncoated stock; near-black ink; vermilion only for
   apparatus (labels, rules, the dot, the current place). */

@font-face { font-family: Cardo; src: url("assets/fonts/cardo-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Cardo; src: url("assets/fonts/cardo-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Cardo; src: url("assets/fonts/cardo-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* Base colours sit a shade off the intended tone; the grain brings them back to it.
     --desk is that tone, for the places grain cannot reach (scrollbar, overscroll, browser chrome). */
  --desk: #12285a;
  --ground: #0c2358;
  --leaf: #f7f2e6;
  --ink: #141312;
  --soft: #5d584e;
  --verm: #e3422c;
  --verm-text: #b3321c;
  --verm-bright: #ff7a5f;
  --verm-deep: #c4331d;
  --cream: #efe8d8;
  --cream-soft: #b7c0d8;
  --rule: #dad1be;
  --plate: #ffffff;
  --selection: #f3c6b9;
  --monogram: #e3422c;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='d' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.32 0 0 0 0 0.25 0 0 0 0 0.13 0 0 0 0.36 -0.145'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)'/%3E%3C/svg%3E");
  --ground-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='a' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.26 -0.105'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3Cfilter id='b' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0.02 0 0 0 0 0.08 0.32 0 0 0 -0.13'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  /* The top edge of a sheet catches the light. */
  --edge: inset 0 1px 0 rgba(255, 255, 255, .7);
  --shadow: 0 1px 0 rgba(0, 0, 0, .1), 12px 16px 30px -14px rgba(3, 10, 36, .55);
  --serif: Cardo, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #08122b;
    --ground: #040e29;
    --leaf: #17181f;
    --ink: #ece6d8;
    --soft: #aba493;
    --verm: #e04a2f;
    --verm-text: #ee8f77;
    --cream: #e4ddcc;
    --cream-soft: #8f99b4;
    --rule: #30313b;
    --plate: #dcd7cb;
    --selection: #5a2a22;
    --monogram: #9c3726;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='d' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.97 0 0 0 0 0.9 0 0 0 0.2 -0.083'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)'/%3E%3C/svg%3E");
    --ground-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='a' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.17 -0.07'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3Cfilter id='b' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.02 0.3 0 0 0 -0.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
    --edge: inset 0 1px 0 rgba(255, 255, 255, .05);
    --shadow: 0 1px 0 rgba(0, 0, 0, .45), 12px 16px 30px -14px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
  scroll-padding-top: 96px; /* the sticky masthead (70px) and a little air */
  background-color: var(--desk);
  scrollbar-color: color-mix(in srgb, var(--cream) 32%, var(--desk)) var(--desk);
  transition: background-color .3s ease;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  color: var(--ink);
  font: 400 18.5px/1.62 var(--serif);
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  /* The desk: oltremare printed solid, with the mottle of ink on uncoated stock. */
  background-color: var(--ground);
  background-image: var(--ground-grain);
}

::selection { background: var(--selection); color: var(--ink); }
.on-ground ::selection { background: var(--verm-deep); color: #fff; }
h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--verm-text); outline-offset: 3px; }
.on-ground :focus-visible { outline-color: var(--cream); }

/* Apparatus is set in the font's true small capitals, letterspaced, with old-style figures. */
.sc {
  font-variant-caps: small-caps;
  text-transform: lowercase;
  letter-spacing: .1em;
  font-variant-numeric: oldstyle-nums;
}
/* Separators in apparatus lines are vermilion points. */
.mid { color: var(--verm); }
.on-ground .mid { color: var(--verm-bright); }

/* Reading links: always underlined, the rule in vermilion. */
.ul {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  text-decoration-color: color-mix(in srgb, var(--verm) 70%, transparent);
  transition: color .18s ease;
}
.ul:hover { color: var(--verm-text); }

/* Arrows say where a link goes: → stays on this site, ↗ opens elsewhere. They lean that way on hover. */
.arrow { width: .72em; height: .72em; flex: none; transition: transform .22s var(--ease); }
a:hover > .arrow.to-page { transform: translateX(2px); }
a:hover > .arrow.to-away { transform: translate(1.5px, -1.5px); }

.wrap { position: relative; z-index: 1; width: min(var(--page, 1200px), calc(100% - 96px)); margin-inline: auto; }

.skip { position: fixed; left: -9999px; top: 10px; z-index: 30; padding: 8px 12px; background: var(--leaf); color: var(--ink); border: 1px solid var(--rule); box-shadow: var(--edge), var(--shadow); }
.skip:focus { left: 16px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Masthead: the SJ mark and the section list, printed on the ground. */
.masthead { position: sticky; top: 0; z-index: 20; background-color: var(--ground); background-image: var(--ground-grain); transition: box-shadow .25s ease; }
/* Once the page moves under it, a hairline separates the masthead from the leaves. */
.masthead.is-stuck { box-shadow: 0 1px 0 color-mix(in srgb, var(--cream) 16%, transparent); }
.masthead .wrap { display: flex; justify-content: space-between; align-items: center; height: 70px; color: var(--cream); }
.mark { display: inline-flex; align-items: center; font-size: 27px; line-height: 1; letter-spacing: -.01em; transition: color .18s ease; }
.mark:hover { color: #fff; }
/* A running head: once the name has scrolled away, it is set beside the mark, as at the top of a page. */
.mark-name {
  margin-left: 18px; padding: 4px 0 4px 18px;
  border-left: 1px solid color-mix(in srgb, var(--cream) 30%, transparent);
  font-size: 17px; color: var(--cream-soft);
  opacity: 0; transform: translateX(-6px);
  transition: opacity .3s ease, transform .45s var(--ease), color .18s ease;
}
.mark:hover .mark-name { color: var(--cream); }
.masthead.has-head .mark-name { opacity: 1; transform: none; }
.masthead nav { position: relative; display: flex; gap: 32px; font-size: 19px; }
.masthead nav a { padding: 10px 0; transition: color .18s ease; }
.masthead nav a:hover { color: #fff; }
.masthead nav a[aria-current] { color: var(--verm-bright); }
/* The dot from the rule ornament travels to the section being read. */
.nav-dot {
  position: absolute; left: 0; bottom: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--verm-bright);
  opacity: 0;
  transform: translateX(var(--x, 0));
  transition: transform .55s var(--ease), opacity .25s ease;
  pointer-events: none;
}
.nav-dot.is-on { opacity: 1; }

/* A leaf: paper with a fine tooth under one raking light, so every shadow falls the same way. */
.leaf {
  position: relative;
  background-color: var(--leaf);
  background-image: var(--grain);
  box-shadow: var(--edge), var(--shadow);
}
.label { font-weight: 400; font-size: 19px; line-height: 1.3; color: var(--verm-text); }

/* The rule ornament: a hairline broken by one vermilion point. */
.dotrule {
  --dot: 54px;
  position: relative; height: 1px; margin: 30px 0 28px;
  background: linear-gradient(90deg, var(--rule) 0 calc(var(--dot) - 10px), transparent 0 calc(var(--dot) + 17px), var(--rule) 0);
}
.dotrule::before { content: ""; position: absolute; left: var(--dot); top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--verm); }

/* Outlined buttons printed on the ground. */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 20px;
  font-size: 19px;
  color: var(--cream);
  border: 1px solid color-mix(in srgb, var(--cream) 62%, transparent);
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.btn:hover { background: var(--verm-deep); border-color: var(--verm-deep); color: #fff; }
.icon { width: 13px; height: 13px; flex: none; }
.ui { width: 15px; height: 15px; flex: none; }

/* A plate: a figure on white plate paper, with the faint plate mark of the press around it.
   It lifts a little under the pointer, and opens in the viewer. */
.plate { cursor: zoom-in; }
.mount {
  --mark: inset 0 0 0 4px var(--plate), inset 0 0 0 5px rgba(70, 52, 20, .1);
  padding: 10px;
  background: var(--plate);
  border: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
  box-shadow: var(--mark), 3px 5px 12px -8px rgba(40, 30, 10, .35);
  transition: transform .22s var(--ease), box-shadow .22s ease;
}
.plate:hover .mount, .plate:focus-visible .mount { transform: translateY(-3px); box-shadow: var(--mark), 5px 10px 20px -10px rgba(40, 30, 10, .42); }
.mount img { display: block; max-width: 100%; height: auto; }
.plate-cap { display: inline-flex; align-items: center; gap: 7px; font-size: 16px; color: var(--soft); transition: color .18s ease; }

footer {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 8px 28px;
  margin-top: 96px; padding: 26px 0 52px;
  font-size: 18px;
  color: var(--cream-soft);
  border-top: 1px solid color-mix(in srgb, var(--cream) 22%, transparent);
}
footer a { display: inline-flex; align-items: center; gap: 8px; transition: color .18s ease; }
footer a:hover { color: #fff; }
footer .to-top { margin-left: auto; }
/* Separators keep to the end of a line: a no-break space before each point, and the time kept whole. */
footer .clock { white-space: nowrap; }
footer .to-top svg { transition: transform .22s var(--ease); }
footer .to-top:hover svg { transform: translateY(-2px); }

/* Figure viewer: a plate lifts off the leaf and is held up to the light. */
.viewer { padding: 0; border: 0; background: transparent; max-width: none; max-height: none; overflow: visible; color: var(--ink); }
.viewer::backdrop { background: rgba(6, 14, 38, .82); transition: opacity .3s ease; }
.viewer[open]::backdrop { animation: viewer-fade .3s ease; }
.viewer.is-closing::backdrop { opacity: 0; }
.sheet { transform-origin: 0 0; padding: 16px 16px 6px; background-color: var(--leaf); background-image: var(--grain); box-shadow: var(--edge), 16px 24px 48px -16px rgba(0, 0, 0, .6); }
.stage { position: relative; overflow: hidden; margin: auto; background: #fff; overscroll-behavior: contain; }
.stage.can-zoom { cursor: zoom-in; }
.stage.is-zoomed { overflow: auto; cursor: zoom-out; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--soft) 50%, transparent) transparent; }
.stage.is-dragging { cursor: grabbing; user-select: none; }
html:has(.viewer[open]) { overflow: hidden; }
/* The backdrop stops at the scrollbar gutter, so the gutter dims with it. */
html:has(.viewer[open]:not(.is-closing)) { background-color: color-mix(in srgb, rgb(6 14 38) 82%, var(--desk)); }
.stage img { display: block; max-width: none; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; min-height: 52px; padding-top: 4px; font-size: 18px; }
.bar .v-caption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; flex: 1 1 260px; }
.bar .v-title { font-weight: 400; font-size: 19px; color: var(--verm-text); }
.bar .v-count { color: var(--soft); }
.bar .v-tools { display: flex; align-items: center; gap: 2px; }
.bar button, .bar a {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; min-height: 44px; padding: 0 8px;
  font: inherit; letter-spacing: inherit; text-transform: inherit; font-variant: inherit;
  color: var(--ink); background: none; border: 0; cursor: pointer;
  transition: color .18s ease;
}
.bar button:hover, .bar a:hover { color: var(--verm-text); }
.bar button:disabled { color: var(--soft); opacity: .45; cursor: default; }
.bar .v-sep { width: 1px; height: 20px; margin: 0 8px; background: var(--rule); }
/* One point per plate; the current one is vermilion. */
.bar .v-pager { display: inline-flex; align-items: center; }
.bar .v-pip { min-width: 20px; padding: 0; }
.v-pip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: color-mix(in srgb, var(--soft) 45%, transparent);
  transition: background-color .2s ease, transform .25s var(--ease);
}
.v-pip:hover::before { background: var(--soft); }
.v-pip[aria-current="true"]::before { background: var(--verm); transform: scale(1.3); }

@keyframes viewer-fade { from { opacity: 0; } }

@media (prefers-color-scheme: dark) {
  .mount { --mark: inset 0 0 0 4px var(--plate), inset 0 0 0 5px rgba(0, 0, 0, .14); }
  .mount img { filter: brightness(.88) contrast(1.04); }
  .sheet { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cream) 12%, transparent), var(--edge), 16px 24px 48px -16px rgba(0, 0, 0, .6); }
  .stage { background: #dcd7cb; }
  .stage img { filter: brightness(.9) contrast(1.04); }
}

@media (max-width: 700px) {
  .wrap { width: calc(100% - 28px); }
  /* The masthead no longer follows the page, so an arrival needs only a little air above it. */
  html { scroll-padding-top: 20px; }
  .masthead { position: static; }
  .masthead .wrap { height: auto; padding: 6px 2px; }
  .mark { display: none; }
  .masthead nav { width: 100%; justify-content: space-between; gap: 4px; font-size: clamp(15px, 4.3vw, 17px); letter-spacing: .05em; }
  .masthead nav a { padding: 13px 0; }
  .nav-dot { display: none; }
  .dotrule { --dot: 40px; margin: 22px 0 20px; }
  footer { margin-top: 48px; padding: 22px 2px 40px; }
  footer a { min-height: 44px; }
  footer .to-top { margin-left: 0; }
  footer .clock { display: block; }
  footer .clock .mid { display: none; }
  .sheet { padding: 10px 10px 4px; }
  .bar { gap: 4px 6px; font-size: 17px; }
  .bar .v-caption { flex: 1 1 100%; padding: 6px 4px 2px; }
  .bar .v-tools { width: 100%; justify-content: space-between; padding-top: 2px; border-top: 1px solid var(--rule); }
  .bar .v-sep, .bar .v-pager { display: none; }
  .bar .v-close span, .bar .v-original span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after, ::backdrop { transition: none !important; animation: none !important; }
  .plate:hover .mount, .plate:focus-visible .mount, a:hover > .arrow.to-page, a:hover > .arrow.to-away, footer .to-top:hover svg { transform: none; }
}

/* Print: the page becomes a plain offprint on white paper. */
@media print {
  @page { margin: 16mm 15mm; }
  html, body { background: #fff !important; color: #000; }
  body { font-size: 10.5pt; line-height: 1.45; }
  .masthead, .skip, .viewer, footer .to-top, .clock { display: none !important; }
  .wrap { width: auto; }
  .leaf { background: none; box-shadow: none; }
  .label, .mid { color: #000; }
  .dotrule { margin: 10pt 0; background: #999; }
  .dotrule::before { display: none; }
  .ul { text-decoration: none; }
  footer { margin-top: 18pt; padding: 8pt 0 0; color: #444; background: none; border-top: .5pt solid #999; }
}
