/* Notebook cells follow Shibuya's light/dark switch (myst-nb alone follows only the
   operating system's setting, so the two could disagree: dark text on a dark box). */
:root, html.light, html.dark {
  --mystnb-source-bg-color: var(--code-block-background);
  --mystnb-source-border-color: var(--sy-c-border);
  --mystnb-stdout-bg-color: var(--sy-c-surface);
  --mystnb-stdout-border-color: var(--sy-c-border);
}
div.cell_output .output pre { color: var(--sy-c-text); }

/* Cards: a thin border and rounded corners, no filled background. */
.yue .surface { --sd-color-card-border: var(--sy-c-border); --sd-color-card-background: transparent; }
.yue .surface .sd-card { border-radius: 18px; box-shadow: none; }
.yue .sd-container-fluid:has(> .surface) { padding-left: 0; padding-right: 0; }   /* cards line up with the headings */

/* Home page hero, centred: title, the paper's title as the lead, two outlined buttons that fill on hover. */
.yue:has(p.lead) > section:first-of-type > h1 { text-align: center; }
.yue:has(p.lead) p.lead { font-size: 1.35rem; line-height: 1.45; max-width: none; margin: 0 auto; text-align: center; }
.yue .container.buttons { margin: 2rem 0 0; }
.yue .container.buttons > p { justify-content: center; }
.yue .container.buttons a, .yue .container.buttons a:first-child { color: var(--sy-c-bold); background-color: transparent; border-color: var(--sy-c-border); }
.yue .container.buttons a:hover { color: var(--accent-contrast); background-color: var(--accent-9); border-color: var(--accent-9); }

/* Home page (the only page with a lead): a slightly wider column than the other pages, readable line length
   and calm spacing between sections. */
.sy-content:has(p.lead) { max-width: 71rem; }
.yue:has(p.lead) > section > p, .yue:has(p.lead) > section > section > p { max-width: 42rem; }
.yue:has(p.lead) > section > section { margin-top: 3rem; }

/* Home page, How it works: the text beside the animation of a spike raster drifting through time
   windows, stacked on narrow screens; still for reduced motion. */
.how-it-works { display: grid; grid-template-columns: minmax(0, 27rem) minmax(0, 27rem); justify-content: space-between;
  gap: 3rem; align-items: center; }
.how-it-works > p { margin: 0; align-self: center; }
@media (max-width: 900px) { .how-it-works { grid-template-columns: 1fr; gap: 1.5rem; } }
.hero-anim { position: relative; width: 100%; aspect-ratio: 417 / 161; }
.hero-anim svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
@media (max-width: 900px) { .hero-anim { max-width: 30rem; margin: 0 auto; } }
.hero-spikes line { stroke: var(--sy-c-text); stroke-width: 1.6; stroke-linecap: round; opacity: .8; }
.hero-windows line { stroke: var(--sy-c-border); stroke-width: 1; stroke-dasharray: 2 3; }
.hero-now { stroke: var(--sy-c-light); stroke-width: 1; opacity: .6; }
.hero-band { opacity: 0; }
.hero-band rect { fill: var(--accent-a9); fill-opacity: .14; }
.hero-track { fill: var(--sy-c-border); opacity: .5; }
.hero-bar { fill: var(--accent-a9); transform-box: fill-box; transform-origin: left center; }
.hero-label { fill: var(--sy-c-light); font-size: 9px; }
@media (prefers-reduced-motion: reduce) {
  .hero-anim .hero-scroll, .hero-anim .hero-band, .hero-anim .hero-bar { animation: none; }
  .hero-anim .hero-band:first-child { opacity: 1; }
}

/* Body text justified to the column's right edge; narrow cards stay ragged. */
.yue p { text-align: justify; }
.yue .sd-card p { text-align: left; }

/* Page titles: no hidden '#' anchor, which wrapped long titles onto an empty second line. */
.yue h1 > a.headerlink { display: none; }

/* Home page: the cards that link to the other pages show it with an arrow and a lift. */
.links .sd-card-title { color: var(--accent-a11); }
.links .sd-card-title::after { content: "\00a0→"; transition: margin-left .2s; }
.links .sd-card { transition: transform .2s, border-color .2s; }
.links .sd-card:hover { transform: translateY(-2px); border-color: var(--accent-a7); }
.links .sd-card:hover .sd-card-title::after { margin-left: .25rem; }

/* Home page: a smaller title on phones. */
@media (max-width: 480px) { html .yue:has(p.lead) section:first-of-type h1 { font-size: 2.8rem; } }

/* Home page: the result cards lead with their numbers; the sentence below sits at the bottom. */
.stats .sd-card-body { display: flex; flex-direction: column; }
.stats .sd-card-body > p:last-child { margin-bottom: 0; }
.stats .sd-card-title { font-size: .95rem; font-weight: 600; color: var(--sy-c-bold); }
.stats p.stat-number { font-size: 2.1rem; font-weight: 600; line-height: 1.35;
  color: var(--accent-a11); margin: 0; font-variant-numeric: tabular-nums; }
.stats p.stat-label { font-weight: 500; color: var(--sy-c-bold); margin: 0 0 .8rem; }
.stats p.stat-prefix { font-size: .85rem; color: var(--sy-c-light); margin: .6rem 0 -.3rem; }
.stats .stat-row { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between;
  column-gap: .8rem; margin-bottom: .8rem; }
.stats .stat-row p.stat-label { margin: 0; font-size: .85rem; line-height: 1.3; }

/* Home page, result cards: a soft accent tint. */
.stats .sd-card { background: var(--accent-a2); border-color: var(--accent-a5); }


/* Tutorial pages: the run time and device in grey beside the Colab badge. */
.yue .tut-meta { font-size: .85rem; color: var(--sy-c-light); margin-left: .6rem; vertical-align: middle; }
.yue a:has(> img[alt="Open In Colab"]) > img { display: inline; vertical-align: middle; margin: 0; }

/* Left sidebar on the tutorial pages only, listing the tutorials; the top bar holds the rest. */
.globaltoc > ul > li.toctree-l1:not(.current) { display: none; }
.globaltoc > ul > li.toctree-l1.current > :not(ul) { display: none; }
.globaltoc > ul > li.toctree-l1.current > ul { display: block; margin: 0; padding: 0; border: 0; }
.globaltoc > ul > li.toctree-l1.current > ul::before { content: "Tutorials list"; display: block; margin-bottom: 1rem;
  font-size: .8rem; font-weight: 500; letter-spacing: .4px; text-transform: uppercase; color: var(--sy-c-bold); }
body:not(:has(.globaltoc li.toctree-l1.current > ul)) button[aria-controls="lside"] { display: none; }

/* Header at narrow laptop widths: a shorter search box so the six links fit beside it. */
@media (min-width: 768px) and (max-width: 1000px) {
  .sy-head .searchbox { width: 6.5rem; min-width: 0; }
  .sy-head .searchbox input { width: 100%; min-width: 0; }
  .sy-head .searchbox kbd { display: none; }
}
@media (min-width: 768px) and (max-width: 860px) { .sy-head .searchbox { width: 4.5rem; } }

/* Top bar: muted links; the current and the hovered one darker. The current one sits under a
   clear glass lens (on wide screens the lens slides between links, nav-pill.js). */
.sy-head-links .link > a, .sy-head-links .link.current > a { padding: .3rem .5rem; border-radius: 999px;
  color: var(--gray-11); background-color: transparent; transition: color .2s; }
.sy-head-links .link:hover > a, .sy-head-links .link.current > a, .sy-head-links .link.current:hover > a {
  color: var(--sy-c-bold); background-color: transparent; }
:root { --glass-tint: rgba(255, 255, 255, .55); --glass-rim: rgba(0, 0, 0, .07); --glass-edge: rgba(255, 255, 255, .95);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 10px -4px rgba(0, 0, 0, .14); }
html.dark { --glass-tint: rgba(255, 255, 255, .07); --glass-rim: rgba(255, 255, 255, .12); --glass-edge: rgba(255, 255, 255, .16);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px -4px rgba(0, 0, 0, .6); }
.nav-pill, .sy-head-links .link.current > a {
  background-color: var(--glass-tint);
  -webkit-backdrop-filter: blur(8px) saturate(1.5); backdrop-filter: blur(8px) saturate(1.5);
  box-shadow: inset 0 0 0 .5px var(--glass-rim), inset 0 1px 0 var(--glass-edge), var(--glass-shadow); }
.nav-pill { display: none; }
@media (min-width: 768px) {
  .sy-head-links.has-pill { position: relative; }
  .sy-head-links.has-pill .link > a, .sy-head-links.has-pill .link.current > a {
    background-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; position: relative; z-index: 1; }
  .nav-pill { display: block; position: absolute; z-index: 0; border-radius: 999px; opacity: 0; pointer-events: none; }
  .nav-pill.on { opacity: 1; }
  .nav-pill.ready { transition: left .18s cubic-bezier(.2, .8, .2, 1), right .18s cubic-bezier(.2, .8, .2, 1), opacity .15s; }
  .nav-pill.ready.to-right { transition-delay: .03s, 0s, 0s; }
  .nav-pill.ready.to-left { transition-delay: 0s, .03s, 0s; }
  /* The current link is magnified under the lens. */
  .sy-head-links.has-pill .link > a { transition: color .15s, transform .18s cubic-bezier(.2, .8, .2, 1); }
  .sy-head-links.has-pill .link.current > a { transform: scale(1.08); }
  .sy-head-links.has-pill .link { margin: 0 .2rem; }
}
@media (prefers-reduced-motion: reduce) { .sy-head-links.has-pill .link > a { transition: none; } }
@media (prefers-reduced-motion: reduce) { .nav-pill.ready { transition: none; } }

/* Top bar: a glass switch between light and dark (theme-toggle.js); the knob carries a sun or a moon.
   Before the first click it follows the system setting. */
:root { --switch-track: rgba(0, 0, 0, .06); --switch-knob: rgba(255, 255, 255, .9); }
html.dark { --switch-track: rgba(255, 255, 255, .07); --switch-knob: rgba(255, 255, 255, .16); }
.sy-head-actions .theme-toggle { position: relative; display: block; margin-left: 1rem; width: 2.75rem; height: 1.5rem; padding: 0; border: 0; border-radius: 999px;
  cursor: pointer; background-color: var(--switch-track);
  box-shadow: inset 0 0 0 .5px var(--glass-rim), inset 0 1px 2px rgba(0, 0, 0, .08); }
.theme-toggle-knob { position: absolute; top: .125rem; left: .125rem; width: 1.25rem; height: 1.25rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--sy-c-text); background-color: var(--switch-knob);
  -webkit-backdrop-filter: blur(8px) saturate(1.5); backdrop-filter: blur(8px) saturate(1.5);
  box-shadow: inset 0 0 0 .5px var(--glass-rim), inset 0 1px 0 var(--glass-edge), var(--glass-shadow);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
html.dark .theme-toggle-knob { transform: translateX(1.25rem); }
.theme-toggle-icon { --icon-url: var(--lucide-sun-url); width: .8rem; height: .8rem; }
html.dark .theme-toggle-icon { --icon-url: var(--lucide-moon-url); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-9); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .theme-toggle-knob { transition: none; } }

/* Page changes: room for a scrollbar on every page, so the text never shifts sideways between a long page
   and a short one. */
html { scrollbar-gutter: stable; }

/* Page changes: a short cross-fade with the header held still (browsers without support swap pages as before). */
@view-transition { navigation: auto; }
.sy-head { view-transition-name: site-head; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .12s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Notes: rounded like the cards, no side stripe, the icon inside the title band. */
.yue .admonition { border-left: 0; border-radius: 18px; overflow: hidden; }
.yue .admonition p.admonition-title { margin: -.825rem -1rem .825rem; padding: 6px 1rem 6px 2.6rem; }
.yue .admonition:before { left: 1rem; top: 8px; z-index: 1; }
.yue .admonition:after { left: calc(1rem + 4px); top: 12px; z-index: 2; }

/* Home page, Explore: four cards of one size, two by two (one column on phones). */
.yue .explore { display: grid; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
@media (min-width: 768px) { .yue .explore { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .yue .explore { grid-template-columns: repeat(4, 1fr); } }
.yue .explore > .sd-col { width: auto; max-width: none; }

/* Tutorials: the number in grey before the title (sidebar in the toctree's order, cards), and
   "Tutorial N" above each tutorial's title. */
.globaltoc li.toctree-l1.current > ul > li > a::before { display: inline-block; width: 1.9rem; color: var(--sy-c-light); }
.globaltoc li.toctree-l1.current > ul > li:nth-child(1) > a::before { content: "1"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(2) > a::before { content: "2"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(3) > a::before { content: "3"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(4) > a::before { content: "4a"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(5) > a::before { content: "4b"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(6) > a::before { content: "5"; }
.globaltoc li.toctree-l1.current > ul > li:nth-child(7) > a::before { content: "6"; }
.yue .tut-num { display: inline-block; min-width: 2.2rem; text-indent: 0; color: var(--sy-c-light); }
.yue p.tut-eyebrow { margin: 0 0 .3rem; font-size: .95rem; font-weight: 600; color: var(--sy-c-light); text-align: left; }
.yue .tutorials .sd-card-title { padding-left: 2.2rem; text-indent: -2.2rem; }

/* Footer: the copyright and the lab on the left, the credits centred, GitHub on the right (stacked on phones). */
.sy-foot-copyright p { margin: 0; }
.sy-foot-made { margin-top: .6rem; }
@media (min-width: 768px) {
  .sy-foot-reserved { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 2rem; }
  .sy-foot-made { margin-top: 0; text-align: center; }
  .sy-foot-socials { justify-self: end; }
}

/* Tutorial cards: two columns only where each title fits one line and each summary two. */
@media (max-width: 1099px) {
  .sd-row.tutorials > .sd-col { flex: 0 0 auto; width: 100%; }
}
/* Every summary takes two lines, so every card has the same size. */
.sd-row.tutorials .sd-card-text { min-height: 3.5em; min-height: 2lh; }
