import { theme } from "./theme.ts"; /** * The zoom styles. The script adds them to the page once. Theme it with the shared `--comark-*` tokens; they resolve on * `.cz-dialog` itself, so tokens set there theme only the zoomed view. `--cz-backdrop` and `--cz-backdrop-opacity` * change the backdrop. The rules sit in the `comark` layer, so any unlayered rule of the host's wins. */ export const css = `@layer comark{${[ theme(".cz-dialog,[data-zoom],.cz-item>img"), "[data-zoom]{cursor:zoom-in}", "img[data-zoom],.cz-item>img{border-radius:var(--_comark-radius)}", // A thumbnail, an image in a table cell, fits a box of --comark-thumb-height by --comark-thumb-width at its own ratio, // which the plugin writes as --cz-ratio; a fixed height with an automatic width then takes the ratio of its `width` // and `height` attributes before the file loads. --cz-height keeps a small // image, such as an icon, from growing past its file. One with no size known keeps a 3:2 box and shows whole inside // it, since its ratio arrives too late to size the row, and a page's own `img{max-width}` may outrank this layer. "img[data-zoom-thumb]{display:inline-block;width:auto;max-width:var(--comark-thumb-width,8rem);height:min(var(--comark-thumb-height,4rem),calc(var(--comark-thumb-width,8rem) / var(--cz-ratio,1)),var(--cz-height,100vh));max-height:none;margin:.125rem 0;vertical-align:middle;object-fit:cover;object-position:left top;border-radius:calc(var(--_comark-radius) - 4px);outline:1px solid color-mix(in srgb,var(--_comark-foreground) 12%,transparent);outline-offset:-1px;touch-action:manipulation}", "img[data-zoom-thumb]:not([width][height]){--cz-ratio:1.5;aspect-ratio:3/2;object-fit:contain;object-position:center}", "img[data-zoom-thumb]:not([width][height]):not(:focus-visible){outline:0}", "@media (hover:hover) and (pointer:fine){img[data-zoom-thumb]{transition:outline-color .15s ease-out}img[data-zoom-thumb]:hover{outline-color:color-mix(in srgb,var(--_comark-foreground) 32%,transparent)}}", // A `::zoom` block holds no margin of its own for its content's to collapse into, so blocks in a row would touch. ".cz{margin:1.5rem 0}", "[data-zoom]:focus-visible{outline:2px solid var(--_comark-ring);outline-offset:3px}", // The dialog fills the window in place of the browser's centered box. Its styles keep it shown after a close, so the // closing animation runs to its end whatever closed it. ".cz-dialog{position:fixed;inset:0;z-index:2147483000;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;width:auto;height:auto;max-width:none;max-height:none;margin:0;padding:0;overflow:visible;border:0;background:none;color:var(--_comark-foreground);font:13px/1.4 var(--_comark-font);outline:none}", // .cz-backdrop is the backdrop, so it fades with the rest of the view. ".cz-dialog::backdrop{background:none}", ".cz-backdrop{position:absolute;inset:0;background:var(--cz-backdrop,color-mix(in srgb,var(--_comark-background) var(--cz-backdrop-opacity,96%),transparent))}", ".cz-header{position:relative;display:flex;gap:.75rem;align-items:center;min-height:2.75rem;padding:0 .5rem 0 1rem}", ".cz-title{overflow:hidden;font-weight:500;white-space:nowrap;text-overflow:ellipsis}", // The page an image shows, from `data-zoom-href`. It keeps to one line beside the title, which gives way first. ".cz-link{display:inline-flex;flex-shrink:0;gap:.25rem;align-items:center;min-height:2.75rem;max-width:50%;color:var(--_comark-muted);text-decoration:none;white-space:nowrap}", ".cz-link>span{overflow:hidden;text-overflow:ellipsis}", ".cz-link svg{flex-shrink:0;width:.875rem;height:.875rem}", ".cz-link:focus-visible{outline:2px solid var(--_comark-ring);outline-offset:1px;border-radius:calc(var(--_comark-radius) - 2px)}", "@media (hover:hover) and (pointer:fine){.cz-link{transition:color .15s ease-out}.cz-link:hover{color:var(--_comark-foreground);text-decoration:underline;text-underline-offset:.2em}}", ".cz-link[hidden]{display:none}", ".cz-count{color:var(--_comark-muted);font-variant-numeric:tabular-nums}", ".cz-place{margin-left:auto;color:var(--_comark-muted);font-variant-numeric:tabular-nums;white-space:nowrap}", ".cz-place:not(:empty)+.cz-close{margin-left:0}", // Up and Down move between figures, so the count is for keyboards. "@media (hover:none){.cz-place{display:none}.cz-place+.cz-close{margin-left:auto}}", ".cz-dialog button{display:inline-grid;place-items:center;border:0;border-radius:calc(var(--_comark-radius) - 2px);background:none;color:inherit;font:inherit;cursor:pointer}", ".cz-dialog button:focus-visible{outline:2px solid var(--_comark-ring);outline-offset:1px}", ".cz-close{flex-shrink:0;width:2.25rem;height:2.25rem;margin-left:auto;font-size:18px}", // The track keeps the stage's size, so an item taller than the stage doesn't grow it and move its center down. ".cz-stage{position:relative;display:grid;grid-template:minmax(0,1fr)/minmax(0,1fr);place-items:center;overflow:hidden}", ".cz-stage[data-scroll]{grid-template-rows:auto;align-items:start;overflow-y:auto}", ".cz-stage[data-scroll]>.cz-item{transform-origin:top}", ".cz-stage[data-flying]{z-index:1;overflow:visible}", ".cz-item{position:relative;transform-origin:center;cursor:auto}", // The backdrop lets a little of the page through, which would show between a table's rows. An image covers its box. ":where(.cz-item>:first-child:not(img)){background:var(--_comark-background)}", // The copy keeps the item's width on the page, so its images can't grow past it to their natural size. ".cz-item img,.cz-thumb img{max-width:100%;height:auto}", ".cz-item>img,.cz-thumb>div>img{display:block;width:100%}", ".cz-layer{position:absolute;inset:0;pointer-events:none}", ".cz-layer>*{pointer-events:auto}", // shadcn/ui's outline icon buttons, like comark-carousel's, so they stand out over the item's edge. ".cz-dialog .cz-nav{position:absolute;grid-row:2;grid-column:1;top:50%;width:2.5rem;height:2.5rem;border:1px solid var(--_comark-border);border-radius:9999px;background:var(--_comark-background);transform:translateY(-50%)}", ".cz-nav svg{width:1.25rem;height:1.25rem}", ".cz-dialog .cz-close:hover,.cz-dialog .cz-nav:hover{background:var(--_comark-accent)}", ".cz-prev{left:.5rem}", ".cz-next{right:.5rem}", ".cz-footer{position:relative}", // The aside takes a column beside the stage, which the zoom fits into the space left; on a narrow screen, a band below. ".cz-header,.cz-footer{grid-column:1/-1}", ".cz-header{grid-row:1}", ".cz-stage{grid-row:2;grid-column:1}", ".cz-footer{grid-row:3}", ".cz-aside{display:none}", ".cz-dialog[data-aside]{grid-template-columns:minmax(0,1fr) minmax(14rem,22rem)}", ".cz-dialog[data-aside] .cz-aside{position:relative;display:block;grid-row:2;grid-column:2;align-self:center;max-height:100%;overflow:auto;padding:1rem 1.5rem 1rem .5rem}", "@media (max-width:48rem){.cz-dialog[data-aside]{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto auto}.cz-dialog[data-aside] .cz-aside{grid-row:3;grid-column:1;align-self:auto;max-height:30vh;padding:.5rem 1rem}.cz-dialog[data-aside] .cz-footer{grid-row:4}}", ".cz-strip{display:flex;gap:.5rem;justify-content:safe center;overflow-x:auto;padding:.75rem 1rem 1rem}", ".cz-strip .cz-thumb{position:relative;flex:none;width:6rem;height:4rem;overflow:hidden;border:1px solid var(--_comark-border);border-radius:calc(var(--_comark-radius) - 2px);background:var(--_comark-background);opacity:.55;transition:opacity .15s}", ".cz-thumb:hover{opacity:.85}", ".cz-thumb[aria-current=true]{opacity:1;border-color:var(--_comark-foreground)}", // Centered, then scaled to fit by the script around its center. ".cz-thumb>div{position:absolute;top:50%;left:50%;translate:-50% -50%;pointer-events:none}", ].join("")}}`;