/* Docs landing pages (templates/pages/docs-landing.ts and docs-home.ts):
 * the site home's bento carousel, category pills and product cards, and a
 * product's home with its entry cards, topic cards and product list.
 *
 * Colours come from tokens.css only, so light and dark both follow the
 * theme. Layout follows the width main gives us (container queries), not
 * the viewport, since the shell decides the frame. */

/* The home spans the screen between fluid gutters; a product home keeps a
 * wide, centred column so its title lines up with its grids. */
.docs-home {
  --gutter: clamp(16px, 3.4vw, 80px);
  container-type: inline-size;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 72px var(--gutter) 48px;
  font-family: var(--d-font);
  color: var(--d-fg);
}

.docs-home--landing {
  padding-top: 24px;
}

.docs-home--product {
  max-width: calc(1440px + 2 * var(--gutter));
}

.docs-ico {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
}

/* ---- Headings ---- */

.docs-home__head {
  margin: 0 0 28px;
}

.docs-home__title {
  margin: 0 0 10px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.docs-home--product .docs-home__title {
  font-size: 34px;
}

.docs-home__lead {
  max-width: 640px;
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--d-muted);
}

.docs-home__section {
  margin-top: 56px;
}

.docs-home__h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---- Artwork: accent ribbons sweeping in, with a glass icon tile ---- */

.docs-art {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(150px, 12cqw, 200px);
  overflow: hidden;
  background: var(--d-panel-soft);
  --ax: 108%;
  --ay: 125%;
}

.docs-art::before,
.docs-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.docs-art::before {
  background: radial-gradient(
    circle at var(--ax) var(--ay),
    transparent 0 34%,
    var(--d-accent) 34% 41%,
    color-mix(in srgb, var(--d-accent) 35%, var(--d-panel-soft)) 41% 44%,
    var(--d-accent) 44% 50%,
    transparent 50% 56%,
    color-mix(in srgb, var(--d-accent) 60%, var(--d-panel-soft)) 56% 61%,
    color-mix(in srgb, var(--d-accent) 25%, var(--d-panel-soft)) 61% 64%,
    transparent 64%
  );
}

/* Light falling across the ribbons. */
.docs-art::after {
  background: linear-gradient(115deg, color-mix(in srgb, var(--d-panel) 35%, transparent), transparent 55%);
}

.docs-art[data-art="1"] {
  --ax: -12%;
  --ay: 135%;
}

.docs-art[data-art="2"] {
  --ax: 118%;
  --ay: -30%;
}

.docs-art[data-art="3"] {
  --ax: 45%;
  --ay: 175%;
}

.docs-art__tile {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid color-mix(in srgb, var(--d-panel) 70%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--d-panel) 78%, transparent);
  box-shadow: var(--d-shadow-pop);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--d-fg);
}

.docs-art__tile .docs-ico {
  width: 28px;
  height: 28px;
}

/* ---- Site home: the image carousel ----
 * Each slide is one link around one 16:9 image, shown whole. The track's
 * padding leaves room for the hover lift and the focus ring, which the
 * scroller would otherwise clip. */

/* Each slide spans the same width as the product grid below, at 16:9;
 * slides snap to the centre. */
.docs-hero {
  --slide-w: 100%;
  margin: 0 0 28px;
}

.docs-hero__track {
  display: flex;
  gap: 16px;
  margin: -10px;
  padding: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
}

.docs-hero__track::-webkit-scrollbar {
  display: none;
}

.docs-hero__slide {
  display: block;
  flex: none;
  width: var(--slide-w);
  overflow: hidden;
  border: 1px solid var(--d-line);
  border-radius: 20px;
  background: var(--d-panel-soft);
  scroll-snap-align: center;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}

.docs-hero[data-count="1"] .docs-hero__slide {
  margin-inline: auto;
}

.docs-hero:not([data-count="1"]) .docs-hero__track {
  padding-inline: max(10px, calc((100% - var(--slide-w)) / 2));
}

.docs-hero__slide img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.docs-hero__slide:hover {
  border-color: var(--d-line-strong);
  box-shadow: var(--d-shadow-pop);
  transform: translateY(-3px);
}

.docs-hero__slide:focus-visible {
  outline: 2px solid var(--d-focus);
  outline-offset: 3px;
}

.docs-hero__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.docs-hero__pause {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--d-panel-soft);
  color: var(--d-fg-2);
  cursor: pointer;
}

.docs-hero__pause:hover {
  background: var(--d-active);
}

.docs-hero__pause:focus-visible {
  outline: 2px solid var(--d-focus);
  outline-offset: 2px;
}

.docs-hero__pause .docs-ico {
  width: 14px;
  height: 14px;
}

.docs-hero__icon-play,
.docs-hero[data-paused] .docs-hero__icon-pause {
  display: none;
}

.docs-hero[data-paused] .docs-hero__icon-play {
  display: block;
}

.docs-hero__dots {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-radius: var(--d-radius-pill);
  background: var(--d-panel-soft);
}

.docs-hero__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--d-faint);
  cursor: pointer;
  transition:
    width 0.25s,
    background-color 0.25s;
}

.docs-hero__dot--active {
  width: 26px;
  background: var(--d-fg);
}

.docs-hero__dot:focus-visible {
  outline: 2px solid var(--d-focus);
  outline-offset: 3px;
}

/* ---- Site home: categories and product cards ---- */

.docs-catalogue {
  position: relative;
}

.docs-catalogue__label {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

input.docs-catalogue__radio {
  position: absolute;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.docs-catalogue__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.docs-catalogue__pills label {
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--d-radius-pill);
  font-size: 15px;
  color: var(--d-fg-2);
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.docs-catalogue__pills label:hover {
  background: var(--d-hover);
}

.docs-catalogue:has(#docs-cat-all:checked) label[for="docs-cat-all"],
.docs-catalogue:has(#docs-cat-developers:checked) label[for="docs-cat-developers"],
.docs-catalogue:has(#docs-cat-users:checked) label[for="docs-cat-users"] {
  border-color: var(--d-accent-line);
  background: var(--d-accent-soft);
  color: var(--d-accent);
}

.docs-catalogue:has(#docs-cat-all:focus-visible) label[for="docs-cat-all"],
.docs-catalogue:has(#docs-cat-developers:focus-visible) label[for="docs-cat-developers"],
.docs-catalogue:has(#docs-cat-users:focus-visible) label[for="docs-cat-users"] {
  outline: 2px solid var(--d-focus);
  outline-offset: 2px;
}

.docs-catalogue:has(#docs-cat-developers:checked) .docs-product:not([data-audience="developers"]),
.docs-catalogue:has(#docs-cat-users:checked) .docs-product:not([data-audience="users"]) {
  display: none;
}

.docs-catalogue__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.docs-product,
.docs-feature {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-lg);
  background: var(--d-panel);
  color: var(--d-fg);
  text-decoration: none;
}

.docs-product {
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.docs-product:hover {
  border-color: var(--d-accent-line);
  box-shadow: var(--d-shadow-pop);
}

.docs-product__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px 20px;
}

.docs-product__title {
  font-size: 18px;
  font-weight: 600;
}

.docs-product__lead {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--d-muted);
}

.docs-product__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--d-accent-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.docs-product__link .docs-ico {
  width: 15px;
  height: 15px;
  color: var(--d-accent);
  transition: transform 0.2s;
}

.docs-product:hover .docs-product__link .docs-ico {
  transform: translateX(3px);
}

/* ---- Product home: entry cards ---- */

.docs-entries {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.docs-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--d-line);
  border-radius: 12px;
  background: var(--d-panel);
  color: var(--d-fg);
  text-decoration: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.docs-entry:hover {
  border-color: var(--d-accent-line);
  box-shadow: var(--d-shadow-pop);
}

.docs-entry__icon {
  margin-bottom: 14px;
  color: var(--d-accent);
}

.docs-entry__icon .docs-ico {
  width: 30px;
  height: 30px;
  stroke-width: 1.4;
}

.docs-entry__title {
  font-size: 15px;
  font-weight: 600;
}

.docs-entry__lead {
  font-size: 14px;
  line-height: 1.5;
  color: var(--d-muted);
}

/* ---- Product home: topic cards ---- */

/* As many columns as topics, up to three; four topics sit two by two. */
.docs-features {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 16px;
}

.docs-feature .docs-art {
  height: 160px;
}

.docs-feature__body {
  padding: 18px 18px 22px;
}

.docs-feature__title {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.docs-feature__links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-feature__links a {
  font-size: 15px;
  color: var(--d-fg);
  text-decoration: underline;
  text-decoration-color: var(--d-accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.docs-feature__links a:hover {
  color: var(--d-accent);
}

/* ---- Product home: other products ---- */

.docs-explore {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 48px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-explore__item {
  display: flex;
  gap: 16px;
  color: var(--d-fg);
  text-decoration: none;
}

.docs-explore__icon {
  color: var(--d-faint);
  transition: color 0.2s;
}

.docs-explore__icon .docs-ico {
  width: 30px;
  height: 30px;
  stroke-width: 1.3;
}

.docs-explore__text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.docs-explore__text b {
  font-size: 15px;
  font-weight: 600;
}

.docs-explore__text span {
  font-size: 14px;
  line-height: 1.5;
  color: var(--d-muted);
}

.docs-explore__item:hover .docs-explore__icon,
.docs-explore__item:hover b {
  color: var(--d-accent);
}

/* ---- Narrower frames ---- */

@container (min-width: 1000px) {
  .docs-explore {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container (min-width: 1200px) {
  .docs-features[data-count="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@container (max-width: 1100px) {
  .docs-catalogue__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container (max-width: 820px) {
  .docs-entries,
  .docs-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-catalogue__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 560px) {
  .docs-hero__slide {
    border-radius: 14px;
  }

  .docs-catalogue__grid,
  .docs-explore,
  .docs-features {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-entry {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .docs-home {
    padding-bottom: 40px;
  }

  .docs-home__title {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .docs-hero__track {
    scroll-behavior: auto;
  }

  .docs-hero__slide,
  .docs-product,
  .docs-entry,
  .docs-hero__dot,
  .docs-product__link .docs-ico {
    transition: none;
  }
}

/* The home's heading block stays compact under the slide. */
.docs-home--landing .docs-home__head {
  margin-bottom: 18px;
}

.docs-home--landing .docs-catalogue__label {
  margin-bottom: 8px;
}
