/* Demo "skapa": drag picture, the preview's zoom, and the scroll anchors of the finished prov. */

/* The drag picture: what the system draws at the pointer while a file is dragged in (a child of the kit's cursor) */
.skapa-drag {
  position: absolute; left: 12px; top: 14px; width: 42px; border-radius: 4px; overflow: hidden; background: #fff; pointer-events: none;
  box-shadow: 0 0 0 0.5px rgba(4, 40, 60, 0.3), 0 6px 16px rgba(4, 40, 60, 0.34); transform: rotate(5deg);
}
.skapa-drag img { display: block; width: 100%; height: auto; }



/* The preview's scroller is a size container, so the anchors and the pan below can use its size (cqh, cqw) */
[data-demo="skapa"] .rp-pdf-scroller { container: skapa-pv / size; }

/* The zoom label: "Bredd" until a window zooms (a wide stage, the table below) */
.skapa-zv { display: none; }
.skapa-zv[data-z="fit"] { display: inline; }

/* Wide stage (over 760 px): the finished prov is zoomed in with the preview's + (three presses; skapa.js), because the page fits whole beside the copy otherwise and the foot of
   uppgift 4 and page 2 would show. The zoom is the app's (PdfPreview.tsx); the table says per pane width what each press gives (--skapa-z1..3, the label); zoom.mjs writes it */
@container rp (min-width: 761px) {
  [data-demo="skapa"] .rp-preview[data-zoom] .skapa-zv[data-z="fit"] { display: none; }
  [data-demo="skapa"] .rp-preview[data-zoom] .rp-pages { min-width: min-content; }   /* a page wider than the pane starts at its left edge, as in the app */
  [data-demo="skapa"] .rp-preview[data-zoom="1"] .rp-pages { --skapa-w: calc(var(--skapa-z1) * 793.7px); }
  [data-demo="skapa"] .rp-preview[data-zoom="2"] .rp-pages { --skapa-w: calc(var(--skapa-z2) * 793.7px); }
  [data-demo="skapa"] .rp-preview[data-zoom="3"] .rp-pages { --skapa-w: calc(var(--skapa-z3) * 793.7px); }
  [data-demo="skapa"] .rp-preview[data-zoom] .rp-page { width: var(--skapa-w); }
  /* The pan: the app's scroll sideways, as a shift of the pages. The triangle's middle (52.4 % of the page's width) goes to the middle of the pane, but not so far that the left edge of
     the page's text is cut: the text margin ("Hjälpmedel", "Uppgifter") is at 11.8 % of the page's width (the pages' own 28px to the left of it), and it stays 10px inside the pane.
     A pane narrower than the text then cuts the right edge instead (a text line is 76 % of the page), and the coordinate system sits right of the middle; its right end (the
     triangle's last corner at 64 % of the page) is still in view from a 340px pane at 80 %. Never past the page's edges */
  [data-demo="skapa"] .rp-pdf.skapa-panned .rp-pages {
    transform: translateX(calc(-1 * clamp(0px, min(calc(28px + 0.524 * var(--skapa-w) - 50cqw), calc(18px + 0.118 * var(--skapa-w))), calc(var(--skapa-w) + 56px - 100cqw))));
    transition: transform 0.65s cubic-bezier(0.4, 0.1, 0.2, 1);
  }
}
@media (prefers-reduced-motion: reduce) { [data-demo="skapa"] .rp-pdf.skapa-panned .rp-pages { transition: none; } }
/* skapa:zoom start */
@container rp (min-width: 761px) {
  /* pane up to 440 px (fit up to 48 %): + gives 50, 67, 80 % */
  @container rp-pdf (max-width: 440.49px) { [data-demo="skapa"] .rp-pages { --skapa-z1: 0.5; --skapa-z2: 0.67; --skapa-z3: 0.8; } }
  @container rp-pv (max-width: 412.49px) { [data-demo="skapa"] .rp-preview[data-zoom="1"] .skapa-zv[data-z="50"], [data-demo="skapa"] .rp-preview[data-zoom="2"] .skapa-zv[data-z="67"], [data-demo="skapa"] .rp-preview[data-zoom="3"] .skapa-zv[data-z="80"] { display: inline; } }
  /* pane 441 to 575 px (fit 49-65 %): + gives 67, 80, 100 % */
  @container rp-pdf (min-width: 440.5px) and (max-width: 575.49px) { [data-demo="skapa"] .rp-pages { --skapa-z1: 0.67; --skapa-z2: 0.8; --skapa-z3: 1; } }
  @container rp-pv (min-width: 412.5px) and (max-width: 547.49px) { [data-demo="skapa"] .rp-preview[data-zoom="1"] .skapa-zv[data-z="67"], [data-demo="skapa"] .rp-preview[data-zoom="2"] .skapa-zv[data-z="80"], [data-demo="skapa"] .rp-preview[data-zoom="3"] .skapa-zv[data-z="100"] { display: inline; } }
  /* pane 576 to 679 px (fit 66-78 %): + gives 80, 100, 125 % */
  @container rp-pdf (min-width: 575.5px) and (max-width: 679.49px) { [data-demo="skapa"] .rp-pages { --skapa-z1: 0.8; --skapa-z2: 1; --skapa-z3: 1.25; } }
  @container rp-pv (min-width: 547.5px) and (max-width: 651.49px) { [data-demo="skapa"] .rp-preview[data-zoom="1"] .skapa-zv[data-z="80"], [data-demo="skapa"] .rp-preview[data-zoom="2"] .skapa-zv[data-z="100"], [data-demo="skapa"] .rp-preview[data-zoom="3"] .skapa-zv[data-z="125"] { display: inline; } }
  /* pane 680 px and wider (fit 79 % and more): + gives 100, 125, 150 % */
  @container rp-pdf (min-width: 679.5px) { [data-demo="skapa"] .rp-pages { --skapa-z1: 1; --skapa-z2: 1.25; --skapa-z3: 1.5; } }
  @container rp-pv (min-width: 651.5px) { [data-demo="skapa"] .rp-preview[data-zoom="1"] .skapa-zv[data-z="100"], [data-demo="skapa"] .rp-preview[data-zoom="2"] .skapa-zv[data-z="125"], [data-demo="skapa"] .rp-preview[data-zoom="3"] .skapa-zv[data-z="150"] { display: inline; } }
}
/* skapa:zoom end */

/* Invisible anchors on page 1 of Prov (-2: where the preview ends, data-dk-scroll-to) and of Allt (-all), as a share of the page's height less the scroller's height */
.skapa-at { position: absolute; left: 0; width: 1px; height: 1px; visibility: hidden; pointer-events: none; }

/* Allt is shown at the fit width. Wide stage: the box covers only the middle of the page, so the foot of the page (uppgift 4, 89 %) ends 13px below the scroller's lower edge */
.skapa-at-all { top: calc(89.2% - 100cqh - 13px); }
/* Narrower stage and phone: the box spans the page, so the foot ends behind it (106px is the box's height over the scroller's lower edge, 130px on a phone); never above the task's own line */
@container rp (max-width: 999px) { .skapa-at-all { top: min(calc(78.35% - 100cqh + 106px), 41%); } }
@container rp (max-width: 760px) { .skapa-at-all { top: min(calc(78.35% - 100cqh + 130px), 41%); } }

/* Prov. Phone: as Allt. Wide stage: the page is zoomed (above), and the anchor puts the triangle (page y 46.7-65.5 %, its middle at 56.3 %) in the middle of what the box leaves of the scroller,
   but never lower than the scroller's foot at 87.5 % of the page: uppgift 4 starts at 88.8 % (the strip under the box shows page too) */
.skapa-at-2 { top: min(calc(78.35% - 100cqh + 130px), 41%); }
@container rp (min-width: 761px) { .skapa-at-2 { top: min(calc(56.3% - (100cqh - 106px) / 2), calc(87.5% - 100cqh)); } }

/* The foot of the Hem card, for the window's scroll on a phone: an anchor 16px below the card's edge, one window height up */
.skapa-hem-end { top: calc(100% + 16px - var(--rp-vh)); }

/* The editor ends with its task list at the top (data-dk-scroll-to): the app leaves about 15px above the list */
[data-demo="skapa"] .rp-list-tools { scroll-margin-top: 14px; }
