/* ==========================================================================
   Pokoloruj-to – kolorowanie online (page-coloring.php + pt-coloring.js)
   ========================================================================== */

.ptc {
	--ptc-color: #E53935;
	--ptc-bar: 72px;
	--ptc-header: 90px;
	position: relative;
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--ptc-header));
	height: calc(100dvh - var(--ptc-header));
	min-height: 560px;
	padding: 0 16px 16px;
	box-sizing: border-box;
	color: var(--pt-ink);
	font-family: var(--pt-font-body);
}

/* ---------- Pasek górny ---------- */
.ptc__bar {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: var(--ptc-bar);
}
.ptc__back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px 8px 10px;
	border-radius: 999px;
	border: 2px solid var(--pt-ink);
	background: var(--pt-white);
	font-weight: 800;
	font-size: 15px;
	text-decoration: none !important;
	color: var(--pt-ink) !important;
	flex-shrink: 0;
}
.ptc__back:hover { background: var(--pt-tint-yellow); }
.ptc__title {
	margin: 0 !important;
	font-size: 26px !important;
	line-height: 1.1 !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
	flex: 1;
}
.ptc__title span { color: var(--pt-ink-soft); font-weight: 700; }
.ptc__bar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ptc__sep { width: 2px; height: 28px; background: var(--pt-line); margin: 0 4px; }
.ptc__btn { min-height: 46px; padding: 0 18px; }

.ptc__icon {
	width: 46px;
	height: 46px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: 2px solid var(--pt-ink);
	background: var(--pt-white);
	color: var(--pt-ink);
	cursor: pointer;
	padding: 0 !important;
	margin: 0 !important;
	transition: background-color .15s ease, opacity .15s ease;
}
.ptc__icon:hover { background: var(--pt-tint-yellow); }
.ptc__icon:disabled { opacity: .35; cursor: default; background: var(--pt-white); }

/* ---------- Układ ---------- */
.ptc__body {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: 112px minmax(0, 1fr) 236px;
	gap: 14px;
}

/* ---------- Narzędzia ---------- */
.ptc__tools {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	border: 2px solid var(--pt-ink);
	border-radius: var(--pt-radius-m);
	background: var(--pt-white);
	overflow-y: auto;
}
.ptc__tool {
	display: flex !important;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	width: 100%;
	padding: 10px 4px !important;
	margin: 0 !important;
	border-radius: 14px;
	border: 2px solid transparent;
	background: transparent;
	color: var(--pt-ink);
	font-weight: 800;
	font-size: 13px;
	cursor: pointer;
	transition: background-color .15s ease;
}
.ptc__tool:hover { background: var(--pt-tint-yellow); }
.ptc__tool.is-active {
	background: var(--pt-ink);
	color: var(--pt-white);
}
.ptc__tool[data-tool="fill"].is-active svg path:last-child,
.ptc__tool[data-tool="brush"].is-active svg path:first-child { fill: var(--ptc-color); }

.ptc__group {
	margin-top: 6px;
	padding-top: 12px;
	border-top: 2px dashed var(--pt-line);
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.ptc__label {
	margin: 0 !important;
	font-size: 12px !important;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--pt-ink-soft);
}
.ptc__sizes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ptc__size {
	height: 40px;
	padding: 0 !important;
	margin: 0 !important;
	border-radius: 12px;
	border: 2px solid var(--pt-line);
	background: var(--pt-white);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.ptc__size i {
	width: var(--d);
	height: var(--d);
	border-radius: 50%;
	background: var(--pt-ink);
}
.ptc__size.is-active { border-color: var(--pt-ink); background: var(--pt-tint-yellow); }

.ptc__switch {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.25;
	text-align: center;
	cursor: pointer;
}
.ptc__switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ptc__switch-ui {
	width: 44px;
	height: 26px;
	border-radius: 999px;
	background: var(--pt-line);
	border: 2px solid var(--pt-ink);
	position: relative;
	transition: background-color .15s ease;
}
.ptc__switch-ui::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--pt-white);
	border: 2px solid var(--pt-ink);
	box-sizing: border-box;
	transition: transform .15s ease;
}
.ptc__switch input:checked + .ptc__switch-ui { background: #7CB342; }
.ptc__switch input:checked + .ptc__switch-ui::after { transform: translateX(18px); }
.ptc__switch input:focus-visible + .ptc__switch-ui { outline: 3px solid var(--pt-accent); outline-offset: 2px; }

/* grubość i „nie wychodź za linie” tylko dla kredki i gumki */
.ptc:not([data-tool="brush"]):not([data-tool="eraser"]) .ptc__group { opacity: .45; }

/* ---------- Kartka ---------- */
.ptc__stage {
	position: relative;
	min-width: 0;
	min-height: 0;
	border-radius: var(--pt-radius-m);
	border: 2px solid var(--pt-ink);
	background:
		radial-gradient(circle at 1px 1px, rgba(30, 42, 74, .08) 1px, transparent 0) 0 0 / 18px 18px,
		#F3EBDC;
	overflow: hidden;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}
.ptc__canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.ptc__stage[data-tool="fill"] .ptc__canvas {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%231E2A4A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath fill='%23fff' d='m5 11 7-7 8 8-7 7a2 2 0 0 1-2.8 0L5 13.8a2 2 0 0 1 0-2.8Z'/%3E%3Cpath d='M5 12h15'/%3E%3Cpath fill='%231E2A4A' d='M20 16s2 2.3 2 3.5a2 2 0 0 1-4 0c0-1.2 2-3.5 2-3.5Z'/%3E%3C/svg%3E") 20 24, crosshair;
}
.ptc__stage[data-tool="brush"] .ptc__canvas,
.ptc__stage[data-tool="eraser"] .ptc__canvas { cursor: none; }
.ptc__stage[data-tool="picker"] .ptc__canvas { cursor: crosshair; }
.ptc__stage[data-tool="hand"] .ptc__canvas,
.ptc__stage.is-space .ptc__canvas { cursor: grab; }
.ptc__stage.is-panning .ptc__canvas { cursor: grabbing; }

.ptc__loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	font-weight: 800;
}
.ptc__loading[hidden] { display: none; }
.ptc__spinner {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 4px solid var(--pt-line);
	border-top-color: var(--pt-accent);
	animation: ptc-spin .8s linear infinite;
}
@keyframes ptc-spin { to { transform: rotate(360deg); } }

.ptc__zoom {
	position: absolute;
	right: 14px;
	bottom: 14px;
	display: flex;
	align-items: center;
	background: var(--pt-white);
	border: 2px solid var(--pt-ink);
	border-radius: 999px;
	box-shadow: 0 3px 0 var(--pt-ink);
	overflow: hidden;
}
.ptc__zoom button {
	height: 40px;
	min-width: 40px;
	padding: 0 10px !important;
	margin: 0 !important;
	border: 0;
	background: transparent;
	color: var(--pt-ink);
	font-weight: 800;
	font-size: 20px;
	cursor: pointer;
}
.ptc__zoom button:hover { background: var(--pt-tint-yellow); }
.ptc__zoom .ptc__zoom-val { font-size: 13px; min-width: 60px; border-left: 2px solid var(--pt-line); border-right: 2px solid var(--pt-line); }

.ptc__toast {
	position: absolute;
	left: 50%;
	top: 14px;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: calc(100% - 28px);
	padding: 10px 12px 10px 18px;
	border-radius: 999px;
	background: var(--pt-ink);
	color: var(--pt-white);
	font-weight: 700;
	font-size: 14px;
	box-shadow: 0 8px 24px rgba(30, 42, 74, .25);
	animation: ptc-in .2s ease;
}
.ptc__toast[hidden] { display: none; }
.ptc__toast button {
	padding: 6px 12px !important;
	margin: 0 !important;
	border-radius: 999px;
	border: 0;
	background: var(--pt-accent);
	color: var(--pt-ink);
	font-weight: 800;
	font-size: 13px;
	cursor: pointer;
	white-space: nowrap;
}
@keyframes ptc-in { from { opacity: 0; transform: translate(-50%, -6px); } }

/* ---------- Kolory ---------- */
.ptc__palette {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 14px;
	border: 2px solid var(--pt-ink);
	border-radius: var(--pt-radius-m);
	background: var(--pt-white);
	overflow-y: auto;
}
.ptc__current { display: flex; align-items: center; gap: 12px; }
.ptc__current-swatch {
	--c: #E53935;
	width: 56px;
	height: 56px;
	flex-shrink: 0;
	border-radius: 16px;
	border: 2px solid var(--pt-ink);
	background: var(--c);
	box-shadow: 0 3px 0 var(--pt-ink);
}
.ptc__custom {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	border-radius: 12px;
	border: 2px dashed var(--pt-ink);
	font-weight: 800;
	font-size: 13px;
	line-height: 1.2;
	cursor: pointer;
}
.ptc__custom:hover { background: var(--pt-tint-yellow); }
.ptc__custom input {
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
	cursor: pointer;
	flex-shrink: 0;
}
.ptc__custom input::-webkit-color-swatch-wrapper { padding: 0; }
.ptc__custom input::-webkit-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.ptc__custom input::-moz-color-swatch { border: 0; border-radius: 50%; opacity: 0; }

.ptc__swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ptc__swatch {
	--c: #fff;
	aspect-ratio: 1;
	width: 100%;
	padding: 0 !important;
	margin: 0 !important;
	border-radius: 50%;
	border: 2px solid rgba(30, 42, 74, .25);
	background: var(--c);
	cursor: pointer;
	transition: transform .12s ease;
}
.ptc__swatch:hover { transform: scale(1.1); }
.ptc__swatch.is-active {
	border-color: var(--pt-ink);
	box-shadow: 0 0 0 3px var(--pt-white), 0 0 0 5px var(--pt-ink);
	transform: scale(1.05);
}
.ptc__swatches--recent { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.ptc__swatches--recent .ptc__swatch.is-active { box-shadow: 0 0 0 2px var(--pt-white), 0 0 0 3px var(--pt-ink); }

.ptc__error {
	position: absolute;
	inset: var(--ptc-bar) 16px 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	text-align: center;
	background: var(--pt-paper);
	border-radius: var(--pt-radius-m);
	border: 2px solid var(--pt-ink);
}
.ptc__error p { margin: 0 0 6px !important; }

/* ---------- Tablet i telefon ---------- */
@media (max-width: 1100px) {
	.ptc__body { grid-template-columns: 96px minmax(0, 1fr) 190px; }
	.ptc__swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.ptc__btn span { display: none; }
	.ptc__btn { padding: 0 14px; }
}

@media (max-width: 820px) {
	.ptc { padding: 0 8px 8px; min-height: 480px; }
	.ptc__bar { gap: 8px; min-height: 60px; }
	.ptc__back span, .ptc__title span, .ptc__sep { display: none; }
	.ptc__back { padding: 8px; }
	.ptc__title { font-size: 20px !important; }
	.ptc__icon, .ptc__btn { width: 42px; height: 42px; min-height: 42px; }
	.ptc__btn { padding: 0 !important; }
	.ptc__bar-actions { gap: 5px; }

	.ptc__body {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(0, 1fr) auto auto;
		gap: 8px;
	}
	.ptc__stage { order: 1; }
	.ptc__palette { order: 2; }
	.ptc__tools { order: 3; }

	.ptc__palette {
		flex-direction: row;
		align-items: center;
		padding: 8px;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
	}
	.ptc__current-swatch { width: 40px; height: 40px; border-radius: 12px; }
	.ptc__custom span, .ptc__palette .ptc__label { display: none; }
	.ptc__custom { padding: 6px; }
	.ptc__swatches, .ptc__swatches--recent { display: flex; gap: 6px; flex-shrink: 0; }
	.ptc__swatch { width: 36px; height: 36px; flex-shrink: 0; }
	.ptc__swatches--recent { padding-left: 8px; border-left: 2px dashed var(--pt-line); }
	.ptc__swatches--recent .ptc__swatch { width: 30px; height: 30px; }

	.ptc__tools {
		flex-direction: row;
		align-items: center;
		padding: 6px;
		overflow-x: auto;
		overflow-y: hidden;
	}
	.ptc__tool { width: auto; min-width: 64px; padding: 6px 8px !important; font-size: 11px; }
	.ptc__tool svg { width: 22px; height: 22px; }
	.ptc__group {
		flex-direction: row;
		align-items: center;
		margin: 0 0 0 4px;
		padding: 0 0 0 10px;
		border-top: 0;
		border-left: 2px dashed var(--pt-line);
	}
	.ptc__group .ptc__label { display: none; }
	.ptc__sizes { display: flex; }
	.ptc__size { width: 38px; height: 38px; }
	.ptc__switch { min-width: 84px; font-size: 10.5px; }
	.ptc:not([data-tool="brush"]):not([data-tool="eraser"]) .ptc__group { display: none; }
	.ptc__zoom { right: 8px; bottom: 8px; }
	.ptc__zoom button { height: 36px; min-width: 36px; }
}
