/**
 * TPPL Optional Sections Stylesheet
 * 
 * Dedicated styles for Swiss Army Knife optional content sections.
 * Maintains TPPL aesthetic: purple gradient palette, clean typography, responsive design.
 * 
 * File: assets/css/optional-sections.css
 * 
 * @package TPPL
 * @since 1.0.0
 */

/* ========================================
   BASE SECTION STYLES
   ======================================== */

   .optional-section {
    width: 100%;
    position: relative;
    margin: 0;
    box-sizing: border-box;
}

.optional-section__inner {
    width: 100%;
    position: relative;
}

/* Layout Modes */
.optional-section--contained .optional-section__inner {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.optional-section--full_width .optional-section__inner {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* ========================================
   PADDING UTILITIES
   ======================================== */

.padding-top-none { padding-top: 0; }
.padding-top-small { padding-top: 1rem; }
.padding-top-medium { padding-top: 2rem; }
.padding-top-large { padding-top: 4rem; }

.padding-bottom-none { padding-bottom: 0; }
.padding-bottom-small { padding-bottom: 1rem; }
.padding-bottom-medium { padding-bottom: 2rem; }
.padding-bottom-large { padding-bottom: 4rem; }

/* ========================================
   BORDER STYLES
   ======================================== */

.border-none { border: none; }

.border-subtle {
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: 8px;
}

.border-accent {
    border-left: 3px solid #9b59b6;
    border-radius: 4px;
}

.border-bold {
    border: 5px solid #9b59b6;
    border-radius: 12px;
}

/* ========================================
   MEDIA WRAPPER & ALIGNMENT
   
   CENTERING STRATEGY:
   1. Wrapper uses flexbox to control horizontal alignment
   2. Child elements (img/video) are inline-block to respect flex
   3. Full-width mode overrides centering to stretch content
   ======================================== */

.optional-section__media-wrapper {
    position: relative;
    width: 100%;
    display: block; /* Default: no flex, natural flow */
}

/* Flexbox Alignment Classes (Applied by PHP) */
.media-center {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column; /* Stack image + caption vertically */
}

.media-left {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;
}

.media-right {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    flex-direction: column;
}

/* Images - Must be inline-block to work with flex centering */
.optional-section__image {
    max-width: 100%;
    height: auto;
    display: inline-block; /* CRITICAL: Allows flex to center it */
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(155, 89, 182, 0.3);
}

/* Full-width images override centering */
.optional-section--full_width .optional-section__image {
    border-radius: 0;
    width: 100%;
    display: block; /* Full-width = stretch to container */
}

/* Full-width mode disables flex centering */
.optional-section--full_width .media-center,
.optional-section--full_width .media-left,
.optional-section--full_width .media-right {
    display: block; /* Override flex for full-width */
}

/* ========================================
   VIDEO CONTAINER - FIXED VERSION
   ======================================== */

/* Base video container */
.optional-section__video {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(155, 89, 182, 0.3);
    display: inline-block; /* Allows flex centering */
}

/* Full-width videos */
.optional-section--full_width .optional-section__video {
    border-radius: 0;
    display: block;
}

/* ========================================
   VIDEO EMBEDS (YouTube, Vimeo)
   ======================================== */

.optional-section--video_embed .optional-section__video {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
}

.optional-section--video_embed .optional-section__video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ========================================
   VIDEO UPLOADS (MP4 files)
   ======================================== */

/* CRITICAL FIX: Remove absolute positioning for uploaded videos */
.optional-section--video_upload .optional-section__video {
    padding-bottom: 0; /* No aspect ratio hack needed */
    height: auto; /* Let video determine height */
}

.optional-section--video_upload .optional-section__video video {
    position: relative; /* NOT absolute - this was the bug */
    top: auto;
    left: auto;
    width: 100%;
    height: auto;
    display: block;
}

/* Fallback for video-element class */
.optional-section__video-element {
    position: relative; /* NOT absolute */
    width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   CAPTION STYLING
   ======================================== */

.optional-section__caption {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(155, 89, 182, 0.15);
    border-left: 3px solid #9b59b6;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
    font-style: italic;
    width: 100%;
    box-sizing: border-box;
}

/* Caption Alignment - Inherits from parent flex */
.media-center .optional-section__caption { 
    text-align: center;
    align-self: center; /* Flex child alignment */
}

.media-left .optional-section__caption { 
    text-align: left;
    align-self: flex-start;
}

.media-right .optional-section__caption { 
    text-align: right;
    align-self: flex-end;
}

/* Full-width caption centering */
.optional-section--full_width .optional-section__caption {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* ========================================
   TEXT OVERLAY ON MEDIA
   ======================================== */

.optional-section__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    z-index: 10;
    border-radius: 8px;
    pointer-events: none;
}

.optional-section--full_width .optional-section__overlay {
    border-radius: 0;
}

.optional-section__overlay-content {
    color: #fff;
    padding: 2rem;
    width: 100%;
    pointer-events: auto;
}

/* Overlay Positions */
.optional-section__overlay--top-left { justify-content: flex-start; align-items: flex-start; }
.optional-section__overlay--top-center { justify-content: center; align-items: flex-start; }
.optional-section__overlay--top-right { justify-content: flex-end; align-items: flex-start; }
.optional-section__overlay--center { justify-content: center; align-items: center; }
.optional-section__overlay--bottom-left { justify-content: flex-start; align-items: flex-end; }
.optional-section__overlay--bottom-center { justify-content: center; align-items: flex-end; }
.optional-section__overlay--bottom-right { justify-content: flex-end; align-items: flex-end; }

/* ========================================
   TEXT/HTML CONTENT & BANNERS
   ======================================== */

.optional-section__content,
.optional-section__banner {
    width: 100%;
    box-sizing: border-box;
}

/* Standard HTML Content Box */
.optional-section__content {
    background: rgba(155, 89, 182, 0.1);
    border-left: 4px solid #9b59b6;
    padding: 2rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

/* Promotional Banner Box */
.optional-section__banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 3rem 2rem;
    border-radius: 12px;
    box-shadow: 0 15px 50px rgba(102, 126, 234, 0.4);
}

/* Text Alignment */
.align-center .optional-section__content,
.align-center .optional-section__banner {
    text-align: center;
}

.align-left .optional-section__content,
.align-left .optional-section__banner {
    text-align: left;
}

.align-right .optional-section__content,
.align-right .optional-section__banner {
    text-align: right;
}

/* Typography */
.optional-section__header {
    color: #9b59b6;
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.optional-section__banner .optional-section__header {
    color: #fff;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.optional-section__subheader {
    color: rgba(155, 89, 182, 0.8);
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 400;
}

.optional-section__banner .optional-section__subheader {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
}

.optional-section__text {
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1.5rem;
}

.optional-section__text p:last-child {
    margin-bottom: 0;
}

.optional-section__text a {
    color: #e74c3c;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s;
}

.optional-section__text a:hover {
    border-bottom-color: #e74c3c;
}

/* ========================================
   CTA BUTTON
   ======================================== */

.optional-section__cta {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #9b59b6, #764ba2);
    color: #fff;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
    cursor: pointer;
}

.optional-section__cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(155, 89, 182, 0.5);
}

.optional-section__banner .optional-section__cta {
    background: #fff;
    color: #667eea;
}

.optional-section__banner .optional-section__cta:hover {
    box-shadow: 0 10px 30px rgba(255, 255, 255, 0.3);
}

/* ========================================
   CUSTOM EMBED
   ======================================== */

.optional-section__embed {
    width: 100%;
}

/* Embed Alignment */
.align-center .optional-section__embed { 
    display: flex; 
    justify-content: center; 
}

.align-left .optional-section__embed { 
    display: flex; 
    justify-content: flex-start; 
}

.align-right .optional-section__embed { 
    display: flex; 
    justify-content: flex-end; 
}

/* ========================================
   CLICKABLE SECTION WRAPPER
   ======================================== */

a.optional-section {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.3s, box-shadow 0.3s;
}

a.optional-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 50px rgba(155, 89, 182, 0.4);
    z-index: 5;
}

/* ========================================
   ENTRANCE ANIMATIONS (AOS)
   ======================================== */

[data-aos="fade-in"] { 
    opacity: 0; 
    transition: opacity 0.6s ease; 
}

[data-aos="fade-in"].aos-animate { 
    opacity: 1; 
}

[data-aos="slide-up"] { 
    opacity: 0; 
    transform: translateY(30px); 
    transition: opacity 0.6s ease, transform 0.6s ease; 
}

[data-aos="slide-up"].aos-animate { 
    opacity: 1; 
    transform: translateY(0); 
}

[data-aos="zoom-in"] { 
    opacity: 0; 
    transform: scale(0.95); 
    transition: opacity 0.6s ease, transform 0.6s ease; 
}

[data-aos="zoom-in"].aos-animate { 
    opacity: 1; 
    transform: scale(1); 
}

/* ========================================
   DEVICE VISIBILITY
   ======================================== */

@media (min-width: 1025px) { 
    .hide-desktop { display: none !important; } 
}

@media (min-width: 768px) and (max-width: 1024px) { 
    .hide-tablet { display: none !important; } 
}

@media (max-width: 767px) { 
    .hide-mobile { display: none !important; } 
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .optional-section { 
        margin: 2rem 0; 
    }
    
    .padding-top-medium { padding-top: 1.5rem; }
    .padding-top-large { padding-top: 3rem; }
    .padding-bottom-medium { padding-bottom: 1.5rem; }
    .padding-bottom-large { padding-bottom: 3rem; }
    
    .optional-section__content { padding: 1.5rem; }
    .optional-section__banner { padding: 2rem 1.5rem; }
    
    .optional-section__banner .optional-section__header,
    .optional-section__header { 
        font-size: 1.5rem; 
    }
    
    .optional-section__subheader { font-size: 1.1rem; }
    .optional-section__caption { font-size: 0.9rem; }
    .optional-section__overlay-content { padding: 1rem; }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

a.optional-section:focus,
.optional-section__cta:focus {
    outline: 2px solid #9b59b6;
    outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .optional-section, 
    .optional-section__cta, 
    a.optional-section, 
    [data-aos] {
        transition: none !important;
        animation: none !important;
    }
}