/* ------------------------------------------------------------
   Engineering: the two-axis cycle selector, drawn as joined tabs.
   Axis 1 is the cycle strip (.eng-strip), a row of tabs.
   Axis 2 is the DBTL row (.eng-wheel), a second row of tabs set
   inside the selected cycle's frame, Design -> Build -> Test ->
   Learn, with the stage text in the box beneath. The selected
   tab of each row opens into the box below it.
   Nothing is hidden here: the page script sets the `hidden`
   attribute on the cycle panels and stage panels it is not
   showing, so with no script every cycle and every stage reads
   in full.
   Cycle colours: teal, violet, deep blue, kraft, gold, green.
   The ring SVG in each wheel is kept in the markup but not drawn.
   A wheel can carry --n2 / --n3 when a cycle has fewer than four
   sections; its tabs are the numbered --s1 ... --s4 slots.
   ------------------------------------------------------------ */
.eng-strip__item--1, .eng-cycle--1 { --eng-accent: var(--acc-teal);        --eng-soft: var(--acc-teal-soft); }
.eng-strip__item--2, .eng-cycle--2 { --eng-accent: var(--acc-violet);      --eng-soft: var(--acc-violet-soft); }
.eng-strip__item--3, .eng-cycle--3 { --eng-accent: var(--pipe-blue-deep);  --eng-soft: var(--pipe-blue-soft); }
.eng-strip__item--4, .eng-cycle--4 { --eng-accent: var(--acc-kraft);       --eng-soft: var(--acc-kraft-soft); }
.eng-strip__item--5, .eng-cycle--5 { --eng-accent: var(--acc-gold);        --eng-soft: var(--acc-gold-soft); }
.eng-strip__item--6, .eng-cycle--6 { --eng-accent: var(--acc-green);       --eng-soft: var(--acc-green-soft); }

/* ---------- Axis 1: the cycle tabs ---------- */
.eng-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.25rem;
  margin: 1.25rem 0 0;
}

.eng-strip__item { position: relative; display: flex; flex: 1 1 0; min-width: 4.5rem; }
.eng-strip__arrow { display: none; }

.eng-strip__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.6rem 0.5rem 0.7rem;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--ink-3);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.eng-strip__card:hover { border-color: var(--eng-accent); background: var(--eng-soft); }
.eng-strip__card:focus-visible { outline: 3px solid var(--eng-accent); outline-offset: 2px; }

/* The selected cycle: accent frame on three sides, open at the bottom into
   the cycle box, and a heavier top edge so it reads without colour too. */
.eng-strip__card[aria-selected="true"] {
  border: var(--border-w) solid var(--eng-accent);
  border-top-width: 5px;
  border-bottom: 0;
  background: var(--eng-soft);
  padding-bottom: calc(0.7rem + var(--border-w));
  margin-bottom: calc(-1 * var(--border-w));
  position: relative;
  z-index: 1;
}

.eng-strip__num {
  padding: 0.15rem 0.7rem;
  white-space: nowrap;
  border-radius: 999px;
  background: var(--eng-accent);
  color: var(--card);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
}

.eng-strip__title, .eng-strip__out {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eng-strip__badge {
  align-self: flex-start;
  padding: 0.1rem 0.5rem;
  border: 1px dashed var(--eng-accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--eng-accent);
}

/* Unfinished cycle: dashed outline and a hatched tint. */
.eng-strip__card--progress {
  border-style: dashed;
  background: repeating-linear-gradient(135deg, var(--eng-soft) 0 8px, var(--card) 8px 16px);
}

.eng-strip__card--progress[aria-selected="true"] { border-style: dashed; }

/* ---------- The cycle box ---------- */
.eng-cycle {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--card);
  border: var(--border-w) solid var(--eng-accent);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.eng-cycle > h3 { margin-top: 0; font-size: 1.25rem; }

/* The cycle's one-line outcome, copied here from its tab by the page script. */
.eng-cycle__out { margin: 0.25rem 0 0; font-size: 0.9375rem; color: var(--ink-2); }

.eng-view { display: block; }

/* ---------- Axis 2: the DBTL tabs ---------- */
.eng-wheel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.75rem 0 0;
  color: var(--eng-accent);
}

.eng-wheel__ring { display: none; }

.eng-wheel__seg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1 1 0;
  min-width: 5.5rem;
  margin: 0;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--ink-3);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.eng-wheel__seg:hover { border-color: var(--eng-accent); background: var(--eng-soft); }
.eng-wheel__seg:focus-visible { outline: 3px solid var(--eng-accent); outline-offset: 2px; }

.eng-wheel__seg[aria-selected="true"] {
  border: var(--border-w) solid var(--eng-accent);
  border-bottom: 0;
  background: var(--eng-soft);
  padding-bottom: calc(0.5rem + var(--border-w));
  margin-bottom: calc(-1 * var(--border-w));
  position: relative;
  z-index: 1;
}

.eng-wheel__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--eng-accent);
  color: var(--card);
  font-size: 0.75rem;
}

/* A stage not measured yet: dashed outline and a hollow marker. */
.eng-wheel__seg--pending { border-style: dashed; }
.eng-wheel__seg--pending[aria-selected="true"] { border-style: dashed; }
.eng-wheel__seg--pending .eng-wheel__n {
  background: transparent;
  color: var(--eng-accent);
  border: 2px dashed var(--eng-accent);
}

/* ---------- Stage box ---------- */
.eng-stageset {
  padding: 1rem 1.1rem 0.4rem;
  background: var(--eng-soft);
  border: var(--border-w) solid var(--eng-accent);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.eng-stage { margin: 0 0 0.75rem; }
.eng-stage:focus-visible { outline: 3px solid var(--eng-accent); outline-offset: 4px; }
.eng-stage > h4:first-child { margin-top: 0; }

/* A pending stage keeps a dashed rule so the gap is visible. */
.eng-stage--pending { padding-left: 1rem; border-left: var(--border-w-bold) dashed var(--eng-accent); }

/* ---------- Takeaway for the next cycle ---------- */
.eng-changed {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  align-items: baseline;
  margin: 1rem 0 0;
  padding: 0.75rem 1rem 0.85rem;
  background: var(--acc-teal-soft);
  border: var(--border-w) solid var(--acc-teal);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
}

.eng-changed__label {
  flex: 0 0 100%;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--acc-teal);
}

.eng-changed__arrow { flex: none; font-weight: 700; color: var(--acc-teal); }
/* Several takeaways in one box: one arrow per line. */
.eng-changed__item { display: flex; flex: 0 0 100%; gap: 0.6rem; align-items: baseline; }
.eng-changed__text { flex: 1 1 0; min-width: 0; }

@media (max-width: 575.98px) {
  .eng-strip__card { padding-left: 0.2rem; padding-right: 0.2rem; }
  .eng-strip__num { padding: 0.15rem 0.45rem; font-size: 0.75rem; }
  .eng-cycle { padding: 0.75rem 0.75rem 1rem; }
  .eng-wheel__seg { min-width: 4.25rem; padding: 0.45rem 0.35rem; font-size: 0.875rem; }
  .eng-wheel__n { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .eng-strip__card, .eng-wheel__seg { transition: none; }
}

/* ---------- Figures ---------- */
.eng-fig { margin: 1rem 0; }
.eng-fig__img { display: block; max-width: 100%; height: auto; border: 1px solid var(--ink-3); border-radius: var(--radius-sm); background: var(--card); }
.eng-fig__img[data-pending] { border-style: dashed; }
.eng-fig--results-graph .eng-fig__img { width: auto; max-height: 400px; object-fit: contain; margin: 0 auto; }
.eng-fig__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; align-items: start; }
.eng-fig figcaption { margin-top: 0.5rem; font-size: 0.875rem; line-height: 1.4; color: var(--ink-2); }
@media (max-width: 575.98px) { .eng-fig__row { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Enlarge (static/lightbox.js, the site-wide click-to-enlarge) ----------
   Same rules as the other pages. The "Click to enlarge" hint sits at the top of
   the figure here so it does not cover the caption. */
.js-zoomable {
  cursor: zoom-in;
  position: relative;
}

.js-zoomable:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.lb-modal .modal-dialog.lb-dialog {
  width: fit-content;
  max-width: calc(100vw - 2rem);
}

.lb-modal .lb-content {
  position: relative;
  align-items: center;
  background: transparent;
  border: 0;
}

.lb-img {
  display: block;
  width: auto;
  height: auto;
  max-height: calc(100vh - 8rem);
  border-radius: var(--radius-md);
  background: var(--card);
}

.lb-caption {
  margin: 0.75rem 0 0;
  max-width: 60ch;
  text-align: center;
  font-size: 0.9rem;
  color: var(--card);
}

.lb-caption--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.lb-close {
  position: absolute;
  top: -2.25rem;
  right: 0;
}

/* Zoom hint on hover/focus: a small magnifier badge in ink and white. */
figure:has(> .js-zoomable) {
  position: relative;
}

figure:has(> .js-zoomable)::after {
  content: "Click to enlarge";
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--card);
  font-size: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

figure:has(> .js-zoomable:hover)::after,
figure:has(> .js-zoomable:focus-visible)::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  figure:has(> .js-zoomable)::after {
    transition: none;
  }
  .lb-modal.fade .modal-dialog,
  .lb-modal.fade {
    transition: none;
  }
}
