/* The studio's own chrome. The maker moved to the core; rules the studio
   shares with it are kept here as well, deliberately. */

/**
 * Particle Strokes - only what the shared kit cannot know.
 *
 * THE CLASS PREFIX IS `wpiepst-` AND IT MUST STAY UNIQUE. It started as
 * `wpieps-`, which 3D Particle Studio has used for years; every stylesheet
 * of every installed extension is loaded into the same page at the same
 * time, so the two studios were styling each other's elements. It showed as
 * a hint stuck to the top of the stage with a translucent veil across it,
 * and it was invisible in every harness, because a harness loads one
 * stylesheet. tests/structure.test.js checks the prefix against the
 * neighbours now.
 *
 * The three-column frame, the sheet and its little toolbar, the preview and
 * the stamp square. Everything else - cards, sliders, buttons, the foot -
 * styles itself through dsm, and reaching past that is how studios end up
 * looking subtly unlike each other.
 */

/* NO FIXED HEIGHT. The shared shell already does this properly: the
   backdrop is the viewport minus its padding, .dsm is max-height:100% and
   .dsm-body scrolls. Forcing a height here defeated all of that and made
   the dialog taller than the window on any normal screen - which is exactly
   what "man kann damit nicht arbeiten" looks like. Grow into what is there,
   keep a floor so the sheet stays usable, and let the shell scroll if the
   window is genuinely tiny. */
/* The frame carries the size, the body fills what is left - the same shape
   Cinematic Effects uses, and the reason it feels right. The vh limits are
   what keep it inside the window; putting a height on the body instead made
   the dialog taller than the screen. */
#wpie-root .wpiepst-dialog {
	width: min( 1560px, 98vw );
	height: min( 860px, 94vh );
	max-width: none;
}

#wpie-root .wpiepst-body {
	display: flex;
	gap: 14px;
	flex: 1;
	min-height: 0;
}

#wpie-root .wpiepst-left,
#wpie-root .wpiepst-side {
	width: 252px;
	flex: 0 0 auto;
	overflow: auto;
	min-height: 0;
	/* Symmetric, because the sticky preview below reaches OUT by the same
	   amount to cover it. With padding on one side and a negative margin on
	   both, the column was two pixels wider than itself and grew a
	   horizontal scrollbar - which is what a stray scrollbar in a panel
	   nearly always is: a negative margin that does not match its padding. */
	padding: 0 2px;
	/* Cards need the family's breathing room; without it they sit flush
	   against each other and the panel reads as one long list. */
	display: flex;
	flex-direction: column;
	gap: 12px;
}

#wpie-root .wpiepst-side {
	width: 276px;
}

/* The stage, exactly the family's shape: one relative box, the canvas
   centred inside it, and every control positioned absolutely within. My row
   layout was an invention and it showed. */
/* Chequer OUTSIDE, dark sheet INSIDE - the way 3D Particle Studio does it,
   and the way round Thomas expects. The first build had it inverted: chequer
   on the sheet, black around it, and a glowing stroke on a chequerboard
   reads as noise. The subtle chequer on the stage still says "everything
   here is transparent" without sitting under the paint. */
#wpie-root .wpiepst-view {
	position: relative;
	flex: 1;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
	border-radius: 10px;
	background:
		repeating-conic-gradient(
				rgb( 128 128 128 / 7% ) 0 25%,
				transparent 0 50%
			)
			0 0 / 22px 22px,
		#0b0d12;
}

/* The scroller is what makes zoom work: above fit the canvas is bigger than
   the box and you pan to the part you are painting. */
#wpie-root .wpiepst-pan {
	position: absolute;
	inset: 0;
	overflow: auto;
	display: grid;
	place-items: center;
}

#wpie-root .wpiepst-canvas {
	display: block;
	touch-action: none;
	cursor: crosshair;
	/* The sheet is a dark ground, like the prototype's page: glowing
	   particles need something dark to glow against. The transparency story
	   is told by the chequered stage around it, not under the paint. */
	background-color: #05060a;
	box-shadow: 0 10px 40px rgb(0 0 0 / 45%);
}

#wpie-root .wpiepst-canvas.is-fit {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
}

/* With the document behind it the chequerboard would only be in the way;
   the image itself comes from JS as an inline background. */
#wpie-root .wpiepst-canvas.is-doc {
	background-color: transparent;
	background-size: 100% 100%;
	background-position: center;
	background-repeat: no-repeat;
}

/* Show document on the LEFT, the rest on the right - a row of six buttons
   crowded into one corner looked like a mistake, and it was. */
#wpie-root .wpiepst-doc {
	position: absolute;
	top: 10px;
	left: 12px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 11px;
	font-size: 11px;
	line-height: 1.4;
	border-radius: 20px;
	border: 1px solid var(--ed-border, #2b303a);
	background: var(--ed-panel, #1c1f25);
	color: inherit;
	cursor: pointer;
}

#wpie-root .wpiepst-doc[aria-pressed='true'] {
	border-color: var(--accent, #3b66ff);
}

#wpie-root .wpiepst-tools {
	position: absolute;
	top: 10px;
	right: 12px;
	z-index: 3;
	display: flex;
	align-items: center;
	gap: 6px;
}

#wpie-root .wpiepst-tool {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	padding: 4px 8px;
	font-size: 11px;
	line-height: 1.4;
	border-radius: 20px;
	border: 1px solid var(--ed-border, #2b303a);
	background: var(--ed-panel, #1c1f25);
	color: inherit;
	cursor: pointer;
}

/* Bottom centre, the way every studio in the family does it. */
#wpie-root .wpiepst-hint {
	position: absolute;
	/* Explicitly released. A neighbouring studio's rule set `top: 10px`, and
	   with top AND bottom both set on an auto-height box, top wins - so the
	   hint sat at the top no matter how firmly this rule said bottom. */
	top: auto;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
	background: rgb(10 12 16 / 55%);
	color: rgb(255 255 255 / 82%);
	font-size: 10px;
	border-radius: 20px;
	padding: 3px 12px;
	white-space: nowrap;
	pointer-events: none;
}

/* Two sliders to a row. Fourteen full-width ones made a column nobody wants
   to scroll through. */
#wpie-root .wpiepst-grid2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2px 12px;
}

/* The looping test stroke. Sticky, so it stays in view while the sliders
   under it scroll - which is the entire point of having it. */
/* Sticky at the top of the column that holds the sliders. It needs a solid
   background AND to cover the column's own padding, or the cards scroll
   through underneath it - which they did. */
#wpie-root .wpiepst-pvwrap {
	position: sticky;
	top: 0;
	z-index: 4;
	background: var(--surface-panel, #1c1f25);
	margin: -4px -2px 0;
	padding: 4px 2px 10px;
	flex: 0 0 auto;
}

#wpie-root .wpiepst-pvhead {
	font-size: 11px;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--ed-text-dim, #b9c0cc);
	margin-bottom: 6px;
}

#wpie-root .wpiepst-pv {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
	background: #0d1014;
}

/* Choosers. Not invented styling - just the grid the shared button needs. */
#wpie-root .wpiepst-pick {
	display: grid;
	gap: 6px;
}

#wpie-root .wpiepst-pick2 {
	grid-template-columns: 1fr 1fr;
}

#wpie-root .wpiepst-pick3 {
	grid-template-columns: 1fr 1fr;
}

#wpie-root .wpiepst-pick button {
	padding: 6px 4px;
	font-size: 11.5px;
	border-radius: 7px;
	border: 1px solid var(--ed-border, #2b303a);
	background: var(--surface-input, #232830);
	color: var(--text-primary, #e7e9ee);
	cursor: pointer;
}

#wpie-root .wpiepst-pick button[aria-pressed='true'] {
	background: var(--accent, #3b66ff);
	border-color: var(--accent, #3b66ff);
	color: #fff;
}

#wpie-root .wpiepst-lab {
	display: flex;
	justify-content: space-between;
	gap: 6px;
	margin: 6px 0 0;
	font-size: 12px;
	color: var(--text-muted, #98a0ae);
}

#wpie-root .wpiepst-lab b {
	color: var(--text-primary, #e7e9ee);
	font-weight: 600;
}

#wpie-root .wpiepst-side input[type='range'],
#wpie-root .wpiepst-makerside input[type='range'] {
	width: 100%;
}

#wpie-root .wpiepst-sub {
	margin: 20px 0 8px;
	font-size: 11px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ed-text-dim, #b9c0cc);
}

#wpie-root .wpiepst-cols {
	display: flex;
	gap: 8px;
}

#wpie-root .wpiepst-cols > div {
	flex: 1 1 0;
	min-width: 0;
}

#wpie-root .wpiepst-stamprow {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

#wpie-root .wpiepst-thumb {
	width: 48px;
	height: 48px;
	flex: 0 0 auto;
	border-radius: 8px;
	background-color: #20242c;
	background-image:
		linear-gradient(45deg, #2a2f38 25%, transparent 25%),
		linear-gradient(-45deg, #2a2f38 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #2a2f38 75%),
		linear-gradient(-45deg, transparent 75%, #2a2f38 75%);
	background-size: 12px 12px;
	background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

/* Two buttons, and they were touching: the row had no display of its own,
   so nothing separated them. The label got longer as well, hence the wrap. */
#wpie-root .wpiepst-stampbtns {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	gap: 6px;
	min-width: 0;
}

/* The foot's status must not push the buttons off the edge. */
#wpie-root .wpiepst-status {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Section heads: the same dim as the other studios, not the default. */
#wpie-root .wpiepst-left .dsm-card-head,
#wpie-root .wpiepst-side .dsm-card-head {
	color: var(--ed-text-dim, #b9c0cc);
}

#wpie-root .wpiepst-left .dsm-card-head svg,
#wpie-root .wpiepst-side .dsm-card-head svg {
	opacity: 0.85;
}

#wpie-root .wpiepst-prof {
	display: block;
	margin: 8px 0 4px;
	width: 100%;
	height: auto;
	border-radius: 8px;
	background: #12151b;
	border: 1px solid var(--ed-border, #2b303a);
	cursor: crosshair;
	touch-action: none;
}

#wpie-root .wpiepst-dynbody {
	transition: opacity 0.15s;
}

/* The honest number: how many marks a second of drawing puts down. It sits
   right under the sliders that cause it, because that is the only place it
   changes anybody's mind. */
#wpie-root .wpiepst-density {
	margin: 6px 0 2px;
	font: 11px/1.5 ui-monospace, monospace;
	color: var(--text-muted, #98a0ae);
}

#wpie-root .wpiepst-density[data-heavy='true'] {
	color: #e8a33d;
}

/* The curve panel. The dot on a target is how you see at a glance which of
   the six carry a curve, without clicking through all of them. */
#wpie-root .wpiepst-pick button[data-on='true']::after {
	content: '';
	display: inline-block;
	width: 5px;
	height: 5px;
	margin-left: 5px;
	border-radius: 50%;
	background: var(--accent, #3b66ff);
	vertical-align: middle;
}

#wpie-root .wpiepst-pick button[aria-pressed='true'][data-on='true']::after {
	background: #fff;
}

#wpie-root .wpiepst-shapes {
	margin-top: 8px;
}

#wpie-root .wpiepst-shapes button {
	font-size: 10.5px;
	padding: 5px 3px;
}

/* Space held: the sheet can be dragged instead of painted on. */
#wpie-root .wpiepst-pan.is-pan,
#wpie-root .wpiepst-pan.is-pan .wpiepst-canvas {
	cursor: grab;
}

/* Four stamp slots in the studio. A particle draws one of them at random,
   so the row has to show all four at once - a dropdown would hide the very
   thing the feature is about. */
#wpie-root .wpiepst-slots {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 6px;
	margin-bottom: 8px;
}

#wpie-root .wpiepst-slot {
	padding: 2px;
	border-radius: 8px;
	border: 1px solid var(--ed-border, #2b303a);
	background-color: #14171c;
	cursor: pointer;
}

#wpie-root .wpiepst-slot canvas {
	display: block;
	width: 100%;
	height: auto;
}

#wpie-root .wpiepst-slot.is-sel {
	border-color: var(--accent, #3b66ff);
}

#wpie-root .wpiepst-slot.is-empty {
	border-style: dashed;
	background-image:
		linear-gradient(to right, transparent 46%, #3a414d 46% 54%, transparent 54%),
		linear-gradient(to bottom, transparent 46%, #3a414d 46% 54%, transparent 54%);
	background-size: 16px 16px;
	background-position: center;
	background-repeat: no-repeat;
}

/* The gradient strip: bar on top, draggable stops hanging under it. */
/* The core's gradient bar sits in here; it brings its own chrome and its
   own side margins. Nothing but a floor for the stop handles, which hang
   below the bar. */
#wpie-root .wpiepst-grad {
	min-width: 0;
	padding-bottom: 4px;
}

/* A card body is a flex column with a ten pixel gap, so every margin here
   is ADDED to that ten - which is how a twenty pixel margin under the
   gradient became a thirty pixel hole. Under the bar the card's own rhythm
   is enough; the bar already ends in whitespace of its own. */
#wpie-root .wpiepst-grad + .wpiepst-sub {
	margin-top: 0;
}

/* First heading in a card sits under the card head, which has its own
   spacing - twenty on top of that is a hole. */
#wpie-root .wpiepst-sub1 {
	margin-top: 2px;
}

/* A slider and a button side by side, for the times when a full-width
   button under a full-width slider is just two more rows to scroll. */
#wpie-root .wpiepst-inline {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

#wpie-root .wpiepst-inlinegrow {
	flex: 1 1 auto;
	min-width: 0;
}

#wpie-root .wpiepst-inline > button {
	flex: 0 0 auto;
	margin-bottom: 2px;
}

/* Draw and Reset share the row evenly instead of huddling on the left. */
#wpie-root .wpiepst-stampbtns button {
	flex: 1 1 0;
	min-width: 0;
}


/* Favorites: yours, so they read differently from the presets above. */
#wpie-root .wpiepst-fav {
	position: relative;
	padding-right: 18px;
	border-color: var( --accent, #3b66ff );
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#wpie-root .wpiepst-favx {
	position: absolute;
	top: 50%;
	right: 4px;
	transform: translateY( -50% );
	width: 14px;
	height: 14px;
	line-height: 13px;
	text-align: center;
	border-radius: 50%;
	font-size: 12px;
	opacity: 0.5;
}

#wpie-root .wpiepst-favx:hover {
	opacity: 1;
	background: var( --ed-hover, #2b303a );
}

/* ------------------------------ preset grid ------------------------------
 * The family chips are a choice row like any other pick; the grid below
 * shows ONE family, every button a stroke painted by the engine itself.
 * The canvas keeps its own sheet colour (set inline from the preset's
 * palette) - ink needs paper and glow needs night, whatever the theme says.
 */
#wpie-root .wpiepst-cats {
	grid-template-columns: 1fr 1fr;
}

#wpie-root .wpiepst-pgrid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-top: 10px;
}

#wpie-root .wpiepst-pbtn {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 4px 4px 5px;
	border-radius: 7px;
	border: 1px solid var(--ed-border, #2b303a);
	background: var(--surface-input, #232830);
	color: var(--text-primary, #e7e9ee);
	cursor: pointer;
	text-align: center;
}

#wpie-root .wpiepst-pbtn:hover {
	border-color: var(--accent, #3b66ff);
}

#wpie-root .wpiepst-pthumb {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 5px;
}

#wpie-root .wpiepst-pname {
	font-size: 11px;
	line-height: 1.2;
	color: var(--text-muted, #98a0ae);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
