/* 夜读手卷。层级：雾气 0，浮尘画布 0，页面 1，导航 3。界面圆角为 0，卷轴本身是圆杆。 */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181f;
  --text: #e7e9ee;
  --text-soft: #b7bec9;
  --silk: #262c34;
  --silk-shade: rgb(0 0 0 / 32%);
  --weave: rgb(232 226 214 / 5%);
  --ink: #e6dfd2;
  --mount: #171d26;
  --mount-thread: rgb(214 186 132 / 16%);
  --roller-dark: #140f0c;
  --roller-mid: #5a4030;
  --roller-light: #b08a62;
  --knob-dark: #1c1612;
  --knob-light: #7a5a3c;
  --cinnabar: #9a332c;
  --seal: #d4655c;
  --mark: #d4655c;
  --on-cinnabar: #fff6f4;
  --line: rgb(231 233 238 / 16%);
  --shadow: rgb(6 8 12 / 48%);
  --orb-core: 226, 232, 240;
  --orb-alpha: 0.55;
  --orb-crescent: 0.22;
  --mist: 132, 148, 170;
  --dust: 198, 206, 216;
  --nav: rgb(20 24 31 / 88%);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #d7dbe3;
  --text: #1c2128;
  --text-soft: #3e4654;
  --silk: #d9ddd4;
  --silk-shade: rgb(48 58 42 / 16%);
  --weave: rgb(70 78 62 / 8%);
  --ink: #1c1914;
  --mount: #243246;
  --mount-thread: rgb(214 186 132 / 32%);
  --roller-dark: #3a2918;
  --roller-mid: #8d6842;
  --roller-light: #e6c89a;
  --knob-dark: #4a3422;
  --knob-light: #c6a36e;
  --cinnabar: #9a332c;
  --seal: #9a332c;
  --mark: #9a332c;
  --on-cinnabar: #fff6f4;
  --line: rgb(28 33 40 / 14%);
  --shadow: rgb(28 36 48 / 22%);
  --orb-core: 255, 255, 255;
  --orb-alpha: 0.95;
  --orb-crescent: 0.05;
  --mist: 255, 255, 255;
  --dust: 70, 78, 92;
  --nav: rgb(215 219 227 / 90%);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #d7dbe3;
    --text: #1c2128;
    --text-soft: #3e4654;
    --silk: #d9ddd4;
    --silk-shade: rgb(48 58 42 / 16%);
    --weave: rgb(70 78 62 / 8%);
    --ink: #1c1914;
    --mount: #243246;
    --mount-thread: rgb(214 186 132 / 32%);
    --roller-dark: #3a2918;
    --roller-mid: #8d6842;
    --roller-light: #e6c89a;
    --knob-dark: #4a3422;
    --knob-light: #c6a36e;
    --seal: #9a332c;
    --mark: #9a332c;
    --line: rgb(28 33 40 / 14%);
    --shadow: rgb(28 36 48 / 16%);
    --orb-core: 255, 255, 255;
    --orb-alpha: 0.95;
    --orb-crescent: 0.05;
    --mist: 255, 255, 255;
    --dust: 70, 78, 92;
    --nav: rgb(215 219 227 / 90%);
  }
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgb(154 51 44 / 22%);
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.atmosphere,
#dust {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.atmosphere {
  z-index: 0;
  overflow: hidden;
}

#dust {
  z-index: 0;
  width: 100%;
  height: 100%;
}

.orb {
  position: absolute;
  top: -9rem;
  right: -6rem;
  width: min(40rem, 72vw);
  height: min(40rem, 72vw);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, rgba(var(--orb-core), 0.96), rgba(var(--orb-core), 0) 64%);
  box-shadow: inset -2.4rem -1.7rem 0 rgb(12 16 24 / var(--orb-crescent));
  display: none;
}

.mist {
  position: absolute;
  width: 48vw;
  height: 48vw;
  min-width: 18rem;
  min-height: 18rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--mist), 0.34), rgba(var(--mist), 0) 68%);
  filter: blur(8px);
}

.mist-a {
  left: -12vw;
  bottom: -16vw;
}

.mist-b {
  right: 8vw;
  top: 28vh;
  width: 28vw;
  height: 28vw;
  opacity: 0.7;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 72px;
  padding: 0 clamp(1rem, 3vw, 2.25rem);
  background: var(--nav);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  margin-right: auto;
}

.brand-name {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 1.35rem;
  letter-spacing: 0.16em;
}

.brand-sub {
  color: var(--text-soft);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filter,
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 0;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.filter:hover,
.btn:hover {
  border-color: var(--text-soft);
}

.filter[aria-pressed="true"] {
  border-color: var(--mark);
  box-shadow: inset 0 -2px 0 var(--mark);
}

.btn-primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: var(--on-cinnabar);
  padding-inline: 1rem;
}

.btn-primary:hover {
  background: #7f2b25;
  border-color: #7f2b25;
  color: var(--on-cinnabar);
}

.filter:active,
.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  cursor: progress;
  opacity: 0.6;
}

.filter:focus-visible,
.btn:focus-visible,
.brand:focus-visible,
.icp:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 3px;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  padding: clamp(1.25rem, 3vw, 2.4rem) clamp(1rem, 4vw, 3.5rem) clamp(1.5rem, 3vw, 2.6rem);
  perspective: 1400px;
}

.reading {
  position: relative;
  width: min(1080px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: end;
  min-height: clamp(30rem, 68dvh, 42rem);
  padding: 1.25rem 0.5rem 8.5rem;
}

.poet-block {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  justify-self: start;
}

.poet-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dynasty,
.form,
.poet-name {
  margin: 0;
}

.dynasty {
  color: var(--mark);
  font-family: "KaiTi", "STKaiti", "楷体", "Songti SC", "SimSun", serif;
  font-size: 1.15rem;
  letter-spacing: 0.42em;
}

.form {
  color: var(--text-soft);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
}

.poet-name {
  writing-mode: vertical-rl;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(3.4rem, min(7.2vw, 13dvh), 6.6rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.12em;
}

.ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.poet-block,
.verse,
.ink {
  transition: opacity 0.38s ease;
}

.reading.is-leaving .poet-block,
.reading.is-leaving .verse,
.reading.is-leaving .ink {
  opacity: 0;
}

.reading.no-fade .poet-block,
.reading.no-fade .verse,
.reading.no-fade .ink {
  transition: none;
}

.verse {
  position: relative;
  z-index: 1;
  justify-self: end;
  color: var(--ink);
}

.poem {
  writing-mode: vertical-rl;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 1.05rem;
  width: max-content;
  min-height: 0;
  margin-left: auto;
  font-family: "KaiTi", "STKaiti", "楷体", "Songti SC", "SimSun", serif;
  font-size: clamp(1.95rem, 3.4vw, 2.65rem);
  line-height: 1;
}

.reading.is-long .poem {
  font-size: clamp(1.42rem, 1.85vw, 1.75rem);
  gap: 0.62rem;
}

.poem-title,
.poem-col {
  margin: 0;
  letter-spacing: 0.28em;
}

.poem-title {
  font-size: 1.16em;
}

.poem-char {
  display: inline-block;
  opacity: 1;
  animation: ink-in 0.78s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(min(var(--i), 34) * 24ms);
}

.seal {
  align-self: end;
  display: grid;
  place-items: center;
  width: 4.3rem;
  height: 4.3rem;
  margin: 0;
  margin-block-start: 1.15rem;
  writing-mode: vertical-rl;
  color: var(--seal);
  border: 2px solid var(--seal);
  outline: 1px solid var(--seal);
  outline-offset: 3px;
  background: transparent;
  font-family: "KaiTi", "STKaiti", "楷体", "SimSun", serif;
  font-size: 1.28rem;
  letter-spacing: 0.14em;
  line-height: 1;
  transform: rotate(-7deg);
  animation: stamp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(min(var(--n, 8), 34) * 24ms + 70ms);
}

.notice {
  margin: 4rem 0 0;
  font-family: "KaiTi", "STKaiti", "楷体", "SimSun", serif;
  font-size: 1.4rem;
  letter-spacing: 0.16em;
}

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

.footer {
  padding: 0.35rem clamp(1rem, 3vw, 2.25rem) 1.35rem;
}

.icp {
  color: var(--text-soft);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-underline-offset: 0.22em;
}

.icp:hover {
  color: var(--text);
}

.noscript {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 1.25rem 1.5rem;
  color: var(--text-soft);
}

@keyframes ink-in {
  from {
    opacity: 0;
    transform: translateY(0.4em);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stamp {
  0% {
    opacity: 0;
    transform: rotate(-12deg) scale(1.08) translateY(-0.4rem);
  }

  100% {
    opacity: 1;
    transform: rotate(-7deg) scale(1) translateY(0);
  }
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-28px, 18px, 0); }
}

@keyframes mist {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(36px, -22px, 0) scale(1.06); }
}

@media (prefers-reduced-motion: no-preference) {
  .orb { animation: drift 16s ease-in-out infinite alternate; }
  .mist-a { animation: mist 24s ease-in-out infinite alternate; }
  .mist-b { animation: mist 30s ease-in-out infinite alternate-reverse; }
}

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

@media (prefers-reduced-transparency: reduce) {
  .nav {
    background: var(--bg);
    backdrop-filter: none;
  }
}

@media (max-width: 860px) {
  .nav {
    display: grid;
    grid-template-columns: 1fr auto auto;
    column-gap: 0.5rem;
    row-gap: 0.7rem;
    height: auto;
    min-height: 0;
    align-items: center;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    margin-right: 0;
  }

  .nav-actions {
    display: contents;
  }

  #theme {
    grid-column: 2;
    grid-row: 1;
  }

  #next {
    grid-column: 3;
    grid-row: 1;
  }

  .filters {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    flex: none;
    overflow: visible;
    flex-wrap: wrap;
  }

  .stage {
    align-items: stretch;
    padding-top: 1.25rem;
  }

  .reading {
    grid-template-columns: 1fr;
    gap: 1rem;
    min-height: 32rem;
    justify-items: center;
  }

  .poet-block {
    flex-direction: row;
    align-items: center;
    justify-self: center;
    gap: 1rem;
  }

  .poet-name {
    writing-mode: horizontal-tb;
    font-size: clamp(2.2rem, 11vw, 3.2rem);
    order: -1;
  }

  .verse {
    justify-self: center;
  }

  .poem {
    font-size: 1.55rem;
    gap: 0.75rem;
  }

  .reading.is-long .poem {
    font-size: 1.28rem;
    gap: 0.45rem;
  }

  .seal {
    width: 3.5rem;
    height: 3.5rem;
    left: 0.9rem;
    bottom: 0.9rem;
    font-size: 1.05rem;
  }
}

@media (max-width: 420px) {
  .brand-sub {
    display: none;
  }

  .filter,
  .btn {
    padding-inline: 0.55rem;
    letter-spacing: 0.04em;
  }
}

@media (max-height: 760px) and (min-width: 861px) {
  .poet-name {
    font-size: clamp(2.8rem, 10vh, 4.8rem);
  }

}

@media print {
  .atmosphere,
  #dust,
  .nav-actions,
  .noscript {
    display: none;
  }

  body,
  .page {
    background: white;
    color: black;
  }

  .verse {
    color: black;
  }
}
