/* ==========================================================================
   apc/copy-button
   Colors, font size, padding and radius come from theme.json button styles
   (.wp-element-button) and the block's own color/typography/spacing supports.
   ========================================================================== */

/* Zero-specificity resets for the native <button>, so theme styles still win. */
:where(.apc-copy-btn) {
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
	line-height: inherit;
	cursor: pointer;
}

.apc-copy-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .55em;
	width: fit-content;
	max-width: 100%;
	text-align: center;
	box-sizing: border-box;
}

.apc-copy-btn.is-full-width {
	width: 100%;
}

.apc-copy-btn .apc-action-btn__label {
	overflow-wrap: anywhere;
}

/* Icon */
.apc-copy-btn .apc-action-btn__icon {
	position: relative;
	display: inline-flex;
	flex: none;
	width: 1.15em;
	height: 1.15em;
}

.apc-copy-btn.is-icon-left .apc-action-btn__icon {
	order: -1;
}

.apc-copy-btn .apc-action-btn__icon svg {
	display: block;
	width: 100%;
	height: 100%;
	transition: opacity .2s ease, transform .2s ease;
}

.apc-copy-btn .apc-icon-check {
	position: absolute;
	inset: 0;
	opacity: 0;
	transform: scale(.6);
}

/* Copied state: copy icon → check icon */
.apc-copy-btn[data-state="copied"] .apc-icon-copy {
	opacity: 0;
	transform: scale(.6);
}

.apc-copy-btn[data-state="copied"] .apc-icon-check {
	opacity: 1;
	transform: none;
}

/* Icon only: square button */
.apc-copy-btn.is-mode-icon {
	aspect-ratio: 1;
	padding: .75em;
}

/* Custom icon color (Pogas stils → Ikonas krāsa) */
.apc-copy-btn.has-apc-icon-color .apc-action-btn__icon {
	color: var(--apc-btn-icon-color);
}

/* Transparent background: no theme fill/shadow, also on hover/focus */
.apc-copy-btn.is-bg-transparent,
.apc-copy-btn.is-bg-transparent:hover,
.apc-copy-btn.is-bg-transparent:focus,
.apc-copy-btn.is-bg-transparent:active {
	background: transparent;
	box-shadow: none;
}

@media (hover: hover) {
	.apc-copy-btn.is-bg-transparent:hover {
		opacity: .75;
	}
}

@media (prefers-reduced-motion: reduce) {
	.apc-copy-btn .apc-action-btn__icon svg {
		transition: none;
	}
}

/* ==========================================================================
   SHARED – tooltip + toast
   Identical block in apc/file-button/style.css – keep both in sync.
   Customize via CSS variables, e.g. in theme.json / Additional CSS:
     --apc-tooltip-bg, --apc-tooltip-color,
     --apc-toast-bg, --apc-toast-color, --apc-toast-accent, --apc-toast-error
   ========================================================================== */

/* ---------- Tooltip ---------- */

.apc-action-btn[data-apc-tooltip] {
	position: relative;
}

.apc-action-btn[data-apc-tooltip]::before,
.apc-action-btn[data-apc-tooltip]::after {
	position: absolute;
	left: 50%;
	z-index: 20;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translate(-50%, 4px);
	transition: opacity .15s ease, transform .15s ease, visibility .15s;
}

/* Bubble */
.apc-action-btn[data-apc-tooltip]::before {
	content: attr(data-apc-tooltip);
	bottom: calc(100% + 10px);
	width: max-content;
	max-width: min(280px, 80vw);
	padding: .45em .75em;
	border-radius: 6px;
	background: var(--apc-tooltip-bg, #1e1e1e);
	color: var(--apc-tooltip-color, #fff);
	box-shadow: 0 4px 14px rgb(0 0 0 / .18);
	font-size: 13px;
	font-weight: 400;
	font-style: normal;
	line-height: 1.35;
	letter-spacing: normal;
	text-align: center;
	text-transform: none;
	text-decoration: none;
	white-space: normal;
	overflow-wrap: anywhere;
}

/* Arrow */
.apc-action-btn[data-apc-tooltip]::after {
	content: "";
	bottom: calc(100% + 4px);
	border: 6px solid transparent;
	border-bottom-width: 0;
	border-top-color: var(--apc-tooltip-bg, #1e1e1e);
}

/* Show on hover (real pointers only) and keyboard focus */
@media (hover: hover) {
	.apc-action-btn[data-apc-tooltip]:hover::before,
	.apc-action-btn[data-apc-tooltip]:hover::after {
		opacity: 1;
		visibility: visible;
		transform: translate(-50%, 0);
	}
}

.apc-action-btn[data-apc-tooltip]:focus-visible::before,
.apc-action-btn[data-apc-tooltip]:focus-visible::after {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, 0);
}

/* Hide after the action (toast takes over) */
.apc-action-btn[data-apc-tooltip][data-state]::before,
.apc-action-btn[data-apc-tooltip][data-state]::after,
.apc-action-btn[data-apc-tooltip].is-clicked::before,
.apc-action-btn[data-apc-tooltip].is-clicked::after {
	opacity: 0;
	visibility: hidden;
}

/* ---------- Toast ---------- */

.apc-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 100000;
	display: flex;
	align-items: center;
	gap: .65em;
	max-width: min(440px, calc(100vw - 32px));
	padding: .8em 1.15em;
	border-radius: 10px;
	background: var(--apc-toast-bg, #1e1e1e);
	color: var(--apc-toast-color, #fff);
	box-shadow: 0 10px 30px rgb(0 0 0 / .25);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.4;
	overflow-wrap: anywhere;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translate(-50%, 16px);
	transition: opacity .25s ease, transform .25s ease, visibility .25s;
}

.apc-toast.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translate(-50%, 0);
}

.apc-toast__icon {
	position: relative;
	flex: none;
	width: 1.35em;
	height: 1.35em;
	border-radius: 50%;
	background: var(--apc-toast-accent, #2fb36d);
}

.apc-toast__icon::after {
	content: "";
	position: absolute;
	inset: 22%;
	background: #fff;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5 9.5 18 20 6'/%3E%3C/svg%3E") no-repeat center / contain;
	        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5 9.5 18 20 6'/%3E%3C/svg%3E") no-repeat center / contain;
}

.apc-toast.is-error .apc-toast__icon {
	background: var(--apc-toast-error, #d63638);
}

.apc-toast.is-error .apc-toast__icon::after {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E");
	        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E");
}

@media (max-width: 600px) {
	.apc-toast {
		bottom: 16px;
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.apc-action-btn[data-apc-tooltip]::before,
	.apc-action-btn[data-apc-tooltip]::after,
	.apc-toast {
		transition: none;
	}
}
