/* PicSuit Tools: the parts every tool is built from.
   Colours and fonts are the PicSuit theme's; the second values keep a tool usable anywhere else.
   A tool adapts to the width of the place it sits in (a page, a post, a column), not to the screen.
   ========================================================================== */

.pst {
	--pst-ink: var(--ink, #0F1B33);
	--pst-paper: var(--paper, #FAF7F2);
	--pst-white: var(--white, #FFFFFF);
	--pst-line: var(--line, #E6DFD3);
	--pst-line-strong: var(--line-strong, #CFC7B8);
	--pst-muted: var(--muted, #5B6478);
	--pst-soft: var(--soft, #3A4560);
	--pst-tint: var(--tint, #F1ECE3);
	--pst-hover: var(--navy-card, #17264A);
	--pst-display: var(--font-display, inherit);
	container: pst / inline-size;
	display: flex;
	flex-direction: column;
	gap: 16px;
	color: var(--pst-ink);
	font-size: 17px;
	font-weight: 400;
	line-height: 1.55;
	text-align: left;
}

.pst,
.pst *,
.pst *::before,
.pst *::after {
	box-sizing: border-box;
}

/* Text written in a post has margins and list bullets of its own: none of that inside a tool. */
.pst.pst :is(p, ul, ol, dl, dt, dd, fieldset, legend, label) {
	margin: 0;
}

.pst [hidden] {
	display: none;
}

.pst :focus-visible {
	outline: 3px solid var(--pst-ink);
	outline-offset: 3px;
}

.pst-icon {
	display: block;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.pst-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* The white card a tool sits in. */
.pst-card {
	padding: clamp(16px, 2.4vw, 28px);
	border: 1px solid var(--pst-line);
	border-radius: 24px;
	background: var(--pst-white);
}

/* Short reassurances under a tool. */
.pst .pst-notes {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 24px;
	padding: 0;
	color: var(--pst-muted);
	font-size: 15px;
	list-style: none;
}

.pst .pst-notes li {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0;
}

.pst .pst-notes li::before {
	content: none;
}

/* A choice between two or three jobs of a tool. */
.pst-seg {
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
	gap: 4px;
	padding: 4px;
	border-radius: 14px;
	background: var(--pst-tint);
}

.pst-seg__btn {
	min-height: 46px;
	margin: 0;
	padding: 6px 12px;
	border: 0;
	border-radius: 10px;
	background: none;
	color: var(--pst-soft);
	font: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	/* A label that needs two lines in some language breaks into lines of similar length. */
	text-wrap: balance;
	cursor: pointer;
}

.pst-seg__btn[aria-pressed="true"] {
	background: var(--pst-ink);
	color: var(--pst-paper);
}

/* A group of fields with a small heading. */
.pst .pst-group {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
	padding: 0;
	border: 0;
}

.pst .pst-label {
	display: block;
	padding: 0;
	color: var(--pst-muted);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	line-height: 1.55;
	text-transform: uppercase;
}

.pst-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.pst-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	margin: 0;
	padding: 0 11px;
	border: 1px solid var(--pst-line-strong);
	border-radius: 10px;
	background: var(--pst-white);
	color: var(--pst-ink);
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	cursor: pointer;
}

.pst-chip:hover {
	border-color: var(--pst-ink);
}

.pst-chip[aria-pressed="true"] {
	border-color: var(--pst-ink);
	background: var(--pst-ink);
	color: var(--pst-paper);
}

.pst .pst-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	font-size: 15px;
	font-weight: 600;
}

.pst-box {
	position: relative;
	display: flex;
}

.pst-input,
.pst-select {
	width: 100%;
	min-width: 0;
	height: 52px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--pst-line-strong);
	border-radius: 12px;
	background-color: var(--pst-white);
	color: var(--pst-ink);
	font: inherit;
	font-size: 18px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.pst-input:hover,
.pst-select:hover {
	border-color: var(--pst-ink);
}

.pst-select {
	font-size: 16px;
	font-weight: 500;
}

.pst-box--unit .pst-input {
	padding-right: 44px;
}

.pst-unit {
	position: absolute;
	top: 0;
	right: 14px;
	display: flex;
	align-items: center;
	height: 100%;
	color: var(--pst-muted);
	font-size: 15px;
	font-weight: 500;
	pointer-events: none;
}

/* The field the tool has just filled in. */
.pst-input.is-result {
	border-color: var(--pst-ink);
	background-color: var(--pst-paper);
}

.pst .pst-hint {
	color: var(--pst-muted);
	font-size: 14px;
}

.pst-options {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 20px;
}

.pst .pst-check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	font-size: 15px;
	font-weight: 400;
	cursor: pointer;
}

.pst-check input {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--pst-ink);
}

.pst-textbtn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--pst-ink);
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 4px;
	cursor: pointer;
}

.pst-textbtn .pst-icon {
	text-decoration: none;
}

.pst-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 16px;
}

/* The main action of a tool is dark: the accent colour stays with the buttons that lead to the product. */
.pst-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	margin: 0;
	padding: 0 20px;
	border: 0;
	border-radius: 12px;
	background: var(--pst-ink);
	color: var(--pst-paper);
	font: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
}

.pst-btn:hover {
	background: var(--pst-hover);
}

.pst-btn:disabled {
	opacity: 0.5;
	cursor: default;
}

.pst-status {
	color: var(--pst-soft);
	font-size: 14px;
}

.pst-textbtn:disabled {
	opacity: 0.5;
	cursor: default;
}

/* A choice that is not available right now (still focusable, so its reason can be read). */
.pst-chip[aria-disabled="true"] {
	border-color: var(--pst-line);
	color: var(--pst-muted);
	cursor: default;
}

/* A square button with an icon only. */
.pst-iconbtn {
	display: inline-grid;
	flex: none;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--pst-line-strong);
	border-radius: 10px;
	background: var(--pst-white);
	color: var(--pst-ink);
	cursor: pointer;
}

.pst-iconbtn:hover {
	border-color: var(--pst-ink);
}

.pst-iconbtn:disabled {
	opacity: 0.45;
	cursor: default;
}

.pst-range {
	flex: 1;
	min-width: 0;
	height: 44px;
	margin: 0;
	accent-color: var(--pst-ink);
	cursor: pointer;
}

/* A dot of the colour a button stands for. */
.pst-swatch {
	display: block;
	flex: none;
	width: 18px;
	height: 18px;
	border: 1px solid rgba(15, 27, 51, 0.25);
	border-radius: 50%;
	background: var(--c, #FFFFFF);
}

/* "No colour": the chequered pattern that stands for transparency. */
.pst-swatch--none {
	background-color: #FFFFFF;
	background-image:
		linear-gradient(45deg, #CFC7B8 25%, transparent 25%, transparent 75%, #CFC7B8 75%),
		linear-gradient(45deg, #CFC7B8 25%, transparent 25%, transparent 75%, #CFC7B8 75%);
	background-position: 0 0, 4px 4px;
	background-size: 8px 8px;
}

.pst-chip[aria-pressed="true"] .pst-swatch,
.pst-colour.is-on .pst-swatch {
	border-color: rgba(250, 247, 242, 0.7);
}

/* A button that opens the colour picker of the browser: the field itself covers it, unseen. */
.pst .pst-colour {
	position: relative;
	cursor: pointer;
}

.pst-colour input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	opacity: 0;
	cursor: pointer;
}

.pst-colour:focus-within {
	outline: 3px solid var(--pst-ink);
	outline-offset: 3px;
}

.pst-colour.is-on {
	border-color: var(--pst-ink);
	background: var(--pst-ink);
	color: var(--pst-paper);
}

/* Tools that work on a file (assets/js/image.js)
   ========================================================================== */

/* Where a file is dropped, before there is one. */
.pst-drop {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	min-height: 440px;
	padding: 28px 20px;
	border: 2px dashed var(--pst-line-strong);
	border-radius: 20px;
	background: var(--pst-paper);
	text-align: center;
}

.pst-drop__icon {
	display: grid;
	place-items: center;
	width: 108px;
	height: 108px;
	border: 2px dashed var(--pst-line-strong);
	border-radius: 50%;
	background: var(--pst-white);
	color: var(--pst-muted);
}

.pst .pst-drop__title {
	font-family: var(--pst-display);
	font-size: clamp(22px, 2.6vw, 28px);
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.15;
}

.pst .pst-drop .pst-hint {
	max-width: 30em;
}

/* Pasting is for keyboards: on a touch screen the sentence about it is left out. */
@media (hover: none) {
	.pst-drop__paste {
		display: none;
	}
}

/* A file is being dragged over the tool. */
.pst-card {
	position: relative;
}

.pst-card.is-over::after {
	content: "";
	position: absolute;
	inset: 6px;
	border: 3px dashed var(--pst-ink);
	border-radius: 18px;
	background: rgba(250, 247, 242, 0.6);
	pointer-events: none;
}

/* A photo that is moved and zoomed under a fixed frame (assets/js/stage.js). */
.pst-stage {
	position: relative;
	overflow: hidden;
	border-radius: 20px;
	background: var(--pst-ink);
	cursor: grab;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
}

.pst-stage.is-dragging {
	cursor: grabbing;
}

.pst-stage canvas {
	position: absolute;
	top: 0;
	left: 0;
	max-width: none;
	transform-origin: 0 0;
	pointer-events: none;
}

.pst .pst-error {
	padding: 10px 14px;
	border-radius: 10px;
	background: #FBEAE5;
	color: #8A2A17;
	font-size: 15px;
}

@container pst (max-width: 450px) {
	.pst-card {
		padding: 14px;
		border-radius: 20px;
	}

	.pst-seg__btn {
		padding: 6px 8px;
		font-size: 15px;
	}

	.pst-drop {
		min-height: 300px;
		padding: 22px 14px;
	}

	.pst-drop__icon {
		width: 88px;
		height: 88px;
	}
}

/* The layout of a tool that crops a photo: the photo with its controls on one side,
   a panel with the result, its options and the download on the other.
   ========================================================================== */

.pst-photo {
	display: grid;
	grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
	gap: clamp(20px, 3vw, 36px);
}

.pst-photo__work {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

/* With a photo: the stage and what moves the photo. */
.pst-photo__editor {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
	max-width: 480px;
	margin-inline: auto;
}

.pst-photo__stage {
	width: 100%;
	max-width: 100%;
	aspect-ratio: 1;
}

.pst-photo__mask {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	pointer-events: none;
}

.pst-photo__zoom {
	display: flex;
	align-items: center;
	gap: 10px;
}

.pst-photo__tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
}

.pst-photo__tools .pst-textbtn:last-child {
	margin-left: auto;
}

.pst .pst-photo__note {
	min-height: 1.55em;
}

/* Result: what the file will look like, its options, and the download. */
.pst-photo__panel {
	display: flex;
	flex-direction: column;
	gap: 20px;
	min-width: 0;
	padding: clamp(16px, 2vw, 24px);
	border: 1px solid var(--pst-line);
	border-radius: 16px;
	background: var(--pst-paper);
}

/* Three sizes to a row: the buttons line up whatever their labels are in a language. */
.pst-photo__sizes {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 6px;
}

.pst-photo__sizes .pst-chip {
	justify-content: center;
	padding: 0 6px;
}

.pst-photo__more {
	border-top: 1px solid var(--pst-line);
}

.pst-photo__more summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	font-size: 15px;
	font-weight: 600;
	list-style: none;
	cursor: pointer;
}

.pst-photo__more summary::-webkit-details-marker {
	display: none;
}

.pst-photo__more summary .pst-icon {
	transition: transform 0.15s;
}

.pst-photo__more[open] summary .pst-icon {
	transform: rotate(180deg);
}

.pst-photo__more-body {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding: 6px 0 4px;
}

.pst-photo__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.pst-photo__row + .pst-photo__row {
	margin-top: -4px;
}

.pst-photo__out {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: auto;
	padding-top: 18px;
	border-top: 1px solid var(--pst-line);
}

.pst .pst-photo__facts {
	font-size: 15px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.pst-photo__facts span {
	color: var(--pst-muted);
	font-weight: 400;
}

/* The label stays on one line: when it is long in a language, the copy button moves under it. */
.pst-photo__out .pst-btn {
	flex: 1 1 200px;
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.pst-photo__more summary .pst-icon {
		transition: none;
	}
}

/* Narrow places: the photo first, the result under it. */
@container pst (max-width: 840px) {
	.pst-photo {
		grid-template-columns: minmax(0, 1fr);
	}

	.pst-photo .pst-drop {
		min-height: 320px;
	}
}

@container pst (max-width: 450px) {
	.pst-photo .pst-drop {
		min-height: 300px;
	}

	.pst-photo__tools .pst-textbtn:last-child {
		margin-left: 0;
	}

	.pst-photo__panel .pst-chip {
		gap: 6px;
		padding: 0 9px;
		font-size: 14px;
	}
}

@supports not (container-type: inline-size) {
	@media (max-width: 900px) {
		.pst-photo {
			grid-template-columns: minmax(0, 1fr);
		}
	}
}
