:root {
  --c-bg: #fff;
  --c-scrollbar: #ddd;
  --c-scrollbar-hover: #bbb;
  --c-text: #000;
}

:root.dark {
  --c-bg: #050505;
  --c-scrollbar: #222;
  --c-scrollbar-hover: #444;
  --c-text: #fff;
}

html {
  scroll-behavior: smooth;

  background-color: var(--c-bg);
}

html:has(#bg-rose) {
  scrollbar-gutter: stable;
}

body {
  overflow-x: hidden;
  overflow-y: scroll;
}

::selection {
  background: #8884;
}

/* NProgress */
#nprogress {
  pointer-events: none;
}

#nprogress .bar {
  z-index: 50;
  position: fixed;
  top: 0;
  left: 0;

  width: 100%;
  height: 2px;

  background: #888;
  opacity: 0.75;
}

/* Scrollbar */
@supports (scrollbar-width: auto) {
  * {
    scrollbar-width: auto;
  }

  #search-results,
  #nav-panel,
  #toc-panel {
    scrollbar-width: none;
  }
}

@supports (scrollbar-color: auto) {
  * {
    scrollbar-color: var(--c-scrollbar) var(--c-bg);
  }
}

/* Slide Enter Animation */
@keyframes slide-enter {
  0% {
    transform: translateY(10px);
    opacity: 0;
  }

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

@media (prefers-reduced-motion: no-preference) {
  body:not([data-no-sliding]) .slide-enter,
  body:not([data-no-sliding]) .slide-enter-content > *:not(aside) {
    --enter-initial: 0ms;
    --enter-stage: 0;
    animation: slide-enter 1s both 1;
    animation-delay: calc(
      var(--enter-initial) + var(--enter-step) * var(--enter-stage)
    );
  }

  .slide-enter-content > *:nth-child(1) {
    --enter-stage: 1 !important;
  }
  .slide-enter-content > *:nth-child(2) {
    --enter-stage: 2 !important;
  }
  .slide-enter-content > *:nth-child(3) {
    --enter-stage: 3 !important;
  }
  .slide-enter-content > *:nth-child(4) {
    --enter-stage: 4 !important;
  }
  .slide-enter-content > *:nth-child(5) {
    --enter-stage: 5 !important;
  }
  .slide-enter-content > *:nth-child(6) {
    --enter-stage: 6 !important;
  }
  .slide-enter-content > *:nth-child(7) {
    --enter-stage: 7 !important;
  }
  .slide-enter-content > *:nth-child(8) {
    --enter-stage: 8 !important;
  }
  .slide-enter-content > *:nth-child(9) {
    --enter-stage: 9 !important;
  }
  .slide-enter-content > *:nth-child(10) {
    --enter-stage: 10 !important;
  }
  .slide-enter-content > *:nth-child(11) {
    --enter-stage: 11 !important;
  }
  .slide-enter-content > *:nth-child(12) {
    --enter-stage: 12 !important;
  }
  .slide-enter-content > *:nth-child(13) {
    --enter-stage: 13 !important;
  }
  .slide-enter-content > *:nth-child(14) {
    --enter-stage: 14 !important;
  }
  .slide-enter-content > *:nth-child(15) {
    --enter-stage: 15 !important;
  }
  .slide-enter-content > *:nth-child(16) {
    --enter-stage: 16 !important;
  }
  .slide-enter-content > *:nth-child(17) {
    --enter-stage: 17 !important;
  }
  .slide-enter-content > *:nth-child(18) {
    --enter-stage: 18 !important;
  }
  .slide-enter-content > *:nth-child(19) {
    --enter-stage: 19 !important;
  }
  .slide-enter-content > *:nth-child(20) {
    --enter-stage: 20 !important;
  }
}

/* View Transition API */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 9999;
}

.dark::view-transition-old(root) {
  z-index: 9999;
}

.dark::view-transition-new(root) {
  z-index: 1;
}

/* Panel Animation */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.fade-in {
  animation: fade-in var(--fade-in-duration, 0.3s) forwards;
}

.fade-out {
  animation: fade-out var(--fade-out-duration, 0.3s) forwards;
}

/* Search */
#search-input:focus {
  outline: none;
}

#search-input::placeholder {
  color: inherit;
  opacity: 0.4;
}

#search-input::-webkit-search-cancel-button {
  display: none;
}

.search-result-h1 {
  padding: 0 0.625rem 0.375rem;
  border-bottom: 1px solid #7d7d7d4d;
  margin: 0.75rem 0 0.375rem;

  opacity: 0.4;

  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1rem;
  text-transform: uppercase;

  user-select: none;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 1px;

  padding: 0.5rem 0.625rem;
  border-radius: 6px;

  background: transparent;
  outline: none;

  font-size: 1rem;
  transition: opacity 0.2s ease;
}

.search-result-item:first-child {
  margin-top: 8px;
}

.search-result-item[aria-selected='true'] {
  --uno: 'bg-[#88888811] dark:bg-[#88888818]';
}

.search-result-excerpt {
  font-size: 0.875rem;
  line-height: 1.3rem;
  font-weight: 400;

  opacity: 0.5;
}

.search-result-excerpt mark,
mark.pagefind-highlight {
  color: var(--c-text);
  --uno: 'bg-[#88888830] dark:bg-[#8888884d]';
}

.search-kbd-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 1.5rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 0.375rem;
  border-width: 1px;

  font-size: 0.625rem;
  line-height: 1;
  text-transform: uppercase;

  --uno: 'b-[#0000002e] bg-[#ffffffd9] dark:b-[#ffffff38] dark:bg-[#ffffff0F]';
}
