/*!
 * Kripanov Anticopia - Protection styles
 *
 * @package KripanovAnticopia
 * @since   1.0.0
 */

/* Disable text selection. */
body.anticopia-no-select,
body.anticopia-no-select * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow selection inside form fields. */
body.anticopia-no-select input,
body.anticopia-no-select textarea,
body.anticopia-no-select select,
body.anticopia-no-select [contenteditable="true"],
body.anticopia-no-select [contenteditable="true"] * {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Disable image dragging. */
body.anticopia-no-drag img,
body.anticopia-no-drag picture,
body.anticopia-no-drag svg {
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Extra image protection layer. */
body.anticopia-protect-images img,
body.anticopia-protect-images picture img {
    -webkit-touch-callout: none;
    pointer-events: auto;
}

body.anticopia-protect-images figure {
    position: relative;
}

/* Soft overlay on figures to hinder casual save-as.
   Skip embeds (YouTube/Vimeo/etc.): the overlay would block play/tap. */
body.anticopia-protect-images figure:not(.wp-block-embed):not(.wp-block-video):not(.wp-block-audio)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: transparent;
    pointer-events: auto;
}

/* No overlay when the figure contains interactive media (classic embeds, shortcodes). */
body.anticopia-protect-images figure:has(iframe)::after,
body.anticopia-protect-images figure:has(video)::after,
body.anticopia-protect-images figure:has(audio)::after,
body.anticopia-protect-images figure:has(embed)::after,
body.anticopia-protect-images figure:has(object)::after {
    display: none !important;
    pointer-events: none !important;
}

body.anticopia-protect-images figure a,
body.anticopia-protect-images figure button,
body.anticopia-protect-images figure figcaption,
body.anticopia-protect-images figure iframe,
body.anticopia-protect-images figure video,
body.anticopia-protect-images figure audio,
body.anticopia-protect-images figure embed,
body.anticopia-protect-images figure object,
body.anticopia-protect-images .wp-block-embed__wrapper {
    position: relative;
    z-index: 2;
}

/* Mobile long-press / callout. */
body.anticopia-no-touchcallout,
body.anticopia-no-touchcallout * {
    -webkit-touch-callout: none;
}

body.anticopia-no-touchcallout input,
body.anticopia-no-touchcallout textarea,
body.anticopia-no-touchcallout select,
body.anticopia-no-touchcallout [contenteditable="true"],
body.anticopia-no-touchcallout iframe,
body.anticopia-no-touchcallout video,
body.anticopia-no-touchcallout audio,
body.anticopia-no-touchcallout .wp-block-embed,
body.anticopia-no-touchcallout .wp-block-embed * {
    -webkit-touch-callout: default;
}

/* Hide content when printing. */
@media print {
    body.anticopia-no-print {
        display: none !important;
    }
    body.anticopia-no-print::before {
        content: "Protected content. Printing is not allowed.";
        display: block !important;
        font-size: 20px;
        text-align: center;
        padding: 40px;
    }
}

/* Floating notice. */
.anticopia-notice {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translate(-50%, 20px);
    background: rgba(20, 20, 20, 0.92);
    color: #fff;
    padding: 12px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    z-index: 2147483647;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    text-align: center;
}

.anticopia-notice.anticopia-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Text watermark overlay on images. */
.anticopia-wm {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: middle;
    line-height: 0;
}

.wp-block-image .anticopia-wm,
.wp-block-image figure .anticopia-wm,
figure.wp-block-image .anticopia-wm,
.entry-content .anticopia-wm,
.post-thumbnail .anticopia-wm {
    display: block;
    width: 100%;
}

.anticopia-wm img {
    display: block;
    max-width: 100%;
    height: auto;
}

.anticopia-wm__label {
    position: absolute;
    z-index: 5;
    max-width: 90%;
    padding: 0.15em 0.4em;
    margin: 0;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--anticopia-wm-size, 16px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 8px rgba(0, 0, 0, 0.35);
    opacity: var(--anticopia-wm-opacity, 0.35);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anticopia-wm--top-left .anticopia-wm__label {
    top: 6%;
    left: 5%;
    transform: none;
}

.anticopia-wm--top-right .anticopia-wm__label {
    top: 6%;
    right: 5%;
    left: auto;
    transform: none;
}

.anticopia-wm--bottom-left .anticopia-wm__label {
    bottom: 6%;
    left: 5%;
    transform: none;
}

.anticopia-wm--bottom-right .anticopia-wm__label {
    bottom: 6%;
    right: 5%;
    left: auto;
    transform: none;
}

.anticopia-wm--center .anticopia-wm__label {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Keep watermark above soft figure protection overlays. */
body.anticopia-protect-images .anticopia-wm {
    position: relative;
    z-index: 3;
}

/*
 * Host overlay mode (Newspaper / tagDiv):
 * label is appended to .td-module-thumb without wrapping .entry-thumb.
 */
.anticopia-wm-host {
    position: relative !important;
}

.anticopia-wm-host > .anticopia-wm__label {
    z-index: 6;
}

/* Position variants work on host the same as on .anticopia-wm */
.anticopia-wm-host.anticopia-wm--top-left > .anticopia-wm__label {
    top: 6%;
    left: 5%;
    transform: none;
}

.anticopia-wm-host.anticopia-wm--top-right > .anticopia-wm__label {
    top: 6%;
    right: 5%;
    left: auto;
    transform: none;
}

.anticopia-wm-host.anticopia-wm--bottom-left > .anticopia-wm__label {
    bottom: 6%;
    left: 5%;
    transform: none;
}

.anticopia-wm-host.anticopia-wm--bottom-right > .anticopia-wm__label {
    bottom: 6%;
    right: 5%;
    left: auto;
    transform: none;
}

.anticopia-wm-host.anticopia-wm--center > .anticopia-wm__label {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Do not let protect-images figure::after cover module / single featured thumbs. */
body.anticopia-protect-images .td-module-thumb::after,
body.anticopia-protect-images .td-post-featured-image::after,
body.anticopia-protect-images .tdb_single_featured_image::after,
body.anticopia-protect-images .tdb_single_featured_image .tdb-block-inner::after {
    display: none !important;
}

/* Builder hosts: Elementor / Divi / Gutenberg */
.elementor-widget-theme-post-featured-image.anticopia-wm-host,
.elementor-post__thumbnail.anticopia-wm-host,
.elementor-image.anticopia-wm-host,
.et_pb_image_wrap.anticopia-wm-host,
.et_pb_image.anticopia-wm-host,
.wp-block-post-featured-image.anticopia-wm-host,
.wp-block-image.anticopia-wm-host,
figure.wp-block-image.anticopia-wm-host {
    position: relative !important;
}

.elementor-widget-theme-post-featured-image .anticopia-wm__label,
.elementor-post__thumbnail .anticopia-wm__label,
.elementor-image .anticopia-wm__label,
.et_pb_image_wrap .anticopia-wm__label,
.wp-block-post-featured-image .anticopia-wm__label,
.wp-block-image .anticopia-wm__label {
    z-index: 6;
}
