/**
 * Scrollytelling Plugin Styles
 * Minimal custom styles for scrollytelling functionality
 * Relies primarily on Tailwind CSS classes
 * 
 * @package Scrollytelling
 * @version 1.0.0
 */

/* CSS Custom Properties for theming */
:root {
    --scrollytelling-primary-color: #3b82f6;
    --scrollytelling-secondary-color: #6b7280;
    --scrollytelling-success-color: #10b981;
    --scrollytelling-warning-color: #f59e0b;
    --scrollytelling-error-color: #ef4444;
    --scrollytelling-animation-duration: 500ms;
    --scrollytelling-animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    :root {
        --scrollytelling-animation-duration: 0ms;
    }
    
    .story-step,
    .progress-bar,
    .story-container * {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }
}

/* Story Container Styles */
.story-container {
    position: relative;
    width: 100%;
    overflow: visible !important;
    height: auto;
}

/* Sticky Graphic Overlay Container */
.story-container-sticky {
    position: relative;
    width: 100%;
    overflow: visible !important;
}

/* Full-width alignment for sticky story containers */
.wp-block-scrollytelling-sticky-story-container.alignfull {
    width: 100vw;
    max-width: none !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
}

/* Wide alignment for sticky story containers */
.wp-block-scrollytelling-sticky-story-container.alignwide {
    width: 100%;
    max-width: var(--wp--style--global--wide-size, 1200px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Override WordPress layout constraints for sticky story containers */
.is-layout-constrained > .wp-block-scrollytelling-sticky-story-container.alignfull,
.is-layout-constrained > .wp-block-scrollytelling-sticky-story-container.alignwide {
    max-width: none !important;
}

.is-layout-constrained > .wp-block-scrollytelling-sticky-story-container.alignfull {
    width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
}

.is-layout-constrained > .wp-block-scrollytelling-sticky-story-container.alignwide {
    width: 100% !important;
    max-width: var(--wp--style--global--wide-size, 1200px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Sticky Background Graphic */
.story-sticky-graphic {
    position: sticky;
    top: 0;
    width: 100vw;
    height: 100vh;
    left: 50%;
    margin-left: -50vw;
    z-index: 1;
    
    /* Background styling */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: local;
}

/* Sticky graphic for wide alignment containers */
.alignwide .story-sticky-graphic {
    width: 100%;
    left: 0;
    margin-left: 0;
}

/* Scrolling Content Container */
.story-scrolling-content {
    position: relative;
    z-index: 2;
    pointer-events: none; /* Allow interaction with background */
}

/* Text Overlay Sections */
.story-text-overlay {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    pointer-events: auto; /* Re-enable interaction for text */
}

/* Text Panel Styling */
.story-text-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0;
    padding: 2rem;
    max-width: 40rem;
    margin: 0 auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    
    /* Initial hidden state */
    opacity: 0;
    transform: translateY(2rem);
    transition: all var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
}

/* Active text panel */
.story-text-panel.active {
    opacity: 1;
    transform: translateY(0);
}

/* Dark text panel variant */
.story-text-panel.dark {
    background: rgba(0, 0, 0, 0.85);
    color: white;
}

/* Transparent text panel variant */
.story-text-panel.transparent {
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
}

/* Ensure WordPress block wrappers don't create scroll contexts */
.wp-block-scrollytelling-story-container,
.wp-block-scrollytelling-story-container > *,
.story-content,
.story-content > * {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* Prevent any nested containers from creating scrollbars */
.story-container * {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* Target WordPress editor and theme containers that might create scrollbars */
.wp-block,
.wp-block-group,
.wp-block-column,
.wp-block-columns,
.entry-content,
.post-content,
.content-area,
.site-content,
.main-content,
iframe[name*="editor"] {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* Specifically target any iframe or embedded content */
.wp-block-scrollytelling-story-container iframe,
.story-container iframe {
    overflow: hidden !important;
}

/* Hide scrollbars on any potential problem elements */
.story-container ::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.story-container {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

/* Progress Bar Styles */
.story-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--scrollytelling-primary-color), var(--scrollytelling-success-color));
    transition: width var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* Story Step Base Styles */
.story-step {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: all var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
    
    /* Initial hidden state */
    opacity: 0;
    transform: translateY(2rem);
}

/* Active step styles */
.story-step.active {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile optimizations for sticky graphic overlay */
@media (max-width: 768px) {
    .story-sticky-graphic {
        /* Ensure proper mobile viewport coverage */
        width: 100vw;
        left: 50%;
        margin-left: -50vw;
    }
    
    .story-text-overlay {
        padding: 1rem;
    }
    
    .story-text-panel {
        padding: 1.5rem;
        max-width: calc(100vw - 2rem);
        margin: 0 1rem;
    }
    
    /* Reduce animation distances on mobile */
    .story-text-panel {
        transform: translateY(1rem);
    }
    
    .story-text-panel.active {
        transform: translateY(0);
    }
}

/* Tablet optimizations for sticky graphic overlay */
@media (min-width: 769px) and (max-width: 1024px) {
    .story-text-overlay {
        padding: 1.5rem;
    }
    
    .story-text-panel {
        max-width: 35rem;
    }
}

/* Text panel animation variants */
.story-text-panel[data-animation-type="slide-left"] {
    transform: translateX(2rem) translateY(2rem);
}

.story-text-panel[data-animation-type="slide-left"].active {
    transform: translateX(0) translateY(0);
}

.story-text-panel[data-animation-type="slide-right"] {
    transform: translateX(-2rem) translateY(2rem);
}

.story-text-panel[data-animation-type="slide-right"].active {
    transform: translateX(0) translateY(0);
}

.story-text-panel[data-animation-type="scale-in"] {
    transform: scale(0.95) translateY(2rem);
}

.story-text-panel[data-animation-type="scale-in"].active {
    transform: scale(1) translateY(0);
}

.story-text-panel[data-animation-type="fade-in"] {
    opacity: 0;
    transform: translateY(0);
}

.story-text-panel[data-animation-type="fade-in"].active {
    opacity: 1;
    transform: translateY(0);
}

/* Step content container */
.story-step > div {
    max-width: 64rem;
    margin: 0 auto;
    width: 100%;
}

/* Animation variants */
.story-step[data-animation-type="slide-left"] {
    transform: translateX(2rem) translateY(2rem);
}

.story-step[data-animation-type="slide-left"].active {
    transform: translateX(0) translateY(0);
}

.story-step[data-animation-type="slide-right"] {
    transform: translateX(-2rem) translateY(2rem);
}

.story-step[data-animation-type="slide-right"].active {
    transform: translateX(0) translateY(0);
}

.story-step[data-animation-type="scale-in"] {
    transform: scale(0.95) translateY(2rem);
}

.story-step[data-animation-type="scale-in"].active {
    transform: scale(1) translateY(0);
}

/* Typography enhancements for story content */
.story-step h1,
.story-step h2,
.story-step h3,
.story-step h4,
.story-step h5,
.story-step h6 {
    line-height: 1.2;
    margin-bottom: 1rem;
}

.story-step p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.story-step img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .story-step {
        padding: 1rem;
        min-height: 100vh;
    }
    
    .story-progress {
        height: 3px;
    }
    
    .story-step > div {
        max-width: 100%;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .story-step {
        padding: 1.5rem;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .progress-bar {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .story-progress {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* Focus styles for accessibility */
.story-step:focus-visible {
    outline: 2px solid var(--scrollytelling-primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .story-progress,
    .progress-bar {
        display: none;
    }
    
    .story-step {
        opacity: 1 !important;
        transform: none !important;
        min-height: auto;
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }
}

/* Editor-specific styles */
.story-container-editor {
    border: 2px dashed #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    background-color: #f9fafb;
}

/* Sticky Story Step Editor Styles */
.story-step-editor-container {
    position: relative;
    isolation: isolate;
}

.story-step-background-preview {
    pointer-events: none !important;
    user-select: none;
}

.story-step-info-header {
    pointer-events: none;
    user-select: none;
}

.story-step-content-area {
    /* Ensure content area can receive interactions */
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
}

/* Ensure InnerBlocks and their children can be interacted with */
.story-step-content-area .block-editor-inner-blocks,
.story-step-content-area .wp-block,
.story-step-content-area .block-editor-block-list__block,
.story-step-content-area .components-button,
.story-step-content-area .block-editor-media-placeholder,
.story-step-content-area .block-editor-media-placeholder__button {
    pointer-events: auto !important;
    position: relative;
    z-index: 11;
}

/* Image blocks are no longer supported - CSS removed for cleaner editor experience */

/* Block appender button styling */
.story-step-content-area .block-list-appender,
.story-step-content-area .block-editor-button-block-appender {
    pointer-events: auto !important;
    z-index: 12 !important;
    position: relative;
}

/* Prevent any overlay from blocking interactions */
.story-step-editor .story-step-preview {
    pointer-events: none;
}

.story-step-editor .story-step-preview > * {
    pointer-events: auto;
}

.story-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.story-header h3 {
    margin: 0;
    color: #374151;
    font-size: 1.125rem;
    font-weight: 600;
}

.story-info {
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.story-info code {
    background-color: #e5e7eb;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.story-progress-preview {
    border-radius: 0.125rem;
    overflow: hidden;
}

.story-step-editor {
    border-radius: 0.5rem;
    margin: 1rem 0;
    position: relative;
}

.step-header {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.step-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
}

.step-settings {
    margin-top: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Loading states */
.story-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

.story-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 2px solid transparent;
    border-top: 2px solid var(--scrollytelling-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Sticky graphic loading states */
.story-sticky-graphic.scrollytelling-loading {
    position: relative;
}

.scrollytelling-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.scrollytelling-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: scrollytelling-spin 1s linear infinite;
    margin-bottom: 0.75rem;
}

.scrollytelling-loading-text {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
}

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

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

/* Enhanced background image transitions */
.story-sticky-graphic {
    position: sticky;
    top: 0;
    width: 100vw;
    height: 100vh;
    left: 50%;
    margin-left: -50vw;
    z-index: 1;
    
    /* Background styling */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: local;
    
    /* Smooth transitions for preloaded images */
    will-change: background-image, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Preloading optimization */
.story-sticky-graphic.scrollytelling-preloaded {
    transition: background-image 0.6s ease-in-out;
}

/* Mobile loading indicator adjustments */
@media (max-width: 768px) {
    .scrollytelling-loading-indicator {
        padding: 1rem 1.5rem;
        border-radius: 0.5rem;
    }
    
    .scrollytelling-spinner {
        width: 1.5rem;
        height: 1.5rem;
        border-width: 2px;
        margin-bottom: 0.5rem;
    }
    
    .scrollytelling-loading-text {
        font-size: 0.75rem;
    }
}

/* Reduced motion support for loading indicators */
@media (prefers-reduced-motion: reduce) {
    .scrollytelling-spinner {
        animation: none;
        border: 3px solid rgba(255, 255, 255, 0.5);
        border-top: 3px solid white;
    }
    
    .story-container.loading::after {
        animation: none;
        border: 2px solid var(--scrollytelling-primary-color);
    }
}

/* Error states */
.story-container.error {
    border: 2px solid var(--scrollytelling-error-color);
    background-color: rgba(239, 68, 68, 0.05);
}

.story-container.error::before {
    content: '⚠️ Scrollytelling Error: Check console for details';
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    padding: 0.5rem;
    background-color: var(--scrollytelling-error-color);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 1000;
}

/* Success states */
.story-container.loaded {
    animation: fadeIn var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Custom background colors for story steps */
.scrollytelling-bg-transparent { 
    background-color: transparent; 
}

.scrollytelling-bg-white { 
    background-color: #ffffff; 
}

.scrollytelling-bg-gray-light { 
    background-color: #f3f4f6; 
}

.scrollytelling-bg-gray-dark { 
    background-color: #1f2937; 
}

.scrollytelling-bg-black { 
    background-color: #000000; 
}

/* Mobile-specific fixes for container width issues */
@media (max-width: 768px) {
    .wp-block-scrollytelling-sticky-story-container.alignfull {
        width: 100%;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .story-sticky-graphic {
        position: sticky;
        top: 0;
        width: 100%;
        height: 100vh;
        left: 50%;
        margin-left: 0;
        z-index: 1;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: local;
        will-change: background-image, opacity;
        backface-visibility: hidden;
        transform: translateZ(0);
    }
}

/* Custom text colors for story steps */
.scrollytelling-text-default { 
    color: inherit; 
}

.scrollytelling-text-white { 
    color: #ffffff; 
}

.scrollytelling-text-black { 
    color: #000000; 
}

.scrollytelling-text-gray { 
    color: #4b5563; 
}

/* Height utilities */
.scrollytelling-min-h-screen { 
    min-height: 100vh; 
}

.scrollytelling-min-h-96 { 
    min-height: 24rem; 
}

.scrollytelling-min-h-auto { 
    min-height: auto; 
}

/* Layout utilities */
.scrollytelling-flex {
    display: flex;
}

.scrollytelling-items-center {
    align-items: center;
}

.scrollytelling-justify-center {
    justify-content: center;
}

.scrollytelling-p-8 {
    padding: 2rem;
}

.scrollytelling-max-w-4xl {
    max-width: 56rem;
}

.scrollytelling-mx-auto {
    margin-left: auto;
    margin-right: auto;
}

/* Animation utilities */
.scrollytelling-opacity-0 {
    opacity: 0;
}

.scrollytelling-translate-y-8 {
    transform: translateY(2rem);
}

.scrollytelling-translate-x-8 {
    transform: translateX(2rem);
}

.scrollytelling--translate-x-8 {
    transform: translateX(-2rem);
}

.scrollytelling-scale-95 {
    transform: scale(0.95);
}

.scrollytelling-transition-all {
    transition: all var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
}

.scrollytelling-duration-500 {
    transition-duration: 500ms;
}

/* Utility classes for common patterns */
.scrollytelling-fade-in {
    opacity: 0;
    transition: opacity var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
}

.scrollytelling-fade-in.visible {
    opacity: 1;
}

.scrollytelling-slide-up {
    transform: translateY(2rem);
    opacity: 0;
    transition: all var(--scrollytelling-animation-duration) var(--scrollytelling-animation-easing);
}

.scrollytelling-slide-up.visible {
    transform: translateY(0);
    opacity: 1;
}

/* WordPress Core Block Styling within Story Steps */

/* Paragraph blocks */
.story-text-panel .wp-block-paragraph,
.story-step .wp-block-paragraph {
    margin-bottom: 1.5rem;
    line-height: 1.7;
    font-size: 1.125rem;
}

.story-text-panel .wp-block-paragraph:last-child,
.story-step .wp-block-paragraph:last-child {
    margin-bottom: 0;
}

/* Heading blocks */
.story-text-panel .wp-block-heading,
.story-step .wp-block-heading {
    margin-bottom: 1.5rem;
    line-height: 1.2;
    font-weight: 700;
}

.story-text-panel .wp-block-heading:last-child,
.story-step .wp-block-heading:last-child {
    margin-bottom: 0;
}

/* Image blocks */
.story-text-panel .wp-block-image,
.story-step .wp-block-image {
    margin-bottom: 2rem;
    text-align: center;
}

.story-text-panel .wp-block-image:last-child,
.story-step .wp-block-image:last-child {
    margin-bottom: 0;
}

.story-text-panel .wp-block-image img,
.story-step .wp-block-image img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.story-text-panel .wp-block-image img:hover,
.story-step .wp-block-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

/* Image alignment */
.story-text-panel .wp-block-image.alignleft,
.story-step .wp-block-image.alignleft {
    float: left;
    margin-right: 2rem;
    margin-bottom: 1rem;
    max-width: 50%;
}

.story-text-panel .wp-block-image.alignright,
.story-step .wp-block-image.alignright {
    float: right;
    margin-left: 2rem;
    margin-bottom: 1rem;
    max-width: 50%;
}

.story-text-panel .wp-block-image.aligncenter,
.story-step .wp-block-image.aligncenter {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.story-text-panel .wp-block-image.alignwide,
.story-step .wp-block-image.alignwide {
    width: 100%;
    max-width: none;
}

.story-text-panel .wp-block-image.alignfull,
.story-step .wp-block-image.alignfull {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* Image captions */
.story-text-panel .wp-block-image figcaption,
.story-step .wp-block-image figcaption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
    font-style: italic;
}

/* List blocks */
.story-text-panel .wp-block-list,
.story-step .wp-block-list {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.story-text-panel .wp-block-list:last-child,
.story-step .wp-block-list:last-child {
    margin-bottom: 0;
}

.story-text-panel .wp-block-list li,
.story-step .wp-block-list li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.story-text-panel .wp-block-list li:last-child,
.story-step .wp-block-list li:last-child {
    margin-bottom: 0;
}

/* Quote blocks */
.story-text-panel .wp-block-quote,
.story-step .wp-block-quote {
    margin: 2rem 0;
    padding: 1.5rem;
    border-left: 4px solid var(--scrollytelling-primary-color);
    background-color: rgba(59, 130, 246, 0.05);
    font-style: italic;
    font-size: 1.25rem;
    line-height: 1.6;
}

.story-text-panel .wp-block-quote:last-child,
.story-step .wp-block-quote:last-child {
    margin-bottom: 0;
}

.story-text-panel .wp-block-quote cite,
.story-step .wp-block-quote cite {
    display: block;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-style: normal;
    color: #6b7280;
}

/* Separator blocks */
.story-text-panel .wp-block-separator,
.story-step .wp-block-separator {
    margin: 2rem auto;
    border: none;
    border-top: 2px solid #e5e7eb;
    width: 50%;
    max-width: 200px;
}

.story-text-panel .wp-block-separator:last-child,
.story-step .wp-block-separator:last-child {
    margin-bottom: 0;
}

/* Spacer blocks */
.story-text-panel .wp-block-spacer,
.story-step .wp-block-spacer {
    clear: both;
}

/* Group blocks */
.story-text-panel .wp-block-group,
.story-step .wp-block-group {
    margin-bottom: 2rem;
}

.story-text-panel .wp-block-group:last-child,
.story-step .wp-block-group:last-child {
    margin-bottom: 0;
}

.story-text-panel .wp-block-group__inner-container,
.story-step .wp-block-group__inner-container {
    padding: 1.5rem;
    border-radius: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
}

/* Mobile optimizations for core blocks */
@media (max-width: 768px) {
    .story-text-panel .wp-block-paragraph,
    .story-step .wp-block-paragraph {
        font-size: 1rem;
        margin-bottom: 1.25rem;
    }
    
    .story-text-panel .wp-block-heading,
    .story-step .wp-block-heading {
        margin-bottom: 1.25rem;
    }
    
    .story-text-panel .wp-block-image.alignleft,
    .story-step .wp-block-image.alignleft,
    .story-text-panel .wp-block-image.alignright,
    .story-step .wp-block-image.alignright {
        float: none;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
        text-align: center;
    }
    
    .story-text-panel .wp-block-quote,
    .story-step .wp-block-quote {
        margin: 1.5rem 0;
        padding: 1rem;
        font-size: 1.125rem;
    }
    
    .story-text-panel .wp-block-list,
    .story-step .wp-block-list {
        padding-left: 1.25rem;
    }
}

/* Dark mode support for core blocks */
@media (prefers-color-scheme: dark) {
    .story-text-panel .wp-block-quote,
    .story-step .wp-block-quote {
        background-color: rgba(59, 130, 246, 0.1);
        border-left-color: var(--scrollytelling-primary-color);
    }
    
    .story-text-panel .wp-block-separator,
    .story-step .wp-block-separator {
        border-top-color: #374151;
    }
    
    .story-text-panel .wp-block-group__inner-container,
    .story-step .wp-block-group__inner-container {
        background-color: rgba(0, 0, 0, 0.1);
    }
}

/* Ensure proper clearfix for floated images */
.story-text-panel::after,
.story-step::after {
    content: "";
    display: table;
    clear: both;
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}

/* Ensure proper stacking context */
.story-container {
    isolation: isolate;
}

/* Performance optimizations */
.story-step {
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
}

.progress-bar {
    will-change: width;
    transform: translateZ(0);
}
