/**
 * Video Banner Block - Frontend Styles
 */

.wp-block-webtron-video-banner {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Keep below navigation dropdowns */
    z-index: var(--z-base, 1);
    /* Fallback aspect ratio - inline max-height takes precedence when set */
    aspect-ratio: 16 / 9;
}

/* Mobile aspect ratios for better video fit */
@media (max-width: 768px) {
    .wp-block-webtron-video-banner {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 480px) {
    .wp-block-webtron-video-banner {
        aspect-ratio: 1 / 1;
    }
}

.wp-block-webtron-video-banner.alignfull {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.wp-block-webtron-video-banner.alignwide {
    width: calc(100% + 80px);
    margin-left: -40px;
}

/* Poster/Fallback Image */
.webtron-video-banner__poster {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

/* Video - absolute positioned to fill container, scales with aspect-ratio */
.webtron-video-banner__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    object-fit: cover;
    object-position: center;
}

.webtron-video-banner__fallback-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Animated grid background (motion mode) — same layer as the video, behind overlay/content.
   Explicitly absolute + inset:0 so it's a full-bleed BACKGROUND, never an in-flow flex sibling
   of __content (that bug split the banner into two columns). The !important guards against the
   shared motion base CSS or theme resets re-flowing it. */
.wp-block-webtron-video-banner .webtron-video-banner__motion {
    position: absolute !important;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

/* ── Floating featured-doc cards (Animated Grid only, desktop only) ─────────── */
.webtron-video-banner__cards {
    position: absolute;
    inset: 0;
    z-index: 3;          /* above the grid (2), below the overlay tint (3) + content (4) */
    pointer-events: none; /* the layer ignores clicks; individual cards re-enable them */
    overflow: hidden;
}

/* Hide entirely on smaller screens — the banner is too tight for drifting cards. */
@media (max-width: 1023px) {
    .webtron-video-banner__cards {
        display: none;
    }
}

.webtron-video-banner__card {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 230px;
    padding: 9px 14px;
    border-radius: 12px;
    background: color-mix(in srgb, #0b1120 62%, transparent);
    border: 1px solid color-mix(in srgb, #ffffff 14%, transparent);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #e8f3fb;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    pointer-events: auto;  /* cards ARE clickable */
    cursor: pointer;
    opacity: 0;            /* fade in via .is-in */
    /* translate is driven by JS (drift); animate opacity + a hover lift only. */
    transition: opacity 0.5s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
    will-change: transform;
}

.webtron-video-banner__card.is-in {
    opacity: 0.92;
}

.webtron-video-banner__card:hover,
.webtron-video-banner__card:focus-visible {
    opacity: 1;
    border-color: color-mix(in srgb, var(--wds-accent, #38bdf8) 60%, transparent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    filter: brightness(1.08);
    outline: none;
}

.webtron-video-banner__card:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.webtron-video-banner__card-icon {
    font-size: 0.95rem;
    color: var(--wds-accent, #38bdf8);
    flex-shrink: 0;
}

.webtron-video-banner__card-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .webtron-video-banner__card {
        transition: opacity 0.3s ease;
        transform: none !important;
    }
}

.webtron-video-banner__motion .webtron-motion-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Overlay */
.webtron-video-banner__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    pointer-events: none;
}

/* Content Container - FLEX CONTAINER (column direction) */
.webtron-video-banner__content {
    position: relative;
    z-index: 4;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: inherit;
    /* Default: space-between distributes header/middle/footer vertically */
    justify-content: space-between;
    /* Horizontal alignment of flex items (sections) - default center */
    align-items: center;
}

/* ============================================================================
   THREE-SECTION LAYOUT
   ============================================================================ */

/* Section Base - Full width containers */
.webtron-video-banner__section {
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

/* Section Inner - Constrained width container, centered by default */
.webtron-video-banner__section-inner {
    width: 100%;
    box-sizing: border-box;
    /* max-width is set inline from contentWidth attribute */
    /* Default: centered */
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center;
}

/* Nested Group blocks should be full width within section-inner */
.webtron-video-banner__section-inner > .wp-block-group {
    width: 100%;
}

/* Header Section - Top of banner, no flex grow */
.webtron-video-banner__header {
    flex-shrink: 0;
    flex-grow: 0;
}

/* Middle Section - Expands to fill remaining space, uses flexbox for vertical centering */
.webtron-video-banner__middle {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    /* Default: center content vertically within middle section */
    justify-content: center;
}

/* Footer Section - Bottom of banner, no flex grow */
.webtron-video-banner__footer {
    flex-shrink: 0;
    flex-grow: 0;
}

/* ============================================================================
   VERTICAL ALIGNMENT (via data-valign attribute on __content)
   Controls justify-content on the CONTAINER (.webtron-video-banner__content)
   ============================================================================ */

/* Top alignment - all sections stack at top */
.webtron-video-banner__content[data-valign="top"] {
    justify-content: flex-start;
}

.webtron-video-banner__content[data-valign="top"] .webtron-video-banner__middle {
    justify-content: flex-start;
}

/* Center alignment - sections centered */
.webtron-video-banner__content[data-valign="center"] {
    justify-content: center;
}

.webtron-video-banner__content[data-valign="center"] .webtron-video-banner__middle {
    justify-content: center;
}

/* Bottom alignment - all sections stack at bottom */
.webtron-video-banner__content[data-valign="bottom"] {
    justify-content: flex-end;
}

.webtron-video-banner__content[data-valign="bottom"] .webtron-video-banner__middle {
    justify-content: flex-end;
}

/* ============================================================================
   HORIZONTAL ALIGNMENT (via data-halign attribute on __content)
   Controls margin and text-align on section-inner elements
   ============================================================================ */

/* Center alignment (default) */
.webtron-video-banner__content[data-halign="center"] .webtron-video-banner__section-inner {
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center;
}

/* Left alignment */
.webtron-video-banner__content[data-halign="left"] .webtron-video-banner__section-inner {
    margin-left: 0 !important;
    margin-right: auto !important;
    text-align: left;
}

/* Right alignment */
.webtron-video-banner__content[data-halign="right"] .webtron-video-banner__section-inner {
    margin-left: auto !important;
    margin-right: 0 !important;
    text-align: right;
}

/* ============================================================================
   OVERRIDE GROUP BLOCK DEFAULTS INSIDE VIDEO BANNER
   WordPress Group blocks have their own layout - we need to ensure
   the Video Banner's alignment settings take precedence
   ============================================================================ */

/* Reset Group block layout within video banner sections */
.webtron-video-banner__section-inner .wp-block-group {
    margin-left: inherit;
    margin-right: inherit;
}

/* Ensure Group blocks don't override our text alignment */
.webtron-video-banner__content[data-halign="center"] .wp-block-group,
.webtron-video-banner__content[data-halign="center"] .wp-block-group > * {
    text-align: center;
}

.webtron-video-banner__content[data-halign="left"] .wp-block-group,
.webtron-video-banner__content[data-halign="left"] .wp-block-group > * {
    text-align: left;
}

.webtron-video-banner__content[data-halign="right"] .wp-block-group,
.webtron-video-banner__content[data-halign="right"] .wp-block-group > * {
    text-align: right;
}

/* Ensure buttons and other flex containers respect alignment */
.webtron-video-banner__content[data-halign="center"] .wp-block-buttons {
    justify-content: center;
}

.webtron-video-banner__content[data-halign="left"] .wp-block-buttons {
    justify-content: flex-start;
}

.webtron-video-banner__content[data-halign="right"] .wp-block-buttons {
    justify-content: flex-end;
}

/* Legacy content inner - backwards compatibility */
.webtron-video-banner__content-inner {
    max-width: 1170px;
    width: 100%;
}

/* Heading */
.webtron-video-banner__heading {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.5em 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Subheading */
.webtron-video-banner__subheading {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 400;
    line-height: 1.5;
    margin: 0 0 1.5em 0;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Button */
.webtron-video-banner__button {
    display: inline-block;
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.webtron-video-banner__button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Button Styles */
.webtron-video-banner__button.btn-primary {
    background-color: var(--wp--preset--color--primary, #2372ce);
    color: #fff;
    border: 2px solid var(--wp--preset--color--primary, #2372ce);
}

.webtron-video-banner__button.btn-primary:hover {
    background-color: var(--wp--preset--color--primary-dark, #1d428a);
    border-color: var(--wp--preset--color--primary-dark, #1d428a);
}

.webtron-video-banner__button.btn-secondary {
    background-color: #6c757d;
    color: #fff;
    border: 2px solid #6c757d;
}

.webtron-video-banner__button.btn-light {
    background-color: #fff;
    color: #333;
    border: 2px solid #fff;
}

.webtron-video-banner__button.btn-light:hover {
    background-color: #f8f9fa;
}

.webtron-video-banner__button.btn-dark {
    background-color: #333;
    color: #fff;
    border: 2px solid #333;
}

.webtron-video-banner__button.btn-outline-primary {
    background-color: transparent;
    color: var(--wp--preset--color--primary, #2372ce);
    border: 2px solid var(--wp--preset--color--primary, #2372ce);
}

.webtron-video-banner__button.btn-outline-primary:hover {
    background-color: var(--wp--preset--color--primary, #2372ce);
    color: #fff;
}

.webtron-video-banner__button.btn-outline-light {
    background-color: transparent;
    color: #fff;
    border: 2px solid #fff;
}

.webtron-video-banner__button.btn-outline-light:hover {
    background-color: #fff;
    color: #333;
}

/* Content Alignment */
.webtron-video-banner__content[style*="text-align: left"] .webtron-video-banner__section-inner,
.webtron-video-banner__content[style*="text-align: left"] .webtron-video-banner__content-inner {
    text-align: left;
}

.webtron-video-banner__content[style*="text-align: center"] .webtron-video-banner__section-inner,
.webtron-video-banner__content[style*="text-align: center"] .webtron-video-banner__content-inner {
    text-align: center;
}

.webtron-video-banner__content[style*="text-align: right"] .webtron-video-banner__section-inner,
.webtron-video-banner__content[style*="text-align: right"] .webtron-video-banner__content-inner {
    text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
    .webtron-video-banner__section {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .webtron-video-banner__button {
        padding: 12px 30px;
        font-size: 1em;
    }
}

/* Animation for content */
.webtron-video-banner__heading,
.webtron-video-banner__subheading,
.webtron-video-banner__button {
    animation: videoBannerFadeIn 0.8s ease-out forwards;
    opacity: 0;
}

.webtron-video-banner__heading {
    animation-delay: 0.2s;
}

.webtron-video-banner__subheading {
    animation-delay: 0.4s;
}

.webtron-video-banner__button {
    animation-delay: 0.6s;
}

@keyframes videoBannerFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .webtron-video-banner__heading,
    .webtron-video-banner__subheading,
    .webtron-video-banner__button {
        animation: none;
        opacity: 1;
    }
    
    .webtron-video-banner__video {
        display: none;
    }
}
