/* ==========================================================================
   Study progress tracking
   --------------------------------------------------------------------------
   Styles for progress-tracker.js. Colours resolve through the custom
   properties declared in custom.css, so light and dark stay in sync.
   ========================================================================== */

:root {
  --pt-size: 17px;          /* visual size of the checkbox circle */
  --pt-gap: 11px;           /* space between checkbox and heading text */
  --pt-speed: 140ms;
}

/* ---------- Checkbox beside each H2 ---------- */

/* Space is reserved permanently so revealing the box on hover never reflows
   the heading. */
.markdown-section h2.pt-h2 {
  display: flex;
  align-items: baseline;
  gap: var(--pt-gap);
}

.pt-check-wrap {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pt-size);
  height: var(--pt-size);
  /* Nudges the box onto the heading's cap-height rather than its baseline. */
  align-self: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--pt-speed) ease;
}

/* Visible on hover, on keyboard focus, and whenever the section is complete. */
.markdown-section h2.pt-h2 .pt-check-wrap,
.markdown-section h2.pt-h2.pt-done .pt-check-wrap,
.pt-check-wrap:focus-within { opacity: 1; }

/* Touch devices have no hover, so the boxes are always visible there. */
@media (hover: none) {
  .pt-check-wrap { opacity: 1; }
}

.pt-check {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: var(--pt-size);
  height: var(--pt-size);
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color var(--pt-speed) ease, border-color var(--pt-speed) ease;
}
.pt-check:hover { border-color: var(--accent); }
/* The tick is a background image rather than a ::after. <input> is a replaced
   element, and pseudo-elements on replaced elements are not reliably rendered
   across browsers; a background-image always is. */
.pt-check:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.6 6.3l2.4 2.4 4.5-4.9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px 11px;
}
.pt-check:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Deliberately NOT dimmed or struck through: completed sections are still
   study material and get re-read. Only the box changes. */

/* 44px touch target without changing the visual size or shifting layout.
   The box is anchored to the checkbox's RIGHT edge rather than centred on it:
   centring pushed the hit area 3px past the start of the heading text, so a
   tap on the first characters of a heading toggled the checkbox instead of
   following the heading's anchor link. Growing leftwards instead puts the
   extra area in the page's left padding, where nothing else is clickable. */
.pt-check-wrap::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 44px;
  height: 44px;
  transform: translateY(-50%);
}
/* On desktop the expanded area is unnecessary and would only enlarge the
   hover region, so it is kept to the visual box there. */
@media (hover: hover) and (pointer: fine) {
  .pt-check-wrap::before { width: 100%; height: 100%; right: auto; }
}

/* ---------- Per-page bulk controls ---------- */
.pt-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 14px 0 4px;
  padding: 9px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  font-size: 12.5px;
  color: var(--text-muted);
}
.pt-bulk-count { font-variant-numeric: tabular-nums; }
.pt-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pt-bulk-btn {
  padding: 4px 2px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color var(--pt-speed) ease, border-color var(--pt-speed) ease;
}
.pt-bulk-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}
.pt-bulk-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.pt-bulk-sep { color: var(--border); }

@media screen and (max-width: 768px) {
  /* Bigger tap area, and enough separation from the headings above/below that
     a mis-tap does not land on a heading anchor. */
  .pt-bulk { margin: 16px 0 8px; gap: 10px 14px; }
  .pt-bulk-btn { padding: 9px 2px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pt-check-wrap,
  .pt-check,
  .pt-bulk-btn { transition: none !important; }
}
