/* Shibuya, laid out as a sheet of paper on a desk. Every color and font is a --sp-* variable, which
   the look (looks/*.css) sets, in light and dark. */

:root {
  --sp-logo-size: 36px;
  --sp-page-radius: 8px;

  --sy-f-text: var(--sp-font-text);
  --sy-f-heading: var(--sp-font-heading);
  --sy-f-mono: var(--sp-font-mono);

  --code-block-background: var(--sp-code-block-bg);

  --sy-c-text: var(--sp-text);
  --sy-c-heading: var(--sp-text);
  --sy-c-bold: var(--sp-bold);
  --sy-c-light: var(--sp-light);
  --sy-c-link: var(--sp-link);
  --sy-c-link-hover: var(--sp-link-hover);
  --sy-c-background: var(--sp-desk);
  --sy-c-foot-background: var(--sp-desk);
  --sy-c-foot-text: var(--sp-foot-text);
  --sy-c-background-dropback: color-mix(in srgb, var(--sp-desk) 80%, transparent);

  --yue-c-link-1: var(--sp-link);
  --yue-c-link-2: var(--sp-link-hover);
  --yue-c-link-border: var(--sp-link);
  --yue-c-code-text: var(--sp-code-text);
  --yue-c-code-background: var(--sp-code-bg);
  --yue-c-hr: var(--sp-rule);
}

/* Dark-mode code uses the background of its own (dark pygments) style. */
html.dark {
  --code-block-background: var(--syntax-dark-background);
}

/* MyST-NB picks its output colors with --light and --dark, from the system setting or a data-theme
   attribute; Shibuya's color mode is a class instead, which may differ from the system's. */
html.dark {
  --light: ;
  --dark: initial;
}

html.light {
  --light: initial;
  --dark: ;
}

body {
  background-color: var(--sp-desk);
}

/* The page */
.sy-main {
  background-color: var(--sp-page);
  box-shadow: var(--sp-page-shadow);
  border-radius: var(--sp-page-radius);
  margin: 1.5rem 0 4rem;
  min-width: 0;
}

@media (max-width: 767px) {
  .sy-main {
    margin: 0.75rem 0 2rem;
    border-radius: 6px;
  }
}

@media (min-width: 1280px) {
  .sy-rside-inner {
    padding-left: 1.75rem;
  }
}

/* The navbar, a solid band in the look's nav color. */
.sy-head-blur {
  background-color: var(--sp-nav-bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.sy-head-brand,
.sy-head-brand strong,
.sy-head-actions button,
.sy-head-socials a,
.sy-head .theme-switch {
  color: var(--sp-nav-text);
}

.sy-head .hamburger > span {
  background-color: var(--sp-nav-text);
}

/* Below md the links and search fold into a dropdown that keeps the page colors, so only recolor them in the bar itself. */
@media (min-width: 768px) {
  .sy-head .searchbox input {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--sp-nav-text);
  }

  .sy-head .searchbox input::placeholder {
    color: color-mix(in srgb, var(--sp-nav-text) 60%, transparent);
  }

  .sy-head-links a,
  .sy-head-links .link i.external-link {
    color: var(--sp-nav-text);
  }

  .sy-head-links a:hover,
  .sy-head-socials a:hover {
    color: var(--sp-nav-hover);
  }
}

.sy-head-brand img {
  height: var(--sp-logo-size);
  width: auto;
}

/* Sidebars sit on the desk. */
.sy-lside .globaltoc a,
.sy-rside a {
  color: var(--sp-sidebar-link);
}

.sy-lside .globaltoc a:hover,
.sy-rside a:hover {
  color: var(--sp-sidebar-link-hover);
}

/* The current page on the left (or the page it sits under), and the section in view on the right, are underlined. */
.sy-lside .globaltoc a.current,
.sy-lside .globaltoc li.current > a,
.sy-rside .localtoc li.active > a {
  color: var(--sp-link);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.sy-lside .globaltoc .caption {
  font-family: var(--sy-f-heading);
  font-weight: 700;
  color: var(--sp-caption);
}

/* Entries sit further in than the section headings above them. */
.sy-lside .globaltoc > ul {
  padding-left: 1rem;
}

/* Long module paths break rather than run off the edge. */
.sy-lside .globaltoc a {
  overflow-wrap: anywhere;
}

/* Jumps to a section stop 2px short of the line Shibuya uses to pick the active entry in the
   right sidebar (the outer section's scroll-margin-top, offset + 24px), so subpixel rounding can't leave
   the line inside the section above and highlight that one instead. */
.yue section section {
  scroll-margin-top: calc(var(--sy-s-offset-top) + 22px);
}

/* The right sidebar lists two levels of headings. */
.sy-rside .localtoc > ul > li > ul > li > ul {
  display: none;
}

/* Scrollbars sit on the desk: no white track beside the sidebars. */
html,
.sy-scrollbar {
  scrollbar-color: var(--sp-scroll-thumb) var(--sp-desk);
}

/* The left sidebar's scrollbar sits on its left edge, away from the page. */
.sy-lside .sy-scrollbar {
  direction: rtl;
}

.sy-lside .sy-scrollbar > * {
  direction: ltr;
}

/* Breadcrumbs above each page: links in the link color, wrapping when long. Shibuya hides them
   on wide screens and keeps them sticky; they stay sticky only on phones, where they hold the menu button. */
.sy-breadcrumbs {
  display: block;
  background-color: var(--sp-page);
  border-radius: var(--sp-page-radius) var(--sp-page-radius) 0 0;
}

.sy-breadcrumbs ol {
  flex-wrap: wrap;
  white-space: normal;
  row-gap: 0.2rem;
}

.sy-breadcrumbs ol a,
.sy-breadcrumbs .sp-run,
.sy-breadcrumbs .sp-download {
  color: var(--sp-link);
}

.sy-breadcrumbs ol a:hover,
.sy-breadcrumbs .sp-run:hover,
.sy-breadcrumbs .sp-download:hover {
  color: var(--sp-link-hover);
  text-decoration: underline;
}

/* The Run and Download links at the right end of a notebook page's breadcrumbs. */
.sy-breadcrumbs .sp-run,
.sy-breadcrumbs .sp-download {
  margin-left: 1rem;
  white-space: nowrap;
  font-size: 0.94rem;
}

@media (min-width: 768px) {
  .sy-breadcrumbs {
    position: static;
  }

  /* On the home page the trail would only repeat the title. */
  .sy-breadcrumbs.sp-home {
    display: none;
  }
}

@media (min-width: 1280px) {
  .sy-breadcrumbs {
    padding: 0 3rem;
  }
}

/* Code */
.highlight > pre,
pre.literal-block {
  border-radius: 0;
}

/* In light mode, text pygments leaves untagged keeps the look's code color. */
html:not(.dark) .highlight {
  --syntax-text: var(--sp-code-block-text);
}

/* A notebook cell's output sits on the page, not in the code's color, so it reads as a result. */
.yue .cell_output .highlight {
  --code-block-background: transparent;
}

.yue .cell_output .highlight > pre {
  border: 0;
}

/* A code block's caption is a plain label above it. */
.yue .code-block-caption {
  background: none;
  padding: 0 0 0.3rem;
  font-family: var(--sy-f-heading);
  font-weight: 400;
  color: var(--sp-text);
}

/* Names that sphinx-codeautolink links to the API reference are underlined only on hover. */
.highlight a.sphinx-codeautolink-a {
  text-decoration: none;
  text-underline-offset: 3px;
}

.highlight a.sphinx-codeautolink-a:hover {
  text-decoration: underline solid var(--sp-link-hover);
}

/* Headings */
.yue h1,
.yue h2,
.yue h3,
.yue h4 {
  font-family: var(--sy-f-heading);
}

.yue h1 {
  font-weight: 700;
  padding-bottom: 0.2em;
  border-bottom: 3px solid currentColor;
}

.yue h2 {
  padding-bottom: 0.2em;
  border-bottom: 2px solid var(--sp-rule);
}

/* An emphasized part of a heading is a subtitle: "Name *— what it does*". */
.yue h1 em {
  font-size: 0.55em;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
}

/* A section heading that links somewhere keeps the heading's color until hovered. */
.yue h2 > a.reference {
  color: inherit;
  font-weight: inherit;
}

.yue h2 > a.reference:hover {
  color: var(--sp-link-hover);
}

.yue a {
  font-weight: 400;
}

.yue a:hover {
  color: var(--sp-link-hover);
}

/* Toctrees on a page list their pages under small captions rather than section headings. */
.yue .toctree-wrapper {
  margin: 0;
}

.yue .toctree-wrapper p.caption {
  margin: 0.9rem 0 0.1rem;
  padding: 0;
  border: 0;
  font-family: var(--sy-f-heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sp-caption);
}

.yue .toctree-wrapper ul {
  margin: 0;
  padding-top: 0;
  border: 0;
}

.yue .toctree-wrapper li {
  margin: 0.15rem 0;
}

/* Images floated beside text stay modest, and stay inside their section. */
.yue img.align-right,
.yue img.align-left {
  max-width: min(40%, 280px);
  height: auto;
}

.yue section:has(img.align-right, img.align-left) {
  display: flow-root;
}

/* nbsphinx's nbgallery, drawn as the same cards as shibuya_page.gallery. */
.yue .nbsphinx-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: 1rem;
  margin: 0.75rem 0 1.5rem;
}

.yue .nbsphinx-gallery > a {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--sp-card-border);
  border-radius: 6px;
  overflow: hidden;
  color: var(--sp-text);
  box-shadow: none;
  padding: 0;
  text-align: left;
}

.yue .nbsphinx-gallery > a:hover {
  color: var(--sp-link-hover);
  text-decoration: none;
}

.yue .nbsphinx-gallery > a > div:first-child {
  display: block;
  height: auto;
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #ffffff;
}

.yue .nbsphinx-gallery img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
  transition: transform 0.2s ease;
}

.yue .nbsphinx-gallery > a:hover img {
  transform: scale(1.03);
}

.yue .nbsphinx-gallery > a > div:last-child {
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  font-size: 0.95em;
}
