/* ── Problem heading anchor offset ──────────────────────────────── */
.md-typeset h2.problem,
.md-typeset h3.problem { scroll-margin-top: 5rem; }

/* ── Type-tag badges (icon-only, square) ────────────────────────── */
.problem-tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

/* Block-form: dedicated row (used for the blurred topic chips below
   the statement). */
.problem-tags--topics {
  display: flex;
  margin: .3rem 0 1rem;
}

/* Inline-form: rendered next to the problem title — pulls the icons
   alongside the heading text and aligns them to the heading baseline.
   `vertical-align: -.18em` keeps the square icons on the same optical
   line as Persian glyphs that have a low baseline. */
.md-typeset h2.problem .problem-tags--inline,
.md-typeset h3.problem .problem-tags--inline {
  margin-inline-start: .55rem;
  vertical-align: -.18em;
  font-weight: normal;
}

.ptag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .3em;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
}

a.ptag {
  color: inherit;
  text-decoration: none;
}

a.ptag:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.ptag-handwritten,
.ptag-video,
.ptag-exam {
  width: 1.4em;
  height: 1.4em;
  font-size: .8em;  /* shrinks together with the icons inside */
}

.ptag-handwritten svg,
.ptag-video svg,
.ptag-exam svg {
  width: .82em;
  height: .82em;
}

.ptag-handwritten {
  background: var(--md-accent-fg-color);
  color: #fff;
}

.ptag-video {
  background: #0d9488;          /* teal-600 — distinct from the pencil */
  color: #fff;
}

.ptag-exam {
  background: #e67e00;
  color: #fff;
}

/* ── Topic badges: blurred until clicked ───────────────────────── */
.problem-tags--topics { margin: .3rem 0 1rem; }

.ptag-topic {
  gap: .35em;
  padding: .3em .7em;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  filter: blur(8px);
  cursor: pointer;
  user-select: none;
  transition: filter .25s ease;
}

.ptag-topic svg {
  width: .8em;
  height: .8em;
  flex-shrink: 0;
}

.ptag-topic.revealed {
  filter: none;
  cursor: default;
}

.ptag-topic:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 2px;
}

/* Hints / solution wrappers and individual hint nodes are emitted as
   Material admonitions (classes `tip`, `success`, `note`, `abstract`,
   `question`, `warning`) so Material's own CSS draws the side-bar, the
   tinted header, and the matching SVG icon — the exact look the previous
   ``??? tip`` markdown produced. We keep the additional ``hint`` /
   ``problem-hints`` classes on the elements purely as anchors for tiny
   tweaks below. */

.md-typeset details.problem-hints,
.md-typeset details.problem-solution {
  margin-top: .9rem;
  margin-bottom: .9rem;
}

/* When the solution comes right after the hints block (the common case),
   pull it tight so the pair reads as a single unit instead of two
   floating cards with a gulf in between. */
.md-typeset details.problem-hints + details.problem-solution {
  margin-top: .35rem;
}

/* The nested node wrappers reuse Material admonition styling, so all we
   really need to add is a touch of spacing between siblings. */
.md-typeset details.hint { margin-block: .55rem; }

.problem-solution-video video {
  width: 100%;
  max-height: 70vh;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #000;
}

.problem-solution-video {
  border: 1px solid var(--md-default-fg-color--lightest, #e3e3e7);
  border-radius: 9px;
  padding: .45rem;
  background: var(--md-default-bg-color);
}

.problem-solution-summary-video {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  margin-inline-start: .35rem;
  border-radius: .28em;
  background: #0d9488;
  color: #fff;
  vertical-align: -.18em;
}

.problem-solution-summary-video svg {
  width: .78em;
  height: .78em;
}

.problem-solution-attachments {
  margin-top: .75rem;
}

.problem-solution-attachments ul {
  margin-top: .25rem;
}

/* ── Problem feedback ───────────────────────────────────────────── */
.problem-statement__label {
  font-weight: 800;
  letter-spacing: 0;
}

.problem-feedback-row {
  display: none;
}

.problem-feedback {
  --feedback-green: #00b341;
  --feedback-red: #9f1111;
  --feedback-ink: var(--md-default-fg-color);
  --feedback-muted: var(--md-default-fg-color--light);
  --feedback-line: var(--md-default-fg-color--lightest);
  direction: rtl;
  display: grid;
  grid-template-columns: auto minmax(15rem, 24rem);
  align-items: center;
  justify-content: space-between;
  gap: .7rem 1rem;
  min-height: 2.55rem;
  padding: .38rem .5rem;
  border-block: 1px solid var(--feedback-line);
  color: var(--feedback-ink);
  font-size: .66rem;
  font-weight: 700;
}

.problem-feedback__votes {
  justify-self: start;
  direction: rtl;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.problem-feedback__vote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  min-width: 2.55rem;
  height: 1.8rem;
  padding: 0 .55rem;
  border: 1px solid var(--feedback-line);
  border-radius: 999px;
  background: var(--md-default-bg-color);
  color: var(--feedback-muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}

.problem-feedback__vote svg {
  width: .82rem;
  height: .82rem;
}

.problem-feedback__vote:hover,
.problem-feedback__vote:focus-visible {
  border-color: var(--md-default-fg-color--lighter);
  background: color-mix(in srgb, var(--md-default-bg-color) 78%, var(--md-accent-fg-color) 8%);
  color: var(--feedback-ink);
  outline: none;
}

.problem-feedback__vote:active {
  transform: translateY(1px);
}

.problem-feedback__vote.is-active[data-feedback-vote="1"] {
  border-color: rgba(16, 185, 129, .45);
  background: rgba(16, 185, 129, .14);
  color: #059669;
}

.problem-feedback__vote.is-active[data-feedback-vote="-1"] {
  border-color: rgba(239, 68, 68, .45);
  background: rgba(239, 68, 68, .12);
  color: #dc2626;
}

.problem-feedback__difficulty {
  justify-self: end;
  direction: ltr;
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto;
  align-items: center;
  gap: .38rem;
  width: min(18rem, 100%);
  min-width: 0;
}

.problem-feedback__end {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: .95rem;
  height: .95rem;
  opacity: .9;
}

.problem-feedback__end svg {
  width: .82rem;
  height: .82rem;
}

.problem-feedback__end--easy {
  color: var(--feedback-green);
}

.problem-feedback__end--hard {
  color: var(--feedback-red);
}

.problem-feedback__track {
  display: block;
  position: relative;
  height: .44rem;
  border-radius: 999px;
  background:
    linear-gradient(90deg,
      rgba(255, 255, 255, .32),
      transparent 18%,
      transparent 82%,
      rgba(255, 255, 255, .24)),
    linear-gradient(90deg,
      var(--feedback-green) 0%,
      color-mix(in srgb, var(--feedback-green) 78%, var(--feedback-red)) 42%,
      color-mix(in srgb, var(--feedback-green) 42%, var(--feedback-red)) 58%,
      var(--feedback-red) 100%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--md-default-bg-color) 64%, transparent),
    0 1px 4px rgba(15, 23, 42, .12);
  cursor: pointer;
  touch-action: none;
}

.problem-feedback__track:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 5px;
}

.problem-feedback__marker {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: .34rem;
  height: .9rem;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.problem-feedback__marker--avg {
  width: .16rem;
  height: 1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-default-fg-color) 62%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--md-default-bg-color) 72%, transparent);
}

.problem-feedback__marker--mine {
  width: .82rem;
  height: .82rem;
  border: 2px solid var(--md-default-bg-color);
  background: var(--md-accent-fg-color);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--md-accent-fg-color) 24%, transparent),
    0 2px 5px rgba(15, 23, 42, .2);
}

.problem-feedback[data-state="loading"] .problem-feedback__votes,
.problem-feedback[data-state="loading"] .problem-feedback__difficulty {
  opacity: .62;
}

.problem-feedback[data-state="saving"] .problem-feedback__track,
.problem-feedback[data-state="saving"] .problem-feedback__vote {
  cursor: progress;
}

.problem-feedback[data-state="error"] .problem-feedback__difficulty {
  color: #dc2626;
}

.problem-feedback__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[data-md-color-scheme="slate"] .problem-feedback {
  --feedback-line: rgba(148, 163, 184, .22);
}

[data-md-color-scheme="slate"] .problem-feedback__marker--avg {
  background: rgba(255, 255, 255, .7);
}

@media (max-width: 720px) {
  .problem-feedback {
    grid-template-columns: 1fr;
    padding-block: .5rem .65rem;
  }

  .problem-feedback__votes {
    justify-self: start;
  }

  .problem-feedback__difficulty {
    justify-self: stretch;
    width: 100%;
  }

}

/* ── Misc ──────────────────────────────────────────────────────── */
hr.problem-break {
  border: none;
  border-top: 2px dashed var(--md-default-fg-color--lightest, #e3e3e7);
  margin: 1.6rem 0;
}

.assignment-due {
  display: inline-block;
  padding: .25rem .65rem;
  margin: 0 0 1rem;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-size: .9em;
}

[data-md-color-scheme="slate"] .assignment-due {
  background: rgba(252, 211, 77, .15);
  color: #fcd34d;
}

.assignment-volunteer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  margin: 0 0 1.15rem;
  padding: .75rem .85rem;
  border: 1px solid rgba(14, 116, 144, .24);
  border-radius: 8px;
  background: rgba(236, 253, 245, .72);
}

.assignment-volunteer strong,
.assignment-volunteer span {
  display: block;
}

.assignment-volunteer strong {
  color: #0f766e;
}

.assignment-volunteer span {
  color: var(--md-default-fg-color--light);
  font-size: .9em;
}

.assignment-volunteer a {
  flex: 0 0 auto;
  padding: .45rem .7rem;
  border-radius: 7px;
  background: #0f766e;
  color: #fff;
  font-weight: 700;
}

[data-md-color-scheme="slate"] .assignment-volunteer {
  background: rgba(20, 184, 166, .12);
  border-color: rgba(45, 212, 191, .24);
}

[data-md-color-scheme="slate"] .assignment-volunteer strong {
  color: #5eead4;
}

@media (max-width: 42rem) {
  .assignment-volunteer {
    align-items: stretch;
    flex-direction: column;
  }

  .assignment-volunteer a {
    text-align: center;
  }
}
