/* User Provided Stylesheet */

/* ============================================================
   quantem-docs — custom theming on top of MyST book-theme.
   Loaded via `site.options.style` in myst.yml.

   Accent: dark red rgb(204,0,0), lightened slightly in dark
   mode for contrast on the dark background.
   ============================================================ */

:root {
  --qem-accent: rgb(204, 0, 0);
  --qem-accent-soft: rgba(204, 0, 0, 0.12);
}
html.dark {
  --qem-accent: rgb(232, 81, 73);
  --qem-accent-soft: rgba(232, 81, 73, 0.18);
}

/* ---------- Site title (upper-left) ---------- */
.myst-home-link,
.myst-home-link span {
  color: var(--qem-accent) !important;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.myst-home-link:hover span {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}

/* ---------- Top-nav links ---------- */
.myst-top-nav-item {
  font-weight: 500;
}

/* ---------- Article links ----------
   Scoped to <article> so the home-link and navbar controls keep
   their own colors. */
article a:not(.myst-home-link),
article .link,
article .hover-link {
  color: var(--qem-accent) !important;
}

/* Cards: red title, neutral body text */
article a.myst-card {
  color: inherit !important;
}
article a.myst-card .myst-card-title {
  color: var(--qem-accent);
}
article a.myst-card:hover {
  border-color: var(--qem-accent) !important;
}

/* ---------- Places book-theme still uses Tailwind blue ---------- */
.myst-tab-item-header-active {
  color: var(--qem-accent) !important;
  border-bottom-color: var(--qem-accent) !important;
}
.myst-toc-item.active,
.myst-toc-item-exact {
  background-color: var(--qem-accent-soft) !important;
}
.myst-toc-item:focus,
.myst-toc-item:focus-visible {
  outline-color: var(--qem-accent) !important;
}
.myst-code-copy-icon {
  color: var(--qem-accent) !important;
}
.myst-code-copy-icon:hover {
  opacity: 0.7;
}
.outline-blue-200 {
  outline-color: var(--qem-accent-soft) !important;
}
button.myst-search-bar:hover {
  border-color: var(--qem-accent) !important;
  --tw-ring-color: var(--qem-accent) !important;
}

/* ---------- Code blocks ----------
   book-theme leaves `pre` at overflow-x: visible, so one long line pushes
   the whole page sideways on narrow screens. Scroll inside the block
   instead, and never let it widen the article. */
article pre {
  max-width: 100%;
  overflow-x: auto;
}

/* ---------- Inline code spans ---------- */
:not(pre) > code {
  color: rgb(190, 24, 93);
}
html.dark :not(pre) > code {
  color: rgb(244, 114, 182);
}

/* ---------- Left sidebar ----------
   Smaller type, tighter rhythm, bold top-level sections. */
.myst-primary-sidebar-toc {
  font-size: 0.85rem;
}
.myst-primary-sidebar-toc .myst-toc-item {
  margin-top: 0.125rem;
  margin-bottom: 0.125rem;
}
.myst-primary-sidebar-toc a.myst-toc-item {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.myst-primary-sidebar-toc .myst-toc-item > div {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.myst-primary-sidebar-toc button svg {
  height: 1.1rem;
  width: 1.1rem;
}
/* Sidebar items are all normal weight — only the selected page is bold. */
.myst-primary-sidebar-toc .myst-toc-item {
  font-weight: 400;
}
/* book-theme marks the section containing the current page in blue; recolour it
   to the accent (no bold) as a subtle "current section" cue. */
.myst-primary-sidebar-toc .text-blue-800,
html.dark .myst-primary-sidebar-toc .dark\:text-blue-200 {
  color: var(--qem-accent) !important;
  font-weight: 400;
}
/* The exact selected page: accent colour + bold (the only bold item). */
.myst-primary-sidebar-toc a.myst-toc-item-exact,
.myst-primary-sidebar-toc a.myst-toc-item.active {
  color: var(--qem-accent) !important;
  font-weight: 700;
}
/* Snappy sidebar: remove the janky expand/collapse + hover transitions. */
.myst-primary-sidebar,
.myst-primary-sidebar * {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
}
/* Reserve scrollbar gutters on every scroll container in the layout so a
   scrollbar appearing (a folder expands, or a taller page loads on nav) never
   jumps the width. */
.myst-primary-sidebar,
.myst-primary-sidebar-nav,
.myst-primary-sidebar-toc,
.myst-outline {
  scrollbar-gutter: stable;
}
/* Tighten the per-level indent so deep items ("Medium-range order") stay on one
   line despite the space reserved for the scrollbar gutter. */
.myst-primary-sidebar-toc .collapsible-content {
  padding-left: 0.5rem;
}
/* The site title is already in the top bar; drop the duplicate
   root entry at the top of the sidebar. */
.myst-toc > a.myst-toc-item[title="quantEM"] {
  display: none;
}

/* ---------- Search ----------
   The theme's dialog-based search is replaced at runtime (see
   scripts/patch_theme.py) with a flat input in the top bar. No overlay,
   no scroll lock, so opening it never shifts the page. */
.qem-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;          /* allow the input to shrink inside the flex nav */
}
.qem-search input {
  height: 2.5rem;
  width: 100%;
  max-width: 12rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  color: inherit;
  background: rgb(249, 250, 251);
  border: 1px solid rgb(209, 213, 219);
  border-radius: 0.5rem;
  outline: none;
  appearance: none;
}
html.dark .qem-search input {
  background: rgb(55, 65, 81);
  border-color: rgb(75, 85, 99);
}
.qem-search input::-webkit-search-cancel-button {
  appearance: none;
}
.qem-search input:focus {
  border-color: var(--qem-accent);
  box-shadow: 0 0 0 1px var(--qem-accent);
}
@media (min-width: 640px) {
  .qem-search input { max-width: 20rem; }
}
.qem-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1000;
  width: min(26rem, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}
html.dark .qem-search-results {
  background: rgb(28, 25, 23);
  border-color: rgba(255, 255, 255, 0.18);
}
a.qem-search-hit {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: 0.35rem;
  color: inherit !important;
  text-decoration: none;
}
a.qem-search-hit:hover,
a.qem-search-hit.active {
  background: var(--qem-accent);
  color: #fff !important;
}
.qem-search-hit-title {
  font-size: 0.85rem;
  font-weight: 600;
}
.qem-search-hit-text {
  font-size: 0.78rem;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Hide the article-style frontmatter strip ---------- */
.myst-fm-block-header,
.myst-fm-block-date-doi,
header.myst-fm-authors-affiliations {
  display: none !important;
}

/* ---------- Landing page: layered, hover-animated logo ----------
   The logo is stacked from the wordmark base plus one SVG layer per
   element. A runtime injected by scripts/patch_theme.py inlines the
   layers and runs an element's animations only while hovered; leaving
   it pauses in place. Percentages come from scripts/build_logo.py. */
.qem-logo-box {
  position: relative;
  width: 100%;
  max-width: 580px;
  justify-self: center;
  margin: 3.5rem auto 0.5rem auto;
}
.qem-logo-box p {
  margin: 0;
}
.qem-logo-box .qem-lbase {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 460.8 / 266.4;
}
.qem-logo-box .qem-el {
  position: absolute;
  display: block;
  height: auto;
}
.qem-el-eels   { left: 2.19%;  top: 5.12%;  width: 56.22%; aspect-ratio: 259.06 / 148.09; }
.qem-el-dif    { left: 13.46%; top: 5.22%;  width: 29.92%; aspect-ratio: 137.87 / 115.78; }
.qem-el-struct { left: 39.82%; top: 14.11%; width: 23.44%; aspect-ratio: 108.03 / 108.00; }
.qem-el-tomo   { left: 59.44%; top: 15.96%; width: 38.14%; aspect-ratio: 175.76 / 91.60; }

/* Light/dark variants follow the book-theme html.dark toggle. */
html:not(.dark) .qem-logo-box .qem-logo-dark { display: none; }
html.dark .qem-logo-box .qem-logo-light { display: none; }

.qem-tagline {
  text-align: left;
  font-size: 1.15rem;
  opacity: 0.85;
  max-width: 42rem;
  margin: 1rem auto 1.5rem auto;
}

/* ---------- Funding logos (Acknowledgements) ----------
   Logo-only cards: each logo is a link that fills its cell, with the
   light/dark variant chosen by theme. */
.qem-funders {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: center;
  max-width: 420px;
  margin: 1.5rem 0 2rem 0;
}
.qem-funders p {
  margin: 0;
  display: contents;
}
.qem-funders a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 116px;
  padding: 1.25rem 2rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 0.5rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
html.dark .qem-funders a {
  border-color: rgba(255, 255, 255, 0.18);
}
.qem-funders a:hover {
  border-color: var(--qem-accent);
  transform: translateY(-2px);
}
/* MyST wraps a linked image in <a><span class="link-text"><img>, so the
   span must be told to fill the cell before the image can. */
.qem-funders a > span,
.qem-funders .link-text {
  display: block;
  width: 100%;
}
/* The theme caps images inside links at ~1.2em so inline icons stay small;
   these are full logos, so override it. */
.qem-funders img {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 74px !important;
  object-fit: contain;
  margin: 0 !important;
}
/* book-theme adds an external-link icon after off-site links */
.qem-funders a svg,
.qem-funders a .link-icon {
  display: none;
}

html:not(.dark) .qem-only-dark { display: none; }
html.dark .qem-only-light { display: none; }
