/* Shibuya theme variables and layout. */
html[data-accent-color] {
  --sy-f-text: var(--x65-font);
  --sy-f-heading: var(--x65-heading-font);
  --sy-f-mono: var(--x65-mono);
  --sy-c-background: var(--x65-paper);
  --sy-c-background-dropback: var(--x65-panel);
  --sy-c-surface: var(--x65-surface);
  --sy-c-border: var(--x65-rule);
  --sy-c-divider: var(--x65-rule);
  --sy-c-heading: var(--x65-ink);
  --sy-c-bold: var(--x65-ink);
  --sy-c-text: var(--x65-ink);
  --sy-c-light: var(--x65-muted);
  --sy-c-link: var(--x65-link);
  --sy-c-link-hover: var(--x65-link);
  --sy-c-current-text: var(--x65-link);
  --sy-c-current-background: var(--x65-current);
  --sy-c-foot-background: var(--x65-paper);
  --sy-c-foot-divider: var(--x65-rule);
  --sy-c-foot-text: var(--x65-muted);
}

:focus-visible {
  outline: 2px solid var(--x65-accent);
  outline-offset: 3px;
}

.sy-container {
  max-width: 96rem;
}

.sy-head {
  color: var(--x65-header-text);
  background: var(--x65-header);
  border-bottom: 1px solid var(--x65-steel);
}

.sy-head .sy-head-blur {
  display: none;
}

.sy-head-brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--x65-heading-font);
  font-size: 1.25rem;
  letter-spacing: -.025em;
}

.sy-head-brand strong {
  color: var(--x65-header-text);
  font-weight: 800;
}

.sy-head-brand::before {
  content: "";
  background: var(--x65-header-text);
  mask: url("../paw_logo_32.png") center / 1.35rem no-repeat;
  width: 1.75rem;
  height: 1.75rem;
}

.sy-head .searchbox {
  color: var(--x65-ink);
}

.sy-head .searchbox input::placeholder {
  color: var(--x65-muted);
}

.sy-head .theme-switch,
.sy-head .js-menu {
  color: var(--x65-header-text);
}

.sy-head .hamburger span {
  background-color: var(--x65-header-text);
}

.sy-head :focus-visible {
  outline-color: var(--x65-header-text);
}

.skip-to-reading {
  position: fixed;
  inset: .5rem auto auto 1rem;
  z-index: 50;
  padding: .5rem .85rem;
  background: var(--x65-paper);
  color: var(--x65-link);
  border-radius: .25rem;
  transform: translateY(-200%);
}

.skip-to-reading:focus {
  transform: none;
}

.reading-start {
  display: block;
}

.sy-main {
  min-width: 0;
}

/* The breadcrumb row also holds both outline controls at smaller widths. */
.sy-breadcrumbs ol {
  visibility: hidden;
}

.sy-breadcrumbs-inner button {
  min-width: 2rem;
  min-height: 2rem;
  justify-content: center;
  gap: .4rem;
  white-space: nowrap;
  font: 600 .875rem/1.35 var(--x65-font);
}

.sy-breadcrumbs-inner button[aria-controls="lside"]::after {
  content: "Chapters";
}

.sy-breadcrumbs-inner button[aria-controls="rside"]::after {
  content: "On this page";
}

.sy-breadcrumbs .sy-breadcrumbs-inner {
  padding-block: .35rem;
}

.globaltoc,
.localtoc {
  font-family: var(--x65-font);
  font-size: .875rem;
  line-height: 1.4;
}

.globaltoc a,
.localtoc a {
  font-weight: 600;
}

.globaltoc .current > a.current,
.localtoc li.active > a {
  color: var(--x65-link);
  background: var(--x65-current);
  border-radius: .2rem;
  box-shadow: inset 3px 0 var(--x65-accent);
}

.globaltoc li > a.current {
  display: block;
  padding-inline: .4rem;
  font-weight: 750;
}

.localtoc a {
  display: block;
  padding: .125rem .4rem;
}

.globaltoc li.toctree-l1 > a {
  font-weight: 700;
  letter-spacing: -.01em;
}

.localtoc > ul > li > a {
  font-weight: 700;
}

.localtoc h3 {
  font: 700 .875rem/1.35 var(--x65-font);
}

/* Reading column and heading hierarchy. */
.yue {
  --yue-c-code-text: var(--x65-link);
  --yue-c-code-background: var(--x65-surface);
  color: var(--x65-ink);
  font-size: var(--x65-body-size);
  font-weight: 450;
  line-height: 1.6;
  max-width: var(--x65-reading-width);
  margin-inline: auto;
  overflow-wrap: anywhere;
}

/* Shibuya measures the top-level section's margin for its active outline
   threshold. Allow one pixel for rounding on native fragment jumps. */
.yue > section {
  scroll-margin-top: calc(var(--sy-s-offset-top) + 69px);
}

@media (min-width: 80rem) {
  .yue > section {
    scroll-margin-top: calc(var(--sy-s-offset-top) + 25px);
  }
}

.yue h1 {
  margin: 0 0 1.65rem;
  padding-block: 1.1rem 1.3rem;
  border-top: 4px solid var(--x65-accent);
  border-bottom: 1px solid var(--x65-rule);
  font-size: var(--x65-title-size);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.book-chapter-label {
  display: block;
  margin-bottom: .65rem;
  color: var(--x65-link);
  font: 650 .875rem/1.35 var(--x65-mono);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.yue h2 {
  margin-top: 1.65em;
  padding-top: .65em;
  border-top: 1px solid var(--x65-rule);
  font-size: clamp(1.75rem, 1.6rem + .45vw, 2rem);
  font-weight: 700;
  line-height: 1.17;
  letter-spacing: -.025em;
}

.yue h3 {
  font-size: clamp(1.375rem, 1.28rem + .3vw, 1.5rem);
  font-weight: 700;
  line-height: 1.25;
}

.yue :is(h4, h5, h6) {
  font-size: 1.125rem;
  font-weight: 650;
  line-height: 1.35;
}

.yue :is(h1, h2, h3, h4, h5, h6) .headerlink {
  font-size: .5em;
}

.yue a:not(.headerlink) {
  text-decoration: underline;
  text-decoration-thickness: .075em;
  text-underline-offset: .17em;
}

.yue a:hover {
  text-decoration-thickness: .13em;
}

.yue li::marker {
  color: var(--x65-muted);
}

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

/* Technical typography. The theme supplies the Pygments colors and scroll
   containers. Keep source lines intact and let the listing scroll locally. */
.yue :is(code, kbd, samp, pre) {
  font-family: var(--x65-mono);
  font-weight: 450;
  font-variant-ligatures: none;
}

.yue :is(code, kbd) {
  font-size: .85em;
  background: var(--x65-surface);
}

.yue kbd {
  border: 1px solid var(--x65-rule);
  border-bottom-width: 2px;
  border-radius: .25rem;
  padding: .06em .3em;
}

/* The ca65 comment and numeric literal colors need more contrast on the
   light code surface than the default Sphinx syntax palette provides. */
html.light {
  --syntax-light-comment: #3a626d;
  --syntax-light-comment-single: #3a626d;
  --syntax-light-literal-number: #166842;
  --syntax-light-literal-number-bin: #166842;
  --syntax-light-literal-number-hex: #166842;
  --syntax-light-literal-number-integer: #166842;
}

.yue div.highlight pre {
  font-size: clamp(.875rem, .84rem + .15vw, .9375rem);
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
}

.yue .table-wrapper {
  border: 1px solid var(--x65-rule);
  border-radius: .375rem;
  overflow: auto;
}

.yue :is(.table-wrapper, div.highlight pre):focus-visible {
  outline-offset: -3px;
}

.yue .table-wrapper table {
  width: 100%;
  margin: 0;
  font-size: .875rem;
  line-height: 1.45;
  overflow-wrap: normal;
}

.yue .table-wrapper table:has(thead th:nth-child(3)) {
  min-width: 27rem;
}

.yue .table-wrapper th,
.yue .table-wrapper td {
  padding: .55rem .7rem;
  vertical-align: top;
}

.yue .table-wrapper th {
  font-weight: 700;
  background: var(--x65-current);
}

.yue .table-wrapper tbody tr:nth-child(even) {
  background: var(--x65-panel);
}

.yue :is(table, figcaption) :is(code, .literal) {
  white-space: nowrap;
  font-size: .95em;
}

.yue :is(caption, figcaption, .caption) {
  color: var(--x65-muted);
  font-size: .875rem;
  font-weight: 450;
}

.yue figure {
  margin-inline: 0;
}

.yue :is(figure img, iframe) {
  max-width: 100%;
}

.yue figure img {
  height: auto;
}

.yue .admonition {
  --admonition-color: var(--x65-link);
  --admonition-bg: var(--x65-surface);
  border: 1px solid var(--x65-rule);
  border-inline-start: .25rem solid var(--admonition-color);
  background: var(--x65-panel);
}

.yue .admonition.warning,
.yue .admonition.caution,
.yue .admonition.danger {
  --admonition-color: var(--x65-warning);
  --admonition-bg: var(--x65-warning-bg);
}

.yue .admonition > .admonition-title {
  color: var(--admonition-color);
  background: var(--admonition-bg);
  font-weight: 700;
}

/* Use Sphinx's existing toctree order for the two navigation cards. */
.sy-main .navigation {
  gap: .75rem;
  margin: 2.5rem auto 1rem;
  padding-top: 1.25rem;
  max-width: var(--x65-reading-width);
  font-size: var(--x65-body-size);
  border-top: 1px solid var(--x65-rule);
}

.sy-main .navigation a {
  min-height: 100%;
  padding: .8rem 1rem;
  border: 1px solid var(--x65-rule);
  border-radius: .375rem;
  background: var(--x65-panel);
  color: var(--x65-link);
}

.sy-main .navigation a:hover {
  background: var(--x65-current);
  border-color: var(--x65-accent);
}

.navigation .page-info > span {
  color: var(--x65-muted);
  font: 600 .75rem/1.4 var(--x65-font);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.navigation .page-info .title {
  font: 700 1rem/1.35 var(--x65-font);
}

@media (max-width: 36rem) {
  .sy-main .navigation {
    flex-direction: column;
  }

  .sy-main .navigation > div {
    width: 100%;
  }
}
