/* =====================================================================
 * Coloring Page Studio — Global & Print Styles
 * ===================================================================== */

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Spinners */
.spinner {
    border: 3px solid rgba(14, 165, 233, 0.2);
    border-left-color: #0284c7;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 0.8s linear infinite;
}

.spinner-white {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-left-color: #ffffff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Scrollbars */
#historyContainer::-webkit-scrollbar {
    height: 6px;
}
#historyContainer::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}
#historyContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}
#historyContainer::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Global Transitions */
.btn-press {
    transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-press:active {
    transform: scale(0.98);
}

/* Quick Sample Carousel at top of Studio */
.carousel-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    user-select: none;
    cursor: grab;
}
.carousel-scroll:active {
    cursor: grabbing;
}
.carousel-scroll::-webkit-scrollbar {
    display: none;
}

/* =====================================================================
 * PRINT MEDIA QUERY — Guaranteed Single-Sheet Printing (Letter & A4)
 * ---------------------------------------------------------------------
 * Strictly constrains total content height to <= 9.8in (portrait) and
 * <= 7.2in (landscape) so that even with 0.5in printer hardware unprintable
 * margins, the artwork and watermark NEVER spill onto a 2nd page.
 * Includes outline domain name (~1/4" tall) and crisp QR code.
 * ===================================================================== */
@media print {
    *, *:before, *:after {
        box-sizing: border-box !important;
    }

    html, body {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        color: black !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        break-after: avoid !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Completely eliminate non-printable UI elements */
    .no-print, header, nav, footer, #apiKeyModal, #creditModal, #affiliateBox, #actionButtons, #messageBox, #loadingBox, #emptyState, section, #coverCarouselSection {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body > :not(main) {
        display: none !important;
    }

    main {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        background: white !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        break-inside: avoid !important;
        break-after: avoid !important;
    }

    div:has(> #printArea),
    .space-y-4 {
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    #printArea, #printablePage {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: auto !important;
        background: white !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        break-inside: avoid !important;
        break-after: avoid !important;
        overflow: hidden !important;
    }

    .printable-art-wrapper {
        position: relative !important;
        display: inline-block !important;
        width: auto !important;
        height: auto !important;
        margin: auto !important;
        padding: 0 !important;
        line-height: 0 !important;
        box-sizing: border-box !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        break-inside: avoid !important;
        break-after: avoid !important;
    }

    #imageOutput, #printableImg {
        display: block !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        border: none !important;
        box-shadow: none !important;
        margin: auto !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        break-inside: avoid !important;
        break-after: avoid !important;
    }

    body.print-landscape main,
    body.print-landscape #printArea,
    body.print-landscape #printablePage,
    body.print-landscape .printable-art-wrapper,
    body.print-landscape #imageOutput,
    body.print-landscape #printableImg {
        max-height: 7.2in !important;
        max-width: 9.8in !important;
    }

    body.print-portrait main,
    body.print-portrait #printArea,
    body.print-portrait #printablePage,
    body.print-portrait .printable-art-wrapper,
    body.print-portrait #imageOutput,
    body.print-portrait #printableImg {
        max-height: 9.75in !important;
        max-width: 7.8in !important;
    }


    /* Watermark overlay directly in the bottom-right corner of the art */
    .print-watermark {
        position: absolute !important;
        bottom: 0.05in !important;
        right: 0.05in !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-end !important;
        justify-content: flex-end !important;
        gap: 5pt !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        filter: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
        line-height: normal !important;
        z-index: 50 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .print-watermark-text {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        justify-content: flex-end !important;
        gap: 2pt !important;
        background: transparent !important;
    }

    .print-watermark-sub {
        display: inline-block !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        font-size: 11pt !important;
        line-height: 1 !important;
        font-weight: 800 !important;
        letter-spacing: 0.02em !important;
        color: #ffffff !important;
        -webkit-text-stroke: 1.2px #000000 !important;
        paint-order: stroke fill !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        text-shadow: none !important;
        box-shadow: none !important;
        filter: drop-shadow(2px 0 0 #ffffff)
                drop-shadow(-2px 0 0 #ffffff)
                drop-shadow(0 2px 0 #ffffff)
                drop-shadow(0 -2px 0 #ffffff)
                drop-shadow(1.5px 1.5px 0 #ffffff)
                drop-shadow(-1.5px 1.5px 0 #ffffff)
                drop-shadow(1.5px -1.5px 0 #ffffff)
                drop-shadow(-1.5px -1.5px 0 #ffffff) !important;
        white-space: nowrap !important;
        margin: 0 !important;
    }

    .print-watermark-domain {
        display: inline-block !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        font-size: 19pt !important;
        line-height: 1 !important;
        font-weight: 800 !important;
        letter-spacing: 0.01em !important;
        color: #ffffff !important;
        -webkit-text-stroke: 1.5px #000000 !important;
        paint-order: stroke fill !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        text-shadow: none !important;
        box-shadow: none !important;
        filter: drop-shadow(2.5px 0 0 #ffffff)
                drop-shadow(-2.5px 0 0 #ffffff)
                drop-shadow(0 2.5px 0 #ffffff)
                drop-shadow(0 -2.5px 0 #ffffff)
                drop-shadow(2px 2px 0 #ffffff)
                drop-shadow(-2px 2px 0 #ffffff)
                drop-shadow(2px -2px 0 #ffffff)
                drop-shadow(-2px -2px 0 #ffffff) !important;
        white-space: nowrap !important;
        margin: 0 !important;
    }

    .print-watermark-qr {
        display: block !important;
        width: 0.58in !important;
        height: 0.58in !important;
        background: #ffffff !important;
        padding: 2pt !important;
        border: none !important;
        border-radius: 5pt !important;
        box-shadow: none !important;
        filter: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    .print-watermark-qr svg,
    .print-watermark-qr img {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        object-fit: contain !important;
    }
}
