/* ---------- Top menu bar with hover dropdowns ---------- */

.rl-menu {
  background-color: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  font-size: 0.75rem;
}

.rl-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rl-menu__bar {
  display: flex;
  align-items: stretch;
  padding: 0 0.6rem;
}

.rl-menu__item {
  position: relative;
}

.rl-menu__link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 2.4rem;
  padding: 0 0.9rem;
  color: inherit;
  opacity: 0.8;
  border-bottom: 2px solid transparent;
  transition: opacity 0.15s, background-color 0.15s;
}

.rl-menu__item:hover > .rl-menu__link,
.rl-menu__item:focus-within > .rl-menu__link,
.rl-menu__item--active > .rl-menu__link {
  opacity: 1;
}

.rl-menu__item:hover > .rl-menu__link,
.rl-menu__item:focus-within > .rl-menu__link {
  background-color: rgba(255, 255, 255, 0.12);
}

.rl-menu__item--active > .rl-menu__link {
  border-bottom-color: var(--md-accent-fg-color);
  font-weight: 700;
}

.rl-menu__caret {
  font-size: 0.6rem;
  transition: transform 0.15s;
}

.rl-menu__item:hover .rl-menu__caret,
.rl-menu__item:focus-within .rl-menu__caret {
  transform: rotate(180deg);
}

/* Dropdown panels */
.rl-menu__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  min-width: 15rem;
  padding: 0.4rem 0 !important;
  background-color: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  border-radius: 0 0 0.3rem 0.3rem;
  box-shadow: var(--md-shadow-z2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.3rem);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.rl-menu__item:hover > .rl-menu__dropdown,
.rl-menu__item:focus-within > .rl-menu__dropdown,
.rl-menu__sub:hover > .rl-menu__dropdown,
.rl-menu__sub:focus-within > .rl-menu__dropdown {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.rl-menu__dropdown a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  color: inherit;
  white-space: nowrap;
}

.rl-menu__dropdown a:hover,
.rl-menu__dropdown a:focus {
  background-color: var(--md-default-fg-color--lightest);
  color: var(--md-accent-fg-color);
}

.rl-menu__dropdown a.rl-menu__current {
  color: var(--md-primary-fg-color);
  font-weight: 700;
}

[data-md-color-scheme="slate"] .rl-menu__dropdown a.rl-menu__current {
  color: var(--md-accent-fg-color);
}

/* Nested pages fly out to the right */
.rl-menu__sub {
  position: relative;
}

.rl-menu__sub > .rl-menu__dropdown {
  top: -0.4rem;
  left: 100%;
  border-radius: 0.3rem;
  transform: translateX(-0.3rem);
}

.rl-menu__arrow {
  margin-left: 1rem;
}

/* On small screens Material's slide-out drawer takes over */
@media screen and (max-width: 76.2344em) {
  .rl-menu {
    display: none;
  }
}

/* ---------- Interactive Plotly figures ---------- */

.rl-plot {
  margin: 1.5em 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.3rem;
  padding: 0.4rem;
}

.rl-plot-hint {
  margin: 0.2rem 0 0 !important;
  text-align: center;
  font-size: 0.65rem;
  color: var(--md-default-fg-color--light);
}

/* ---------- Practice problems ---------- */

.rl-problem {
  margin: 1.6em 0 0.6em;
  font-weight: 700;
}

.rl-mcq > ul,
.rl-mcq > ol {
  list-style: none;
  margin-left: 0 !important;
  padding: 0;
}

.rl-mcq > ul > li,
.rl-mcq > ol > li {
  margin: 0.4em 0 !important;
  padding: 0.5em 0.8em;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.3rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.rl-mcq > ul > li:hover,
.rl-mcq > ol > li:hover,
.rl-mcq > ul > li:focus,
.rl-mcq > ol > li:focus {
  border-color: var(--md-accent-fg-color);
  outline: none;
}

.rl-mcq li.rl-wrong {
  border-color: #e53935;
  background-color: rgba(229, 57, 53, 0.08);
  text-decoration: line-through;
  opacity: 0.7;
}

.rl-mcq li.rl-right {
  border-color: #43a047;
  background-color: rgba(67, 160, 71, 0.12);
}

.rl-mcq li.rl-locked {
  cursor: default;
}

.rl-explain {
  display: none;
  padding: 0.6em 0.9em;
  border-left: 3px solid #43a047;
  background-color: rgba(67, 160, 71, 0.06);
}

.rl-explain.rl-show {
  display: block;
}

.rl-num {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  margin: 0.8em 0;
  padding: 0.6em 0.8em;
  border: 1px dashed var(--md-default-fg-color--lighter);
  border-radius: 0.3rem;
}

.rl-num input {
  width: 9em;
  padding: 0.3em 0.5em;
  font: inherit;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 0.2rem;
}

.rl-num button {
  padding: 0.3em 0.9em;
  font: inherit;
  color: var(--md-primary-bg-color);
  background-color: var(--md-primary-fg-color);
  border: none;
  border-radius: 0.2rem;
  cursor: pointer;
}

.rl-feedback.rl-good {
  color: #2e7d32;
  font-weight: 700;
}

.rl-feedback.rl-bad {
  color: #c62828;
}

[data-md-color-scheme="slate"] .rl-feedback.rl-good {
  color: #81c784;
}

[data-md-color-scheme="slate"] .rl-feedback.rl-bad {
  color: #ef9a9a;
}

/* ---------- Simulation Lab: config builder ---------- */
.rl-config {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 1.2rem 0;
  background: var(--md-code-bg-color);
  font-size: 0.72rem;
}
.rl-config-head { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; margin-bottom: 0.6rem; }
.rl-config-head label { font-weight: 600; }
.rl-config select, .rl-config input {
  font: inherit;
  color: var(--md-default-fg-color);
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
}
.rl-config-name { width: 13rem; }
.rl-config-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; }
@media (max-width: 60em) { .rl-config-body { grid-template-columns: 1fr; } }
.rl-config fieldset {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  margin: 0 0 0.6rem;
  padding: 0.3rem 0.6rem 0.5rem;
}
.rl-config legend { font-weight: 700; padding: 0 0.3rem; color: var(--md-primary-fg-color); }
.rl-config-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1.2fr) 6.5rem;
  align-items: center;
  column-gap: 0.6rem;
  margin: 0.2rem 0;
}
.rl-config-row input { width: 6.5rem; }
.rl-config-row small { grid-column: 1 / -1; color: var(--md-default-fg-color--light); margin: -0.1rem 0 0.15rem; }
.rl-config-side h4 { margin: 0 0 0.4rem; }
.rl-config-side table { font-size: 0.7rem; width: 100%; }
.rl-config-side td { padding: 0.15rem 0.4rem; border-bottom: 1px solid var(--md-default-fg-color--lightest); }
.rl-config-side td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rl-config-warn { color: #b26a00; margin: 0.4rem 0; }
.rl-config-ok { color: #2e7d32; margin: 0.4rem 0; }
[data-md-color-scheme="slate"] .rl-config-warn { color: #ffb74d; }
[data-md-color-scheme="slate"] .rl-config-ok { color: #81c784; }
.rl-config-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.rl-config-buttons button, a.rl-download {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.8rem;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}
.rl-config-buttons button + button { background: var(--md-default-fg-color--lighter); color: var(--md-default-bg-color); }
a.rl-download { display: inline-block; font-size: 0.8rem; padding: 0.5rem 1rem; }
a.rl-download:hover { color: var(--md-primary-bg-color); opacity: 0.9; }
.rl-config pre { margin: 0.4rem 0; font-size: 0.68rem; }
.rl-config-cmd { background: var(--md-default-bg-color); padding: 0.5rem 0.7rem; border-radius: 4px; overflow-x: auto; }
.rl-config details pre { max-height: 22rem; overflow: auto; background: var(--md-default-bg-color); padding: 0.5rem; }

/* Algorithm charts (scripts/make_flowcharts.py): inline SVG, so text follows the light/dark theme */
.rl-flow-wrap { margin: 1rem 0; overflow-x: auto; }
.rl-flow { display: block; width: 100%; min-width: 560px; max-width: 820px; height: auto; margin: 0 auto;
           color: var(--md-default-fg-color); }
.md-typeset a.rl-flow-link, .md-typeset a.rl-flow-link:hover { cursor: pointer; color: var(--md-default-fg-color); }
.rl-flow-link rect { transition: fill-opacity 0.15s, stroke-width 0.15s; }
.rl-flow-link:hover rect { fill-opacity: 0.3; stroke-width: 2.6; }

/* The four-step summary at the top of "Run it on your computer" */
.rl-steps { border-left: 4px solid var(--md-accent-fg-color); padding: 0.1rem 1rem; margin: 1rem 0;
            background: var(--md-code-bg-color); border-radius: 0 6px 6px 0; }

/* Algorithm videos (scripts/make_algorithm_videos.py) with step buttons (javascripts/video_steps.js) */
.rl-video { margin: 1rem 0 1.4rem; }
.rl-video video { display: block; width: 100%; max-width: 820px; height: auto; border-radius: 6px;
                  border: 1px solid var(--md-default-fg-color--lightest); background: #fff; }
.rl-video-bar { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: 0.45rem; max-width: 820px; }
.rl-video-label { font-size: 0.7rem; font-weight: 700; margin-right: 0.2rem; }
.rl-video-bar button { font: inherit; font-size: 0.68rem; cursor: pointer; padding: 0.2rem 0.55rem; border-radius: 4px;
                       border: 1px solid var(--md-default-fg-color--lighter); background: var(--md-default-bg-color);
                       color: var(--md-default-fg-color); }
.rl-video-bar button:hover { border-color: var(--md-accent-fg-color); }
.rl-video-bar button.rl-video-on { background: #ff9f43; border-color: #c0661a; color: #000; font-weight: 700; }
.rl-video-speed { font-size: 0.68rem; margin-left: auto; }
.rl-video-speed select { font: inherit; }

/* "All the equations on one sheet" (discretization.md): small maths so each line fits without scrolling */
.md-typeset .rl-eqsheet { font-size: 0.66rem; }
.md-typeset .rl-eqsheet .arithmatex { font-size: 0.92em; }
.md-typeset .rl-eqsheet table:not([class]) { font-size: 0.6rem; }
.md-typeset .rl-eqsheet table:not([class]) td:first-child { white-space: nowrap; }
.rl-flow-legend { font-size: 0.7rem; margin: 0.4rem 0 0.2rem; }

/* Builder: the picture of the initial state of the chosen setup */
.rl-config-look { margin: 0.6rem 0 0.8rem; border: 1px solid var(--md-default-fg-color--lightest); border-radius: 6px;
                  padding: 0.3rem 0.7rem; }
.rl-config-look summary { cursor: pointer; font-weight: 700; font-size: 0.75rem; }
.rl-config-look img { display: block; width: 100%; height: auto; margin-top: 0.4rem; background: #fff; border-radius: 4px; }
.rl-config-look-note { font-size: 0.66rem; margin: 0.3rem 0 0.2rem; color: var(--md-default-fg-color--light); }

/* The link back to the author's homepage, at the right end of the menu bar */
.rl-menu__item--home { margin-left: auto; }
