/* ============================================================
   小可爱的小书房 · 暮色星图版
   共享设计系统：暮蓝、灯金、旧木、纸白与一缕粉线。
   ============================================================ */

:root {
  color-scheme: dark;
  --night: #0b0d12;
  --night-raised: #111721;
  --night-soft: #182130;
  --paper: #f3eadb;
  --paper-soft: #e7dbc8;
  --paper-deep: #d1bea4;
  --ink: #28231f;
  --ink-soft: #685e55;
  --cream: #f4e7d2;
  --cream-soft: #cbbba5;
  --gold: #e1b66f;
  --gold-bright: #f3d092;
  --rose: #c98f97;
  --rose-deep: #8f5d67;
  --indigo: #14294b;
  --indigo-soft: #29466f;
  --line-night: rgba(238, 218, 188, .18);
  --line-paper: rgba(65, 49, 36, .17);
  --glass: rgba(12, 14, 18, .62);
  --focus: #f6d18d;
  --shadow-deep: 0 30px 90px rgba(0, 0, 0, .34);
  --shadow-paper: 0 26px 70px rgba(15, 10, 7, .22), 0 2px 4px rgba(15, 10, 7, .12);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --gutter: clamp(1.35rem, 5vw, 5.6rem);
  --content: 82rem;
  --header-h: 5.6rem;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="day"] {
  color-scheme: light;
  --night: #d8d3ca;
  --night-raised: #e5dfd5;
  --night-soft: #c9c1b6;
  --paper: #fbf5e9;
  --paper-soft: #eee3d2;
  --paper-deep: #d8c5aa;
  --ink: #2a2520;
  --ink-soft: #675d54;
  --cream: #2e2924;
  --cream-soft: #62584f;
  --gold: #a66f30;
  --gold-bright: #8a5824;
  --rose: #9a5d68;
  --rose-deep: #7d4651;
  --indigo: #617897;
  --indigo-soft: #7f94ae;
  --line-night: rgba(55, 45, 35, .18);
  --line-paper: rgba(66, 50, 38, .16);
  --glass: rgba(244, 237, 226, .74);
  --focus: #80501f;
  --shadow-deep: 0 30px 80px rgba(64, 48, 36, .17);
  --shadow-paper: 0 24px 60px rgba(72, 51, 34, .16), 0 2px 4px rgba(72, 51, 34, .08);
}

* { box-sizing: border-box; }

html {
  min-width: 20rem;
  scroll-behavior: smooth;
  background: var(--night);
  scrollbar-color: var(--rose) var(--night);
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 83% 4%, rgba(42, 66, 103, .22), transparent 33rem),
    var(--night);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::selection { background: var(--rose); color: #fff8ed; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { color: inherit; font: inherit; }
button { border: 0; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: .025em;
}

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

::view-transition-old(root),
::view-transition-new(root) { animation-duration: .45s; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: .8rem;
  left: .8rem;
  padding: .75rem 1rem;
  transform: translateY(-160%);
  border-radius: .25rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  transition: transform .2s;
}

.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Header */

.site-header {
  position: sticky;
  z-index: 80;
  top: 0;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto minmax(3rem, 1fr);
  align-items: center;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line-night);
  background: color-mix(in srgb, var(--night) 82%, transparent);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
}

.home-page .site-header {
  position: absolute;
  width: 100%;
  background: linear-gradient(to bottom, rgba(7, 7, 8, .62), transparent);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.brand {
  justify-self: start;
  font-family: var(--serif);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  letter-spacing: .17em;
  white-space: nowrap;
}

.brand::before {
  display: inline-block;
  width: .42rem;
  height: .42rem;
  margin: 0 .72rem .1rem 0;
  border: 1px solid currentColor;
  transform: rotate(45deg);
  content: "";
  opacity: .72;
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 3vw, 3rem);
}

.primary-nav a {
  position: relative;
  padding: .7rem 0;
  color: var(--cream-soft);
  font-family: var(--serif);
  font-size: .95rem;
  letter-spacing: .14em;
  transition: color .25s var(--ease);
}

.primary-nav a::after {
  position: absolute;
  right: 0;
  bottom: .42rem;
  left: 0;
  height: 1px;
  transform: scaleX(0);
  background: currentColor;
  content: "";
  transform-origin: right;
  transition: transform .35s var(--ease);
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] { color: var(--cream); }

.primary-nav a:hover::after,
.primary-nav a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

.theme-orbit {
  position: relative;
  justify-self: end;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line-night);
  border-radius: 50%;
  background: rgba(7, 8, 11, .22);
  color: var(--cream);
  cursor: pointer;
  transition: transform .35s var(--ease), background .3s, border-color .3s;
}

.theme-orbit:hover {
  transform: rotate(18deg);
  border-color: color-mix(in srgb, var(--gold) 65%, transparent);
  background: rgba(226, 183, 111, .1);
}

.theme-orbit svg {
  width: 100%;
  height: 100%;
  padding: .62rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.35;
}

.theme-orbit .theme-sun {
  opacity: 0;
  transform: scale(.55) rotate(-35deg);
  transform-origin: center;
  transition: opacity .3s, transform .45s var(--ease);
}

.theme-orbit .theme-moon {
  opacity: 1;
  transform-origin: center;
  transition: opacity .3s, transform .45s var(--ease);
}

[data-theme="day"] .theme-orbit .theme-sun {
  opacity: 1;
  transform: scale(1) rotate(0);
}

[data-theme="day"] .theme-orbit .theme-moon {
  opacity: 0;
  transform: scale(.55) rotate(30deg);
}

/* Shared actions and typography */

.paper-action,
.line-action,
.reader-back,
.back-shelf,
.next-one {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.9rem;
  color: inherit;
  font-size: .9rem;
  font-weight: 560;
  letter-spacing: .08em;
}

.paper-action {
  padding: .75rem 1.15rem .72rem;
  border: 1px solid currentColor;
  background: transparent;
  transition: color .25s, background .25s, transform .3s var(--ease);
}

.paper-action:hover {
  transform: translateY(-2px);
  background: currentColor;
  color: var(--night);
}

.line-action { position: relative; padding: .7rem 0; }

.line-action::after {
  position: absolute;
  right: 0;
  bottom: .38rem;
  left: 0;
  height: 1px;
  background: currentColor;
  content: "";
  transform-origin: left;
  transition: transform .3s var(--ease);
}

.line-action:hover::after { transform: scaleX(.62); }

.arrow-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.paper-surface {
  background:
    linear-gradient(rgba(85, 62, 44, .032) 1px, transparent 1px) 0 0 / 100% 2.15rem,
    var(--paper);
  color: var(--ink);
}

.section-shell {
  width: min(var(--content), calc(100% - 2 * var(--gutter)));
  margin: 0 auto;
}

.section-heading { max-width: 46rem; }

.section-heading h2,
.catalog-heading h1,
.night-heading h1 {
  margin-bottom: 1rem;
  font-size: clamp(2.5rem, 5vw, 5.2rem);
  line-height: 1.07;
  letter-spacing: .01em;
}

.section-heading p,
.catalog-heading p,
.night-heading p {
  max-width: 39rem;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(1rem, 1.45vw, 1.2rem);
  line-height: 1.9;
}

/* Paper dialog */

body.dialog-open { overflow: hidden; }

.veil {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: clamp(1.2rem, 4vw, 3rem);
  border: 0;
  background: transparent;
  color: var(--ink);
  opacity: 0;
  transition: opacity .32s;
}

.veil[open] { display: grid; place-items: center; }

.veil::backdrop {
  background: rgba(4, 6, 9, .78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.veil.open { opacity: 1; }

.unfold {
  position: relative;
  width: min(43rem, 100%);
  max-height: min(79vh, 48rem);
  padding: clamp(2rem, 5vw, 4rem);
  overflow: auto;
  border: 1px solid rgba(67, 49, 35, .2);
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(152, 93, 104, .14) 8% calc(8% + 1px), transparent calc(8% + 1px)),
    repeating-linear-gradient(0deg, transparent 0 2rem, rgba(70, 52, 38, .06) 2rem calc(2rem + 1px)),
    var(--paper);
  box-shadow: var(--shadow-paper);
  transform: translateY(1.8rem) rotateX(-3deg) scale(.96);
  opacity: 0;
  transition: transform .5s var(--ease), opacity .3s;
}

.veil.open .unfold {
  transform: translateY(0) rotateX(0) scale(1);
  opacity: 1;
}

.unfold::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(8% - .32rem);
  width: .65rem;
  background: radial-gradient(circle, var(--rose) 0 .16rem, transparent .18rem) center 1.1rem / .65rem 2rem repeat-y;
  content: "";
  opacity: .5;
}

.close-unfold {
  position: sticky;
  z-index: 2;
  top: 0;
  float: right;
  width: 2.5rem;
  height: 2.5rem;
  margin: -1.25rem -1.25rem 1rem 1rem;
  border: 1px solid var(--line-paper);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 1.6rem;
  line-height: 1;
}

.unfold .label {
  margin: 0 0 2rem;
  padding-right: 2rem;
  color: var(--rose-deep);
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.unfold .body {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2vw, 1.18rem);
  line-height: 2;
}

.unfold .body p { margin: 0 0 1.35em; }

/* Footer */

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 10rem;
  padding: 2rem var(--gutter);
  border-top: 1px solid rgba(236, 216, 187, .13);
  background: #090b10;
  color: #e9dcc8;
}

[data-theme="day"] .site-footer { background: #2b2723; }

.footer-brand {
  font-family: var(--serif);
  letter-spacing: .13em;
}

.footer-nav { display: flex; gap: 1.8rem; }

.footer-nav a {
  color: #bcae9c;
  font-size: .83rem;
  letter-spacing: .12em;
}

.footer-nav a:hover,
.footer-nav a[aria-current="page"] { color: #f0dfc7; }

.site-footer > :last-child { justify-self: end; }
.mobile-nav { display: none; }

/* Motion */

@keyframes breathe {
  0%, 100% { opacity: .45; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.12); }
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(.35rem, -.55rem, 0); }
}

@media (max-width: 760px) {
  :root {
    --gutter: 1.25rem;
    --header-h: 4.7rem;
  }

  body { padding-bottom: 4.65rem; }

  .site-header {
    grid-template-columns: 1fr auto;
    padding: 0 var(--gutter);
  }

  .brand {
    font-size: .94rem;
    letter-spacing: .1em;
  }

  .brand::before { margin-right: .5rem; }
  .primary-nav { display: none; }

  .theme-orbit {
    width: 2.75rem;
    height: 2.75rem;
  }

  .section-heading h2,
  .catalog-heading h1,
  .night-heading h1 {
    font-size: clamp(2.25rem, 12vw, 3.7rem);
  }

  .site-footer {
    display: block;
    min-height: 8rem;
    padding: 2.6rem var(--gutter) 2rem;
    text-align: center;
  }

  .footer-nav,
  .site-footer > :last-child { display: none; }

  .mobile-nav {
    position: fixed;
    z-index: 90;
    right: .7rem;
    bottom: max(.7rem, env(safe-area-inset-bottom));
    left: .7rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 3.65rem;
    padding: .35rem;
    border: 1px solid rgba(239, 218, 188, .18);
    border-radius: .7rem;
    background: rgba(9, 11, 15, .9);
    color: #d9cbb8;
    box-shadow: 0 1.2rem 3.5rem rgba(0, 0, 0, .32);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
  }

  .mobile-nav a {
    display: grid;
    place-items: center;
    border-radius: .45rem;
    font-size: .78rem;
    letter-spacing: .08em;
  }

  .mobile-nav a[aria-current="page"] {
    background: rgba(226, 183, 111, .12);
    color: #f1d7ae;
  }

  .unfold {
    max-height: 82vh;
    padding: 2rem 1.6rem 2rem 2.35rem;
  }

  .unfold::before { left: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
