/**
 * Buzzonic global UI enhancements (loads after Tailwind / style.css)
 */

:root {
    --buzz-focus: rgba(168, 85, 247, 0.45);
    --buzz-focus-ring: 0 0 0 3px rgba(168, 85, 247, 0.2);
    /* Fixed header: h-20 (5rem) + safe area */
    --buzz-header-height: 5rem;
    --buzz-header-offset: max(7rem, calc(var(--buzz-header-height) + 2rem + env(safe-area-inset-top, 0px)));
}

html {
    scroll-behavior: smooth;
    /* Anchor links / in-page scroll clear fixed nav */
    scroll-padding-top: var(--buzz-header-offset);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        sans-serif;
}

/* --------------------------------------------------------------------------
   Unified reading flow (site pages): start-aligned copy, consistent rhythm.
   Intentionally centered blocks (.text-center) keep centered text.
   -------------------------------------------------------------------------- */
.min-h-screen p,
.min-h-screen li {
    text-align: start;
}

.min-h-screen .text-center p,
.min-h-screen .text-center li,
.min-h-screen [class*="text-center"] p:where(:not([class*="text-left"])),
.min-h-screen [class*="text-center"] li:where(:not([class*="text-left"])) {
    text-align: center;
}

/* Body copy: one consistent size/line-height unless a page sets a Tailwind text-* on the element */
.min-h-screen p:not([class*="text-xs"]):not([class*="text-sm"]):not([class*="text-md"]):not([class*="text-lg"]):not(
        [class*="text-xl"]
    ):not([class*="text-2xl"]):not([class*="text-3xl"]):not([class*="text-4xl"]):not([class*="text-5xl"]) {
    font-size: 1rem;
    line-height: 1.65;
}

/* Kill inline justified blocks site-wide (footer etc. handled separately) */
p[style*="justify"] {
    text-align: start !important;
}

/* Primary page titles: extra clearance under fixed header on small screens */
@media (max-width: 1023px) {
    /* Skip homepage swiper (full-bleed bg-black); industry/service heroes need top inset */
    body > div.min-h-screen > section:first-of-type:not(.bg-black),
    body > div.min-h-screen > main > section:first-of-type:not(.bg-black) {
        padding-top: var(--buzz-header-offset);
    }

    .min-h-screen > section:first-of-type h1,
    .min-h-screen > main > section:first-of-type h1 {
        scroll-margin-top: var(--buzz-header-offset);
    }
}

@media (min-width: 1024px) {
    .min-h-screen > section:first-of-type h1,
    .min-h-screen > main > section:first-of-type h1 {
        scroll-margin-top: 1.5rem;
    }
}

::selection {
    background: rgba(251, 146, 60, 0.35);
    color: inherit;
}

/* Skip link (keyboard / screen reader) */
.skip-to-content {
    position: fixed;
    left: 0.75rem;
    top: 0.75rem;
    z-index: 100000;
    padding: 0.65rem 1.1rem;
    background: linear-gradient(90deg, #f59e0b, #ea580c);
    color: #fff !important;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    text-decoration: none;
    box-shadow: 0 10px 25px rgba(234, 88, 12, 0.35);
    transform: translateY(-200%);
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.skip-to-content:focus {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Accessible focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--buzz-focus);
    outline-offset: 2px;
}

/* Contact form (buzz-contact-form) */
#buzz-contact-form input[type="text"],
#buzz-contact-form input[type="email"],
#buzz-contact-form input[type="tel"],
#buzz-contact-form select,
#buzz-contact-form textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#buzz-contact-form input:focus,
#buzz-contact-form select:focus,
#buzz-contact-form textarea:focus {
    border-color: #a855f7;
    box-shadow: var(--buzz-focus-ring);
}

#buzz-contact-form input[aria-invalid="true"],
#buzz-contact-form select[aria-invalid="true"],
#buzz-contact-form textarea[aria-invalid="true"] {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

#buzz-contact-submit:disabled {
    cursor: not-allowed;
    opacity: 0.85;
    transform: none !important;
}

/* Toast banners */
.buzz-toast-animate {
    animation: buzz-toast-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes buzz-toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, -12px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Scroll-to-top control */
.scroll-to-top {
    cursor: pointer;
    border: none;
    font: inherit;
}

.scroll-to-top:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* Slightly nicer card depth on hover for generic card-hover if present */
.card-hover,
.card-hover.group {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Contact submit spinner (if Tailwind animate-spin missing on element) */
@keyframes buzz-spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: buzz-spin 1s linear infinite;
}
