/**
 * ============================================================
 * Valley Vision Child Theme — assets/css/custom.css
 * ============================================================
 *
 * This file is for:
 *  1. Elementor widget overrides (fix spacing, fonts, colors)
 *  2. Print styles
 *  3. Animation utilities
 *  4. Any quick one-off style fixes
 *
 * This loads AFTER style.css so everything here overrides it.
 * Think of this as the "patch" file — style.css is the system.
 *
 * HOW TO USE:
 * Add your custom CSS overrides here instead of editing
 * style.css directly. This keeps the core styles clean and
 * makes updates easier.
 * ============================================================
 */


/* ============================================================
   SECTION 1: ELEMENTOR OVERRIDES
   ------------------------------------------------------------
   Elementor generates its own inline CSS and sometimes
   overrides theme styles. These rules fix common conflicts.
   ============================================================ */

/* Ensure Elementor sections respect our body font */
.elementor-widget-text-editor *,
.elementor-widget-text-editor p,
.elementor-widget-text-editor li {
    font-family: var(--font-body) !important;
    line-height: 1.7;
}

/* Elementor heading widgets — use our heading font */
.elementor-widget-heading .elementor-heading-title {
    font-family: var(--font-heading) !important;
    font-weight: 700;
}

/* Elementor button widgets — inherit our button styles */
.elementor-widget-button .elementor-button {
    font-family: var(--font-heading) !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
}

/* Elementor primary button color override */
.elementor-widget-button .elementor-button.elementor-button-primary {
    background-color: var(--color-secondary) !important;
    border-color: var(--color-secondary) !important;
    color: var(--color-white) !important;
}

.elementor-widget-button .elementor-button.elementor-button-primary:hover {
    background-color: var(--color-gold-light) !important;
    border-color: var(--color-gold-light) !important;
}

/* Remove extra padding Elementor adds to sections */
.elementor-section.elementor-section-boxed > .elementor-container {
    max-width: var(--container-max);
}

/* Ensure Elementor full-width sections work with our header */
.elementor-section.elementor-section-full_width {
    width: 100%;
}

/* Fix Elementor image widget */
.elementor-widget-image img {
    border-radius: 0; /* Reset — apply custom radius per widget */
}

/* Elementor column inner spacing */
.elementor-column-gap-default > .elementor-row > .elementor-column > .elementor-element-populated {
    padding: 10px;
}

/* Elementor popup overlay — match brand */
.elementor-popup-modal .dialog-message {
    font-family: var(--font-body);
}

/* Elementor native form fields — additional overrides (main styles in style.css Section 13) */
.elementor-field-group input[type="text"],
.elementor-field-group input[type="email"],
.elementor-field-group input[type="tel"],
.elementor-field-group textarea,
.elementor-field-group select {
    font-family: var(--font-body) !important;
    font-size: var(--text-base) !important;
    border: 2px solid var(--color-border) !important;
    border-radius: var(--radius-sm) !important;
    transition: border-color var(--transition-base) !important;
}

.elementor-field-group input:focus,
.elementor-field-group textarea:focus,
.elementor-field-group select:focus {
    border-color: var(--color-secondary) !important;
    outline: none !important;
}

.elementor-field-type-submit .elementor-button {
    background-color: var(--color-secondary) !important;
    color: var(--color-white) !important;
    font-family: var(--font-heading) !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    border-radius: var(--radius-sm) !important;
    transition: background-color var(--transition-base), transform var(--transition-fast) !important;
}

.elementor-field-type-submit .elementor-button:hover {
    background-color: var(--color-gold-light) !important;
    transform: translateY(-2px) !important;
}


/* ============================================================
   SECTION 2: HELLO ELEMENTOR PARENT THEME OVERRIDES
   ------------------------------------------------------------
   Hello Elementor is intentionally minimal. These rules
   patch any gaps between the parent theme and our design.
   ============================================================ */

/* Ensure body has no default margin from Hello Elementor */
body.elementor-page {
    overflow-x: hidden;
}

/* Hello Elementor sometimes adds extra padding to page content */
.page-content {
    padding: 0;
}

/* Fix Hello Elementor header if it interferes with ours */
.site-header.header-default {
    display: none; /* Hide Hello Elementor's default header — we use ours */
}

/* Hello Elementor footer override */
.site-footer.footer-default {
    display: none; /* Hide Hello Elementor's default footer — we use ours */
}


/* ============================================================
   SECTION 3: ANIMATION UTILITIES
   ------------------------------------------------------------
   Lightweight CSS animations for page elements.
   Apply these classes in Elementor or page templates.
   ============================================================ */

/* Fade in from below (standard reveal animation) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in (no direction) */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Scale in (subtle pop) */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Apply these classes to trigger animations */
.animate-fade-up {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease forwards;
}

.animate-slide-left {
    animation: slideInLeft 0.6s ease forwards;
}

.animate-slide-right {
    animation: slideInRight 0.6s ease forwards;
}

/* Delay utilities (use with animation classes) */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }

/* Start animations hidden until triggered */
.animate-on-scroll {
    opacity: 0;
    /* JS in main.js adds 'animated' class when element enters viewport */
}

.animate-on-scroll.animated {
    animation: fadeInUp 0.6s ease forwards;
}


/* ============================================================
   SECTION 4: WORDPRESS ADMIN BAR COMPENSATION
   ------------------------------------------------------------
   When a logged-in WordPress user views the site, WordPress
   adds a 32px admin toolbar at the top. This compensates
   for the fixed header so content isn't hidden behind it.
   ============================================================ */

/* WordPress admin bar is 32px on desktop, 46px on mobile */
body.admin-bar #site-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar #site-header {
        top: 46px;
    }

    body.admin-bar .site-nav {
        top: calc(var(--header-height-sm) + 46px);
    }
}

/* Compensate hero margin when admin bar is present */
body.admin-bar .hero {
    margin-top: calc(var(--header-height) + 32px);
}

body.admin-bar .page-hero {
    margin-top: calc(var(--header-height) + 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .hero,
    body.admin-bar .page-hero {
        margin-top: calc(var(--header-height-sm) + 46px);
    }
}


/* ============================================================
   SECTION 5: PRINT STYLES
   ------------------------------------------------------------
   Clean up the page for printing (estimate PDFs, etc.)
   ============================================================ */

@media print {

    /* Hide non-essential elements */
    #site-header,
    .menu-toggle,
    .hero-actions,
    .trust-bar,
    .footer-cta,
    #site-footer,
    .btn,
    .portfolio-overlay {
        display: none !important;
    }

    /* Remove hero overlay for printing */
    .hero-overlay {
        display: none !important;
    }

    /* Reset body for print */
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }

    /* Ensure links print their destination */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #555;
    }

    /* Don't print tel: and mailto: link destinations */
    a[href^="tel:"]::after,
    a[href^="mailto:"]::after {
        content: none;
    }

    /* Keep headings navy on print */
    h1, h2, h3 {
        color: #1A2E4A;
        page-break-after: avoid;
    }

    /* Prevent images from breaking across pages */
    img {
        page-break-inside: avoid;
        max-width: 100%;
    }

    /* Service cards stack vertically for print */
    .services-grid,
    .portfolio-grid,
    .grid-2,
    .grid-3 {
        display: block !important;
    }

    .service-card,
    .portfolio-item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}


/* ============================================================
   SECTION 6: ACCESSIBILITY ENHANCEMENTS
   ============================================================ */

/* Ensure focus states are always visible */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
}

/* Skip link — shown when focused via keyboard */
.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 9999;
    background: var(--color-secondary);
    color: var(--color-white);
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--text-sm);
    transition: top var(--transition-base);
}

.skip-link:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-primary:   #000033;
        --color-secondary: #CC7700;
        --color-border:    #666666;
    }
}

/* Reduced motion support — disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ============================================================
   SECTION 7: UTILITY OVERRIDES
   ------------------------------------------------------------
   Add any quick fixes or client-specific tweaks here.
   Label each with a comment explaining what it does and why.
   ============================================================ */

/* Example: Remove WordPress default image captions */
/*
.wp-caption {
    max-width: 100%;
    background: none;
    border: none;
}
*/

/* Example: Style blockquotes (for blog/testimonials) */
blockquote {
    border-left: 4px solid var(--color-secondary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--color-text-light);
    background: var(--color-bg-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* Style WordPress gallery blocks */
.wp-block-gallery {
    gap: 1rem !important;
}

/* Style WordPress image captions */
.wp-block-image figcaption {
    font-size: var(--text-xs);
    color: var(--color-text-light);
    font-style: italic;
    text-align: center;
    padding-top: 0.5rem;
}
