blob: 08fc4f2072a33a82dca8ed736dd9eb2ce39569d8 [file]
/*
* Copyright 2026 The Fuchsia Authors
*
* Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
* <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
* license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
* This file may not be copied, modified, or distributed except according to
* those terms.
*/
/*
* Meander border: the Greek-key band of the Franklin Bittner bookplate as a
* responsive CSS border, drawn entirely with SVG.
*
* <div class="meander">...</div>
*
* How it works: the element's border reserves room for the band, and its
* ::before and ::after pseudo-elements paint it as background layers: corners
* drawn once, and edges repeated with `round` between them, so each side
* always ends on whole motifs. Each corner image reaches 1.5 units over the
* start of the neighbouring edges, so the joins are overdrawn and cannot open
* into hairline gaps.
*
* Things to know:
* - The frame uses ::before and ::after, so they are not free for other uses.
* The element gets `position: relative` (any position but static works) and
* `isolation: isolate`.
* - Do not give the framed element itself an `overflow` other than visible: it
* would clip the frame. Put scrolling content in an inner element instead.
* - The element's border box is the outer edge of the band; the hand-inked
* line may wander up to 2.15 units beyond it, so do not clip that.
* - The paper in the band, including the white channels, shows whatever is
* behind it: the element's own background if it has one (it fills the
* border box, so the band sits on it), otherwise the page.
* - Each side repeats a 1-motif piece, stretched or squeezed slightly so a
* whole number fit.
* - Keep the element at least 153.7 units in each direction (better, 201.7);
* below that the corners overlap.
*/
.meander {
/*
* One design unit. The band is 41.7 units deep. Scales from 0.5px on very
* small screens up to 1px from a 600px-wide viewport.
*/
--meander-unit: clamp(0.5px, 0.1667vw, 1px);
--meander-padding: calc(24 * var(--meander-unit));
position: relative;
isolation: isolate;
border: calc(41.7 * var(--meander-unit)) solid transparent;
padding: var(--meander-padding);
}
.meander::before,
.meander::after {
content: "";
position: absolute;
inset: calc(-43.85 * var(--meander-unit));
z-index: -1;
pointer-events: none;
box-sizing: border-box;
}
/*
* Top and bottom edges, repeated between the corners. Their padding marks out
* the stretch between the corners (padding, not border: Chrome snaps border
* widths to whole device pixels, which would shift the edges off the corners).
*/
.meander::before {
padding: 0 calc(79 * var(--meander-unit));
background:
url("images/meander/frame-edge-top.svg") left top /
calc(48 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
round no-repeat content-box,
url("images/meander/frame-edge-bottom.svg") left bottom /
calc(48 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
round no-repeat content-box;
}
/* Left and right edges, repeated between the corners; the corners on top. */
.meander::after {
padding: calc(79 * var(--meander-unit)) 0;
background:
url("images/meander/frame-corner-tl.svg") left top /
calc(80.5 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
no-repeat border-box,
url("images/meander/frame-corner-tr.svg") right top /
calc(80.5 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
no-repeat border-box,
url("images/meander/frame-corner-br.svg") right bottom /
calc(80.5 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
no-repeat border-box,
url("images/meander/frame-corner-bl.svg") left bottom /
calc(80.5 * var(--meander-unit)) calc(80.5 * var(--meander-unit))
no-repeat border-box,
url("images/meander/frame-edge-left.svg") left top /
calc(80.5 * var(--meander-unit)) calc(48 * var(--meander-unit))
no-repeat round content-box,
url("images/meander/frame-edge-right.svg") right top /
calc(80.5 * var(--meander-unit)) calc(48 * var(--meander-unit))
no-repeat round content-box;
}