/* ==========================================================================
   Koharu — Layout shell
   Header, sidebar, footer, drawer, floating controls, search.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page frame
   -------------------------------------------------------------------------- */
.site {
  display: flex;
  min-height: 100vh;
  /* See the note on `body` in base.css: `vh` is the retracted-address-bar
     height and re-lays out the page whenever the bar moves. */
  min-height: 100dvh;
  flex-direction: column;
  color: hsl(var(--foreground));
}

.site-main {
  position: relative;
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  gap: 1rem;
}

/* Two-column grid: 256px sticky sider + fluid content column. */
.page-wrap {
  display: flex;
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  align-items: flex-start;
  justify-content: center;
}

.page-main {
  display: flex;
  min-width: 0;
  flex-grow: 1;
  flex-direction: column;
  gap: 2rem;
}

/* The white "card" that every page's content sits on. */
.content-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  padding: 2rem 2.5rem;
  background: var(--gradient-bg-start);
  box-shadow: var(--box-bg-shadow) 0px 50px 50px -50px;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 30;
  padding-block: 0.625rem;
  color: #fff;
  text-shadow: 0 0.2rem 0.3rem rgba(0, 0, 0, 0.5);
  user-select: none;
  transition: transform var(--duration-ui) var(--ease-in-out), color var(--duration-ui) var(--ease-out),
    border-color var(--duration-ui) var(--ease-out);
  border-bottom: 1px solid transparent;
}

/* Backdrop that fades in once the page is scrolled.
   The source theme paints a diagonal gradient here; the design brief asked for a
   flat surface instead — `--background` is white in the light theme and follows
   the dark theme's own background, so the nav stays legible either way. The 1px
   border stays for a crisp edge and the shadow below gives the lift. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: hsl(var(--background));
  transition: opacity var(--duration-ui) var(--ease-out);
}

.site-header.is-scrolled {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--border));
  text-shadow: none;
  /* Depth only — the border above is the hairline. `0 1px 0` as well would
     stack a second line on it and read as a 2px seam. */
  box-shadow: 0 6px 16px hsl(var(--foreground) / 0.08);
}

.site-header.is-scrolled::before {
  opacity: 1;
}

/* Hide on scroll down, reveal on scroll up. */
.site-header.is-hidden {
  transform: translateY(-100%);
}

.header-inner {
  display: flex;
  max-width: 80rem;
  margin-inline: auto;
  align-items: center;
  justify-content: space-between;
  padding-inline: 1.5rem;
}

.header-logo {
  display: flex;
  margin-block: -1rem;
  margin-right: 1rem;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.header-logo img,
.header-logo svg {
  height: 2rem;
  width: auto;
}

/* "Bear Days" display face used for the wordmark. */
.logo-text {
  margin: 0;
  font-family: "Bear Days", var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
  color: #e9546b;
  text-shadow: 3px 4px 2px #060000, -1px -1px 0px #ffffff;
}

.dark .logo-text {
  color: #ed788c;
}

.header-nav {
  display: flex;
  flex-grow: 1;
  align-items: center;
}

.nav-list {
  display: flex;
  flex-grow: 1;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  position: relative;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Animated underline that grows from the centre on hover / current page.
 *
 * 400ms, not the 300ms the rest of the UI uses: the source's link utility asks
 * for `duration-300` but loses to `#site-header a::after { transition-duration:
 * 400ms }`, an ID-qualified rule that outranks it, which is what actually runs
 * (`src/styles/global/tailwind.css:118-125`). Both properties are on the same
 * 400ms — the source's `transition-all` covers the underline's colour change on
 * scroll as well. */
.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0.25rem;
  left: 50%;
  display: block;
  height: 2px;
  width: 0;
  transform: translateX(-50%);
  background: #fff;
  transition: width 400ms var(--ease-in-out), background-color 400ms var(--ease-in-out);
}

.nav-link:hover::after,
.nav-item.is-current > .nav-link::after,
.nav-item.is-current > .nav-parent::after {
  width: 75%;
}

.site-header.is-scrolled .nav-link::after {
  background: hsl(var(--foreground));
}

.nav-icon {
  display: inline-flex;
  margin-right: 0.375rem;
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  height: 100%;
  width: 100%;
}

/* Dropdown ---------------------------------------------------------------- */
.nav-parent {
  display: inline-flex;
  height: 2.5rem;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
  background: none;
  border: 0;
}

.nav-chevron {
  position: absolute;
  right: -0.375rem;
  height: 1.5rem;
  width: 1.5rem;
  transition: transform var(--duration-ui) var(--ease-in-out);
}

.nav-item.is-open .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: 10rem;
  padding: 0.25rem 0;
  margin: 0;
  list-style: none;
  border-start-start-radius: 1rem;
  border-end-end-radius: 1rem;
  background: rgb(0 0 0 / 0.3);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.85);
  transform-origin: top left;
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out),
    visibility var(--duration-fast);
}

.nav-item.is-open .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  color: #fff;
  text-shadow: none;
  transition: background var(--duration-ui) var(--ease-out);
}

.nav-dropdown li:first-child a {
  border-start-start-radius: 1rem;
}

.nav-dropdown li:last-child a {
  border-end-end-radius: 1rem;
}

.nav-dropdown a:hover {
  background: var(--gradient-shoka-button);
}

/* Right-hand action cluster ---------------------------------------------- */
.header-actions {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 0.5rem;
}

.header-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  /* Source: `transition duration-300 hover:scale-125` around a size-8 icon. */
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow,
    transform, filter, backdrop-filter;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 300ms;
}

.header-action:hover {
  transform: scale(1.25);
}

.header-action svg {
  height: 2rem;
  width: 2rem;
}

/* Light / dark switch -----------------------------------------------------
   Ported 1:1 from components/theme/theme-toggle.css. The indicator is a bare
   circle whose inset box-shadow *is* the sun; flipping the checkbox shrinks
   it into a moon disc and blooms a ring of sparkles behind it. */
.theme-toggle {
  display: flex;
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: scale(0.8);
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow,
    transform, filter, backdrop-filter;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 300ms;
}

.theme-toggle:hover {
  transform: scale(0.9);
}

.theme-toggle .toggle {
  display: block;
  cursor: pointer;
}

.toggle-input {
  display: none;
}

.toggle-indicator {
  position: relative;
  display: block;
  height: 36px;
  width: 36px;
  border-radius: 50%;
  box-shadow: inset 16px -16px 0 0 var(--theme-toggle-color, #ffbb52);
  transform: scale(1) rotate(-2deg);
  transition:
    box-shadow 0.5s ease 0s,
    transform 0.4s ease 0.1s;
}

.toggle-indicator::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: inherit;
  height: inherit;
  border-radius: inherit;
  background: transparent;
  transition: background 0.3s ease;
}

.toggle-indicator::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  height: 8px;
  width: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  box-shadow:
    0 -23px 0 var(--theme-toggle-color, #ffbb52),
    0 23px 0 var(--theme-toggle-color, #ffbb52),
    23px 0 0 var(--theme-toggle-color, #ffbb52),
    -23px 0 0 var(--theme-toggle-color, #ffbb52),
    15px 15px 0 var(--theme-toggle-color, #ffbb52),
    -15px 15px 0 var(--theme-toggle-color, #ffbb52),
    15px -15px 0 var(--theme-toggle-color, #ffbb52),
    -15px -15px 0 var(--theme-toggle-color, #ffbb52);
  transform: scale(0);
  transition: all 0.3s ease;
}

/* Dark mode (moon) */
.toggle-input:checked + .toggle-indicator {
  box-shadow: inset 32px -32px 0 0 var(--theme-background-color, #17181c);
  transform: scale(0.5) rotate(0deg);
  transition:
    transform 0.3s ease 0.1s,
    box-shadow 0.2s ease 0s;
}

.toggle-input:checked + .toggle-indicator::before {
  background: var(--theme-toggle-color, #ffbb52);
  transition: background 0.3s ease 0.1s;
}

.toggle-input:checked + .toggle-indicator::after {
  transform: scale(1.5);
  transition: transform 0.5s ease 0.15s;
}

/* Hamburger (<= 992px) ---------------------------------------------------- */
.menu-toggle {
  position: fixed;
  top: 0;
  left: 0.75rem;
  z-index: 52;
  display: none;
  height: 3.5rem;
  align-items: center;
  transition: transform var(--duration-ui) var(--ease-in-out);
}

.menu-toggle.is-hidden {
  transform: translateY(-100%);
}

.menu-toggle button {
  display: flex;
  height: 2.5rem;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  background: rgb(255 255 255 / 0.2);
  color: hsl(var(--primary));
}

.menu-toggle svg {
  height: 1.5rem;
  width: 1.5rem;
}

/* Hamburger → X. The source animates the three <line>s with a spring
   (stiffness 300 / damping 25); --ease-spring is the closest CSS equivalent. */
.menu-line {
  transform-box: view-box;
  transition: transform 300ms var(--ease-spring), opacity 300ms var(--ease-spring);
}

.menu-line-1 {
  transform-origin: 12px 6px;
}

.menu-line-2 {
  transform-origin: 12px 12px;
}

.menu-line-3 {
  transform-origin: 12px 18px;
}

.menu-toggle.is-open .menu-line-1 {
  transform: translateY(6px) rotate(45deg);
}

.menu-toggle.is-open .menu-line-2 {
  opacity: 0;
}

.menu-toggle.is-open .menu-line-3 {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile header slot ------------------------------------------------------
   Below 992px the logo column collapses and this centred slot takes over:
   the wordmark, or — on article pages — the reading-progress pill that
   opens the table of contents. */
.mobile-post-header {
  position: relative;   /* containing block for the swap below */
  display: none;
  min-width: 0;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.mph-logo {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.mph-logo img {
  height: 2rem;
  width: auto;
}

.mph-pill {
  display: flex;
  width: calc(100vw - 12rem);
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.75rem 0.25rem 0.375rem;
  border: 0;
  border-radius: 9999px;
  background: hsl(var(--foreground) / 0.1);
  color: inherit;
  text-align: start;
  backdrop-filter: blur(4px);
  transition: background-color var(--duration-ui) var(--ease-in-out);
}

.mph-pill:hover {
  background: hsl(var(--foreground) / 0.2);
}

.mph-progress {
  flex-shrink: 0;
  height: 2rem;
  width: 2rem;
  transform: rotate(-90deg);
}

.mph-progress-track,
.mph-progress-value {
  fill: transparent;
  stroke: currentColor;
  stroke-width: 2.5;
}

.mph-progress-track {
  opacity: 0.2;
}

.mph-progress-value {
  stroke: hsl(var(--primary));
  stroke-linecap: round;
  /* 2πr for r = 14.75 (32px box, 2.5px stroke). */
  stroke-dasharray: 92.677;
  stroke-dashoffset: 92.677;
}

.mph-title {
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/*
 * Wordmark <-> pill swap. The source mounts one or the other inside an
 * `AnimatePresence mode="wait"` and cross-fades it on `animation.spring.gentle`
 * — `spring(stiffness 200, damping 25)`, or `{ duration: 0 }` when the reader
 * has asked for less motion (`MobilePostHeader/index.tsx:72-88`). Its wrapper is
 * `flex items-center gap-2`, so `mode="wait"` is also what keeps the pair from
 * ever occupying the slot at the same time.
 *
 * `mode="wait"` needs a hand-off to be scheduled, and this slot is rewritten
 * from the scroll spy, so a timer per crossing would land in the scroll path.
 * The port cross-fades instead: both change in one tick, and the outgoing node
 * leaves the flow (`position: absolute`) for the length of the fade so the
 * incoming one occupies the slot alone and stays centred exactly where the
 * source puts it. `visibility` is what actually takes it out — it drops off the
 * accessibility tree and stops taking clicks — and its delayed step is what
 * keeps it painted until the fade has run.
 */
.mph-logo,
.mph-pill {
  transition: opacity var(--duration-ui) var(--ease-out), visibility 0s linear 0s;
}

.mph-logo.is-faded,
.mph-pill.is-faded {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-ui) var(--ease-out),
    visibility 0s linear var(--duration-ui);
}

/* The source drops the swap outright rather than shortening it. */
@media (prefers-reduced-motion: reduce) {
  .mph-logo,
  .mph-pill,
  .mph-logo.is-faded,
  .mph-pill.is-faded {
    transition: none;
  }
}

html.motion-off .mph-logo,
html.motion-off .mph-pill,
html.motion-off .mph-logo.is-faded,
html.motion-off .mph-pill.is-faded {
  transition: none;
}

/*
 * The heading name inside the pill. `HeadingTitle` cross-fades it on a
 * `mode="wait"` too — out at `{ opacity: 0, y: -12, filter: blur(4px) }`, in
 * from `{ opacity: 0, y: 20, filter: blur(4px) }`, `spring(400, 30)` on the
 * transform with the blur on its own 200ms tween. Same reasoning as above, so
 * the port runs the arriving half only, re-triggered on each heading change.
 *
 * `filter` is a repaint-heavy property on a node the scroll spy rewrites, which
 * is why this is an in-only pass over a small text node and not a permanent
 * layer: it costs one 300ms animation each time the reader crosses a heading.
 * `HeadingTitle` carries no reduced-motion branch, so neither does this.
 */
@keyframes koharu-mph-title-in {
  from {
    opacity: 0;
    transform: translateY(1.25rem);
    filter: blur(4px);
  }
}

.mph-title.is-swapping {
  animation: koharu-mph-title-in var(--duration-ui) var(--ease-spring);
}

/*
 * The source's dropdown motion: `initial` and `exit` are
 * `{ opacity: 0, scale: 0.85 }`, the resting state is
 * `{ opacity: 1, scale: 1, originY: 0 }`, and the transition is
 * `animation.spring.popoverContent` — `spring(stiffness 300, damping 20)`
 * (`MobileTOCDropdown.tsx:94-99`, `design-tokens.ts`).
 *
 * `originY: 0` is the part that makes it read as a dropdown rather than a
 * balloon: it grows down out of the pill it hangs from. `--ease-spring` is the
 * port's stand-in for that spring.
 *
 * Driven by `.is-open` instead of `[hidden]`, because `base.css` gives `[hidden]`
 * a `display: none` and nothing transitions out of that. The script keeps the
 * panel laid out for the length of the close. Same shape as `.mobile-drawer`.
 *
 * Left ungated by the motion switches on purpose: the source has no
 * `shouldReduceMotion` branch here, and this is a transition the reader just
 * asked for, not ambient decoration.
 */
.mph-panel {
  position: fixed;
  top: 4.5rem;
  left: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  max-height: 60vh;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  background: hsl(var(--background) / 0.8);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: scale(0.85);
  transform-origin: 50% 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-ui) var(--ease-spring);
}

.mph-panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Hero banner
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  z-index: 0;
  display: flex;
  height: 60dvh;
  max-height: var(--hero-height, 50rem);
  overflow: hidden;
}

/* The source theme's `compact` variant (h-[42dvh] min-h-72 max-h-120,
   tablet:h-[36dvh] tablet:min-h-64) belongs to the moments-style pages, which
   are out of scope here — every cover is full height, as on the home page. */

/*
 * 主题设置 → 外观 → 头图黑色遮罩. The variable is set on `.hero`; 40% there
 * (the default) resolves to the `rgb(0 0 0 / 0.4)` this scrim has always been.
 * The picture underneath is never filtered — the scrim is what makes the white
 * title readable, so it is the thing with the knob.
 */
.hero-overlay {
  position: absolute;
  inset: 0;
  height: 100%;
  background: rgb(0 0 0 / var(--hero-mask, 0.4));
}

.hero-content {
  position: absolute;
  inset: 0;
  bottom: 8dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-inline: 1.25rem;
  color: #fff;
  text-align: center;
}

.hero-title-alt {
  margin: 0;
  font-size: 3rem;
  line-height: 1.2;
  text-shadow: 0 0.2rem 0.3rem rgba(0, 0, 0, 0.5);
}

.hero-title {
  display: flex;
  max-width: 80rem;
  margin: 0.75rem 0 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-shadow: 0 0.2rem 0.3rem rgba(0, 0, 0, 0.5);
}

/* Article headers drop one step (text-4.5xl → 2.5rem) and lose the wide
   tracking; the ≤768px step is text-2xl → 1.5rem. */
.hero.is-post .hero-title {
  font-size: 2.5rem;
  letter-spacing: 0.02em;
}

.hero-subtitle {
  margin: 1.25rem 0 0;
  font-size: 0.875rem;
  text-shadow: 0 0.2rem 0.3rem rgba(0, 0, 0, 0.5);
}

.hero-meta {
  display: flex;
  margin: 0.75rem 0 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: 1rem;
}

.hero-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hero-meta svg {
  height: 1rem;
  width: 1rem;
}

.hero-media {
  position: relative;
  z-index: -10;
  height: 100%;
  min-height: 15rem;
  width: 100%;
}

.hero-media img {
  height: 100%;
  width: 100%;
  object-fit: cover;
}

/*
 * Banner with both shapes uploaded: the two pictures are stacked and exactly
 * one of them is drawn. The two are never cross-faded against each other on
 * first paint, because only one of them has ever been at `opacity: 1`.
 *
 * The switch is the orientation media feature, which is `width > height` — a
 * square window counts as portrait and keeps 站点头图, which is what the
 * setting promises. Both pictures load eagerly (see `template-parts/hero.php`),
 * so the crossfade below never reveals a half-arrived image.
 */
.hero-media.has-pair img {
  position: absolute;
  inset: 0;
}

.hero-media.has-pair .hero-img--wide {
  opacity: 0;
}

/* Armed only once the script has seen both pictures finish loading; until then
   the switch is instant, which is the right answer for a window that is being
   dragged around before anything has arrived anyway. */
.hero-media.has-pair.is-ready img {
  transition: opacity var(--duration-normal) var(--ease-out);
}

@media (orientation: landscape) {
  .hero-media.has-pair .hero-img--square {
    opacity: 0;
  }

  .hero-media.has-pair .hero-img--wide {
    opacity: 1;
  }
}

/* Movement goes, the fade stays — the same split the rest of the theme uses. */
@media (prefers-reduced-motion: reduce) {
  .hero-media.has-pair img {
    transition: none;
  }
}

html.motion-off .hero-media.has-pair img {
  transition: none;
}

/* Animated wave divider along the bottom edge of the hero. */
.hero-wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 15dvh;
  min-height: 3.125rem;
  max-height: 9.375rem;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.page-sider {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  width: 16rem;
  min-width: 16rem;
  max-width: 16rem;
  flex-direction: column;
  align-self: flex-start;
  overflow: auto;
  padding-inline: 0.5rem;
  box-shadow: var(--box-bg-shadow) 50px -10px 30px -50px;
}

/* Keep the sider clear of the fixed header while it is visible. */
@media (min-width: 993px) {
  .page-sider {
    top: 3.5rem;
    height: calc(100vh - 3.5rem);
  }

  .site-header.is-hidden ~ .site-main .page-sider {
    top: 0;
    height: 100vh;
  }

  /* On a post the segmented control takes over: the column is a fixed block and
     `.sider-content` carries the scrolling, so the sidebar sits flush with the
     page instead of being a panel you scroll separately. */
  body.single-post .page-sider {
    overflow: hidden;
  }
}

.sider-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4.5rem;
}

.sider-avatar {
  position: relative;
  height: 10rem;
  width: 10rem;
  border-radius: 9999px;
}

.sider-avatar img {
  height: 100%;
  width: 100%;
  border-radius: 9999px;
  object-fit: cover;
  box-shadow: 0 0 2rem var(--box-bg-shadow);
  /* The source's avatar carries a bare `transition` utility alongside the hover
     animation (`HomeInfo.astro:42`). */
  transition: all var(--duration-fast, 150ms) var(--ease-in-out);
}

/*
 * The avatar wobbles when the pointer is over it — `hover:animate-shake`, which
 * compiles to `animation: shake 2s ease` (`tailwind.config.mjs:98`).
 *
 * Gated on the motion preference, and registered with the Settings Center's
 * switch in base.css, exactly as the source does in
 * `src/styles/global/motion.css:8,22`.
 */
@media (prefers-reduced-motion: no-preference) {
  .sider-avatar img:hover {
    animation: koharu-shake 2s ease;
  }
}

.sider-name {
  margin: 0.5rem 0 0;
}

.sider-desc {
  margin: 0.75rem 0 0;
  text-align: center;
  color: hsl(var(--muted-foreground));
}

.sider-social {
  display: grid;
  margin-top: 0.5rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.social-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.75rem;
  padding: 0.25rem 0.375rem;
  /* The icon is fill="currentColor", so the brand tint has to land here — not
     only on ::before below — or every icon inherits the body text colour. */
  color: var(--link-color, hsl(var(--primary)));
  transition: transform var(--duration-ui) var(--ease-out),
    color var(--duration-ui) var(--ease-out);
}

/* GitHub's brand colour is near-black, which vanishes on a dark background.
   The source theme makes this one an exception (Social.astro). It has to be
   repeated on the svg: the :hover rule below targets the svg directly, and a
   direct rule beats an inherited one no matter how specific the ancestor is —
   so without this the icon would go dark-on-dark when hovered. */
.dark .social-link[data-platform="github"],
.dark .social-link[data-platform="github"] > svg,
.dark .social-link[data-platform="github"]:hover > svg {
  color: hsl(var(--foreground));
}

.social-link:hover {
  transform: scale(1.05);
}

.social-link > svg,
.social-link > img {
  position: relative;
  z-index: 1;
  display: inline-block;
  height: 1.5rem;
  width: 1.5rem;
  transition: color var(--duration-ui) var(--ease-out);
}

/* Diagonal colour sweep on hover. */
.social-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 0.75rem;
  background: var(--link-color, hsl(var(--primary)));
  transform: translate(-100%, 100%);
  transition: transform var(--duration-ui) var(--ease-out);
}

.social-link:hover::before {
  transform: translate(0, 0);
}

.social-link:hover > svg,
.social-link:hover > img {
  color: hsl(var(--background));
}

.sider-stats {
  display: flex;
  margin-top: 0.75rem;
  justify-content: center;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1rem;
  white-space: nowrap;
  user-select: none;
  color: hsl(var(--muted-foreground));
}

.sider-stat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem;
  transition: color var(--duration-ui) var(--ease-out);
}

.sider-stat:hover {
  color: hsl(var(--shoka-blue));
}

.sider-stat strong {
  font-size: 1.125rem;
  line-height: 1.25rem;
  font-weight: 700;
}

.sider-stat-sep {
  margin-inline: 0.75rem;
  width: 1px;
  background: hsl(var(--muted-foreground));
}

.sider-nav {
  display: flex;
  margin-top: 1.5rem;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding-bottom: 1rem;
}

/* Shoka gradient pill used for sidebar navigation buttons.
   Only the current page carries the gradient; everything else is a quiet
   foreground-tinted row that darkens on hover. The source theme does the same
   (`HomeInfo.astro` gives the non-current button `bg-none shadow-none`), and an
   earlier port of this file had it backwards. */
.sider-btn {
  display: flex;
  height: 3rem;
  width: 10rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.75rem;
  background: none;
  color: hsl(var(--muted-foreground) / 0.8);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity var(--duration-ui) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out),
    color var(--duration-ui) var(--ease-out),
    box-shadow var(--duration-ui) var(--ease-out);
}

.sider-btn:hover {
  opacity: 1;
  color: hsl(var(--foreground));
  background: hsl(var(--foreground) / 0.05);
}

.sider-btn.is-current {
  background: var(--gradient-shoka-button);
  color: #fff;
  box-shadow: 0 0 0.75rem var(--color-pink-a3);
}

.sider-btn.is-current:hover {
  color: #fff;
  background: var(--gradient-shoka-button);
  box-shadow: 0 0 0.75rem var(--color-pink);
}

.sider-btn svg {
  margin-right: 0.5rem;
  height: 1.25rem;
  width: 1.25rem;
}

/* Submenu groups. The tinted box around trigger and children mirrors the
   source's `bg-foreground/10` wrapper. */
.sider-group {
  display: flex;
  width: 10rem;
  flex-direction: column;
  border-radius: 0.75rem;
  background: hsl(var(--foreground) / 0.1);
}

.sider-group .sider-parent {
  width: 100%;
  border-radius: 0.75rem;
}

.sider-parent .sider-chevron {
  margin-right: 0;
  margin-left: 0.5rem;
  transition: transform var(--duration-ui) var(--ease-in-out);
}

.sider-group.is-open .sider-chevron {
  transform: rotate(180deg);
}

/* The fold: a grid row that goes from 0fr to 1fr, as the source does, so the
   height animates without measuring anything in script. `visibility` takes the
   collapsed links out of the tab order; it is stepped rather than interpolated,
   which is why it waits for the row to finish closing.

   The curve is the plain `ease` keyword, not this file's `--ease-in-out` token.
   They are different curves: `--ease-in-out` is cubic-bezier(0.4, 0, 0.2, 1),
   while the keyword is cubic-bezier(0.25, 0.1, 0.25, 1). The source writes the
   keyword (`HomeInfo.astro:171` — `transition: grid-template-rows 0.3s ease`).
   `--duration-ui` is that same 300ms. */
.sider-sub {
  display: grid;
  grid-template-rows: 1fr;
  visibility: visible;
}

.sider-sub > div {
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
}

.sider-group:not(.is-open) .sider-sub {
  grid-template-rows: 0fr;
  visibility: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .sider-sub {
    transition: grid-template-rows var(--duration-ui) ease,
      visibility 0s linear 0s;
  }

  .sider-group:not(.is-open) .sider-sub {
    transition: grid-template-rows var(--duration-ui) ease,
      visibility 0s linear var(--duration-ui);
  }
}

.sider-group.is-open .sider-sub {
  padding-bottom: 0.5rem;
}

.sider-sub-btn {
  height: 2.5rem;
  width: 8.5rem;
  font-size: 0.875rem;
}

/* The children carry an icon too, as the source's do — at the text's own size
   rather than the parent buttons' 1.25rem. */
.sider-sub-btn svg {
  height: 1rem;
  width: 1rem;
  margin-right: 0.375rem;
}

/* Segmented control ------------------------------------------------------
   The article sidebar shows one panel at a time, switched by this row. Colours
   and proportions come from the source theme's `Segmented` component: a
   foreground-tinted pill, the selected segment filled with the Shoka gradient,
   the others dimmed.

   Only the selected segment shows its label — the source animates the others'
   labels down to zero width, which is also what keeps three Chinese labels from
   overflowing a 256px column. */
.sider-segmented {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.25rem;
  border-radius: 0.375rem;
  background: hsl(var(--foreground) / 0.08);
  backdrop-filter: blur(4px);
}

.sider-seg-tab {
  position: relative;
  isolation: isolate;
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.25rem 0.25rem;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.sider-seg-tab:hover {
  opacity: 0.85;
}

.sider-seg-tab.is-active {
  opacity: 1;
  color: #fff;
}

/* The gradient fill sits behind the label, faded in only when selected — same
   trick the source uses so the pill can cross-fade instead of swapping. */
.sider-seg-tab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 0.25rem;
  background: var(--gradient-shoka-button);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.sider-seg-tab.is-active::before {
  opacity: 1;
}

.sider-seg-tab > svg {
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
}

/* The label collapses for the segments that are not selected. It is a width
   collapse rather than `display: none` so the pill can animate, and it keeps the
   row inside the column at every width — the full labels do not fit side by
   side in 256px.

   The labels stay in the DOM and keep their `aria-hidden` off the inactive
   ones' text nodes, so a screen reader announces the tab by its `aria-label`
   on the button rather than by the (zero-width) text. */
.sider-seg-tab > span {
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width var(--duration-fast) var(--ease-out),
    margin-left var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}

.sider-seg-tab.is-active > span {
  max-width: 8rem;
  margin-left: 0;
  opacity: 1;
}

/* Panel container. On a post the sider itself stops scrolling and this element
   takes over, so the column reads as one fixed block with its contents moving
   inside it — the arrangement the source theme has. */
.sider-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 1.5rem;
  padding-top: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.sider-panel[hidden] {
  display: none;
}

.sider-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Swapping panels slides the incoming one in from the right, as the source's
   `<sider-content>` does (`HomeSider.astro:177-184` adds `.entering` inside a
   `requestAnimationFrame` after hiding the others, then `:250-265` runs
   `slide-in-from-right 0.15s ease-out` — the keyframe is below, under the
   motion query the source puts it in).

   `entering` is left on the panel until the next swap clears it, exactly as the
   source does: the animation is one-shot, and re-adding the class is what
   replays it. The base rule is the reduced-motion result, so the media block
   only ever has to turn it on.

   The easing is the `ease-out` keyword, not this file's `--ease-out` token —
   same trap as `.sider-sub` above, different pair of curves: the token is
   cubic-bezier(0, 0, 0.2, 1), the keyword is cubic-bezier(0, 0, 0.58, 1).

   Not in base.css's motion-off list: that list is for the continuous decorative
   motion (spinning sakura, shaking tabs), not for one-shot feedback on
   something the reader just clicked — the same reason the dropdown and the
   light/dark toggle are not in it either. */
.sider-panel.entering {
  animation: none;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes koharu-slide-in-right {
    from {
      opacity: 0;
      transform: translateX(12px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .sider-panel.entering {
    animation: koharu-slide-in-right 0.15s ease-out;
  }
}

/* Series list ------------------------------------------------------------ */
.series-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.series-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
  border-radius: 0.375rem;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  line-height: 1.5;
  text-decoration: none;
  transition: background var(--duration-ui) var(--ease-out);
}

.series-link:hover {
  background: hsl(var(--accent) / 0.5);
}

.series-link.is-current {
  color: hsl(var(--primary));
  font-weight: 500;
}

.series-dot {
  height: 0.5rem;
  width: 0.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: hsl(var(--muted-foreground) / 0.4);
  transition: background var(--duration-ui) var(--ease-out);
}

.series-link:hover .series-dot {
  background: hsl(var(--muted-foreground) / 0.6);
}

.series-link.is-current .series-dot {
  background: hsl(var(--primary));
}

.series-title {
  display: -webkit-box;
  flex: 1;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.series-empty {
  margin: 0;
  padding-block: 2rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* Reading progress bar pinned under the sider. */
.sider-progress {
  margin-top: auto;
  width: 100%;
  padding-top: 1rem;
}

.sider-progress-bar {
  height: 0.25rem;
  transform-origin: left;
  border-radius: 9999px;
  background: hsl(var(--primary));
  transform: scaleX(0);
}

/* Both progress readouts chase the scroll position rather than snapping to it.
   The source feeds each one through Motion's `useSpring` — the bar
   (`ScrollProgress.tsx:20-24`) and the pill's ring (`ProgressCircle.tsx:27`) use
   the same `{ stiffness: 100, damping: 30, restDelta: 0.001 }` — and script
   here has no spring to call, so the smoothing is done in CSS instead.

   `linear` is the faithful curve, not a shortcut: that spring is overdamped
   (ζ = 30 / 2√100 = 1.5), so it has no overshoot to reproduce and its settled
   behaviour is a plain exponential lag with a ~260ms time constant. A linear
   transition is that same lag. An eased one would be a different shape.

   Only while motion is allowed, and only when the visitor has not flipped the
   Settings Center's motion switch off — the source bypasses the spring in both
   of those cases and assigns the raw scroll value (`ScrollProgress.tsx:27`:
   `shouldReduceMotion || masterMotion ? scrollYProgress : springProgress`). */
@media (prefers-reduced-motion: no-preference) {
  .sider-progress-bar,
  .mph-progress-value {
    transition: transform 260ms linear, stroke-dashoffset 260ms linear;
  }
}

html.motion-off .sider-progress-bar,
html.motion-off .mph-progress-value {
  transition: none;
}

/* The Settings Center's reading-progress switch. It covers both places the
   source theme reads progress — the bar under the sider and the ring inside the
   mobile pill. The pill itself stays: it is also the table-of-contents opener,
   so only its ring goes and its padding closes up behind it. */
.scroll-progress-off .sider-progress,
.scroll-progress-off .mph-progress {
  display: none;
}

.scroll-progress-off .mph-pill {
  padding-inline-start: 0.75rem;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: auto;
  padding-bottom: 1.5rem;
}

.footer-inner {
  display: flex;
  max-width: 80rem;
  margin-inline: auto;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-inline: 1.5rem;
}

.footer-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.footer-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.75;
  transition: opacity var(--duration-ui) var(--ease-out);
}

.footer-stat:hover {
  opacity: 1;
}

.footer-stat svg {
  height: 1rem;
  width: 1rem;
}

.footer-stat-sep {
  height: 1rem;
  width: 1px;
  background: hsl(var(--muted-foreground) / 0.3);
}

.footer-copy {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.footer-copy .author {
  font-weight: 500;
  opacity: 0.75;
}

.footer-sakura {
  margin-inline: 0.25rem;
  height: 1.25rem;
  width: 1.25rem;
  color: #ffc0cb;
  animation: koharu-spin 10s linear infinite;
  /* The footer is `margin-top: auto`, so this spin is always on screen at the
     end of a fling. Pinning it to its own layer keeps the rotation from
     repainting the footer text around it. */
  will-change: transform;
}

@keyframes koharu-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* The 「页脚导航」 menu, printed only when one is assigned to that location. */
.footer-nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.375rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.footer-nav-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* A hairline between links — a separator element would be one more thing for the menu editor to render. */
.footer-nav-list li + li::before {
  content: "";
  width: 1px;
  height: 0.75rem;
  background: hsl(var(--muted-foreground) / 0.3);
}

.footer-nav-list a {
  color: hsl(var(--muted-foreground));
  transition: color var(--duration-ui) var(--ease-out);
}

.footer-nav-list a:hover,
.footer-nav-list .current-menu-item > a {
  color: hsl(var(--primary));
}

.footer-filing {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground) / 0.8);
}

.footer-link {
  position: relative;
  opacity: 0.75;
  transition: opacity var(--duration-ui) var(--ease-out);
}

.footer-link:hover {
  opacity: 1;
}

.footer-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: currentColor;
  transition: width var(--duration-ui) var(--ease-out);
}

.footer-link:hover::after {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Mobile drawer
   -------------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgb(0 0 0 / 0.5);
}

.drawer-overlay.is-open {
  display: block;
}

.mobile-drawer {
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 50;
  display: none;
  /*
   * `100dvh`, with `100vh` before it as the fallback for browsers that do not
   * know the unit. `100vh` on a phone is the height with the address bar
   * *retracted* — the same fact `base.css` records a few lines above where it
   * reaches for `100dvh` on `html`.
   *
   * It matters here because the drawer's scroller is `.mobile-drawer-inner` at
   * `height: 100%`: a drawer taller than the screen hands its scroller more room
   * than there is screen. Measured on the live site at 390×844, the menu inside
   * came to 790px in an 832px scroller — 42px of slack, so nothing overflowed,
   * so nothing scrolled, and the last entries sat below the fold with no way to
   * reach them. That is the whole bug: not a locked page, a scroller that
   * believed it had room it did not have. With `dvh` the scroller tracks the
   * visible height and the menu scrolls.
   *
   * The source theme has the same `h-screen` here; this is the one place the
   * port knowingly differs, because on a phone the source's own choice is what
   * puts the last menu entry out of reach.
   */
  height: 100vh;
  height: 100dvh;
  width: 70vw;
  min-width: 16rem;
  transform: translateX(-100%);
  padding: 0.75rem 1rem 0;
  background: var(--gradient-bg-start);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  backdrop-filter: blur(4px);
  transition: transform var(--duration-ui) var(--ease-in-out);
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer-inner {
  display: flex;
  height: 100%;
  width: 100%;
  flex-direction: column;
  overflow: auto;
  /*
   * The drawer is the only scrollable thing on screen while it is open — the page
   * behind it is locked — so its scroll should stop at its own edges rather than
   * chain out to a document that cannot move. Same treatment, and the same
   * reason, as 设置中心's panel (`settings.css`).
   */
  overscroll-behavior: contain;
}

/* The drawer has no head row of its own: the hamburger outside it morphs into
   the X that closes it, as in the source theme. */

/* Inside the drawer the sider becomes a plain full-width column. */
.mobile-drawer .page-sider {
  position: static;
  display: flex;
  height: auto;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  /*
   * 2rem, not 0.5rem, and the number is load-bearing. `.mobile-drawer-inner` is
   * `overflow: auto`, so it clips its children's paint at its own top edge —
   * which is 12px down, where the drawer's padding ends. At `0.5rem` the avatar
   * landed at 20px and its `0 0 2rem rgba(0,0,0,.1)` glow was cut off 8px into
   * a 16px falloff, leaving a hard step: a light 12px strip above it, then the
   * shadow. Measured down the drawer at x=100: 253,251,251 for 12px, then
   * 249,247,247 stepping to 243,241,241 — the "light leak". At 2rem the avatar
   * starts at 44px and the glow is fully faded out by 28px, so nothing is
   * clipped and the top of the drawer is one flat field, which is what the
   * source measures (253,251,251 the whole way down to the avatar).
   *
   * The source gets the same clearance from a 32px row of its own at the top of
   * the drawer (language switcher and close button); the port has neither, so
   * the space is kept as space.
   */
  margin-top: 2rem;
  padding-inline: 0;
  overflow: visible;
  box-shadow: none;
}

.mobile-drawer .sider-profile {
  padding-top: 0;
}

/* --------------------------------------------------------------------------
   Floating controls (bottom-right)
   -------------------------------------------------------------------------- */
.floating-group {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: hsl(var(--primary));
}

.floating-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  /* Feedback on a toggle the reader just pressed, so it stays animated under
     reduced motion — the rule base.css documents for hovers, dropdowns and the
     drawer, which is why `.mobile-drawer`'s own slide is ungated too. Only the
     continuous decorative motion (sakura, tab shake) is in that list. */
  transition: opacity var(--duration-fast) var(--ease-in-out),
    transform var(--duration-fast) var(--ease-in-out);
}

/* Opening and closing the toolbar slides the whole stack up out of the toggle
   and back down behind it, fading as it goes — the source's `FloatingGroup.tsx`
   gives the group `initial={{ y: 50, opacity: 0 }}`, `animate={{ y: 0,
   opacity: 1 }}`, `exit={{ y: 50, opacity: 0 }}` at `duration: 0.15, ease:
   'easeInOut'`, which is this file's `--duration-fast` (150ms) and
   `--ease-in-out` (the CSS `ease-in-out`, cubic-bezier(0.4, 0, 0.2, 1)).

   The collapsed state is the *absence* of `.is-open` rather than the `hidden`
   attribute, because a transition cannot run on a box that is already
   `display: none`. main.js takes `hidden` off first and adds the class a frame
   later, then puts `hidden` back once the animation is over — the same
   arrangement the mobile drawer uses.

   `pointer-events` is off while collapsed so the invisible buttons are not
   clickable during the 150ms the fade takes. */
.floating-stack:not(.is-open) {
  opacity: 0;
  transform: translateY(50px);
  pointer-events: none;
}

/* The source slides the entire group out of the way while the mobile drawer is
   open (`FloatingGroup.tsx` animates `x: 200, opacity: 0` when `$isDrawerOpen`
   at `duration: 0.3, ease: 'easeInOut'`). Without this the buttons kept
   floating *over* the drawer: `.mobile-drawer` and `.floating-group` are both
   `z-index: 50`, and the group comes later in the document, so it painted on
   top of the panel it was supposed to get out of. */
.floating-group {
  transition: opacity var(--duration-ui) var(--ease-in-out),
    transform var(--duration-ui) var(--ease-in-out);
}

body.drawer-open .floating-group {
  opacity: 0;
  transform: translateX(200px);
  pointer-events: none;
}

.floating-btn {
  display: flex;
  height: 2.25rem;
  width: 2.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 0;
  border-radius: 9999px;
  background: hsl(var(--background) / 0.8);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  backdrop-filter: blur(4px);
  opacity: 0.8;
  /* `transform` is in the list because a press shrinks the button — the source
     gives its floating buttons `transition-all duration-200`, and
     `SettingsPanelContent.tsx` presses down with `active:scale-[0.96]`. Before
     this the corner buttons had no press state at all: they changed colour on
     hover and nothing on click, which is what "点击没有对应的动画" described. */
  transition: background var(--duration-tween, 200ms) var(--ease-out),
    opacity var(--duration-tween, 200ms) var(--ease-out),
    transform var(--duration-tween, 200ms) var(--ease-out);
}

.floating-btn:hover {
  background: hsl(var(--background));
  opacity: 1;
}

.floating-btn:active {
  transform: scale(0.96);
}

/* A press the reader just made, so it stays under reduced motion — the rule
   base.css states for hovers and toggles, not for ambient decoration. */
@media (prefers-reduced-motion: reduce) {
  .floating-btn:active {
    transform: none;
  }
}

html.motion-off .floating-btn:active {
  transform: none;
}

.floating-btn svg {
  height: 1.25rem;
  width: 1.25rem;
}

/* The toolbar toggle and the settings button each carry both of their icons;
   `[aria-expanded]` on the button — which main.js already maintains — decides
   which one is drawn. The settings gear fills in while its panel is open,
   which is the source's `ri:settings-3-line` → `ri:settings-3-fill` swap. */
.floating-toggle-icon,
.settings-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-toggle-icon--open,
.settings-toggle-icon--open,
#koharu-floating-toggle[aria-expanded="true"] .floating-toggle-icon:not(.floating-toggle-icon--open),
#koharu-settings-open[aria-expanded="true"] .settings-toggle-icon:not(.settings-toggle-icon--open) {
  display: none;
}

#koharu-floating-toggle[aria-expanded="true"] .floating-toggle-icon--open,
#koharu-settings-open[aria-expanded="true"] .settings-toggle-icon--open {
  display: flex;
}

/* --------------------------------------------------------------------------
   Search dialog
   -------------------------------------------------------------------------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-tween) var(--ease-out);
}

.search-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.search-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding-inline: 1rem;
  /* The wrapper covers the viewport, so while the close fade is running it
     would otherwise go on swallowing clicks aimed at the page behind it. */
  pointer-events: none;
}

.search-wrap.is-open {
  pointer-events: auto;
}

.search-panel {
  width: 100%;
  max-width: 48rem;
  overflow: auto;
  border-radius: 0.75rem;
  background: var(--gradient-bg-start);
  color: hsl(var(--foreground));
  box-shadow: var(--box-bg-shadow) 0px 50px 50px -50px;
}

/*
 * The dialog's entrance and exit. The source animates all three of its layers
 * at `duration: 0.2` (`SearchDialog.tsx:94-118`): the overlay fades, the
 * full-screen wrapper fades, and the panel itself travels from
 * `opacity: 0, scale: 0.95, y: -10`. The wrapper's fade sits behind the
 * overlay's at the same duration, so nothing distinguishes it — two layers here
 * instead of three, with the same result.
 *
 * Both directions, which is the part this used to miss: the source gives the
 * overlay and the panel an `exit` at the same values, so the dialog dissolved
 * on the way out too, and closing used to be the one hard cut left in the
 * header. Driven by `.is-open` rather than by a replayed `@keyframes`, because
 * a keyframe cannot run backwards — and because `[hidden]` is a `display: none`
 * that nothing transitions out of, so the script takes the class off, waits out
 * the 200ms, and only then sets `hidden`.
 *
 * The curve is the one thing not carried over: the source gives Motion a
 * duration and no `ease`, so it runs Motion's own default, which is not one of
 * the CSS keywords. The nearest keyword is used and the difference at 200ms is
 * not something the eye resolves.
 */
.search-panel {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transition: opacity var(--duration-tween) var(--ease-out),
    transform var(--duration-tween) var(--ease-out);
}

.search-wrap.is-open .search-panel {
  opacity: 1;
  transform: none;
}

/* Movement goes, the fade stays — the same split the source makes everywhere it
   checks for reduced motion, and the same one `.settings-panel` uses. */
@media (prefers-reduced-motion: reduce) {
  .search-panel {
    transform: none;
  }
}

html.motion-off .search-panel {
  transform: none;
}

.search-panel-inner {
  position: relative;
  padding: 1.5rem;
}

.search-head {
  position: relative;
  display: flex;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
}

.search-head h2 {
  display: flex;
  margin: 0;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

/* The title's icon has to carry a size of its own.
   `koharu_icon()` writes no `width`/`height` attributes unless it is passed a
   size, and the other call sites all size the SVG from CSS — this one had no
   rule, so the icon was an unsized replaced element inside a flex row. That is
   what turned 搜索 into a vertical title: this `h2` is itself a flex item of a
   `space-between` row, so its width comes from its contents, and with the icon's
   size indefinite the content-based width came out as icon + gap + a single
   character. CJK breaks between any two characters, so the two stacked.
   Measured with the real markup and stylesheets, 1440 and 390 alike: unsized
   45×58 with two line boxes; sized 65×29 with one. */
.search-head h2 svg {
  height: 1.25rem;
  width: 1.25rem;
}

.search-close {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  background: rgb(0 0 0 / 0.05);
  transition: background var(--duration-ui) var(--ease-out);
}

.search-close:hover {
  background: rgb(0 0 0 / 0.1);
}

.dark .search-close {
  background: rgb(255 255 255 / 0.1);
}

.dark .search-close:hover {
  background: rgb(255 255 255 / 0.2);
}

.search-results {
  height: calc(80dvh - 140px);
  overflow: auto;
  scroll-behavior: smooth;
}

.search-field {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  background: hsl(var(--background));
}

.search-hint {
  padding-top: 2rem;
  text-align: center;
  font-size: 0.875rem;
  opacity: 0.6;
}

.search-result {
  display: block;
  padding: 0.75rem;
  border-radius: 0.5rem;
  transition: background var(--duration-ui) var(--ease-out);
}

.search-result:hover {
  background: hsl(var(--foreground) / 0.05);
}

.search-result-title {
  font-weight: 600;
  color: hsl(var(--primary));
}

.search-result-excerpt {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.search-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 0.5rem;
  font-size: 0.75rem;
  color: rgb(0 0 0 / 0.5);
}

.dark .search-foot {
  color: rgb(255 255 255 / 0.5);
}

kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.125rem 0.375rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem;
  background: hsl(var(--muted));
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.7rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .site-header {
    padding-block: 0.5rem;
    padding-left: 0.75rem;
    padding-right: 0;
    backdrop-filter: blur(8px);
  }

  .header-inner {
    width: 100%;
    padding-left: 2.5rem;
    padding-right: 0.75rem;
  }

  .header-logo {
    display: none;
  }

  .mobile-post-header {
    display: flex;
  }

  .nav-list {
    display: none;
  }

  /* The nav wrapper has to go too, not just its list. `.header-nav` is
     `flex-grow: 1`, so with the list hidden it was still a flex item asking for
     an equal share of the row — 91px of it, measured at 390px — and it pushed
     the centred logo slot that much to the right. The logo sat at cx 223 in a
     390px viewport (dead centre is 195); with the wrapper out of the row the
     slot starts where the source's does and the logo lands at 177, which is the
     source's own measured position. Nothing is lost by hiding it: every link
     inside it is `display: none` at this width already, and the drawer is the
     navigation here. */
  .header-nav {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  /* While the drawer is up the hamburger stays, morphed into the X that closes
     it — that is the source theme's arrangement. An earlier port did the
     opposite: it hid the hamburger here and gave the drawer its own X in the
     top-right corner, so the panel had a close button in a place the source
     never puts one. */

  .mobile-drawer {
    display: block;
  }

  .page-sider {
    display: none;
  }

  .content-card {
    padding: 1.5rem 1.5rem 0.5rem;
    box-shadow: none;
  }
}

@media (max-width: 768px) {
  .page-wrap {
    margin-inline: 0;
  }

  /* Only the article header steps down to text-2xl; the 5xl wordmark-sized
     headers (home / archives / categories) keep their size at every width. */
  .hero.is-post .hero-title {
    font-size: 1.5rem;
  }

  .hero-meta {
    font-size: 0.75rem;
  }

  .footer-inner {
    padding-bottom: 2.5rem;
    padding-inline: 0.75rem;
  }

  .search-panel-inner {
    padding: 0.75rem;
  }

  /* The source's `md:size-4` — the icon steps down with the panel's padding. */
  .search-head h2 svg {
    height: 1rem;
    width: 1rem;
  }
}
