/* Heyzine-Inspired Styles */

.stf__wrapper {
    margin: 0 auto;
}

/* Page Base */
.page {
    background-color: white;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    /* Subtle inner texture */
}

/* Hardcover Effect */
.page.hardcover {
    border: 1px solid #444;
    /* Dark edge for cover */
    /* We can add a thicker shadow to simulate board thickness */
}

/* Page Spreads */
.page.--right {
    box-shadow: inset 10px 0 20px -10px rgba(0, 0, 0, 0.2);
    /* Spine shadow */
    border-left: 1px solid #ddd;
}

.page.--left {
    box-shadow: inset -10px 0 20px -10px rgba(0, 0, 0, 0.2);
    /* Spine shadow */
    border-right: 1px solid #ddd;
}

.page-content {
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

/* Mobile Portrait - Standard Mobile View */
@media (max-width: 768px) {
    #controls {
        bottom: 12px !important;
        padding: 0.5rem 1rem !important;
        width: 95% !important;
        max-width: 95% !important;
        justify-content: center !important;
        gap: 1rem !important;
    }

    #zoom-controls {
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) scale(0.9) !important;
        padding: 0.375rem !important;
    }

    #zoom-controls button {
        width: 2.25rem !important;
        height: 2.25rem !important;
        font-size: 0.875rem !important;
    }

    .book-container {
        transform: scale(0.85) !important;
    }

    #zoom-container {
        padding: 0.5rem !important;
        padding-bottom: 5rem !important;
    }

    #scroll-container {
        padding: 1rem !important;
        padding-bottom: 5rem !important;
    }

    /* Loading state adjustments */
    #loading p {
        font-size: 0.875rem !important;
    }

    #loading .animate-spin {
        width: 3rem !important;
        height: 3rem !important;
    }
}

/* Mobile Landscape - Optimized for horizontal viewing */
@media (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {

    /* Reduce vertical padding to maximize book viewing area */
    body {
        overflow: hidden !important;
    }

    #zoom-container {
        padding: 0.25rem !important;
        padding-bottom: 4.5rem !important;
    }

    /* Compact bottom controls */
    #controls {
        bottom: 8px !important;
        padding: 0.375rem 1rem !important;
        gap: 0.75rem !important;
        font-size: 0.875rem !important;
        width: auto !important;
        max-width: 90% !important;
    }

    #controls button {
        width: 2rem !important;
        height: 2rem !important;
    }

    #controls .font-mono {
        font-size: 0.75rem !important;
        min-width: 50px !important;
    }

    /* Right side zoom controls - make more compact */
    #zoom-controls {
        right: 6px !important;
        top: 50% !important;
        transform: translateY(-50%) scale(0.85) !important;
        padding: 0.25rem !important;
        gap: 0.5rem !important;
    }

    #zoom-controls button {
        width: 2rem !important;
        height: 2rem !important;
        font-size: 0.75rem !important;
    }

    /* Book scaling for landscape */
    .book-container {
        transform: scale(0.75) !important;
    }

    /* Scroll view optimization */
    #scroll-container {
        padding: 0.5rem !important;
        padding-bottom: 4rem !important;
    }

    #scroll-content {
        gap: 1rem !important;
    }

    .scroll-page-wrapper {
        margin-bottom: 0.5rem !important;
    }

    /* Loading state - more compact */
    #loading {
        padding: 1rem !important;
    }

    #loading .animate-spin {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }

    #loading p {
        font-size: 0.75rem !important;
        letter-spacing: 0.1em !important;
    }

    /* Divider in controls */
    #controls .w-px {
        height: 1rem !important;
    }
}

/* Extra small landscape phones (iPhone SE, etc.) */
@media (max-width: 768px) and (max-height: 400px) and (orientation: landscape) {
    #controls {
        bottom: 4px !important;
        padding: 0.25rem 0.75rem !important;
        gap: 0.5rem !important;
        font-size: 0.75rem !important;
    }

    #controls button {
        width: 1.75rem !important;
        height: 1.75rem !important;
        font-size: 0.75rem !important;
    }

    #zoom-controls {
        right: 4px !important;
        transform: translateY(-50%) scale(0.75) !important;
        padding: 0.25rem !important;
    }

    #zoom-controls button {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    .book-container {
        transform: scale(0.65) !important;
    }

    #zoom-container {
        padding: 0.125rem !important;
        padding-bottom: 3.5rem !important;
    }

    /* Hide some less critical controls on very small landscape */
    #controls .w-px {
        display: none !important;
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    #controls {
        bottom: 16px !important;
        padding: 0.625rem 1.25rem !important;
    }

    #zoom-controls {
        right: 12px !important;
    }

    .book-container {
        transform: scale(0.9) !important;
    }
}

/* Touch-friendly enhancements for all mobile */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    button {
        min-width: 2.5rem !important;
        min-height: 2.5rem !important;
    }

    /* Better touch feedback */
    button:active {
        transform: scale(0.95) !important;
        opacity: 0.8 !important;
    }

    /* Prevent text selection on touch */
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Allow text selection in specific areas if needed */
    input,
    textarea {
        -webkit-user-select: auto;
        user-select: auto;
    }
}

/* Ensure book pages are always visible */
.stf__item {
    touch-action: pan-y pinch-zoom !important;
}