/* ============================================================
   Solution Express Media LLC — Interactive Layer
   ------------------------------------------------------------
   Loaded last. Styles for the interaction layer in
   js/interactions.js, plus the
   touch/pointer refinements that make the site feel native on
   both phones and desktops.

     1.  Base touch & pointer hygiene
     2.  Focus visibility
     3.  Scroll progress bar
     4.  Nav auto-hide
     5.  Mobile menu refinements
     6.  Dropdown on touch
     7.  Press feedback & ripple
     8.  Card tilt / spotlight
     9.  Scrollable blocks
    10.  Copy button
    11.  Image fade-in
    12.  Scrollspy
    13.  Reduced motion
    14.  Responsive navigation
    15.  Narrow-screen overflow
    16.  Footer email
   ============================================================ */

/* ============================================================
   1. Base touch & pointer hygiene
   ============================================================ */
html {
  -webkit-text-size-adjust: 100%;   /* stop iOS enlarging text on rotate */
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  overflow-x: hidden;               /* no accidental horizontal pan */
  -webkit-tap-highlight-color: transparent;
}

/* Interactive elements should never show the grey iOS flash, and
   should never be selected by an accidental long-press. */
a, button, .btn, [role="button"], .faq-question,
.mobile-nav-section-toggle {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;       /* removes the 300ms tap delay */
}

/* Every tappable control clears the 44x44px minimum touch target. */
@media (pointer: coarse) {
  .btn,
  .nav-link,
  .mobile-nav-link,
  .footer-links a,
  .faq-question,
  #menu-toggle,
  #menu-close,
  #back-to-top {
    min-height: 44px;
  }

  .btn, #menu-toggle, #menu-close {
    min-width: 44px;
  }

  /* Space out dense link lists so neighbouring targets are distinct. */
  .footer-links li + li { margin-top: var(--space-2); }
}

/* Screen-reader-only utility used by the live region. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   2. Focus visibility
   Keyboard users always get a clear ring; mouse users do not.
   ============================================================ */
:focus { outline: none; }

:focus-visible,
.using-keyboard a:focus,
.using-keyboard button:focus,
.using-keyboard input:focus,
.using-keyboard textarea:focus,
.using-keyboard select:focus,
.using-keyboard [tabindex]:focus {
  outline: 3px solid var(--color-blue);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   3. Scroll progress bar
   ============================================================ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: calc(var(--z-sticky) + 10);
  pointer-events: none;
  background: transparent;
}

.scroll-progress-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--color-blue), var(--color-amber));
  will-change: transform;
}

/* ============================================================
   4. Nav auto-hide (small screens)
   ============================================================ */
#site-nav {
  transition: transform var(--transition-base),
              background-color var(--transition-base),
              box-shadow var(--transition-base);
  will-change: transform;
}

#site-nav.nav--hidden {
  transform: translateY(-100%);
}

@media (min-width: 1025px) {
  #site-nav.nav--hidden { transform: none; }
}

/* ============================================================
   5. Mobile menu refinements
   ============================================================ */
#mobile-menu {
  transition: transform var(--transition-base), opacity var(--transition-base);
  overscroll-behavior: contain;     /* menu scroll does not chain to the page */
  -webkit-overflow-scrolling: touch;
}

#menu-overlay {
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* Collapsible service sections inside the drawer. */
.mobile-nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-text-light);
}

.mobile-nav-chevron {
  display: inline-flex;
  transition: transform var(--transition-base);
}

.mobile-nav-chevron svg {
  width: 18px;
  height: 18px;
}

.mobile-nav-section.is-collapsed .mobile-nav-chevron {
  transform: rotate(-90deg);
}

.mobile-nav-panel {
  overflow: hidden;
  transition: max-height var(--transition-base);
}

/* ============================================================
   6. Dropdown behaviour on touch
   The desktop rule hides dropdowns under 768px; on tablets in the
   768-1024px range they open on tap instead of hover.
   ============================================================ */
@media (hover: none) {
  .nav-dropdown {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
  }
}

/* components.css transitions `visibility` alongside opacity. During the
   first frame of hidden -> visible the computed value is still `hidden`,
   which makes .focus() a no-op — so ArrowDown opened the panel but left
   focus stranded on the trigger. Flip visibility instantly on open, and
   delay it on close so the fade-out is still visible. */
.nav-dropdown {
  transition: opacity var(--transition-base),
              transform var(--transition-base),
              visibility 0s linear 250ms;
}

.nav-dropdown.is-open {
  transition: opacity var(--transition-base),
              transform var(--transition-base),
              visibility 0s linear 0s;
}

.nav-dropdown-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.nav-dropdown-trigger svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-base);
}

/* ============================================================
   7. Press feedback & ripple
   Touch devices get no :hover, so the pressed state carries the
   feedback instead.
   ============================================================ */
.btn {
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast),
              box-shadow var(--transition-base),
              background-color var(--transition-base),
              color var(--transition-base);
}

.is-pressed {
  transform: scale(0.97);
}

.btn.is-pressed {
  transform: scale(0.96);
}

.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
  animation: btn-ripple 600ms ease-out forwards;
}

.btn--ghost .btn-ripple,
.btn--secondary .btn-ripple {
  background: rgba(37, 99, 235, 0.22);
}

@keyframes btn-ripple {
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

/* Hover lifts belong to pointer devices only — on a phone they
   stick after a tap and look like a stuck state. */
@media (hover: none) {
  .service-card:hover,
  .testimonial-card:hover,
  .blog-card:hover,
  .value-card:hover,
  .feature-card:hover {
    transform: none;
    box-shadow: var(--shadow-card);
  }
}

/* ============================================================
   8. Card tilt / spotlight (pointer devices only)
   ============================================================ */
.has-tilt {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --spot-x: 50%;
  --spot-y: 50%;
  transform-style: preserve-3d;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow var(--transition-base);
}

.has-hover .has-tilt:hover {
  transform: perspective(900px)
             rotateX(var(--tilt-x))
             rotateY(var(--tilt-y))
             translateY(-6px);
  box-shadow: var(--shadow-xl);
}

/* Cursor-following highlight, drawn above the card background. */
.has-hover .has-tilt::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
  background: radial-gradient(
    360px circle at var(--spot-x) var(--spot-y),
    rgba(37, 99, 235, 0.10),
    transparent 62%
  );
}

.has-hover .has-tilt:hover::after {
  opacity: 1;
}

/* ============================================================
   9. Scrollable blocks (wide tables etc.)
   ============================================================ */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.table-wrap {
  position: relative;
  max-width: 100%;
}

.table-wrap table {
  min-width: 100%;
}

/* Fading edge tells the user there is more to the right. */
.scroll-x.can-scroll:not(.at-end)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95));
}

.scroll-x::-webkit-scrollbar {
  height: 8px;
}

.scroll-x::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.scroll-x::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* ============================================================
   10. Copy button
   ============================================================ */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: var(--space-2);
  vertical-align: middle;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-white);
  color: var(--color-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-base),
              color var(--transition-base),
              border-color var(--transition-base);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}

/* Reveal on hover of the neighbouring link, or on keyboard focus. */
a:hover + .copy-btn,
.copy-btn:hover,
.copy-btn:focus-visible {
  opacity: 1;
  color: var(--color-blue);
  border-color: var(--color-blue);
}

.copy-btn.is-copied {
  opacity: 1;
  color: var(--color-success);
  border-color: var(--color-success);
}

.copy-btn.is-copied::after {
  content: 'Copied';
  position: absolute;
  transform: translateY(-28px);
  font-size: var(--font-size-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-success);
  background: var(--color-white);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-success);
  white-space: nowrap;
}

/* ============================================================
   11. Image fade-in
   ============================================================ */
.img-fade {
  opacity: 0;
  transition: opacity 500ms ease;
}

.img-fade.is-loaded {
  opacity: 1;
}

/* No JS: never leave images invisible. */
html:not(.js-enabled) .img-fade {
  opacity: 1;
}

/* ============================================================
   12. Scrollspy
   ============================================================ */
.toc-link.is-current,
.section-nav a.is-current,
[data-scrollspy] a.is-current {
  color: var(--color-blue);
  font-weight: var(--fw-semibold);
  border-left-color: var(--color-blue);
}

/* ============================================================
   13. Reduced motion
   Anyone who asks for less motion gets content, not animation.
   ============================================================ */
@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;
  }

  .animate-on-scroll {
    opacity: 1 !important;
    transform: none !important;
  }

  .has-tilt,
  .has-hover .has-tilt:hover {
    transform: none !important;
  }

  .img-fade { opacity: 1 !important; }
}

.reduce-motion .animate-on-scroll {
  opacity: 1;
  transform: none;
}

/* ============================================================
   No-JS safety net — reveal animations must not hide content
   if the script fails to load.
   ============================================================ */
html:not(.js-enabled) .animate-on-scroll {
  opacity: 1;
  transform: none;
}

/* ============================================================
   14. Responsive navigation fixes
   ------------------------------------------------------------
   The nav bar previously overflowed on phones: the logo, the
   full-width "Get Free SEO Audit" button and the hamburger
   together were wider than a 390px viewport, pushing the menu
   button off-screen and making it untappable.
   ============================================================ */
.nav-container {
  gap: var(--space-4);
  min-width: 0;
}

.nav-logo {
  min-width: 0;                     /* allow the logo block to shrink */
}

.nav-logo-text {
  min-width: 0;
}

.nav-logo-name,
.nav-logo-tagline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-cta {
  flex-shrink: 0;
}

/* Two labels, one shown at a time. */
.cta-label-short { display: none; }
.cta-label-full  { display: inline; }

@media (max-width: 1024px) {
  .nav-container { padding-left: var(--space-4); padding-right: var(--space-4); }
}

@media (max-width: 640px) {
  /* Short CTA label so the button, logo and hamburger all fit. */
  .cta-label-full  { display: none; }
  .cta-label-short { display: inline; }

  #nav-cta-btn,
  .nav-cta .btn--sm {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    font-size: var(--font-size-sm);
  }

  .nav-logo-tagline { display: none; }

  .nav-logo-name {
    font-size: var(--font-size-sm);
    max-width: 42vw;
  }

  .nav-container { gap: var(--space-3); }
}

@media (max-width: 400px) {
  /* Tightest phones: the logo mark alone carries the brand;
     the full name still reads in the drawer header. */
  .nav-logo-name { max-width: 30vw; }

  .nav-cta .btn--sm {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .nav-container { gap: var(--space-2); }
}

/* The drawer header has more room than the top bar, but the brand
   name must still stop short of the close button rather than sliding
   underneath it. */
.mobile-menu-header {
  gap: var(--space-4);
}

.mobile-menu-header .nav-logo {
  min-width: 0;
  flex: 1 1 auto;
}

#menu-close {
  flex-shrink: 0;
}

#mobile-menu .nav-logo-name {
  max-width: 100%;
  font-size: var(--font-size-base);
}

/* ============================================================
   15. Narrow-screen overflow fixes
   ------------------------------------------------------------
   Several pages scrolled sideways on phones. Two root causes:

   a) `.btn` sets `white-space: nowrap`, so a long CTA such as
      "Identify Your SEO Issues — Free Audit" had a min-content
      width of ~440px. Inside a grid it forced the whole column
      (and the page) wider than the viewport.

   b) Grid and flex children default to `min-width: auto`, which
      refuses to shrink below their content's minimum width, so
      that 440px propagated all the way up to <body>.
   ============================================================ */

/* (b) Let layout children actually shrink.
   Covers every grid container in the stylesheets. */
.grid > *,
.about-grid > *,
.about-values > *,
.article-layout > *,
.audit-checklist > *,
.audit-grid > *,
.blog-featured > *,
.contact-grid > *,
.footer-grid > *,
.form-grid-2 > *,
.hero-grid > *,
.local-seo-grid > *,
.problem-grid > *,
.process-steps > *,
.service-detail-row > *,
.tech-pillars > *,
.why-grid > * {
  min-width: 0;
}

/* Note: `min-width: 0` on the children above is sufficient on its
   own — no grid-template overrides are needed, so the existing
   breakpoints keep their original column counts. */

/* Long words, quoted key phrases and URLs must break rather than
   push the page sideways. */
body {
  overflow-wrap: break-word;
}

p, li, h1, h2, h3, h4, h5, h6,
blockquote, em, strong, .testimonial-text,
.contact-info-value, .audit-point, .check-list li {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Preserve deliberate no-wrap where it matters (short labels). */
.nav-link,
.btn--sm,
.testimonial-stars {
  overflow-wrap: normal;
}

@media (max-width: 640px) {
  /* (a) Long CTA labels wrap onto two lines instead of forcing
     the viewport wider. */
  .btn {
    white-space: normal;
    text-align: center;
    max-width: 100%;
  }

  /* Full-width CTAs read better than ragged half-width ones. */
  .btn--lg,
  .btn--xl {
    width: 100%;
  }

  /* The nav CTA stays compact and on one line. */
  .nav-cta .btn--sm {
    white-space: nowrap;
    width: auto;
  }

  .hero-ctas,
  .cta-group {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Two-column blocks that only collapsed at 768px still overflowed
   on the narrowest phones. */
@media (max-width: 600px) {
  .contact-grid,
  .audit-grid,
  .form-grid-2,
  .grid--auto-2,
  .grid--auto-3,
  .grid--auto-4 {
    grid-template-columns: 1fr;
  }
}

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

iframe {
  max-width: 100%;
}

/* ============================================================
   16. Footer email
   ============================================================ */
.footer-email {
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  line-height: var(--lh-relaxed);
  /* A long address must wrap rather than widen the footer column. */
  overflow-wrap: anywhere;
}

.footer-email a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-email a:hover,
.footer-email a:focus-visible {
  color: var(--color-white);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The policy pages use a centred single-column footer. */
.site-footer .footer-copyright + .footer-email,
.site-footer > .container > .footer-email {
  text-align: center;
}
