/*
 * Extra styles for the P4 Mazes pages.
 * The shared theme (site/css/main.css) doesn't style these, so they live here.
 */

/* ---- "Task" / "Note" / "Warning" callout boxes ---- */
.admonition {
  border-left: 4px solid #4b2e83;
  background-color: #f3f0f9;
  padding: 10px 15px;
  margin-bottom: 15px;
}
.admonition > p:last-child {
  margin-bottom: 0;
}
.admonition-title {
  font-weight: 600;
  color: #4b2e83;
  margin-bottom: 5px;
}
.admonition.note {
  border-left-color: #1c67ca;
  background-color: #eef4fc;
}
.admonition.note .admonition-title {
  color: #1c67ca;
}
.admonition.warning {
  border-left-color: #b7791f;
  background-color: #fdf6e7;
}
.admonition.warning .admonition-title {
  color: #8a5a12;
}

/* ---- Collapsible <details> sections ---- */
details {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 15px;
  margin-bottom: 15px;
}
details > summary {
  font-weight: 600;
  cursor: pointer;
}
details[open] > summary {
  margin-bottom: 10px;
}

/* ---- "P4 - Mazes" side menu (uses the theme's .nav-box style) ---- */
.mazes-nav {
  margin: 0 0 15px 0;
}
.mazes-nav ul {
  margin-left: 15px;
}
.mazes-nav li {
  margin-bottom: 4px;
}
.mazes-nav .current {
  font-weight: 600;
}
@media (min-width: 768px) {
  .mazes-nav {
    float: right;
    width: 230px;
    margin: 0 0 15px 25px;
  }
}

/* ---- "Previous / Next" links at the bottom of each page ---- */
.mazes-pager {
  clear: both;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  border-top: 1px solid #e8e8e8;
  padding-top: 15px;
  margin-top: 30px;
}

/* ---- Responsive 16:9 video embed (Panopto) ---- */
.video-embed {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  margin-bottom: 8px;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px solid #464646;
  box-sizing: border-box;
}
.video-fallback {
  font-size: 0.9em;
  color: #555;
}

/* ---- Office-hours checklist (empty box before each item) ---- */
.checklist {
  list-style: none;
  padding-left: 0;
}
.checklist li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 6px;
}
.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.25em;
  width: 15px;
  height: 15px;
  border: 2px solid #4b2e83;
  border-radius: 3px;
}

/* ---- Milestone boxes (top of the first page of each milestone) ---- */
.milestone {
  clear: none;
  border: 2px solid #4b2e83;
  border-radius: 6px;
  padding: 0 0 12px 0;
  margin-bottom: 20px;
  overflow: hidden;
}
.milestone-header {
  background-color: #4b2e83;
  color: #fff;
  font-weight: 600;
  font-size: 1.1em;
  padding: 8px 15px;
  margin-bottom: 10px;
}
.milestone > :not(.milestone-header) {
  margin-left: 15px;
  margin-right: 15px;
}
.milestone dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 15px;
  margin-bottom: 10px;
}
.milestone dt {
  font-weight: 600;
}
.milestone dd {
  margin: 0;
}
.milestone ul {
  padding-left: 20px;
}
.milestone-checkin {
  display: inline-block;
  background-color: #4b2e83;
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  font-weight: 600;
}
.milestone-checkin:hover,
.milestone-checkin:focus {
  color: #fff;
  background-color: #32215a;
}

/* ---- "M1" / "M2" labels in the side menu ---- */
.milestone-tag {
  display: inline-block;
  font-size: 0.75em;
  font-weight: 600;
  color: #4b2e83;
  border: 1px solid #4b2e83;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: 1px;
}

/* ---- One-line "part of Milestone N" note on later pages of a milestone ---- */
.milestone-reminder {
  border-left: 4px solid #4b2e83;
  padding: 4px 12px;
  color: #4b2e83;
  font-weight: 600;
}

/* ---- Make bold text actually bold ----
 * main.css sets body text to weight 300, and Bootstrap sets <b>/<strong> to
 * "bolder", which only goes one step up from 300, to 400 (normal). The Google
 * Font only loads 400 and 600, so body text already renders at 400 and bold
 * text looks identical. Pin bold to 600, the weight the font provides. */
b,
strong {
  font-weight: 600;
}

/* ---- "Review first: ... lecture slides" line on the Debugging page ---- */
.slides-link {
  border-left: 4px solid #1c67ca;
  background-color: #eef4fc;
  padding: 6px 12px;
}

/* ---- Step-through algorithm animations (trace-player.js) ---- */
.trace-player {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
  background-color: #fff;
}
.trace-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}
.trace-figure {
  flex: 1 1 280px;
  max-width: 420px;
  min-width: 0;
}
.trace-svg {
  display: block;
  width: 100%;
  height: auto;
}
.trace-panel {
  flex: 1 1 220px;
  min-width: 0;
  font-size: 0.95em;
}
.trace-panel p {
  margin-bottom: 6px;
}
.trace-caption {
  min-height: 4.5em;
  background-color: #f7f7f7;
  border-radius: 4px;
  padding: 8px 10px;
  margin: 10px 0;
}
.trace-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.trace-controls button {
  border: 1px solid #4b2e83;
  background-color: #fff;
  color: #4b2e83;
  border-radius: 4px;
  padding: 4px 10px;
  font-weight: 600;
}
.trace-controls button:hover:not(:disabled) {
  background-color: #f3f0f9;
}
.trace-controls button:focus-visible {
  outline: 2px solid #1c67ca;
  outline-offset: 2px;
}
.trace-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}
.trace-count {
  margin-left: auto;
  color: #555;
  font-size: 0.9em;
}

/* Graph drawing */
.trace-player .edge {
  stroke: #bbb;
  stroke-width: 2.5;
  transition: stroke 0.3s, stroke-width 0.3s;
}
.trace-player .edge.added { stroke: #222; stroke-width: 4.5; }
.trace-player .edge.skipped { stroke: #ccc; stroke-dasharray: 6 5; }
.trace-player .edge.tree { stroke: #4b2e83; stroke-width: 3.5; }
.trace-player .edge.current { stroke: #dd6b20; stroke-width: 5.5; stroke-dasharray: none; }
.trace-player .edge.path { stroke: #c53030; stroke-width: 5.5; }
.trace-player .arrowhead.base { fill: #bbb; }
.trace-player .arrowhead.tree { fill: #4b2e83; }
.trace-player .arrowhead.current { fill: #dd6b20; }
.trace-player .arrowhead.path { fill: #c53030; }
.trace-player .edge-weight {
  font-size: 14px;
  font-weight: 600;
  fill: #333;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
}
.trace-player .v circle {
  fill: #fff;
  stroke: #888;
  stroke-width: 2;
  transition: fill 0.3s, stroke 0.3s;
}
.trace-player .v text {
  font-size: 15px;
  font-weight: 600;
  fill: #333;
  text-anchor: middle;
  dominant-baseline: central;
}
.trace-kruskal .v circle { stroke: rgba(0, 0, 0, 0.25); }
.trace-kruskal .v text { fill: #fff; }
.trace-player .v.inpq circle { fill: #eef4fc; stroke: #1c67ca; }
.trace-player .v.final circle { fill: #4b2e83; stroke: #4b2e83; }
.trace-player .v.final text { fill: #fff; }
.trace-player .v.removing circle { stroke: #dd6b20; stroke-width: 4; }
.trace-player .dist-label {
  font-size: 14px;
  font-weight: 600;
  fill: #1c67ca;
  text-anchor: middle;
}

/* Legend under the graph */
.trace-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
  font-size: 0.85em;
  color: #444;
}
.trace-legend svg {
  vertical-align: middle;
  margin-right: 4px;
}

/* State panel beside the graph */
.trace-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}
.trace-table th,
.trace-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #e8e8e8;
  text-align: left;
}
.trace-table tr.changed td {
  background-color: #fdf0e3;
}
.trace-edges {
  padding-left: 22px;
  margin-bottom: 0;
}
.trace-edges li.current {
  color: #dd6b20;
  font-weight: 600;
}
.trace-edges li.skipped {
  color: #888;
}
.trace-mark {
  font-size: 0.85em;
  font-style: italic;
}

@media (max-width: 420px) {
  .trace-player {
    padding: 10px;
  }
  .trace-controls button {
    padding: 4px 7px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .trace-player .edge,
  .trace-player .v circle {
    transition: none;
  }
}
