/* themes/oregonhealing/css/lesson-figures.css: lesson figures (diagrams
   and screenshots in a lesson body), rendered by
   modules/learn/learn.figures.php and loaded only on a lesson page that has
   one. Everything reads the --lrn-* tokens, so the base theme and Alder
   (which re-points them in alder-learn.css) both draw the diagrams in their
   own colours and fonts. Plain figures in a lesson body (an /uploads/learn
   image in a <figure>) share the source line and the enlarge button. Sibling: js/lesson-figures.js (enlarge on desktop).

   Diagram vocabulary (the classes an SVG under img/lessons/ may use; each
   file also carries plain fill and stroke attributes as a fallback when
   opened on its own):
     lf-panel      the drawing's background card
     lf-box        a step or a thing (cream fill, hairline)
     lf-box--key   the one box the reader should land on (green fill)
     lf-box--soft  a side note or an optional branch (tint fill)
     lf-box--warn  a stop or a common mistake (sand fill, dashed edge)
     lf-line       a connector; lf-line--dash for "only if"
     lf-head       a marker fill (arrowheads)
     lf-t          body text; lf-t--b bold, lf-t--s small,
                   lf-t--m muted, lf-t--on text on lf-box--key
     lf-step       a numbered step disc; lf-step-n its number */

.lrn-lesson .ocd-prose .lesson-fig { margin: 1.75em 0; }
.lesson-fig__art { position: relative; }
.lesson-fig svg { display: block; width: 100%; height: auto; overflow: visible; }
/* The lesson's own body font (Inter in Alder, Lora in the base theme), not the system-ui fallback the file carries for standalone viewing. */
.lesson-fig .lesson-fig__art svg, .lesson-fig-dialog__body svg { font-family: inherit; }

/* Narrow drawings for phones: the wide one would shrink its text below 10px. */
.lesson-fig--has-narrow .lesson-fig__art--wide { display: none; }
@media (min-width: 600px) {
  .lesson-fig--has-narrow .lesson-fig__art--wide { display: block; }
  .lesson-fig--has-narrow .lesson-fig__art--narrow { display: none; }
}

:is(.lesson-fig, .lesson-fig-dialog) .lf-panel { fill: var(--lrn-page, #f7fcf8); stroke: var(--lrn-line, #cfe6d8); stroke-width: 1; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-box { fill: var(--lrn-cream, #f7efdf); stroke: var(--lrn-line, #cfe6d8); stroke-width: 1.5; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-box--key { fill: var(--lrn-green, #1c6b3c); stroke: var(--lrn-green, #1c6b3c); }
:is(.lesson-fig, .lesson-fig-dialog) .lf-box--soft { fill: var(--lrn-tint, #f0fbf3); stroke: var(--lrn-line, #cfe6d8); }
:is(.lesson-fig, .lesson-fig-dialog) .lf-box--warn { fill: #fbf3e4; stroke: #b9864a; stroke-dasharray: 5 4; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-line { fill: none; stroke: var(--lrn-muted, #5f7a6c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-line--dash { stroke-dasharray: 6 5; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-head { fill: var(--lrn-muted, #5f7a6c); stroke: none; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-step { fill: var(--lrn-accent, #2f9e4f); stroke: none; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-t { fill: var(--lrn-ink, #0e2a1b); font-family: inherit; font-size: 17px; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-t--b { font-weight: 700; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-t--s { font-size: 14px; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-t--m { fill: var(--lrn-muted, #5f7a6c); }
:is(.lesson-fig, .lesson-fig-dialog) .lf-t--on { fill: #fff; }
:is(.lesson-fig, .lesson-fig-dialog) .lf-step-n { fill: #fff; font-family: inherit; font-size: 15px; font-weight: 700; }

/* Screenshots: a quiet browser-frame edge so a page grab never reads as part of this page. */
.lesson-fig--screen picture { display: block; position: relative; }
.lrn-lesson .ocd-prose .lesson-fig--screen img {
  display: block; width: 100%; height: auto; margin: 0;
  border: 1px solid var(--lrn-line, #cfe6d8); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(14, 42, 27, .06), 0 8px 24px -12px rgba(14, 42, 27, .18);
}

.lrn-lesson .ocd-prose .lesson-fig figcaption,
.lrn-lesson #lesson-body figure figcaption { margin-top: 10px; font-size: 14px; line-height: 1.5; color: var(--lrn-muted, #5f7a6c); }
/* The source line, on its own line. Plain figures (an /uploads/learn image from before this convention) get it too. */
.lesson-fig figcaption small,
#lesson-body figure figcaption small { display: block; margin-top: 2px; font-size: 12.5px; letter-spacing: .01em; opacity: .9; }
/* js/lesson-figures.js wraps a plain figure's image in this frame so the enlarge button has a corner to sit by. */
.lesson-fig__frame { display: block; position: relative; }
/* A plain figure has no narrow crop, so its enlarge button shows on phones too, under the image on the caption's line. */
.lesson-fig--plain .lesson-fig__zoom { display: inline-flex; top: calc(100% + 6px); right: 0; }
.lesson-fig--plain figcaption { min-height: 50px; padding-right: 56px; }
.lesson-fig--plain:not(:has(figcaption)) { padding-bottom: 50px; }
.lesson-fig--plain .lesson-fig__frame { cursor: zoom-in; }

/* Base theme, two-column lesson (1024px and up): the 48rem text column draws a 960-wide diagram at
   0.8 scale, so its 14px labels land near 11px. Lesson figures reach 28px into the sidebar gap (56px)
   and the layout's right padding (32px) on each side, which puts the smallest label at 12px at 1280;
   the caption keeps the text column's edges. Alder sizes its own column and is left alone. */
@media (min-width: 1024px) {
  body:not(.al-theme) .lrn-layout:not(.lrn-layout--single) #lesson-body .lesson-fig { margin-left: -28px; margin-right: -28px; }
  body:not(.al-theme) .lrn-layout:not(.lrn-layout--single) #lesson-body .lesson-fig figcaption { padding-left: 28px; padding-right: 28px; }
  body:not(.al-theme) .lrn-layout:not(.lrn-layout--single) #lesson-body .lesson-fig--zoomable figcaption { padding-right: 84px; }
}

/* Enlarge (js/lesson-figures.js adds the button on wide screens only). */
.lesson-fig__zoom {
  position: absolute; top: 8px; right: 8px; display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 1px solid var(--lrn-line, #cfe6d8); border-radius: 999px;
  background: rgba(255, 255, 255, .92); color: var(--lrn-ink, #0e2a1b); cursor: zoom-in;
  opacity: .85; transition: opacity .15s ease;
}
.lesson-fig__zoom svg { width: 18px; height: 18px; }
.lesson-fig:hover .lesson-fig__zoom, .lesson-fig--plain:hover .lesson-fig__zoom, .lesson-fig__zoom:focus-visible { opacity: 1; }
.lesson-fig__zoom:focus-visible { outline: 2px solid var(--lrn-accent, #2f9e4f); outline-offset: 2px; }
@media (min-width: 900px) {
  /* The button sits just under the art on the caption's line, so it never covers a box or a line of a screenshot. */
  .lesson-fig__zoom { display: inline-flex; top: calc(100% + 6px); right: 0; }
  .lesson-fig--zoomable figcaption { min-height: 50px; padding-right: 56px; }
  .lesson-fig--zoomable:not(:has(figcaption)) { padding-bottom: 50px; }
  .lesson-fig--zoomable .lesson-fig__art, .lesson-fig--zoomable picture, .lesson-fig--zoomable .lesson-fig__frame { cursor: zoom-in; }
}

.lesson-fig-dialog {
  width: min(96vw, 1600px); max-width: none; max-height: 94vh; padding: 0; border: 0; border-radius: 12px;
  background: var(--lrn-page, #f7fcf8); color: var(--lrn-ink, #0e2a1b); overflow: auto;
}
.lesson-fig-dialog::backdrop { background: rgba(14, 42, 27, .72); }
.lesson-fig-dialog__body { padding: 20px; }
.lesson-fig-dialog__body svg, .lesson-fig-dialog__body img { display: block; width: 100%; height: auto; }
.lesson-fig-dialog__body img { border-radius: 8px; }
/* On a phone a plain figure opens at its own width (up to 900px) and pans sideways inside the dialog; Close stays put. */
.lesson-fig-dialog--pan .lesson-fig-dialog__close { float: none; display: block; margin: 8px 8px 0 auto; }
.lesson-fig-dialog--pan .lesson-fig-dialog__body { overflow-x: auto; padding: 12px; }
.lesson-fig-dialog--pan .lesson-fig-dialog__body img { width: auto; min-width: 100%; max-width: 900px; }
.lesson-fig-dialog__close {
  position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; z-index: 1;
  min-width: 44px; min-height: 44px; padding: 0 16px; border: 1px solid var(--lrn-line, #cfe6d8); border-radius: 999px;
  background: #fff; color: var(--lrn-ink, #0e2a1b); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.lesson-fig-dialog__close:focus-visible { outline: 2px solid var(--lrn-accent, #2f9e4f); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) { .lesson-fig__zoom { transition: none; } }
