/* =====================================================================
   Regilyze — Global UX / Responsiveness / Motion Enhancements
   ---------------------------------------------------------------------
   Loaded site-wide (via includes/header.php) AFTER styles.min.css so it
   layers on top of the existing design system. It is intentionally
   ADDITIVE and conservative — it hardens responsiveness, accessibility
   and motion smoothness without changing the brand look (orange #FF6B35,
   Sora / DM Sans, cream/navy). Uses the existing :root tokens with safe
   fallbacks.
   ===================================================================== */

/* ── 1. Responsiveness hardening ───────────────────────────────────── */

/* Stop iOS from auto-inflating text in landscape. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Kill accidental horizontal scrolling on mobile (decorative blobs,
   wide grids, etc. can push past the viewport). */
html, body { overflow-x: hidden; }
body { max-width: 100%; position: relative; }

/* Media never overflows its container. */
img, svg, video, canvas, picture, iframe { max-width: 100%; }
img, video, canvas { height: auto; }

/* Long unbreakable strings (URLs, codes) wrap instead of widening the page. */
p, li, h1, h2, h3, h4, a, span, td, dd, blockquote { overflow-wrap: break-word; }

/* Code / preformatted blocks scroll internally rather than stretching. */
pre, code, table { max-width: 100%; }
pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Remove the grey tap-flash on touch for a more native feel. */
* { -webkit-tap-highlight-color: transparent; }

/* Smoother momentum scrolling inside any scrollable region. */
[style*="overflow"], .scroll, .scrollable { -webkit-overflow-scrolling: touch; }

/* Honour notch / safe-area on modern phones for fixed bars. */
.top-bar, .header, .mobile-nav-content {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── 2. Crisper type rendering ─────────────────────────────────────── */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* On-brand text selection. */
::selection { background: rgba(255, 107, 53, 0.22); color: inherit; }
::-moz-selection { background: rgba(255, 107, 53, 0.22); color: inherit; }

/* ── 3. Accessibility — visible keyboard focus (was missing) ───────── */
/* Mouse / touch users see no ring; keyboard users get a clear one. */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-orange, #FF6B35);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Buttons/links already have backgrounds — keep the ring tight & on-brand. */
a:focus-visible, button:focus-visible,
.btn:focus-visible, .nav-link:focus-visible, .mobile-nav-link:focus-visible {
  outline: 2px solid var(--accent-orange, #FF6B35);
  outline-offset: 3px;
}

/* ── 4. Smoother micro-interactions (subtle, on existing components) ─ */
/* Gentle, consistent easing so colour/shadow changes never "snap". */
a:not(.btn) { transition: color .18s ease, opacity .18s ease; }

button, .btn, [role="button"] {
  transition: background-color .2s ease, border-color .2s ease,
              color .2s ease, box-shadow .25s ease, transform .15s ease;
  will-change: transform;
}
/* A tactile press on tap/click (only where the component can move). */
.btn:active, button:active, [role="button"]:active { transform: translateY(1px); }

/* Form fields: smooth, on-brand focus (keyboard only → no clash with
   existing mouse styling). */
input, textarea, select {
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent-orange, #FF6B35);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

/* Images that sit in cards/heroes ease in rather than popping. */
.card img, .blog-card img, .team-card img, .hero img {
  transition: transform .4s cubic-bezier(.22,.61,.36,1), opacity .4s ease;
}

/* ── 5. Touch ergonomics — comfortable tap targets (coarse pointers) ─ */
@media (pointer: coarse) {
  .nav-link, .mobile-nav-link,
  .footer a, .top-bar-link, .footer-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  /* Buttons stay at least finger-sized without changing their layout box. */
  .btn, button { min-height: 44px; }
}

/* ── 6. Small-screen polish ────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Avoid 1px sub-pixel horizontal jiggle from full-bleed sections. */
  section, .section { max-width: 100vw; }
  /* Tap-friendly spacing between stacked inline links. */
  .mobile-nav-link { margin: 2px 0; }
}

/* ── 7. Motion preference — full guard (completes animations.js) ───── */
/* animations.js already trims its own animations; this also neutralises
   smooth-scroll and any inline/page-level animations site-wide, and is a
   safety net if animations.js fails to load. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:active, button:active, [role="button"]:active { transform: none !important; }
}

/* ── 8. Print: hide chrome, keep content readable ──────────────────── */
@media print {
  .top-bar, .header, .mobile-nav, .menu-toggle, .footer-cta, .btn { display: none !important; }
  body { overflow: visible; }
}
