/*
Theme Name: Nexus
Theme URI: https://47-studio.com/base47
Author: Base47
Author URI: https://47-studio.com/base47
Description: Clean, responsive WordPress theme with customizable layouts, navigation options, and Canvas Mode for custom HTML layouts. Compatible with popular page builders and WooCommerce.
Version: 4.0.0
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: nexus-theme
Tags: custom-header, custom-menu, featured-images, flexible-header, footer-widgets, full-width-template, theme-options, threaded-comments, translation-ready
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.4
*/

/* ------------------------------------
   1. BASE RESET (safe + minimal)
------------------------------------ */

html, body {
    margin: 0;
    padding: 0;
}

/* Allow templates to manage spacing */
.entry-content {
    margin: 0 !important;
    padding: 0 !important;
}

/* Media should behave but not change layout */
img, video, picture, canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Optional basic anchor behavior */
a {
    color: inherit;
    text-decoration: none;
}

/* Accessibility skip link */
.skip-link {
    position: absolute;
    left: -9999px;
}

/* ------------------------------------
   2. CANVAS MODE - First Section Fix
   Pure HTML - Zero WordPress interference
------------------------------------ */

body.base47-canvas {
    margin: 0 !important;
    padding: 0 !important;
    /* DO NOT set background - let templates control it */
}

body.base47-canvas * {
    /* Let templates control everything */
    box-sizing: border-box;
}

/* ------------------------------------
   3. MOBILE-SPECIFIC FIXES
   Block WordPress button styles that override templates
------------------------------------ */

@media (max-width: 768px) {
    /* Force remove any WordPress button styling */
    .wp-block-button__link,
    .wp-block-file__button {
        all: unset !important;
    }
    
    /* Ensure template containers work on mobile */
    .container,
    .row,
    section {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Fix any WordPress-added padding on mobile */
    body.page,
    body.single,
    body.home {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* FIX: First section always broken - kill ALL wrappers */
    body > *:not(script):not(style),
    #page,
    main,
    article,
    .entry-content > *:first-child,
    section:first-of-type,
    .header,
    header {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure first template section displays correctly */
    body {
        overflow-x: hidden !important;
    }
}

/* ------------------------------------
   2. STOP WORDPRESS / THEMES 
      from adding layout interference
------------------------------------ */

#page,
.site,
.site-main,
.entry-content,
.wp-site-blocks,
main,
#base47-main,
article,
.post,
.page {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Remove all browser-added whitespace */
* {
    box-sizing: border-box;
}

/* ------------------------------------
   3. FULL MOBILE SAFARI HEIGHT FIX
------------------------------------ */

:root {
    --vh: 1vh;
}

@media (max-width: 768px) {
    html, body {
        height: auto !important;
    }
}

/* ------------------------------------
   4. DO NOT TOUCH SECTION / CONTAINER 
      PADDING OR TYPOGRAPHY ON MOBILE
------------------------------------ */

/* Nothing here — templates must be untouched */

/* ------------------------------------
   4.5 CANVAS MODE (Like Elementor Canvas)
   Pure HTML - Zero WordPress interference
------------------------------------ */

body.base47-canvas {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
}

body.base47-canvas * {
    /* Let Canvas templates control everything */
    box-sizing: border-box;
}

/* Canvas mode styling (admin bar remains visible for accessibility) */
body.base47-canvas.admin-bar {
    /* Canvas-specific admin bar handling can go here if needed */
}

/* Ensure canvas content layout */
body.base47-canvas #page,
body.base47-canvas .base47-site {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Remove spacing from main content area when Base47 templates are used */
body.base47-canvas .b47-main,
body.base47-canvas main {
    margin: 0 !important;
    padding: 0 !important;
}

/* Remove container padding for full-width Base47 templates */
body.base47-canvas .b47-container,
body.base47-canvas .b47-page-inner {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
}

/* ----
--------------------------------
   5. MOBILE-SPECIFIC FIXES (v1.6.0)
   Block WordPress button styles that override Mivon
------------------------------------ */

@media (max-width: 768px) {
    /* Force remove any WordPress button styling */
    .wp-block-button__link,
    .wp-block-file__button {
        all: unset !important;
    }
    
    /* Ensure Mivon containers work on mobile */
    .container,
    .row,
    section {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Fix any WordPress-added padding on mobile */
    body.page,
    body.single,
    body.home {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* FIX: First section always broken - kill ALL wrappers */
    body > *:not(script):not(style),
    #page,
    main,
    article,
    .entry-content > *:first-child,
    section:first-of-type,
    .header,
    header {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Ensure first Mivon section displays correctly */
    body {
        overflow-x: hidden !important;
    }
}

/* --------------------------------
   6. SCROLL-TO-TOP BUTTON STYLING
------------------------------------ */

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #ff4d00;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(255, 77, 0, 0.3);
}

.scroll-to-top:hover {
    background-color: #e63900;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 77, 0, 0.4);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top i {
    font-size: 18px;
}

/* Hide scroll-to-top on Canvas Mode pages */
body.base47-canvas .scroll-to-top,
body.base47-app-canvas .scroll-to-top {
    display: none !important;
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
    
    .scroll-to-top i {
        font-size: 16px;
    }
}