/* ===========================================================================
   Practice Engine widget — cream editorial styling.
   Uses architect tokens, so it inherits the per-course --accent from the
   surrounding .course-* wrapper and flips automatically in dark mode.
   =========================================================================== */

.pe-autoblock { margin: 3.5rem 0 1rem; }
.pe-intro { text-align: center; max-width: 760px; margin: 0 auto 1.5rem; }
.pe-intro h2 { margin: 0.5rem 0 0.6rem; }
.pe-intro-lede { color: var(--ink-2); font-size: 1.02rem; line-height: 1.65; margin: 0 auto; max-width: 640px; }

.pe-widget {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: var(--arch-shadow-md);
  padding: 1.5rem 1.6rem 1.7rem;
  max-width: 760px;
  margin: 0 auto;
}

/* ---- header ---- */
.pe-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.pe-kicker {
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.pe-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--ink); line-height: 1.2; margin-top: 0.15rem; }
.pe-stats { display: flex; gap: 1.1rem; }
.pe-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.pe-stat b { font-family: var(--font-display); font-size: 1.25rem; color: var(--ink); }
.pe-stat i { font-family: var(--font-mono); font-style: normal; font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* ---- meta row: skill + difficulty pips ---- */
.pe-meta { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; justify-content: space-between; margin: 1.1rem 0 0.4rem; }
.pe-skill { font-size: 0.92rem; color: var(--ink-2); font-weight: 600; }
.pe-skill::before { content: "Skill · "; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.pe-levels { display: inline-flex; gap: 5px; }
.pe-lv { width: 22px; height: 6px; border-radius: 3px; background: var(--line-strong); transition: background .2s; }
.pe-lv.on { background: var(--accent); }
.pe-lv.cap { opacity: 0.4; }

/* ---- progress to 15 ---- */
.pe-progress { position: relative; height: 22px; border-radius: 11px; background: var(--accent-tint); overflow: hidden; margin: 0.3rem 0 1.1rem; }
.pe-progress-bar { position: absolute; inset: 0 auto 0 0; height: 100%; background: var(--accent); border-radius: 11px; transition: width .35s ease; }
.pe-progress-bar.done { background: linear-gradient(90deg, var(--accent), var(--accent-bright)); }
.pe-progress-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink); mix-blend-mode: normal; }

/* ---- problem stem ---- */
.pe-stem {
  font-size: 1.18rem; line-height: 1.6; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.1rem 1.25rem; margin-bottom: 1rem; min-height: 2.5rem;
}
.pe-stem .katex { font-size: 1.05em; }

/* ---- answer area ---- */
.pe-inputwrap { display: flex; flex-direction: column; gap: 0.4rem; }
.pe-input {
  width: 100%; box-sizing: border-box;
  font-family: var(--font-mono); font-size: 1.1rem; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line-strong); border-radius: 10px;
  padding: 0.7rem 0.9rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.pe-input::placeholder { color: var(--muted); font-family: var(--font-body); }
.pe-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.pe-input.ok { border-color: #1E8E5A; background: rgba(30,142,90,0.06); }
.pe-input.err { border-color: #C0392B; background: rgba(192,57,43,0.05); }
.pe-preview { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); min-height: 1.1em; padding-left: 0.2rem; }
.pe-preview.ok { color: var(--accent); }

/* ---- multiple choice ---- */
.pe-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 540px) { .pe-choices { grid-template-columns: 1fr; } }
.pe-choice {
  text-align: left; font-size: 1.02rem; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line-strong); border-radius: 10px;
  padding: 0.75rem 0.95rem; cursor: pointer; transition: border-color .12s, background .12s, transform .12s;
}
.pe-choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.pe-choice.sel { border-color: var(--accent); background: var(--accent-tint); }
.pe-choice.correct { border-color: #4FD8B0; background: rgba(79,216,176,0.14); color: #9AF2D8; font-weight: 600; }
.pe-choice.wrong { border-color: #FF8080; background: rgba(255,128,128,0.10); color: #FFC3C3; }
.pe-choice:disabled { cursor: default; }

/* ---- actions ---- */
.pe-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.pe-btn {
  font-family: var(--font-mono); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.03em;
  border-radius: 10px; padding: 0.7rem 1.3rem; cursor: pointer; border: 1px solid var(--accent);
  background: var(--accent); color: #0A0E1F; font-weight: 700; transition: filter .15s, transform .15s, background .15s;
}
.pe-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.pe-btn.pe-ghost { background: transparent; color: var(--accent); }
.pe-btn.pe-ghost:hover { background: var(--accent-tint); }
.pe-btn.pe-next { background: var(--accent-bright, var(--accent)); border-color: var(--accent-bright, var(--accent)); color: #0A0E1F; }

/* ---- feedback ---- */
.pe-feedback {
  margin-top: 1.1rem; padding: 0.85rem 1.1rem; border-radius: 12px; font-size: 1rem; line-height: 1.55;
  border: 1px solid var(--line);
}
.pe-feedback.good { background: rgba(30,142,90,0.09); border-color: rgba(30,142,90,0.35); color: var(--ink); }
.pe-feedback.bad { background: rgba(192,57,43,0.07); border-color: rgba(192,57,43,0.30); color: var(--ink); }
.pe-fb-icon { font-weight: 800; margin-right: 0.2rem; }
.pe-feedback.good .pe-fb-icon { color: #1E8E5A; }
.pe-feedback.bad .pe-fb-icon { color: #C0392B; }

/* ---- worked steps ---- */
.pe-steps { margin-top: 0.9rem; padding: 1rem 1.2rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.pe-steps-title { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.55rem; }
.pe-steplist { margin: 0; padding-left: 1.3rem; }
.pe-steplist li { color: var(--ink-2); font-size: 0.98rem; line-height: 1.7; padding: 0.15rem 0; }
.pe-steplist li .katex { color: var(--ink); }

/* ---- footer / hint ---- */
.pe-foot { margin-top: 0.9rem; }
.pe-hint { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); line-height: 1.5; }
.pe-hint.flash { color: #C0392B; font-weight: 700; }

@media (max-width: 560px) {
  .pe-widget { padding: 1.2rem 1.1rem 1.4rem; }
  .pe-head { gap: 0.6rem; }
  .pe-stats { gap: 0.8rem; }
  .pe-title { font-size: 1.15rem; }
  .pe-stem { font-size: 1.05rem; }
}

/* ---- contextual "Practice this now ↓" call-to-action (in lesson content) ---- */
.pe-cta-slot {
  display: inline-flex;
  margin: 1.25rem 0.65rem 0.4rem 0;
  vertical-align: top;
}
.pe-cta {
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.03em;
  color: #fff; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 10px; padding: 0.6rem 1.05rem;
  box-shadow: var(--arch-shadow-sm); transition: filter .15s, transform .15s, box-shadow .15s;
}
.pe-cta:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: var(--arch-shadow-md); }
.pe-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pe-cta-arrow { display: inline-block; font-weight: 900; animation: peBob 1.6s ease-in-out infinite; }
@keyframes peBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .pe-cta-arrow { animation: none; } }
@media (max-width: 540px) {
  .pe-cta-slot { display: flex; margin-right: 0; }
  .pe-cta { width: 100%; justify-content: center; }
}

/* ---- "Practicing: <topic>" chip inside the widget ---- */
.pe-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.2rem 0 0.9rem; }
.pe-focus-on { font-size: 0.85rem; color: var(--ink-2); background: var(--accent-tint); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.8rem; }
.pe-focus-on strong { color: var(--accent); }
.pe-focus-clear { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; color: var(--muted); background: transparent; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.3rem 0.7rem; cursor: pointer; transition: color .12s, border-color .12s; }
.pe-focus-clear:hover { color: var(--ink); border-color: var(--accent); }

/* ===========================================================================
   Question integrity — discourage copying/screenshotting the problem text.
   (Client-side deterrence: a browser cannot block native OS screenshots.)
   =========================================================================== */
/* Block selecting/copying everything in the widget EXCEPT the answer field. */
.pe-widget {
  position: relative;
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.pe-input, .pe-input * { -webkit-user-select: text; -moz-user-select: text; user-select: text; }

/* Faint tiled watermark over the question — marks any screenshot, near-invisible live. */
.pe-stem {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='130'><text x='8' y='80' transform='rotate(-22 120 65)' font-family='monospace' font-size='15' fill='%231B2A4A' fill-opacity='0.05'>drijezie.com</text></svg>");
}

/* Capture guard: hide/blur the questions while the tab or window isn't focused
   (deters switching to another app to capture or look up an answer). */
.pe-capguard {
  position: absolute; inset: 0; z-index: 6; display: none;
  align-items: center; justify-content: center; text-align: center; padding: 1.25rem;
  border-radius: 16px; background: var(--surface);
  font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink-2); line-height: 1.7;
}
body.pe-capture-hide .pe-capguard { display: flex; }
body.pe-capture-hide .pe-stem,
body.pe-capture-hide .pe-answer,
body.pe-capture-hide .pe-steps,
body.pe-capture-hide .pe-feedback { filter: blur(9px); }

/* ---- print: never waste ink on the interactive gym (also stops print-to-PDF capture) ---- */
@media print { .pe-autoblock, .pe-widget, .pe-cta-slot { display: none !important; } }
