/**
 * WP Page Builder — Sections base stylesheet
 *
 * Shared variables and utility classes used by all section components.
 * Section-specific CSS is inlined at runtime via WPB_Renderer::get_sections_css().
 *
 * CSS custom properties can be overridden per-theme or per-section via inline style.
 */

/* ─── Custom Properties ───────────────────────────────────────────────── */
/*
 * Variables are scoped to .wpb-section and the WPB layout/page wrappers
 * to avoid polluting :root and colliding with the active theme's own
 * custom properties (e.g. --wpb-color-primary could override a theme var).
 */
.wpb-section,
.wpb-page-content,
.wpb-container,
.wpb-layout--sidebar-right,
.wpb-layout--sidebar-left {
    --wpb-color-primary:     #2271b1;
    --wpb-color-primary-dk:  #135e96;
    --wpb-color-accent:      #d63638;
    --wpb-color-text:        #1e1e1e;
    --wpb-color-muted:       #666;
    --wpb-color-border:      #e5e7eb;
    --wpb-color-bg:          #ffffff;
    --wpb-color-bg-alt:      #f8f9fa;
    --wpb-color-bg-dark:     #111827;
    --wpb-color-bg-dark-alt: #1f2937;

    --wpb-radius:     12px;
    --wpb-radius-sm:  6px;
    --wpb-radius-lg:  20px;
    --wpb-shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --wpb-shadow:     0 4px 16px rgba(0,0,0,.08);
    --wpb-shadow-lg:  0 10px 40px rgba(0,0,0,.12);

    --wpb-transition: 0.2s ease;
    --wpb-font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --wpb-font-mono:  ui-monospace, "SFMono-Regular", Consolas, monospace;
}

/* ─── Page Layout ─────────────────────────────────────────────────────── */
.wpb-builder-page .entry-content,
.wpb-builder-page .post-content {
    padding: 0;
    max-width: none;
}

.wpb-page-content {
    width: 100%;
}

.wpb-layout--sidebar-right,
.wpb-layout--sidebar-left {
    display: grid;
    gap: 40px;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.wpb-layout--sidebar-right  { grid-template-columns: 1fr 300px; }
.wpb-layout--sidebar-left   { grid-template-columns: 300px 1fr; }

.wpb-sidebar {
    position: sticky;
    top: 80px;
}

.wpb-sidebar__inner {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ─── Container ───────────────────────────────────────────────────────── */
.wpb-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
}

.wpb-container--narrow      { max-width: 800px; }
.wpb-container--wide        { max-width: 1400px; }
.wpb-container--full        { max-width: none; padding-left: 0; padding-right: 0; }
/* React UI writes these two values — keep them as aliases */
.wpb-container--boxed       { max-width: 1200px; }
.wpb-container--full-width  { max-width: none; padding-left: 0; padding-right: 0; }

/* ─── Section wrapper ─────────────────────────────────────────────────── */
.wpb-section {
    position: relative;
    overflow: hidden;
}

.wpb-scheme--dark {
    background-color: var(--wpb-bg, var(--wpb-color-bg-dark));
    color: #f9fafb;
}

.wpb-scheme--dark .wpb-section-header__title {
    color: #f9fafb;
}

.wpb-scheme--dark .wpb-section-header__subtitle {
    color: #9ca3af;
}

.wpb-scheme--light {
    background-color: var(--wpb-bg, var(--wpb-color-bg));
    color: var(--wpb-color-text);
}

.wpb-scheme--muted {
    background-color: var(--wpb-bg, var(--wpb-color-bg-alt));
    color: var(--wpb-color-text);
}

/* ─── Separator ───────────────────────────────────────────────────────── */
.wpb-separator {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    overflow: hidden;
    line-height: 0;
}

.wpb-separator--top    { top: 0; }
.wpb-separator--bottom { bottom: 0; }

.wpb-separator svg {
    display: block;
    width: 100%;
}

/* ─── Section header ──────────────────────────────────────────────────── */
.wpb-section-header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 48px;
}

.wpb-section-header__title {
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 16px;
    color: var(--wpb-color-text);
}

.wpb-section-header__subtitle {
    font-size: 1.0625rem;
    color: var(--wpb-color-muted);
    line-height: 1.7;
    margin: 0;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.wpb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--wpb-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background var(--wpb-transition), color var(--wpb-transition), border-color var(--wpb-transition), box-shadow var(--wpb-transition);
    white-space: nowrap;
}

.wpb-btn--primary {
    background: var(--wpb-color-primary);
    color: #fff;
    border-color: var(--wpb-color-primary);
}

.wpb-btn--primary:hover {
    background: var(--wpb-color-primary-dk);
    border-color: var(--wpb-color-primary-dk);
    color: #fff;
}

.wpb-btn--secondary {
    background: transparent;
    color: var(--wpb-color-primary);
    border-color: var(--wpb-color-primary);
}

.wpb-btn--secondary:hover {
    background: var(--wpb-color-primary);
    color: #fff;
}

.wpb-btn--outline {
    background: transparent;
    color: var(--wpb-color-text);
    border-color: var(--wpb-color-border);
}

.wpb-btn--outline:hover {
    border-color: var(--wpb-color-primary);
    color: var(--wpb-color-primary);
}

.wpb-btn--ghost {
    background: transparent;
    color: var(--wpb-color-primary);
    border-color: transparent;
    padding-left: 0;
    padding-right: 0;
}

.wpb-btn--ghost:hover {
    text-decoration: underline;
    color: var(--wpb-color-primary-dk);
}

.wpb-btn--sm  { padding: 8px 16px;  font-size: .875rem; }
.wpb-btn--lg  { padding: 16px 32px; font-size: 1.125rem; }
.wpb-btn--xl  { padding: 18px 40px; font-size: 1.25rem; }

/* Dark section button overrides */
.wpb-scheme--dark .wpb-btn--secondary {
    color: #fff;
    border-color: rgba(255,255,255,.4);
}

.wpb-scheme--dark .wpb-btn--secondary:hover {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.6);
}

.wpb-scheme--dark .wpb-btn--outline {
    color: #f9fafb;
    border-color: rgba(255,255,255,.35);
}

.wpb-scheme--dark .wpb-btn--outline:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.6);
    color: #fff;
}

.wpb-scheme--dark .wpb-btn--ghost {
    color: #d1d5db;
}

.wpb-scheme--dark .wpb-btn--ghost:hover {
    color: #fff;
}

/* ─── Padding ─────────────────────────────────────────────────────────── */
.wpb-padding--compact  { padding-top: 24px;  padding-bottom: 24px;  }
.wpb-padding--normal   { padding-top: 48px;  padding-bottom: 48px;  }
.wpb-padding--spacious { padding-top: 80px;  padding-bottom: 80px;  }

/* ─── Shadow ──────────────────────────────────────────────────────────── */
.wpb-shadow--small  { box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05); }
.wpb-shadow--medium { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.wpb-shadow--large  { box-shadow: 0 10px 40px rgba(0,0,0,.12); }

/* ─── Border radius ───────────────────────────────────────────────────── */
.wpb-radius--small  { border-radius: 4px; }
.wpb-radius--medium { border-radius: 8px; }
.wpb-radius--large  { border-radius: 16px; }

/* ─── Typography (consumes --wpb-heading-color / --wpb-text-color / --wpb-muted-color) ── */
.wpb-section h1,
.wpb-section h2,
.wpb-section h3,
.wpb-section h4,
.wpb-section h5,
.wpb-section h6 {
    color: var(--wpb-heading-color, inherit);
}

.wpb-section {
    /* Only override when explicitly set — the default falls through to scheme color. */
    color: var(--wpb-text-color, inherit);
}

.wpb-section .wpb-hero__subheadline,
.wpb-section .wpb-section-header__subtitle,
.wpb-section figcaption,
.wpb-section .wpb-cr__text,
.wpb-section .wpb-dfi__caption,
.wpb-section [class*="__muted"],
.wpb-section [class*="-muted"] {
    color: var(--wpb-muted-color, inherit);
}

/* Heading size scales — apply to the primary headline */
.wpb-heading-size--small  h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.wpb-heading-size--small  h2 { font-size: clamp(1.25rem, 2.4vw, 1.625rem); }
.wpb-heading-size--large  h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
.wpb-heading-size--large  h2 { font-size: clamp(2rem, 4vw, 3rem); }
.wpb-heading-size--xlarge h1 { font-size: clamp(3rem, 6vw, 5.5rem); line-height: 1.05; }
.wpb-heading-size--xlarge h2 { font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.1; }

/* ─── Buttons (consume --wpb-btn-color) ───────────────────────────────── */
.wpb-section .wpb-btn,
.wpb-section button.wpb-btn {
    --wpb-btn-accent: var(--wpb-btn-color, var(--wpb-color-primary, #2271b1));
}

.wpb-btn-variant--primary .wpb-btn {
    background: var(--wpb-btn-accent);
    color: #fff;
    border: 1px solid var(--wpb-btn-accent);
}
.wpb-btn-variant--primary .wpb-btn:hover { filter: brightness(.92); }

.wpb-btn-variant--outline .wpb-btn {
    background: transparent;
    color: var(--wpb-btn-accent);
    border: 1.5px solid var(--wpb-btn-accent);
}
.wpb-btn-variant--outline .wpb-btn:hover {
    background: var(--wpb-btn-accent);
    color: #fff;
}

.wpb-btn-variant--ghost .wpb-btn {
    background: color-mix(in oklab, var(--wpb-btn-accent) 12%, transparent);
    color: var(--wpb-btn-accent);
    border: 1px solid transparent;
}
.wpb-btn-variant--ghost .wpb-btn:hover {
    background: color-mix(in oklab, var(--wpb-btn-accent) 22%, transparent);
}

.wpb-btn-variant--minimal .wpb-btn {
    background: transparent;
    color: var(--wpb-btn-accent);
    border: 0;
    padding-left: 0;
    padding-right: 0;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Button sizes */
.wpb-btn-size--small  .wpb-btn { padding: 6px 14px;  font-size: .875rem; min-height: 34px; }
.wpb-btn-size--medium .wpb-btn { padding: 10px 20px; font-size: .95rem;  min-height: 42px; }
.wpb-btn-size--large  .wpb-btn { padding: 14px 28px; font-size: 1.05rem; min-height: 50px; }

/* Button radii */
.wpb-btn-radius--none   .wpb-btn { border-radius: 0; }
.wpb-btn-radius--small  .wpb-btn { border-radius: 4px; }
.wpb-btn-radius--medium .wpb-btn { border-radius: 8px; }
.wpb-btn-radius--large  .wpb-btn { border-radius: 16px; }
.wpb-btn-radius--pill   .wpb-btn { border-radius: 999px; }

/* ─── Badges (consume --wpb-badge-color) ──────────────────────────────── */
.wpb-section .wpb-badge,
.wpb-section [class*="__badge"] {
    --wpb-badge-accent: var(--wpb-badge-color, var(--wpb-color-primary, #6c5ce7));
}

.wpb-badge-variant--filled .wpb-badge,
.wpb-badge-variant--filled [class*="__badge"] {
    background: var(--wpb-badge-accent);
    color: #fff;
    border: 1px solid var(--wpb-badge-accent);
}

.wpb-badge-variant--outline .wpb-badge,
.wpb-badge-variant--outline [class*="__badge"] {
    background: transparent;
    color: var(--wpb-badge-accent);
    border: 1.5px solid var(--wpb-badge-accent);
}

.wpb-badge-variant--soft .wpb-badge,
.wpb-badge-variant--soft [class*="__badge"] {
    background: color-mix(in oklab, var(--wpb-badge-accent) 16%, transparent);
    color: var(--wpb-badge-accent);
    border: 1px solid transparent;
}

/* ─── Visibility toggles ──────────────────────────────────────────────── */
@media (max-width: 767px)  { .wpb-hide--mobile  { display: none !important; } }
@media (min-width: 768px) and (max-width: 1023px) { .wpb-hide--tablet { display: none !important; } }
@media (min-width: 1024px) { .wpb-hide--desktop { display: none !important; } }

/* Section fully hidden (visibility.visible = false) */
.wpb-section--hidden { display: none !important; }

/* ─── Inner gap (spacing between direct children of section content) ──── */
.wpb-gap--tight  > .wpb-container > *:not(:last-child) { margin-bottom: 16px; }
.wpb-gap--normal > .wpb-container > *:not(:last-child) { margin-bottom: 24px; }
.wpb-gap--wide   > .wpb-container > *:not(:last-child) { margin-bottom: 40px; }

/* ─── Text alignment (applies at section scope) ───────────────────────── */
.wpb-align--left   { text-align: left; }
.wpb-align--center { text-align: center; }
.wpb-align--right  { text-align: right; }

/* ─── Reverse column order on mobile (for split-type layouts) ─────────── */
@media (max-width: 767px) {
    .wpb-reverse-mobile .wpb-row,
    .wpb-reverse-mobile .wpb-cols,
    .wpb-reverse-mobile .wpb-grid { flex-direction: column-reverse; }
}

/* ─── Background image / video wrappers ───────────────────────────────── */
.wpb-bg-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.wpb-bg-video {
    position: relative;
}

.wpb-bg-video-el {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.wpb-bg-video > :not(.wpb-bg-video-el):not(.wpb-bg-overlay) {
    position: relative;
    z-index: 2;
}

.wpb-bg-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.wpb-bg-image > :not(.wpb-bg-overlay),
.wpb-bg-video > :not(.wpb-bg-video-el):not(.wpb-bg-overlay) {
    position: relative;
    z-index: 2;
}

/* ─── Utility ─────────────────────────────────────────────────────────── */
.wpb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .wpb-layout--sidebar-right,
    .wpb-layout--sidebar-left {
        grid-template-columns: 1fr;
    }

    .wpb-sidebar {
        position: static;
        order: 2;
    }
}

@media (max-width: 768px) {
    .wpb-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .wpb-section-header {
        margin-bottom: 32px;
    }

    /* Sidebar layouts: full-width on mobile */
    .wpb-layout--sidebar-right,
    .wpb-layout--sidebar-left {
        padding: 0 16px;
        gap: 24px;
    }

    /* Prevent any fixed-width child from causing horizontal scroll */
    .wpb-page-content {
        overflow-x: hidden;
    }
}

/* Prevent horizontal overflow at all breakpoints */
.wpb-section {
    max-width: 100%;
}

/* Buttons: ensure minimum touch target on mobile */
@media (max-width: 768px) {
    .wpb-btn {
        min-height: 44px;
    }

    .wpb-btn--sm {
        min-height: 36px;
    }
}

/* ─── Image Display Effects ───────────────────────────────────────────── */
/*
 * Applied via CSS classes on section wrapper (wpb-img-hover--*, wpb-img-depth--*).
 * Works for ALL section types that use images — no per-section changes needed.
 */

/* Image containers — smooth transitions */
.wpb-section img {
    transition: transform .4s ease, filter .4s ease, box-shadow .4s ease;
}

/* ── Depth (shadow levels 1-5, like Flatsome) ── */
.wpb-img-depth--1 img { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.wpb-img-depth--2 img { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.wpb-img-depth--3 img { box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.wpb-img-depth--4 img { box-shadow: 0 16px 48px rgba(0,0,0,.15); }
.wpb-img-depth--5 img { box-shadow: 0 24px 64px rgba(0,0,0,.18); }

/* ── Hover effects ── */

/* zoom — scale up on hover */
.wpb-img-hover--zoom img:hover {
    transform: scale(1.05);
}

/* zoom-fade — scale + slight opacity change */
.wpb-img-hover--zoom-fade img:hover {
    transform: scale(1.08);
    opacity: .9;
}

/* glow — bright shadow on hover */
.wpb-img-hover--glow img:hover {
    box-shadow: 0 0 24px rgba(var(--wpb-color-primary-rgb, 34,113,177), .35);
}

/* grayscale — desaturated by default, color on hover */
.wpb-img-hover--grayscale img {
    filter: grayscale(100%);
}
.wpb-img-hover--grayscale img:hover {
    filter: grayscale(0%);
}

/* fade-in — starts dimmed, full on hover */
.wpb-img-hover--fade-in img {
    opacity: .7;
}
.wpb-img-hover--fade-in img:hover {
    opacity: 1;
}

/* lift — moves up with deeper shadow */
.wpb-img-hover--lift img:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0,0,0,.15);
}

/* blur — blurred by default, sharp on hover */
.wpb-img-hover--blur img {
    filter: blur(2px);
}
.wpb-img-hover--blur img:hover {
    filter: blur(0);
}

/* ── Depth + Hover combined — hover deepens shadow ── */
.wpb-img-depth--1 img:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.wpb-img-depth--2 img:hover { box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.wpb-img-depth--3 img:hover { box-shadow: 0 12px 40px rgba(0,0,0,.16); }
.wpb-img-depth--4 img:hover { box-shadow: 0 20px 56px rgba(0,0,0,.18); }
.wpb-img-depth--5 img:hover { box-shadow: 0 28px 72px rgba(0,0,0,.2); }

/* ── Dark scheme adjustments ── */
.wpb-scheme--dark .wpb-img-depth--1 img { box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.wpb-scheme--dark .wpb-img-depth--2 img { box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.wpb-scheme--dark .wpb-img-depth--3 img { box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.wpb-scheme--dark .wpb-img-depth--4 img { box-shadow: 0 16px 48px rgba(0,0,0,.4); }
.wpb-scheme--dark .wpb-img-depth--5 img { box-shadow: 0 24px 64px rgba(0,0,0,.45); }
.wpb-scheme--dark .wpb-img-hover--glow img:hover { box-shadow: 0 0 32px rgba(255,255,255,.15); }

/* ─── Per-Image Display Options ───────────────────────────────────────── */

/* Wrapper element for per-image display */
.wpb-img-wrap { display: inline-block; overflow: hidden; max-width: 100%; }
.wpb-img-wrap img { display: block; width: 100%; height: 100%; }

/* Border radius — on wrapper so it clips the background, not just the image */
.wpb-img-radius--small { border-radius: 6px; }
.wpb-img-radius--medium { border-radius: 12px; }
.wpb-img-radius--large { border-radius: 24px; }
.wpb-img-radius--circle { border-radius: 50%; }
.wpb-img-radius--circle.wpb-img-wrap { aspect-ratio: 1; }

/* Shadow — on wrapper so it surrounds the visible frame */
.wpb-img-shadow--small { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.wpb-img-shadow--medium { box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.wpb-img-shadow--large { box-shadow: 0 16px 48px rgba(0,0,0,.16); }
