/* LIRRA color scheme (layout follows the RTD-RAX site) */
:root {
  --primary-color: #2b5c9e;
  --primary-dark-color: #1d4475;
  --primary-light-color: #6d95c9;
  --side-nav-background: #dbe2ec;
  --page-background-color: #f2eee4;
  --fragment-background: #f8f5ee;
  --fragment-keyword: #8a2be2;
  --fragment-string: #0a7d57;
  --lirra-accept: #2e7d32;
  --lirra-reject: #c77700;
}

/* Dark mode overrides */
html.dark-mode {
  --primary-color: #7fb0ec;
  --primary-dark-color: #5b93d8;
  --primary-light-color: #a9cbf4;
  --side-nav-background: #1b1c22;
  --page-background-color: #252628;
  --fragment-background: #20212a;
  --fragment-keyword: #b76ffa;
  --fragment-string: #42d998;
  --lirra-accept: #6cc070;
  --lirra-reject: #f0a640;
}

@media screen and (min-width: 768px) {
  html {
    --page-font-size: 17.2px;
    --navigation-font-size: 15.8px;
    --toc-font-size: 14.7px;
    --code-font-size: 15.4px;
    --title-font-size: 24px;
    --content-maxwidth: 960px;
  }
}

/* Project name in monospace (texttt style) */
#projectname {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Version number styling */
#projectnumber {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-weight: 400;
  opacity: 0.7;
}

#projectlogo a,
#projectname a {
  color: inherit;
  text-decoration: none;
}

#projectnavlinks {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.projectnavlink {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--primary-color);
  color: #fff;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

html.dark-mode .projectnavlink {
  color: #10141a;
}

.projectnavlink:hover,
.projectnavlink:focus {
  background: var(--primary-dark-color);
  color: #fff;
}

/* Make search bar + dark mode toggle sit side by side in sidebar */
@media screen and (min-width: 768px) {
  *:has(> #MSearchBox):has(> doxygen-awesome-dark-mode-toggle) {
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap;
    padding: 0 var(--spacing-medium);
  }

  *:has(> doxygen-awesome-dark-mode-toggle) > #MSearchBox {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
  }

  *:has(> #MSearchBox) > doxygen-awesome-dark-mode-toggle {
    flex-shrink: 0;
  }
}

/* Shared figure treatment */
.contents .image:has(img) {
  width: min(100%, 50rem);
  margin: 1rem auto 0.4rem;
  box-sizing: border-box;
  padding: 0.85rem 0.85rem 0.7rem;
  overflow: hidden;
  background: var(--fragment-background);
  border: 1px solid var(--separator-color);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}

.contents .image:has(img) img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: none;
}

.contents .image:has(img) .caption {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--separator-color);
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--page-foreground-color);
  font-weight: 600;
}

.contents .image:has(img) + p:has(> em) {
  max-width: min(100%, 50rem);
  margin: 0 auto 1.25rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--page-foreground-color);
  opacity: 0.8;
}

.contents .image:has(img) + p:has(> em) em {
  display: block;
}

/* Square top-down and MuJoCo views stay narrower than the composite videos */
.image:has(img[src$="_mujoco.gif"]),
.image:has(img[src$="_theta.gif"]),
.image:has(img[src$="_phi.gif"]) {
  width: min(100%, 34rem);
}

/* The loop diagram has its own white card so its colors read in both themes */
.image:has(img[src$="lirra_loop.svg"]) {
  width: min(100%, 52rem);
}

.image:has(img[src$="lirra_loop.svg"]) img {
  background: #ffffff;
}

/* Logo at the top right of every page, outside the content column */
div.header {
  position: relative;
}

div.header::after {
  content: "";
  position: absolute;
  right: clamp(1rem, 3vw, 2.5rem);
  bottom: 0.9rem;
  width: 84px;
  height: 84px;
  background: url("lirra_logo.svg") center / contain no-repeat;
  pointer-events: none;
}

/* Keep Doxygen's summary links on API pages clear of the logo */
@media screen and (min-width: 1280px) {
  div.header div.summary {
    margin-right: calc(84px + clamp(1rem, 3vw, 2.5rem));
  }
}

/* Only where the column leaves room beside it; narrower windows drop it */
@media screen and (max-width: 1279px) {
  div.header::after {
    display: none;
  }
}

/* Paper front matter on the introduction */
.lirra-front {
  text-align: center;
  margin: 1.4rem auto 1.8rem;
  padding: 1.3rem 1rem 1.1rem;
  max-width: 46rem;
  background: var(--fragment-background);
  border: 1px solid var(--separator-color);
  border-radius: 12px;
}

.lirra-lead {
  font-size: 1.36rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--primary-color);
  margin: 0 auto 1.1rem;
}

.lirra-by {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.6;
  margin-bottom: 0.3rem;
}

.lirra-authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.6rem;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--page-foreground-color);
}

.lirra-author {
  white-space: nowrap;
}

.lirra-paper {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--page-foreground-color);
  margin: 0 auto 1rem;
  max-width: 40rem;
}

.lirra-affil {
  margin-top: 0.45rem;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.lirra-name {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--primary-color);
}

.lirra-venue {
  margin-top: 0.1rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Wide result tables scroll inside the page instead of the page scrolling */
.contents table.markdownTable {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

@media screen and (max-width: 767px) {
  .lirra-lead {
    font-size: 1.12rem;
  }

  #titlearea table,
  #titlearea tbody,
  #titlearea tr {
    display: block;
    width: 100%;
  }

  #projectlogo,
  #projectalign {
    display: block;
    width: 100%;
    text-align: left;
  }

  #projectlogo {
    padding-bottom: 0.35rem;
  }
}

/* Algorithm box on the Theory page */
.lirra-algo {
  container-type: inline-size;
  margin: 1.2rem auto 1.4rem;
  max-width: 56rem;
  border-top: 2px solid var(--page-foreground-color);
  border-bottom: 2px solid var(--page-foreground-color);
  padding: 0.2rem 0 0.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
}
.lirra-algo .algo-title {
  border-bottom: 1px solid var(--page-foreground-color);
  padding: 0.35rem 0.4rem;
  margin-bottom: 0.35rem;
}
.lirra-algo .algo-input {
  padding: 0.1rem 0.4rem 0.3rem 2.4rem;
}
.lirra-algo .algo-line {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) auto;
  column-gap: 0.7rem;
  align-items: baseline;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
}
.lirra-algo .algo-line:hover {
  background: var(--fragment-background);
}
.lirra-algo .algo-no {
  text-align: right;
  font-size: 0.8rem;
  opacity: 0.55;
}
.lirra-algo .algo-cmt {
  color: var(--primary-color);
  font-size: 0.85rem;
  font-style: italic;
  white-space: nowrap;
}
.lirra-algo .algo-i1 .algo-code { padding-left: 1.4rem; }
.lirra-algo .algo-i2 .algo-code { padding-left: 2.8rem; }
.lirra-algo .algo-i3 .algo-code { padding-left: 4.2rem; }
/* Narrow box: comments move under their line */
@container (max-width: 720px) {
  .lirra-algo .algo-line { grid-template-columns: 1.4rem minmax(0, 1fr); }
  .lirra-algo .algo-cmt { grid-column: 2; white-space: normal; line-height: 1.3; margin-bottom: 0.15rem; }
  .lirra-algo .algo-i1 .algo-cmt { padding-left: 1.4rem; }
  .lirra-algo .algo-i2 .algo-cmt { padding-left: 2.8rem; }
  .lirra-algo .algo-i3 .algo-cmt { padding-left: 4.2rem; }
}

/* Episode videos (full-resolution MP4 instead of GIF) */
.lirra-video {
  margin: 0.8rem auto 0.4rem;
  max-width: 100%;
}
.lirra-video video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--separator-color);
  background: #000;
}
