/**
 * pages/global.css — Universal polish for ALL pages
 * Phase 6 Page-by-Page Polish
 *
 * This file applies the Phase 2 visual elevations universally:
 *   • Typography optical tuning (letter-spacing, text-wrap)
 *   • Branded scrollbar
 *   • Branded text selection
 *   • Form focus glow
 *   • CTA button shimmer
 *   • Reduced-motion + touch device guards
 *
 * Safe additive — uses :root-level selectors only, no scoping needed.
 * Loaded AFTER existing page CSS so source order wins ties.
 */

/* ============================================================
   TYPOGRAPHY OPTICAL TUNING — applied to ALL pages
   text-wrap and font-feature-settings are progressive enhancements;
   browsers that don't support them simply ignore.
   ============================================================ */
h1 {
    letter-spacing: -0.03em;
    text-wrap: balance;
    font-feature-settings: 'kern' 1, 'liga' 1, 'ss01' 1, 'cv01' 1;
}

h2 {
    letter-spacing: -0.02em;
    text-wrap: balance;
    font-feature-settings: 'kern' 1, 'liga' 1;
}

h3 {
    letter-spacing: -0.01em;
    text-wrap: balance;
}

h4,
h5,
h6 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

/* Stat numbers — tabular figures + tight tracking */
.stat-number,
[class*="stat-num"] {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Eyebrow / label / tag style — tracked out uppercase */
.stat-label,
.eyebrow,
.section-eyebrow {
    letter-spacing: 0.08em;
}

/* ============================================================
   BRANDED SCROLLBAR — for every page
   ============================================================ */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.4), rgba(78, 205, 196, 0.35));
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.6), rgba(78, 205, 196, 0.5));
    background-clip: padding-box;
}

html {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.4) transparent;
}

/* ============================================================
   BRANDED TEXT SELECTION — every page
   ============================================================ */
::selection {
    background: rgba(168, 85, 247, 0.4);
    color: #fff;
}

::-moz-selection {
    background: rgba(168, 85, 247, 0.4);
    color: #fff;
}

/* ============================================================
   UNIVERSAL FORM FOCUS GLOW
   Branded purple ring on input focus.
   ============================================================ */
input:not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="radio"]):not([type="checkbox"]):focus,
textarea:focus,
select:focus {
    border-color: rgba(168, 85, 247, 0.7) !important;
    box-shadow:
        0 0 0 3px rgba(168, 85, 247, 0.16),
        0 4px 24px rgba(168, 85, 247, 0.1) !important;
    outline: none !important;
}

/* ============================================================
   UNIVERSAL CTA BUTTON SHIMMER
   Adds a subtle white sweep across .cta-button on hover.
   The existing .cta-button has its own ::before, so we use ::after.
   ============================================================ */
.cta-button {
    position: relative;
    overflow: hidden;
}

.cta-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(120deg,
            transparent 30%,
            rgba(255, 255, 255, 0.18) 50%,
            transparent 70%);
    transform: translateX(-110%);
    transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    z-index: 1;
}

.cta-button:hover::after {
    transform: translateX(110%);
}

.cta-button>* {
    position: relative;
    z-index: 2;
}

/* ============================================================
   UNIVERSAL BACK-TO-TOP BUTTON STYLES
   The button is injected by ux-enhancements.js on every page.
   Same purple gradient circle as the homepage.
   ============================================================ */
#mac-back-to-top {
    position: fixed;
    right: clamp(1rem, 3vw, 2rem);
    bottom: clamp(6.5rem, 12vw, 8.5rem);
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c084fc 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.35),
        0 0 30px rgba(168, 85, 247, 0.35);
    cursor: pointer;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.85);
    transition:
        opacity 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        visibility 0.35s,
        box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#mac-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#mac-back-to-top:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(168, 85, 247, 0.55);
}

#mac-back-to-top:active {
    transform: translateY(-1px) scale(0.95);
    transition-duration: 0.1s;
}

@media (max-width: 768px) {
    #mac-back-to-top {
        width: 44px;
        height: 44px;
        right: 0.85rem;
        bottom: 7.5rem;
    }
}

/* ============================================================
   UNIVERSAL MOBILE TAP HIGHLIGHT
   Branded purple ripple instead of default grey/blue.
   ============================================================ */
@media (hover: none) and (pointer: coarse) {

    a,
    button,
    [role="button"] {
        -webkit-tap-highlight-color: rgba(168, 85, 247, 0.18);
    }
}

/* ============================================================
   REDUCED MOTION GUARD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

    .cta-button::after,
    #mac-back-to-top {
        transition: opacity 0.01ms !important;
        animation: none !important;
    }

    #mac-back-to-top.is-visible {
        transform: none !important;
    }
}

/* ============================================================
   SECTION REVEAL ANIMATIONS — universal scroll-in effect
   Many existing pages have sections that start at opacity:0
   waiting for an .animate-in class. We don't change that, but
   we DO add a smoother transition curve.
   ============================================================ */
section.animate-in,
section.is-visible {
    transition:
        opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================================
   IMPROVED FOCUS-VISIBLE FOR KEYBOARD USERS
   Hide focus outline for mouse users, show distinct ring for keyboard users.
   ============================================================ */
:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.7);
    outline-offset: 3px;
    border-radius: 4px;
}

:focus:not(:focus-visible) {
    outline: none;
}
