/* ===========================================
 * xFact — Global Styles
 * ===========================================
 * Animations, utilities, and design tokens that
 * extend theme.json beyond what it can express.
 * =========================================== */

/* ── CSS Custom Properties (Light Mode) ──────────────── */

:root {
    --has-surface-background-color: #f5f7fa;
    --has-surface-alt-background-color: #ffffff;
    --has-surface-background-color-card: #ffffff;
    --wp--preset--color--surface-alt: #e2e8f0;
    --wp--preset--color--text-primary: #1a202c;
    --wp--preset--color--text-secondary: #4a5568;
    --wp--preset--color--text-secondary: #718096;
    --xfact-dark-section: #0d2d6b;
    --xfact-dark-section-text: #ffffff;
    --xfact-dark-section-secondary: rgba(255, 255, 255, 0.75);
    --xfact-dark-section-muted: rgba(255, 255, 255, 0.55);
    --wp--preset--color--primary: #5c8ae6;
    --wp--preset--color--primary-dark: #3a6bd4;
    --wp--preset--color--primary-dark: #123e99;
    --xfact-btn-from: #123e99;
    --xfact-btn-to: #2a5bb8;
    --xfact-btn-hover-from: #1a4fb3;
    --xfact-btn-hover-to: #3a6bd4;
    --xfact-spacing-section: 5.625rem;
    --xfact-spacing-section-lg: 7rem;
    --xfact-spacing-hero-top: 10rem;

    /* Systems Window Glassmorphism */
    --xfact-glass-bg: rgba(255, 255, 255, 0.1);
    --xfact-glass-bg-hover: rgba(255, 255, 255, 0.15);
    --xfact-glass-border: rgba(255, 255, 255, 0.2);
    --xfact-glass-border-hover: rgba(255, 255, 255, 0.3);
    --xfact-glass-blur: blur(12px);
    --xfact-glass-radius: 12px;
}

/* ── Base ─────────────────────────────────────────────── */

html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--has-surface-background-color);
    color: var(--wp--preset--color--text-primary);
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ── Focus Styles ──────────────────────────────────────── */

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Skip to Content ───────────────────────────────────── */

.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1.5rem;
    background: var(--wp--preset--color--primary);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.875rem;
}

.skip-to-content:focus {
    left: 0.5rem;
    top: 0.5rem;
    border-radius: 0.25rem;
}

/* ── Theme Utility Classes ─────────────────────────────── */

.has-surface-background-color {
    background-color: var(--has-surface-background-color);
}

.has-surface-alt-background-color {
    background-color: var(--has-surface-alt-background-color);
}

.has-surface-background-color-card {
    background-color: var(--has-surface-background-color-card);
}

.xfact-border {
    border-color: color-mix(in srgb, var(--wp--preset--color--text-primary), transparent 80%);
}

.xfact-text {
    color: var(--wp--preset--color--text-primary);
}

.xfact-text-secondary {
    color: var(--wp--preset--color--text-secondary);
}

.xfact-text-muted {
    color: var(--wp--preset--color--text-secondary);
}

/* ── Layout Utilities ──────────────────────────────────── */

.xfact-container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-width: 80rem;
    /* 1280px / max-w-7xl */
    padding-left: 1rem;
    padding-right: 1rem;
}

.xfact-container--narrow {
    max-width: 48rem;
    /* 768px / max-w-3xl */
}

@media (min-width: 640px) {
    .xfact-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .xfact-container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

.xfact-section {
    padding-top: var(--xfact-spacing-section);
    padding-bottom: var(--xfact-spacing-section);
}

.xfact-section-lg {
    padding-top: var(--xfact-spacing-section-lg);
    padding-bottom: var(--xfact-spacing-section-lg);
}

.xfact-section-border {
    border-bottom: 1px solid color-mix(in srgb, var(--wp--preset--color--text-primary), transparent 80%);
}


/* ── Typography Utilities ─────────────────────────────── */

.xfact-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--wp--preset--color--primary);
    margin: 0 0 0.25rem;
}

.xfact-section-heading {
    margin-top: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--wp--preset--color--text-primary);
    line-height: 1.1;
}

@media (min-width: 768px) {
    .xfact-section-heading {
        font-size: 1.875rem;
    }
}

@media (min-width: 1024px) {
    .xfact-section-heading {
        font-size: 2.25rem;
    }
}

.xfact-section-subtitle {
    margin-top: 1rem;
    font-size: 1.125rem;
    color: var(--wp--preset--color--text-secondary);
    max-width: 48rem;
}

/* ── Glassmorphism (Systems Window) ───────────────────── */

.xfact-glass {
    background: var(--xfact-glass-bg);
    backdrop-filter: var(--xfact-glass-blur);
    -webkit-backdrop-filter: var(--xfact-glass-blur);
    border: 1px solid var(--xfact-glass-border);
    border-radius: var(--xfact-glass-radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

.xfact-dark-section {
    background-color: var(--xfact-dark-section);
}

.xfact-dark-section-text {
    color: var(--xfact-dark-section-text);
}

.xfact-dark-section-secondary {
    color: var(--xfact-dark-section-secondary);
}

.xfact-dark-section-muted {
    color: var(--xfact-dark-section-muted);
}

/* ── Card Utilities ────────────────────────────────────── */

.xfact-card,
.xfact-card-interactive {
    background-color: var(--has-surface-background-color-card);
    border: 1px solid color-mix(in srgb, var(--wp--preset--color--text-primary), transparent 80%);
    border-radius: var(--xfact-glass-radius);
    overflow: hidden;
}

.xfact-card-interactive {
    transition: all 0.3s ease;
    text-decoration: none !important;
    display: block;
    color: inherit;
}

/* Glassmorphism Context for Cards */
.xfact-dark-section .xfact-card,
.xfact-dark-section .xfact-card-interactive,
html[data-theme="dark"] .xfact-card,
html[data-theme="dark"] .xfact-card-interactive {
    background: var(--xfact-glass-bg);
    backdrop-filter: var(--xfact-glass-blur);
    -webkit-backdrop-filter: var(--xfact-glass-blur);
    border: 1px solid var(--xfact-glass-border);
}

.xfact-card-interactive:hover {
    border-color: var(--wp--preset--color--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.xfact-dark-section .xfact-card-interactive:hover,
html[data-theme="dark"] .xfact-card-interactive:hover {
    background: var(--xfact-glass-bg-hover);
    border-color: var(--xfact-glass-border-hover);
}

.xfact-card-interactive:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary);
    outline-offset: 2px;
}

/* ── Theme Toggle Button ── */
button.xfact-theme-toggle {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    width: 3rem !important;
    height: 1.75rem !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 9999px !important;
    background: transparent !important;
    cursor: pointer !important;
}

button.xfact-theme-toggle:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary);
    outline-offset: 2px;
}

button.xfact-theme-toggle--icon-only {
    width: 2.25rem !important;
    height: 2.25rem !important;
    border-radius: 50% !important;
    color: var(--wp--preset--color--text-secondary) !important;
    background: rgba(0, 0, 0, 0.05) !important;
    backdrop-filter: var(--xfact-glass-blur) !important;
    -webkit-backdrop-filter: var(--xfact-glass-blur) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

html[data-theme="dark"] button.xfact-theme-toggle--icon-only,
.xfact-dark-section button.xfact-theme-toggle--icon-only {
    background: var(--xfact-glass-bg) !important;
    border-color: var(--xfact-glass-border) !important;
    color: rgba(255, 255, 255, 0.8) !important;
}

button.xfact-theme-toggle--icon-only:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="dark"] button.xfact-theme-toggle--icon-only:hover,
.xfact-dark-section button.xfact-theme-toggle--icon-only:hover {
    background: var(--xfact-glass-bg-hover) !important;
    border-color: var(--xfact-glass-border-hover) !important;
    color: #ffffff !important;
}

button.xfact-theme-toggle--icon-only svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

span.xfact-theme-toggle__track {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 9999px !important;
    background: #d1d5db !important;
    transition: background 0.3s;
}

html[data-theme="dark"] span.xfact-theme-toggle__track {
    background: var(--wp--preset--color--primary) !important;
}

span.xfact-theme-toggle__thumb {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    border-radius: 50% !important;
    background: #fff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    transform: translateX(4px) !important;
    transition: transform 0.3s;
}

html[data-theme="dark"] span.xfact-theme-toggle__thumb {
    transform: translateX(24px) !important;
}

svg.xfact-theme-toggle__icon-moon,
svg.xfact-theme-toggle__icon-sun {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 0.75rem !important;
    height: 0.75rem !important;
}

svg.xfact-theme-toggle__icon-moon {
    display: none !important;
    color: var(--wp--preset--color--primary) !important;
}

svg.xfact-theme-toggle__icon-sun {
    display: block !important;
    color: #718096 !important;
}

html[data-theme="dark"] svg.xfact-theme-toggle__icon-moon {
    display: block !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

html[data-theme="dark"] svg.xfact-theme-toggle__icon-sun {
    display: none !important;
}

/* ── Remove WP Default Block Margins ──────────────── */
/* WordPress adds default margins between blocks.
   The source template has seamless section transitions. */

.wp-site-blocks>*+* {
    margin-block-start: 0 !important;
}

.wp-site-blocks>.xfact-header+* {
    margin-block-start: 0 !important;
}

.entry-content>*+* {
    margin-block-start: 0 !important;
}

/* ── Root padding responsive overrides ──────────── */
/* Match source template: px-4 sm:px-6 lg:px-8      */

@media (min-width: 640px) {
    body {
        --wp--style--root--padding-right: 1.5rem;
        --wp--style--root--padding-left: 1.5rem;
    }
}

@media (min-width: 1024px) {
    body {
        --wp--style--root--padding-right: 2rem;
        --wp--style--root--padding-left: 2rem;
    }
}

/* ── Full-width block padding fix ───────────────── */
/* Our full-width blocks (hero, cta, page-hero, metrics)
   already contain .xfact-container with correct padding.
   Strip WP's root padding from the block wrapper to
   prevent double-padding. */

.xfact-hero.alignfull,
.xfact-cta-section.alignfull,
.xfact-page-hero.alignfull,
.xfact-metrics-strip.alignfull,
.wp-block-xfact-hero.alignfull,
.wp-block-xfact-cta-section.alignfull,
.wp-block-xfact-page-hero.alignfull,
.wp-block-xfact-metrics-strip.alignfull {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Also strip from has-global-padding on full-width custom blocks */
.wp-site-blocks>.alignfull.wp-block-xfact-hero,
.wp-site-blocks>.alignfull.wp-block-xfact-cta-section,
.wp-site-blocks>.alignfull.wp-block-xfact-page-hero,
.wp-site-blocks>.alignfull.wp-block-xfact-metrics-strip,
.wp-site-blocks>.alignfull:where(.xfact-hero),
.wp-site-blocks>.alignfull:where(.xfact-cta-section),
.wp-site-blocks>.alignfull:where(.xfact-page-hero),
.wp-site-blocks>.alignfull:where(.xfact-metrics-strip) {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Block-scoped Fade-in Pattern */
/* Base state: always visible (handles JS disabled & block editor) */
.xfact-fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

/* Hidden state: only applies when JS is confirmed active */
html.xfact-has-fade .xfact-fade-in {
    opacity: 0;
    transform: translateY(20px);
}

/* Revealed state */
html.xfact-has-fade .xfact-fade-in.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Gradient Overlay Utilities ────────────────────────── */

.has-xfact-gradient-bg,
.has-xfact-hover-bg {
    --xfact-overlay-angle: to bottom;
    position: relative;
    isolation: isolate;
}

/* ── Global Gradient Base ── */
.has-xfact-gradient-bg::before,
.has-xfact-hover-bg a:hover::before,
.has-xfact-hover-bg .wp-block-navigation-item__content:hover::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: var(--xfact-card-bg, var(--xfact-hover-bg));
    opacity: 1;
    z-index: -2;
}

/* ── Light Mode Fade Overlay ── */
.has-xfact-gradient-bg::after,
.has-xfact-hover-bg a:hover::after,
.has-xfact-hover-bg .wp-block-navigation-item__content:hover::after {
    content: "";
    display: block !important;
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(var(--xfact-overlay-angle), rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.8) 100%);
    z-index: -1;
    pointer-events: none;
}

/* ── Dark Mode Only Black Fade Overlay ── */
.xfact-dark-section .has-xfact-gradient-bg::after,
html[data-theme="dark"] .has-xfact-gradient-bg::after,
.xfact-dark-section .has-xfact-hover-bg a:hover::after,
.xfact-dark-section .has-xfact-hover-bg .wp-block-navigation-item__content:hover::after,
html[data-theme="dark"] .has-xfact-hover-bg a:hover::after,
html[data-theme="dark"] .has-xfact-hover-bg .wp-block-navigation-item__content:hover::after {
    content: "";
    display: block !important;
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(var(--xfact-overlay-angle), rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.8) 100%);
    z-index: -1;
    pointer-events: none;
}

/* ── Header Submenu Sleek Glow Override ── */
/* The header is dark blue (primary-dark), so black/white overlays clash. We use a contextual primary-dark fade. */
.xfact-header .wp-block-navigation__submenu-container .has-xfact-hover-bg a:hover::before,
.xfact-header .wp-block-navigation__submenu-container .has-xfact-hover-bg .wp-block-navigation-item__content:hover::before {
    opacity: 1 !important; /* Fully saturated gradient base */
}

.xfact-header .wp-block-navigation__submenu-container .has-xfact-hover-bg a:hover::after,
.xfact-header .wp-block-navigation__submenu-container .has-xfact-hover-bg .wp-block-navigation-item__content:hover::after {
    display: block !important;
    background: linear-gradient(
        var(--xfact-overlay-angle), 
        var(--xfact-semantic-primary-dark) 0%, 
        color-mix(in srgb, var(--xfact-semantic-primary-dark) 80%, transparent) 100%
    );
}
/* ===========================================
 * WP-Admin Editor Overrides
 * ===========================================
 * Ensures ServerSideRender blocks display with correct padding and backgrounds
 * in the Gutenberg block editor.
 * =========================================== */

/* Prevent Gutenberg's 100vw hack from causing horizontal scrollbars in the editor, and remove default vertical margins */
.editor-styles-wrapper {
    overflow-x: hidden !important;
}

/* Force border-box sizing in the editor to match frontend layout (prevents padding from blowing up block heights) */
.editor-styles-wrapper,
.editor-styles-wrapper *,
.editor-styles-wrapper *::before,
.editor-styles-wrapper *::after {
    box-sizing: border-box !important;
}

.editor-styles-wrapper .wp-block[data-align="full"] {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Remove frontend header offset padding in the editor since header is relative */
.editor-styles-wrapper .wp-site-blocks {
    padding-top: 0 !important;
}

/* Restore missing spacing variables in editor context */
.editor-styles-wrapper {
    --xfact-spacing-section: 5.625rem;
    --xfact-spacing-section-lg: 7rem;
    --xfact-spacing-hero-top: 10rem;
}

/* Compensate for the missing absolute header overlay in the editor */
.editor-styles-wrapper .xfact-page-hero {
    padding-top: 10rem !important;
    /* Match frontend exactly */
    min-height: 38rem !important;
    /* Match frontend exactly */
}

/* Careers: Current Openings block container in editor */
.editor-styles-wrapper .wp-block-xfact-code-embed {
    padding-top: 7rem !important;
    padding-bottom: 7rem !important;
}

.editor-styles-wrapper .xfact-border-top {
    border-top: 1px solid #e2e8f0 !important;
}

/* Fix for disabled wrapper from SSR */
.editor-styles-wrapper .components-disabled {
    opacity: 1 !important;
}