/* =========================================================
   Album style "Polaroids" - photos thrown on a table.

   Photos are made by JS, set after set, and a full set of variables decides where they lie:
   --x/--y center, --r rotation, --w width (all in % of the table), --z layer.
   Phones get their own compositions (and set size) from JS, on a portrait table that fits
   the screen - here only the table changes its shape.

   Throwing and taking sets off the table are Web Animations in polaroids.js - here is only
   where the photos lie at rest. Three states of the table (data-state attribute, set by JS):
     wait   - the first set is not thrown yet, invisible;
     busy   - a set is flying in or out, photos don't react;
     ready  - lying; from now on hover and picking up work.
   ========================================================= */

/* Photos are put in by JS (the draw has to survive cache), so without script there is
   nothing to show. The theme removes .no-js in <head>. */
.no-js .a13-polaroids{display:none}

.a13-polaroids{
	--a13p-paper:#FAF8F2;
	--a13p-paper-shade:#E7E1D2;
	--a13p-glow:rgba(0,0,0,.035);
	--a13p-scrim:rgba(4,8,15,.86);
	--a13p-accent:currentColor;
	--a13p-grain:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
	--a13p-ink:#2B2925;
	--a13p-ui:currentColor;
	position:relative;
	padding:clamp(30px,5vw,80px) 20px;
}
/* On a dark background (detected by JS or forced by the shortcode) - light glow around the table
   and light minimal navigation. */
.a13-polaroids--dark{
	--a13p-glow:rgba(255,255,255,.045);
	--a13p-ui:rgba(255,255,255,.9);
}

/* ---------- table ---------- */

/* --a13p-fit: width at which the set with its navigation fits the window height, set by JS
   when "Fit to the screen" is on. */
.a13-polaroids__table{
	position:relative;
	width:min(100%,var(--a13p-max,900px),var(--a13p-fit,100000px));
	aspect-ratio:900/703;
	margin-inline:auto;
}

/* Light from above - the table has no edges, only a glow in which photos lie. */
.a13-polaroids__table::before{
	content:""; position:absolute; inset:-16% -12% -20%; pointer-events:none;
	background:radial-gradient(56% 46% at 50% 40%,var(--a13p-glow),transparent 72%);
}

/* ---------- single polaroid ---------- */

.a13-polaroid{
	position:absolute; left:var(--x); top:var(--y); width:var(--w); z-index:var(--z,1);
	margin:0; padding:0; border:0; background:none; color:inherit; font:inherit; cursor:pointer;
	transform-origin:50% 50%;
	transform:translate(-50%,-50%) rotate(var(--r));
	transition:transform .42s cubic-bezier(.2,.8,.25,1);
	will-change:transform;
	-webkit-tap-highlight-color:transparent;
}
.a13-polaroids--click-off .a13-polaroid{cursor:default}
/* theme styles buttons on hover/focus - photo is not a button visually */
.a13-polaroid:hover,.a13-polaroid:focus{background:none; color:inherit}

.a13-polaroid__paper{
	display:block; position:relative;
	/* isolation: paper texture blends with multiply and without it would reach photos lying
	   underneath - the group has to end on this one sheet. */
	isolation:isolate;
	/* Frame 30% narrower than a classic polaroid - the photo is the hero, not the paper.
	   These values give the proportion of the whole print: 0.043 + 0.914 (1:1 window) + 0.133
	   = 1.09 of width. Compositions in polaroids.php count with it (photo heights on the table) -
	   change it here, check them there. */
	padding:4.3% 4.3% 13.3%;
	border-radius:3px;
	background:linear-gradient(154deg,#FCFBF7,var(--a13p-paper) 42%,var(--a13p-paper-shade));
	/* Shadow grows with the layer: a photo on top lies higher, so it casts a longer shadow
	   on those below. Without it the pile looks like stickers on one plane. */
	--lift:calc(1 + var(--z,1) * .1);
	box-shadow:
		0 calc(1px * var(--lift)) calc(2px * var(--lift)) rgba(0,0,0,.24),
		0 calc(6px * var(--lift)) calc(14px * var(--lift)) rgba(0,0,0,.22),
		0 calc(20px * var(--lift)) calc(44px * var(--lift)) rgba(0,0,0,.2);
	transition:box-shadow .5s ease;
}
/* Paper texture - without it white looks like a CSS rectangle, not a print.
   Grain stays on the frame: window and caption lie above, because the print is glossy. */
.a13-polaroid__paper::after{
	content:""; position:absolute; inset:0; z-index:0; border-radius:inherit; pointer-events:none;
	background:var(--a13p-grain); opacity:.07; mix-blend-mode:multiply;
}

.a13-polaroid__window{
	display:block; position:relative; z-index:1; overflow:hidden;
	aspect-ratio:1; background:#14161A;
	box-shadow:inset 0 0 0 1px rgba(0,0,0,.14), inset 0 2px 12px rgba(0,0,0,.4);
}
.a13-polaroid__window img{
	width:100%; height:100%; max-width:none; object-fit:cover; display:block;
	filter:saturate(.94) contrast(1.03);
}
/* Emulsion gloss - one diagonal flare, like on a real print under a lamp. */
.a13-polaroid__window::after{
	content:""; position:absolute; inset:0; pointer-events:none;
	background:linear-gradient(116deg,rgba(255,255,255,.13),rgba(255,255,255,.03) 34%,transparent 58%);
}

.a13-polaroid__caption{
	position:absolute; z-index:2; left:8%; right:8%; bottom:3%;
	font-style:italic; font-size:.86rem; line-height:1.3;
	color:rgba(11,19,32,.6); text-align:center;
	overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.a13-polaroid__caption[hidden]{display:none}

/* ---------- states ---------- */

html:not(.no-js) .a13-polaroids[data-state="wait"] .a13-polaroid{opacity:0}

/* Photos flying in and out go beyond the table and the section - without clipping they would
   add a horizontal scrollbar for a moment. Only while flying: a lifted photo must not be clipped. */
.a13-polaroids[data-state="busy"]{overflow-x:clip}
.a13-polaroids[data-state="busy"] .a13-polaroid{pointer-events:none}

/* ---------- swipe ---------- */

/* The browser keeps vertical scrolling and pinch zoom, horizontal moves go to the script.
   Mouse drag selects nothing and drags no images. The lifted photo lies inside the table,
   so it's covered too. */
.a13-polaroids--swipe .a13-polaroids__table,
.a13-polaroids--swipe .a13-polaroids__scrim{
	touch-action:pan-y pinch-zoom;
	-webkit-user-select:none; user-select:none;
}
.a13-polaroids--swipe .a13-polaroid img{-webkit-user-drag:none}

/* ---------- reaction to cursor ---------- */

@media (hover:hover){
	/* :not(.is-lifted) is needed - otherwise hover (higher specificity) would beat
	   the transform of a lifted photo and it would land next to the screen center. */
	.a13-polaroids[data-state="ready"]:not(.a13-polaroids--click-off) .a13-polaroid:not(.is-lifted):hover{
		z-index:40;
		transform:translate(-50%,-50%) rotate(calc(var(--r) * .5)) translateY(-12px) scale(1.035);
	}
	.a13-polaroids:not(.a13-polaroids--click-off) .a13-polaroid:not(.is-lifted):hover .a13-polaroid__paper{
		box-shadow:
			0 2px 3px rgba(0,0,0,.3),
			0 12px 26px rgba(0,0,0,.34),
			0 34px 64px rgba(0,0,0,.3);
	}
}
.a13-polaroid:focus-visible{outline:none; z-index:40}
.a13-polaroid:focus-visible .a13-polaroid__paper{
	box-shadow:0 0 0 2px var(--a13p-accent), 0 12px 26px rgba(0,0,0,.34), 0 34px 64px rgba(0,0,0,.3);
}

/* ---------- lifted: straightened, big, on top ---------- */

/* #mid is a stacking context (z-index:2) below the header (11) and theme borders (1003) -
   without lifting it, the menu would be drawn over the scrim and the photo. Only while
   a photo is lifted, so the rest of the theme keeps its order. */
.a13-polaroids-open #mid{z-index:10000}

/* Above the header and theme borders, below lightGallery. */
.a13-polaroids__scrim{
	position:fixed; inset:0; z-index:10000;
	background:var(--a13p-scrim);
	backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
	opacity:0; transition:opacity .45s ease;
}
.a13-polaroids__scrim[hidden]{display:none}
.a13-polaroids__scrim.is-visible{opacity:1}

.a13-polaroid.is-lifted{
	z-index:10001; cursor:zoom-out;
	transform:translate(-50%,-50%) translate(var(--dx),var(--dy)) rotate(0deg) scale(var(--s));
	transition:transform .62s cubic-bezier(.22,.9,.24,1);
}
.a13-polaroid.is-lifted .a13-polaroid__paper{
	box-shadow:0 30px 90px rgba(0,0,0,.6), 0 4px 12px rgba(0,0,0,.4);
}
/* Caption scales with the frame, so it has to be made smaller again. */
.a13-polaroid.is-lifted .a13-polaroid__caption{
	font-size:calc(.86rem / var(--s,1) * .74);
}

/* Arrows to browse the set - added by JS on lifting. */
.a13-polaroids__arrow{
	position:fixed; top:50%; z-index:10002; transform:translateY(-50%);
	width:52px; height:52px; display:grid; place-items:center;
	margin:0; padding:0; border-radius:0;
	border:1px solid rgba(255,255,255,.24); background:rgba(0,0,0,.4); color:#fff;
	cursor:pointer; transition:background .25s,border-color .25s,color .25s;
}
/* Own display beats [hidden] from the browser sheet - without it arrows stay on screen
   after putting the photo down, even though JS sets hidden. */
.a13-polaroids__arrow[hidden]{display:none}
.a13-polaroids__arrow:hover,.a13-polaroids__arrow:focus{background:#fff; border-color:#fff; color:#000}
.a13-polaroids__arrow--prev{left:clamp(10px,3vw,38px)}
.a13-polaroids__arrow--next{right:clamp(10px,3vw,38px)}
.a13-polaroids__arrow svg{width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.6}

/* ---------- navigation between sets ---------- */

/* Three styles, chosen in album settings / shortcode (a class on .a13-polaroids):
     minimal - no background: thin long arrows and plain dots, in the color of the section text
               (light on a dark background detected by JS or forced by tone="dark");
     paper   - a strip of the same paper as the photos with dark ink - readable on any background;
     sides   - only two arrows next to the table edges, colored like minimal.
   Colors: --a13p-nav-ink (icons, all styles), --a13p-nav-bg (strip, paper only). */
.a13-polaroids__nav{
	display:flex; align-items:center; justify-content:center; gap:clamp(10px,1.6vw,18px);
	width:max-content; max-width:100%; margin:clamp(28px,4vw,56px) auto 0;
	color:var(--a13p-nav-ink,var(--a13p-ui));
}

.a13-polaroids__step{
	display:grid; place-items:center;
	margin:0; padding:0; border:0;
	background:none; color:inherit; cursor:pointer;
	transition:background-color .25s, transform .25s, opacity .25s;
}
.a13-polaroids__step:hover,.a13-polaroids__step:focus-visible{background:none; color:inherit}
.a13-polaroids__step--prev:hover{transform:translateX(-3px)}
.a13-polaroids__step--next:hover{transform:translateX(3px)}
.a13-polaroids__step svg{display:block; fill:none; stroke:currentColor}

.a13-polaroids__sets{display:flex; align-items:center}
.a13-polaroids__set{margin:0; padding:0; background:none; color:inherit; cursor:pointer}

.a13-polaroids__count{
	min-width:4.5em; text-align:center;
	font-size:.8rem; letter-spacing:.14em; font-variant-numeric:tabular-nums;
}

/* ----- minimal ----- */

.a13-polaroids--nav-minimal .a13-polaroids__nav{gap:clamp(14px,2.4vw,30px)}

/* Long thin arrow with a shaft - light for the eye, but a big target for the finger. */
.a13-polaroids--nav-minimal .a13-polaroids__step{width:56px; height:44px; opacity:.7}
.a13-polaroids--nav-minimal .a13-polaroids__step:hover,
.a13-polaroids--nav-minimal .a13-polaroids__step:focus-visible{opacity:1}
.a13-polaroids--nav-minimal .a13-polaroids__step svg{width:34px; height:14px; stroke-width:1.1}
.a13-polaroids--nav-minimal .a13-polaroids__step--prev svg{transform:scaleX(-1)}

/* Plain dots; the button is bigger than the dot, so it's easy to hit. */
.a13-polaroids--nav-minimal .a13-polaroids__sets{gap:2px}
.a13-polaroids--nav-minimal .a13-polaroids__set{
	width:22px; height:22px; border:0; border-radius:50%;
	display:grid; place-items:center;
}
.a13-polaroids--nav-minimal .a13-polaroids__set::before{
	content:""; width:6px; height:6px; border-radius:50%;
	background:currentColor; opacity:.3;
	transition:opacity .3s, transform .3s cubic-bezier(.2,.8,.25,1);
}
.a13-polaroids--nav-minimal .a13-polaroids__set:hover,
.a13-polaroids--nav-minimal .a13-polaroids__set:focus-visible{background:none; color:inherit}
.a13-polaroids--nav-minimal .a13-polaroids__set:hover::before,
.a13-polaroids--nav-minimal .a13-polaroids__set:focus-visible::before{opacity:.65}
.a13-polaroids--nav-minimal .a13-polaroids__set.is-current::before{opacity:1; transform:scale(1.35)}

/* ----- paper ----- */

.a13-polaroids--nav-paper .a13-polaroids__nav{
	padding:6px; border-radius:999px;
	background:var(--a13p-nav-bg,linear-gradient(154deg,#FCFBF7,var(--a13p-paper) 42%,var(--a13p-paper-shade)));
	box-shadow:0 1px 2px rgba(0,0,0,.2), 0 6px 18px rgba(0,0,0,.16);
	color:var(--a13p-nav-ink,var(--a13p-ink));
}
/* Transparent background - no strip, so no shadow of a strip either. */
.a13-polaroids--nav-paper.a13-polaroids--nav-bare .a13-polaroids__nav{box-shadow:none}

.a13-polaroids--nav-paper .a13-polaroids__step{width:42px; height:42px; border-radius:50%}
.a13-polaroids--nav-paper .a13-polaroids__step:hover,
.a13-polaroids--nav-paper .a13-polaroids__step:focus-visible{
	background:rgba(0,0,0,.07);
	/* from the icons color, so it shows on any strip - light icons on a dark one too */
	background:color-mix(in srgb,currentColor 12%,transparent);
}
.a13-polaroids--nav-paper .a13-polaroids__step svg{width:18px; height:18px; stroke-width:1.6}

/* Dots are tiny polaroids: a frame with a thicker bottom edge, lying crooked.
   The current one lies straight, filled, a bit bigger. */
.a13-polaroids--nav-paper .a13-polaroids__sets{gap:10px}
.a13-polaroids--nav-paper .a13-polaroids__set{
	width:13px; height:15px; border-radius:1px;
	border:1.5px solid currentColor; border-bottom-width:4px;
	opacity:.4;
	transform:rotate(-8deg);
	transition:opacity .3s, transform .35s cubic-bezier(.2,.8,.25,1), background-color .3s;
}
.a13-polaroids--nav-paper .a13-polaroids__set:nth-child(3n+2){transform:rotate(6deg)}
.a13-polaroids--nav-paper .a13-polaroids__set:nth-child(3n){transform:rotate(-3deg)}
.a13-polaroids--nav-paper .a13-polaroids__set:hover,
.a13-polaroids--nav-paper .a13-polaroids__set:focus-visible{background:none; color:inherit; opacity:.8; transform:rotate(0) translateY(-2px)}
.a13-polaroids--nav-paper .a13-polaroids__set.is-current{opacity:1; transform:rotate(0) scale(1.18); background-color:currentColor}

/* ----- side arrows ----- */

/* No dots, only two arrows at the middle of the table edges. JS puts them inside the table,
   so they follow its size; the table leaves them room on both sides - only when there are
   sets to switch (--has-nav). The arrows layer lets clicks through to photos. */
.a13-polaroids--nav-sides{--a13p-side:clamp(40px,6vw,72px)}
.a13-polaroids--nav-sides.a13-polaroids--has-nav .a13-polaroids__table{
	width:min(100% - 2 * var(--a13p-side),var(--a13p-max,900px),var(--a13p-fit,100000px));
}
.a13-polaroids--nav-sides .a13-polaroids__nav{
	position:absolute; top:0; bottom:0; left:calc(-1 * var(--a13p-side)); right:calc(-1 * var(--a13p-side)); z-index:50;
	justify-content:space-between;
	width:auto; max-width:none; margin:0;
	pointer-events:none;
}
.a13-polaroids--nav-sides .a13-polaroids__step{
	width:var(--a13p-side); height:min(160px,60%);
	opacity:.65; pointer-events:auto;
}
.a13-polaroids--nav-sides .a13-polaroids__step:hover,
.a13-polaroids--nav-sides .a13-polaroids__step:focus-visible{opacity:1}
.a13-polaroids--nav-sides .a13-polaroids__step svg{width:16px; height:34px; stroke-width:1.2}
.a13-polaroids--nav-sides .a13-polaroids__step--prev svg{transform:scaleX(-1)}

/* Changing sets - buttons stay, but don't invite clicking. */
.a13-polaroids[data-state="busy"] .a13-polaroids__nav button{cursor:progress}

/* ---------- album text ---------- */

.a13-polaroids-text{
	max-width:900px; margin-inline:auto;
}
.a13-polaroids-text--above{padding-bottom:0}
.a13-polaroids-text--below{padding-top:0}

/* ---------- narrow screen: portrait table that fits the screen ---------- */

@media (max-width:700px){
	.a13-polaroids{padding:24px 12px}
	/* The whole set with its navigation has to be in view: table height is the screen height
	   minus room for the header, navigation and photos sticking out of the table edges
	   (230 px); width follows from the 3:4 proportion. Never narrower than 220 px -
	   on a phone turned sideways it's better to scroll a bit than to look at stamps.
	   svh: the height without the browser bars, which come and go while scrolling.
	   With "Fit to the screen" on, JS measures it exactly (--a13p-fit). */
	.a13-polaroids__table{
		aspect-ratio:3/4;
		width:min(100%,var(--a13p-fit,max(220px,calc((100vh - 230px) * .75))));
		width:min(100%,var(--a13p-fit,max(220px,calc((100svh - 230px) * .75))));
	}
	.a13-polaroids--nav-sides.a13-polaroids--has-nav .a13-polaroids__table{
		width:min(100% - 2 * var(--a13p-side),var(--a13p-fit,max(220px,calc((100vh - 230px) * .75))));
		width:min(100% - 2 * var(--a13p-side),var(--a13p-fit,max(220px,calc((100svh - 230px) * .75))));
	}
	.a13-polaroids--nav-sides .a13-polaroids__step svg{width:12px; height:26px}
	.a13-polaroids__nav{margin-top:20px}
	.a13-polaroid__caption{font-size:.8rem}
	.a13-polaroids__arrow{width:44px; height:44px; top:auto; bottom:clamp(12px,4vh,32px); transform:none}
}

/* ---------- calm motion ---------- */

@media (prefers-reduced-motion:reduce){
	.a13-polaroid,.a13-polaroid.is-lifted,.a13-polaroid__paper,.a13-polaroids__scrim{transition:none}
}
