/**
 * Interactive Scroll Widget Styles
 * Advanced 3-page scroll system with layer-based effects
 *
 * @version 2.0.0
 */

/* ============================================
   WRAPPER & BASE STRUCTURE
   ============================================ */

.gabara-interactive-scroll-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
}

.gabara-scroll-page {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.gabara-scroll-page[data-transitioning="true"] {
    pointer-events: none;
}

/* ============================================
   PAGE 1: FLOATING CLOSED SCROLL
   ============================================ */

.gabara-scroll-page1 {
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* Overlay for color effects */
.gabara-scroll-page1::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.gabara-scroll-image-container {
    position: relative;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gabara-scroll-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.gabara-scroll-clickable {
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.gabara-scroll-clickable:active {
    transform: scale(0.95);
}

.gabara-scroll-clickable:hover {
    transform: scale(1.05);
}

/* Placeholder when no image uploaded */
.gabara-scroll-placeholder {
    width: 300px;
    height: 400px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.gabara-scroll-placeholder p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    margin: 0;
}

/* ============================================
   PAGE 1: HOVER EFFECTS
   ============================================ */

/* Glow Effect */
.gabara-scroll-page1[data-hover-effect="glow"] .gabara-scroll-clickable:hover {
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 60px rgba(255, 255, 255, 0.4));
}

/* Scale Effect */
.gabara-scroll-page1[data-hover-effect="scale"] .gabara-scroll-clickable:hover {
    transform: scale(1.05);
}

/* Float Effect */
.gabara-scroll-page1[data-hover-effect="float"] .gabara-scroll-clickable {
    animation: gabara-float 3s ease-in-out infinite;
}

@keyframes gabara-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Pulse Effect */
.gabara-scroll-page1[data-hover-effect="pulse"] .gabara-scroll-clickable {
    animation: gabara-pulse 2s ease-in-out infinite;
}

@keyframes gabara-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

/* ============================================
   EFFECTS LAYER SYSTEM
   ============================================ */

.gabara-effects-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* Behind layer (z-index below scroll) */
.gabara-effects-behind {
    z-index: 10;
}

/* Front layer (z-index above scroll) */
.gabara-effects-front {
    z-index: 100;
}

.gabara-effects-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================
   PAGE 2: CHAPTER SELECTION
   ============================================ */

.gabara-scroll-page2 {
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: auto;
}

/* Overlay for color effects */
.gabara-scroll-page2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Page 2 Background Image */
.gabara-page2-background-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gabara-page2-background-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.gabara-scroll-container {
    position: relative;
    z-index: 50;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.gabara-scroll-content-wrapper {
    position: relative;
    z-index: 2;
    padding: 60px 40px;
    width: 100%;
    box-sizing: border-box;
}

/* Title & Subtitle */
.gabara-page2-title {
    text-align: center;
    font-size: 42px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.gabara-page2-subtitle {
    text-align: center;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 50px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Chapter Grid */
.gabara-chapters-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
}

.gabara-chapters-grid::-webkit-scrollbar {
    width: 8px;
}

.gabara-chapters-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.gabara-chapters-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.gabara-chapters-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.gabara-chapter-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 20px 25px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    width: 100%;
    min-height: 100px;
}

.gabara-chapter-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.gabara-chapter-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.gabara-chapter-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gabara-chapter-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.gabara-chapter-title {
    font-size: 22px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.gabara-chapter-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    line-height: 1.5;
}

/* Back Button */
.gabara-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 12px 24px;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    margin-top: 30px;
    border: none;
}

.gabara-back-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-5px);
}

.gabara-back-icon {
    font-size: 20px;
}

/* ============================================
   PAGE 3: PLACEHOLDER (for now)
   ============================================ */

.gabara-scroll-page3 {
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
}

/* Page 3 Background Image */
.gabara-page3-background-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gabara-page3-background-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.gabara-chapter-content-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    max-width: 1000px;
    max-height: 90vh;
    margin: 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 60px 40px;
    box-sizing: border-box;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.gabara-chapter-content-wrapper::-webkit-scrollbar {
    width: 8px;
}

.gabara-chapter-content-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.gabara-chapter-content-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.gabara-chapter-content-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.gabara-chapter-content {
    width: 100%;
    max-width: 1200px;
    margin: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.gabara-chapter-content[data-chapter].hidden {
    display: none;
}

.gabara-chapter-header {
    text-align: center;
    margin-bottom: 40px;
}

.gabara-chapter-header .chapter-icon {
    font-size: 48px;
    margin-bottom: 20px;
    display: block;
}

.gabara-chapter-header h2 {
    font-size: 36px;
    margin: 0 0 15px 0;
    color: #fff;
    font-weight: 700;
}

.gabara-chapter-header .chapter-description {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.gabara-chapter-content-title {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 30px 0;
    text-align: center;
}

.gabara-content-blocks {
    display: flex;
    flex-direction: column;
    gap: 40px;
    flex: 1;
    margin-bottom: 20px;
}

.gabara-content-block {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.gabara-block-heading {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 15px 0;
    order: 0 !important;
}

.gabara-content-block {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    animation: fadeInUp 0.6s ease-out;
}

.gabara-content-block.text-only {
    max-width: 800px;
    margin: 0 auto;
}

/* Layout: Text Top */
.gabara-content-block[data-layout="text_top"] {
    flex-direction: column;
}

/* Layout: Media Top */
.gabara-content-block[data-layout="media_top"] {
    flex-direction: column;
}

.gabara-content-block[data-layout="media_top"] .gabara-block-text {
    order: 2;
}

.gabara-content-block[data-layout="media_top"] .gabara-block-media {
    order: 1;
}

/* Layout: Text Left / Media Right */
.gabara-content-block[data-layout="text_left"] {
    flex-direction: row;
}

.gabara-content-block[data-layout="text_left"] .gabara-block-text {
    order: 1;
    flex: 1;
}

.gabara-content-block[data-layout="text_left"] .gabara-block-media {
    order: 2;
    flex: 0 0 auto;
}

/* Layout: Media Left / Text Right */
.gabara-content-block[data-layout="text_right"] {
    flex-direction: row;
}

.gabara-content-block[data-layout="text_right"] .gabara-block-text {
    order: 2;
    flex: 1;
}

.gabara-content-block[data-layout="text_right"] .gabara-block-media {
    order: 1;
    flex: 0 0 auto;
}

.gabara-block-text {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.8;
    font-size: 16px;
}

.gabara-block-text h1,
.gabara-block-text h2,
.gabara-block-text h3,
.gabara-block-text h4,
.gabara-block-text h5,
.gabara-block-text h6 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

.gabara-block-text p {
    margin: 0 0 15px 0;
}

.gabara-block-text p:last-child {
    margin-bottom: 0;
}

.gabara-block-text ul,
.gabara-block-text ol {
    margin: 0 0 15px 20px;
    padding: 0;
}

.gabara-block-text li {
    margin-bottom: 8px;
}

.gabara-block-text a {
    color: #4a90e2;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.gabara-block-text a:hover {
    color: #6bb0ff;
}

.gabara-block-media {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.2);
}

.gabara-block-media img,
.gabara-block-media video,
.gabara-block-media iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    object-fit: cover;
}

.gabara-block-media iframe,
.gabara-block-video iframe {
    aspect-ratio: 16 / 9;
    min-height: 300px;
}

.gabara-local-video {
    max-width: 100%;
    border-radius: 8px;
    object-fit: contain;
}

.gabara-block-video {
    width: 100%;
    height: 100%;
}

/* Audio Narration */
.gabara-block-audio {
    margin-top: 15px;
    width: 100%;
}

.gabara-narration-audio {
    width: 100%;
    max-width: 500px;
    height: 40px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.3);
}

/* Text Alignment Controls */
.gabara-text-align-left {
    text-align: left;
}

.gabara-text-align-center {
    text-align: center;
}

.gabara-text-align-right {
    text-align: right;
}

/* Media Alignment Controls */
.gabara-block-media.gabara-align-left {
    margin-right: auto;
    margin-left: 0;
}

.gabara-block-media.gabara-align-center {
    margin-left: auto;
    margin-right: auto;
}

.gabara-block-media.gabara-align-right {
    margin-left: auto;
    margin-right: 0;
}

.gabara-chapter-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
    margin-top: auto;
    padding-top: 30px;
    padding-bottom: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    flex-shrink: 0;
}

.gabara-chapter-nav-button,
.gabara-chapter-navigation .gabara-back-button,
.gabara-nav-button {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    backdrop-filter: blur(10px);
    white-space: nowrap;
    flex: 0 1 auto;
}

.gabara-chapter-nav-button:hover,
.gabara-chapter-navigation .gabara-back-button:hover,
.gabara-nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.gabara-chapter-nav-button:active,
.gabara-chapter-navigation .gabara-back-button:active {
    transform: translateY(0);
}

.gabara-chapter-nav-button.disabled,
.gabara-prev-chapter.disabled,
.gabara-next-chapter.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   TRANSITIONS & ANIMATIONS
   ============================================ */

.gabara-page-transition-fade-out {
    opacity: 0;
    transform: scale(0.95);
}

.gabara-page-transition-fade-in {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .gabara-scroll-image {
        max-width: 90%;
    }

    .gabara-chapters-grid {
        gap: 12px;
        max-height: 55vh;
    }

    .gabara-page2-title {
        font-size: 36px;
    }

    .gabara-scroll-content-wrapper {
        padding: 40px 30px;
    }

    .gabara-scroll-container {
        max-width: 90%;
    }

    .gabara-back-button {
        font-size: 15px;
        padding: 10px 20px;
    }

    .gabara-chapter-item {
        padding: 15px 20px;
        gap: 15px;
        min-height: 80px;
    }

    .gabara-chapter-icon {
        width: 70px;
        height: 70px;
    }

    .gabara-chapter-title {
        font-size: 20px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .gabara-scroll-page {
        min-height: 100vh;
    }

    .gabara-scroll-image {
        max-width: 85%;
    }

    .gabara-scroll-placeholder {
        width: 200px;
        height: 300px;
    }

    .gabara-chapters-grid {
        gap: 10px;
        max-height: 50vh;
    }

    .gabara-page2-title {
        font-size: 28px;
    }

    .gabara-page2-subtitle {
        font-size: 16px;
        margin-bottom: 30px;
    }

    .gabara-scroll-content-wrapper {
        padding: 30px 20px;
    }

    .gabara-scroll-container {
        max-width: 95%;
        padding: 20px 10px;
    }

    .gabara-chapter-item {
        padding: 15px;
        gap: 12px;
        min-height: 70px;
    }

    .gabara-chapter-icon {
        width: 60px;
        height: 60px;
    }

    .gabara-chapter-title {
        font-size: 18px;
    }

    .gabara-back-button {
        font-size: 14px;
        padding: 10px 18px;
        margin-top: 20px;
    }

    /* Page 2 Background adjustment */
    .gabara-page2-background-image,
    .gabara-page3-background-image {
        max-width: 100%;
        max-height: 100%;
    }

    /* Page 3 Responsive - Tablet */
    .gabara-chapter-content-wrapper {
        padding: 40px 30px;
        max-width: 90%;
    }

    .gabara-chapter-header h2 {
        font-size: 28px;
    }

    .gabara-chapter-header .chapter-icon {
        font-size: 40px;
    }

    .gabara-content-block[data-layout="text_left"],
    .gabara-content-block[data-layout="text_right"] {
        flex-direction: column;
    }

    .gabara-content-block[data-layout="text_left"] .gabara-block-text,
    .gabara-content-block[data-layout="text_right"] .gabara-block-text {
        order: 1;
    }

    .gabara-content-block[data-layout="text_left"] .gabara-block-media,
    .gabara-content-block[data-layout="text_right"] .gabara-block-media {
        order: 2;
        width: 100%;
    }

    .gabara-block-media iframe {
        min-height: 250px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .gabara-scroll-image {
        max-width: 95%;
    }

    .gabara-scroll-placeholder {
        width: 180px;
        height: 280px;
    }

    .gabara-scroll-placeholder p {
        font-size: 14px;
    }

    /* Page 2 - Ultra Small Screens */
    .gabara-page2-title {
        font-size: 24px;
    }

    .gabara-page2-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .gabara-chapters-grid {
        gap: 8px;
        max-height: 45vh;
    }

    .gabara-chapter-item {
        padding: 12px;
        gap: 10px;
        min-height: 60px;
    }

    .gabara-chapter-icon {
        width: 50px;
        height: 50px;
    }

    .gabara-chapter-title {
        font-size: 16px;
    }

    .gabara-chapter-description {
        font-size: 13px;
    }

    /* Page 3 Responsive - Mobile */
    .gabara-chapter-content-wrapper {
        padding: 30px 20px;
        max-width: 95%;
        max-height: 85vh;
    }

    .gabara-chapter-header h2 {
        font-size: 24px;
    }

    .gabara-chapter-header .chapter-icon {
        font-size: 36px;
    }

    .gabara-chapter-header .chapter-description {
        font-size: 16px;
    }

    .gabara-content-blocks {
        gap: 30px;
    }

    .gabara-content-block {
        gap: 20px;
    }

    .gabara-block-text {
        font-size: 15px;
    }

    .gabara-block-media iframe {
        min-height: 200px;
    }

    .gabara-chapter-navigation {
        flex-direction: column;
        gap: 12px;
        margin-top: 30px;
        padding-top: 25px;
    }

    .gabara-chapter-nav-button,
    .gabara-chapter-navigation .gabara-back-button,
    .gabara-nav-button {
        width: 100%;
        padding: 12px 20px;
        font-size: 13px;
        justify-content: center;
    }

    .gabara-back-button {
        width: 100%;
        justify-content: center;
        font-size: 13px;
    }

    .gabara-narration-audio {
        height: 35px;
    }

    .gabara-scroll-container {
        max-width: 100%;
        padding: 15px 10px;
    }

    .gabara-page2-background-image,
    .gabara-page3-background-image {
        width: 100% !important;
        height: 100% !important;
    }
}

/* ============================================
   EDITOR MODE STYLES
   ============================================ */

[data-editor-mode="true"] .gabara-scroll-page {
    min-height: 600px;
}

[data-editor-mode="true"] .gabara-scroll-placeholder {
    border-color: #2196F3;
}

[data-editor-mode="true"] .gabara-scroll-placeholder p {
    color: #2196F3;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

.gabara-effects-canvas {
    will-change: transform;
    transform: translateZ(0);
}

.gabara-scroll-image {
    will-change: transform, filter;
    transform: translateZ(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    .gabara-scroll-page,
    .gabara-scroll-image,
    * {
        animation: none !important;
        transition: none !important;
    }
}