/**
 * Smart Local Youtube — Consent Box & Placeholder Styles
 *
 * @copyright  (C) 2025 NextSoftware Team. https://nextsoftware.dev/
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

/* ── Screen-reader-only utility ── */
.sly-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Backdrop (center modal) ── */
.sly-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999998;
}

/* ── Base ── */
.sly-consent {
    --sly-bg: #ffffff;
    --sly-text: #374151;
    --sly-link: #2563eb;
    --sly-btn-agree-bg: #16a34a;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #15803d;
    --sly-btn-decline-bg: #e5e7eb;
    --sly-btn-decline-text: #4b5563;
    --sly-btn-decline-hover: #d1d5db;

    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9em;
    position: fixed;
    box-sizing: border-box;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    line-height: 1.5;
    z-index: 9999999;
    background: var(--sly-bg);
    color: var(--sly-text);
}

.sly-consent a {
    color: var(--sly-link);
}

/* ── Close button (top-right corner) ── */
.sly-consent__close {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    font-size: 1.4em;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    color: var(--sly-text);
    opacity: 0.5;
    border-radius: 4px;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.sly-consent__close:hover {
    opacity: 1;
}

.sly-consent__close:focus-visible {
    outline: 3px solid var(--sly-link);
    outline-offset: 2px;
    opacity: 1;
}

/* ── Header ── */
.sly-consent__header {
    display: flex;
    align-items: flex-start;
    padding: 12px 36px 0 16px;
    gap: 8px;
}

.sly-consent__icon {
    flex: 0 0 auto;
    font-size: 1.1em;
}

.sly-consent__title {
    flex: 1 1 auto;
    margin: 0;
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.3;
}

/* ── Body ── */
.sly-consent__body {
    padding: 8px 16px;
}

.sly-consent__body p {
    margin: 0 0 4px;
}

.sly-consent__link {
    font-size: 0.9em;
}

/* ── Actions ── */
.sly-consent__actions {
    padding: 8px 16px 16px;
}

.sly-consent__actions form {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Buttons ── */
.sly-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    white-space: nowrap;
    transition: background 0.3s ease;
}

.sly-btn:focus-visible {
    outline: 3px solid var(--sly-link);
    outline-offset: 2px;
}

.sly-btn--primary {
    color: var(--sly-btn-agree-text);
    background: var(--sly-btn-agree-bg);
}

.sly-btn--primary:hover {
    background: var(--sly-btn-agree-hover);
}

.sly-btn--secondary {
    color: var(--sly-btn-decline-text);
    background: var(--sly-btn-decline-bg);
    font-size: 0.85em;
}

.sly-btn--secondary:hover {
    background: var(--sly-btn-decline-hover);
}

/* ── Positions ── */
.sly-consent.sly-consent--pos-1,
.sly-consent.sly-consent--pos-3,
.sly-consent.sly-consent--pos-4 {
    border-radius: 8px;
}

/* Position 1: Center modal */
.sly-consent.sly-consent--pos-1 {
    top: 50%;
    left: 50%;
    width: 500px;
    height: auto;
    transform: translate(-50%, -50%);
}

/* Position 2: Bottom full-width bar */
.sly-consent.sly-consent--pos-2 {
    bottom: 0;
    left: 0;
    padding: 8px 16px;
    width: 100%;
    height: auto;
}

@media (min-width: 1200px) {
    .sly-consent.sly-consent--pos-2 {
        display: flex;
        align-items: center;
        padding: 16px 20%;
        padding-right: max(20%, 48px);
    }

    .sly-consent.sly-consent--pos-2 .sly-consent__header {
        flex: 0 0 auto;
        padding: 0 8px 0 0;
    }

    .sly-consent.sly-consent--pos-2 .sly-consent__body {
        flex: 1 1 auto;
        padding: 0 8px;
    }

    .sly-consent.sly-consent--pos-2 .sly-consent__actions {
        flex: 0 0 auto;
        padding: 0;
    }
}

/* Position 3: Bottom-right corner */
.sly-consent.sly-consent--pos-3 {
    bottom: 10px;
    right: 10px;
    width: 400px;
    height: auto;
}

/* Position 4: Bottom-left corner */
.sly-consent.sly-consent--pos-4 {
    bottom: 10px;
    left: 10px;
    width: 400px;
    height: auto;
}

/* ── Theme: Clean (default — white/green) ── */
.sly-consent.sly-theme-clean {
    --sly-bg: #ffffff;
    --sly-text: #374151;
    --sly-link: #2563eb;
    --sly-btn-agree-bg: #16a34a;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #15803d;
    --sly-btn-decline-bg: #f3f4f6;
    --sly-btn-decline-text: #4b5563;
    --sly-btn-decline-hover: #e5e7eb;
}

/* ── Theme: Midnight (navy/amber) ── */
.sly-consent.sly-theme-midnight {
    --sly-bg: #1e293b;
    --sly-text: #e2e8f0;
    --sly-link: #fbbf24;
    --sly-btn-agree-bg: #f59e0b;
    --sly-btn-agree-text: #1e293b;
    --sly-btn-agree-hover: #d97706;
    --sly-btn-decline-bg: #334155;
    --sly-btn-decline-text: #cbd5e1;
    --sly-btn-decline-hover: #475569;
}

/* ── Theme: Forest (emerald/coral) ── */
.sly-consent.sly-theme-forest {
    --sly-bg: #064e3b;
    --sly-text: #ecfdf5;
    --sly-link: #6ee7b7;
    --sly-btn-agree-bg: #f97316;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #ea580c;
    --sly-btn-decline-bg: #065f46;
    --sly-btn-decline-text: #a7f3d0;
    --sly-btn-decline-hover: #047857;
}

/* ── Theme: Slate (warm gray/blue) ── */
.sly-consent.sly-theme-slate {
    --sly-bg: #f8fafc;
    --sly-text: #475569;
    --sly-link: #3b82f6;
    --sly-btn-agree-bg: #3b82f6;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #2563eb;
    --sly-btn-decline-bg: #e2e8f0;
    --sly-btn-decline-text: #64748b;
    --sly-btn-decline-hover: #cbd5e1;
}

/* ── Theme: Warm (cream/teal) ── */
.sly-consent.sly-theme-warm {
    --sly-bg: #fffbeb;
    --sly-text: #78350f;
    --sly-link: #0d9488;
    --sly-btn-agree-bg: #0d9488;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #0f766e;
    --sly-btn-decline-bg: #fef3c7;
    --sly-btn-decline-text: #92400e;
    --sly-btn-decline-hover: #fde68a;
}

/* ── Dark Mode: Auto (follows OS preference) ── */
@media (prefers-color-scheme: dark) {
    .sly-consent:not(.sly-light) {
        --sly-bg: #1f2937;
        --sly-text: #f3f4f6;
        --sly-link: #60a5fa;
        --sly-btn-decline-bg: #374151;
        --sly-btn-decline-text: #d1d5db;
        --sly-btn-decline-hover: #4b5563;
    }

    .sly-consent.sly-theme-clean:not(.sly-light) {
        --sly-bg: #1f2937;
        --sly-text: #f3f4f6;
        --sly-link: #60a5fa;
        --sly-btn-agree-bg: #22c55e;
        --sly-btn-agree-text: #ffffff;
        --sly-btn-agree-hover: #16a34a;
        --sly-btn-decline-bg: #374151;
        --sly-btn-decline-text: #d1d5db;
        --sly-btn-decline-hover: #4b5563;
    }

    .sly-consent.sly-theme-slate:not(.sly-light) {
        --sly-bg: #1e293b;
        --sly-text: #e2e8f0;
        --sly-link: #60a5fa;
        --sly-btn-agree-bg: #3b82f6;
        --sly-btn-agree-text: #ffffff;
        --sly-btn-agree-hover: #2563eb;
        --sly-btn-decline-bg: #334155;
        --sly-btn-decline-text: #94a3b8;
        --sly-btn-decline-hover: #475569;
    }

    .sly-consent.sly-theme-warm:not(.sly-light) {
        --sly-bg: #292524;
        --sly-text: #fef3c7;
        --sly-link: #2dd4bf;
        --sly-btn-agree-bg: #14b8a6;
        --sly-btn-agree-text: #ffffff;
        --sly-btn-agree-hover: #0d9488;
        --sly-btn-decline-bg: #44403c;
        --sly-btn-decline-text: #d6d3d1;
        --sly-btn-decline-hover: #57534e;
    }

    .sly-backdrop {
        background: rgba(0, 0, 0, 0.7);
    }

    .sly-placeholder {
        --sly-bg: #1f2937;
        --sly-text: #f3f4f6;
        --sly-link: #60a5fa;
        --sly-btn-decline-bg: #374151;
    }
}

/* ── Dark Mode: Forced dark ── */
.sly-consent.sly-dark {
    --sly-bg: #1f2937;
    --sly-text: #f3f4f6;
    --sly-link: #60a5fa;
    --sly-btn-decline-bg: #374151;
    --sly-btn-decline-text: #d1d5db;
    --sly-btn-decline-hover: #4b5563;
}

.sly-consent.sly-dark.sly-theme-clean {
    --sly-btn-agree-bg: #22c55e;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #16a34a;
}

.sly-consent.sly-dark.sly-theme-slate {
    --sly-bg: #1e293b;
    --sly-text: #e2e8f0;
    --sly-btn-agree-bg: #3b82f6;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #2563eb;
    --sly-btn-decline-bg: #334155;
    --sly-btn-decline-text: #94a3b8;
    --sly-btn-decline-hover: #475569;
}

.sly-consent.sly-dark.sly-theme-warm {
    --sly-bg: #292524;
    --sly-text: #fef3c7;
    --sly-link: #2dd4bf;
    --sly-btn-agree-bg: #14b8a6;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #0d9488;
    --sly-btn-decline-bg: #44403c;
    --sly-btn-decline-text: #d6d3d1;
    --sly-btn-decline-hover: #57534e;
}

/* ── Animations ── */
.sly-consent.fadeInDown {
    animation: sly-fadeInDown 1s both;
}

.sly-consent.fadeInUp {
    animation: sly-fadeInUp 1s both;
}

.sly-consent.fadeInLeft {
    animation: sly-fadeInLeft 1s both;
}

.sly-consent.fadeInRight {
    animation: sly-fadeInRight 1s both;
}

@keyframes sly-fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Override for center modal which uses translate centering */
.sly-consent.sly-consent--pos-1.fadeInDown {
    animation: sly-fadeInDown-center 1s both;
}

@keyframes sly-fadeInDown-center {
    from {
        opacity: 0;
        transform: translate(-50%, -150%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes sly-fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 100%, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.sly-consent.sly-consent--pos-1.fadeInUp {
    animation: sly-fadeInUp-center 1s both;
}

@keyframes sly-fadeInUp-center {
    from {
        opacity: 0;
        transform: translate(-50%, 50%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes sly-fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(100%, 0, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.sly-consent.sly-consent--pos-1.fadeInLeft {
    animation: sly-fadeInLeft-center 1s both;
}

@keyframes sly-fadeInLeft-center {
    from {
        opacity: 0;
        transform: translate(50%, -50%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes sly-fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(-100%, 0, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.sly-consent.sly-consent--pos-1.fadeInRight {
    animation: sly-fadeInRight-center 1s both;
}

@keyframes sly-fadeInRight-center {
    from {
        opacity: 0;
        transform: translate(-150%, -50%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .sly-consent.fadeInDown,
    .sly-consent.fadeInUp,
    .sly-consent.fadeInLeft,
    .sly-consent.fadeInRight,
    .sly-consent.sly-consent--pos-1.fadeInDown,
    .sly-consent.sly-consent--pos-1.fadeInUp,
    .sly-consent.sly-consent--pos-1.fadeInLeft,
    .sly-consent.sly-consent--pos-1.fadeInRight {
        animation: none;
    }

    .sly-consent.sly-consent--pos-1 {
        transform: translate(-50%, -50%);
    }

    .sly-btn,
    .sly-consent__close {
        transition: none;
    }
}

/* ── Demo mode badge ── */
.sly-consent__demo-badge {
    position: absolute;
    top: 8px;
    right: 40px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #f59e0b;
    color: #fff;
    pointer-events: none;
    z-index: 1;
    line-height: 1.5;
}

/* ── Inline placeholder (position 5 — replaces map) ── */
.sly-placeholder {
    --sly-bg: #f3f4f6;
    --sly-text: #374151;
    --sly-link: #2563eb;
    --sly-btn-agree-bg: #16a34a;
    --sly-btn-agree-text: #ffffff;
    --sly-btn-agree-hover: #15803d;
    --sly-btn-decline-bg: #d1d5db;

    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 24px;
    border-radius: 8px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9em;
    line-height: 1.5;
    background: var(--sly-bg);
    color: var(--sly-text);
    border: 1px dashed var(--sly-btn-decline-bg);
}

.sly-placeholder a {
    color: var(--sly-link);
}

.sly-placeholder__icon {
    font-size: 2em;
    margin-bottom: 8px;
    opacity: 0.6;
}

.sly-placeholder__title {
    margin: 0 0 8px;
    font-size: 1.1em;
    font-weight: 600;
}

.sly-placeholder__body {
    margin-bottom: 12px;
}

.sly-placeholder__body p {
    margin: 0 0 4px;
}

.sly-placeholder__link {
    font-size: 0.9em;
    color: var(--sly-link);
}

.sly-placeholder__actions {
    margin-top: 8px;
}

/* Placeholder theme inheritance */
.sly-placeholder.sly-theme-clean { --sly-bg: #ffffff; --sly-text: #374151; --sly-link: #2563eb; --sly-btn-agree-bg: #16a34a; --sly-btn-agree-text: #ffffff; --sly-btn-agree-hover: #15803d; --sly-btn-decline-bg: #e5e7eb; }
.sly-placeholder.sly-theme-midnight { --sly-bg: #1e293b; --sly-text: #e2e8f0; --sly-link: #fbbf24; --sly-btn-agree-bg: #f59e0b; --sly-btn-agree-text: #1e293b; --sly-btn-agree-hover: #d97706; --sly-btn-decline-bg: #334155; }
.sly-placeholder.sly-theme-forest { --sly-bg: #064e3b; --sly-text: #ecfdf5; --sly-link: #6ee7b7; --sly-btn-agree-bg: #f97316; --sly-btn-agree-text: #ffffff; --sly-btn-agree-hover: #ea580c; --sly-btn-decline-bg: #065f46; }
.sly-placeholder.sly-theme-slate { --sly-bg: #f8fafc; --sly-text: #475569; --sly-link: #3b82f6; --sly-btn-agree-bg: #3b82f6; --sly-btn-agree-text: #ffffff; --sly-btn-agree-hover: #2563eb; --sly-btn-decline-bg: #e2e8f0; }
.sly-placeholder.sly-theme-warm { --sly-bg: #fffbeb; --sly-text: #78350f; --sly-link: #0d9488; --sly-btn-agree-bg: #0d9488; --sly-btn-agree-text: #ffffff; --sly-btn-agree-hover: #0f766e; --sly-btn-decline-bg: #fef3c7; }

/* Placeholder forced dark */
.sly-placeholder.sly-dark { --sly-bg: #1f2937; --sly-text: #f3f4f6; --sly-link: #60a5fa; --sly-btn-decline-bg: #374151; }

/* ── YouTube-specific placeholder: background image + play button overlay ── */

/* When the placeholder has a resolved image (custom / per_video / youtube_thumb) */
.sly-placeholder--has-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    min-height: 180px;
}

.sly-placeholder--has-image .sly-placeholder__link {
    color: #fcd34d;
}

/* Dim overlay keeps headline/notification legible over any thumbnail */
.sly-placeholder--has-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

.sly-placeholder--has-image > * {
    position: relative;
    z-index: 1;
}

/* Play-button overlay — rendered as ::after so it stacks cleanly above the image */
.sly-placeholder::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(80px, 18%);
    height: min(80px, 18%);
    transform: translate(-50%, -50%);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 2;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

/* Hide play-button overlay when there's no image (icon mode, or image failed to resolve) */
.sly-placeholder:not(.sly-placeholder--has-image)::after,
.sly-placeholder.sly-playbtn-none::after {
    display: none;
}

.sly-placeholder.sly-playbtn-light::after {
    background-image: url("../images/play-light.png");
}

.sly-placeholder.sly-playbtn-dark::after {
    background-image: url("../images/play-dark.png");
}

.sly-placeholder.sly-playbtn-red::after {
    background-image: url("../images/play-red.png");
}

.sly-placeholder--has-image:hover::after {
    opacity: 1;
}

/* With an image the placeholder also shows the headline, text and button, so the
   play button joins the flow above them instead of sitting on top of the text. */
.sly-placeholder--has-image::after {
    position: static;
    order: -1;
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
    transform: none;
}
