@import "./css/code-block.css";
@import "./css/homepage.css";
@import "./css/site-header.css";
@import "./css/table-of-contents.css";

@view-transition {
  navigation: auto;
}

/* ::view-transition-group(root) {
  animation-duration: 200ms;
} */

/* Override core's body max-width so it doesn't constrain the docs layout */
body {
  max-width: none;
  background-color: var(--ui-background-color);
  color: var(--ui-text-color);

  width: 100vw;
  overflow-x: clip;
}

:root {
  --sidebar-w: 0px;
  --toc-w: 0px;
  --header-h: 56px;
  --border: var(--ui-neutral-200);
  --bg-subtle: var(--ui-neutral-100);
  --code-bg: #24292e; /* github-dark background */

  scroll-behavior: smooth;

  @media (min-width: 769px) {
    --sidebar-w: 220px;
  }

  @media (min-width: 1100px) {
    --toc-w: 180px;
  }
}

/* Layout */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  align-items: start;
}

.docs-layout-wide {
  grid-template-columns: 1fr;

  @media (width > 769px) {
    grid-template-columns: var(--sidebar-w) 1fr;
  }

  .docs-content {
    width: 100%;
    max-width: 100%;
  }
}

/* Sidebar */
.docs-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100svh;
  width: 260px;
  z-index: 99;
  translate: -100% 0;
  transition: translate 300ms var(--ease-glide);
  overflow-y: auto;
  overflow-x: clip;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  padding-block: 1rem;
  padding-inline: 0.5rem;
  background: var(--ui-background-color);

  @media (min-width: 769px) {
    position: sticky;
    top: 4.5rem;
    width: auto;
    bottom: auto;
    z-index: auto;
    translate: none;
    transition: none;
    padding-inline: 0.5rem;
  }

  small,
  a {
    display: flex;
    justify-content: flex-start;
    width: 100%;
  }
}

body:has(.sidebar-toggle:checked) {
  > header,
  main.docs-content {
    translate: 260px 0;
  }

  .docs-sidebar {
    translate: 0 0;
  }
}

.docs-sidebar a[aria-current] {
  background: color-mix(in srgb, var(--ui-primary) 10%, transparent);
}

/* Main content */
.docs-content {
  container-type: inline-size;
  padding: 2.5rem var(--ui-spacing-4);
  min-width: 0;
  width: 100vw;
  margin-inline: auto;

  transition: translate 300ms var(--ease-glide);

  @media (min-width: 769px) {
    width: min(680px, 100%);
    padding-inline: 3rem;
  }
}

.docs-content > .prose {
  margin-bottom: 1rem;
}

.docs-content > .prose h2 {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

/* Preview + code block pairing */
.example {
  margin-bottom: 2rem;
}

.preview {
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  padding: 2.5rem 2rem;
  background: var(--ui-neutral-0);
  display: flex;
  flex-wrap: wrap;
  /* gap: 0.75rem; */
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.preview-padded {
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
}

/* Color scale */
.color-scale {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 2rem;
}

.color-swatch {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  color: var(--ui-neutral-600);
}

.color-swatch-block {
  width: 100%;
  aspect-ratio: 1 / 1.5;
  border-radius: 6px;
}

/* Easing demos */
.easings-animate-toggle {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--ui-spacing-3);
  padding: var(--ui-spacing-3) var(--ui-spacing-4);
  margin-inline: calc(var(--ui-spacing-4) * -1);
  background: var(--ui-background-color);
  border-bottom: 1px solid var(--border);
}

.easing-demo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-subtle);
  border-radius: 8px;
  width: 100%;
}

.easing-track {
  flex: 1;
}

.easing-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--ui-primary);
  transition: translate 600ms linear;
}

.docs-content:has(.switch:checked) .easing-dot {
  translate: calc(100cqi - 2rem) 0;
}

.search-field {
  @media (width < 1024px) {
    display: none;
  }
}

/* Search dialog */
.search-dialog {
  max-width: min(560px, calc(100vw - 2rem));
  width: 100%;

  > article {
    header {
      label {
        width: 100%;
      }
    }
  }

  &[open] {
    display: flex;
    flex-direction: column;
  }
}

.search-results {
  overflow-y: auto;
  max-height: 60vh;
  padding: 0.5rem;
}

.search-result {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0 var(--ui-spacing-3);
  padding: var(--ui-spacing-2) var(--ui-spacing-3);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ui-text-color);

  &:hover {
    background: var(--ui-neutral-100);
  }

}

.search-result-body {
  display: grid;
}

.search-result-title {
  font-size: 0.9375rem;
}

.search-result-desc {
  font-size: 0.8125rem;
  color: var(--ui-neutral-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: var(--ui-spacing-4);
  color: var(--ui-neutral-500);
  font-size: 0.875rem;
  list-style: none;
}

/* Icons dialog */
.icons-dialog {
  max-width: min(960px, calc(100vw - 2rem));
  height: 85vh;
  flex-direction: column;

  > article {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;

    header {
      position: sticky;
      top: 0;
      background: var(--ui-background-color);
      z-index: 1;

      label:first-of-type {
        width: 100%;
      }
    }
  }

  &[open] {
    display: flex;
  }
}

.icons-dialog-content {
  flex: 1;
  padding: var(--ui-spacing-4);
}

/* Icons page */
.icons-search-bar {
  display: flex;
  gap: 1rem;
  justify-content: center;

  label:has(input[type="search"]) {
    width: 100%;
  }
}

.icons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
}

.icon-item {
  display: flex;
}

.icon-copy-btn {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-neutral-700);
  position: relative;

  &::after {
    content: "Copied!";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ui-neutral-100);
    border-radius: inherit;
    color: var(--ui-constructive-500);
    opacity: 0;
    transition: opacity 100ms;
    pointer-events: none;
    z-index: 1;
  }

  svg {
    height: auto;
    width: auto;
  }

  &[data-copied]::after {
    opacity: 1;
  }
}

.callout {
  background-color: var(--ui-neutral-50);
  border: 1px solid var(--ui-neutral-200);
  border-radius: var(--ui-spacing-2);
  padding: var(--ui-spacing-3) var(--ui-spacing-4);
  font-size: 0.875rem;
  color: var(--ui-neutral-700);
  margin-bottom: 1rem;
}
