/**
 * Global Fixes - Responsive & Accessibility Improvements
 * Joe Garage Door Repair
 * 
 * This file contains:
 * - Mobile responsiveness fixes (360px - 1024px+)
 * - Accessibility improvements (WCAG AA)
 * - Layout consistency fixes
 * - Typography normalization
 */

/* ═══════════════════════════════════════════════════════════════
   BASE RESPONSIVE FIXES
   ═══════════════════════════════════════════════════════════════ */

/* Prevent horizontal scrolling */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all images are responsive */
img {
  max-width: 100%;
  height: auto;
}

/* Ensure all containers don't overflow */
.container,
.footer__grid,
.services-grid,
.cards-grid,
section > div {
  max-width: 100%;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY IMPROVEMENTS
   ═══════════════════════════════════════════════════════════════ */

/* Focus visible styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

/* Remove outline for mouse users */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* Minimum tap target size (44px) */
a, button, 
input[type="submit"], 
input[type="button"],
.btn,
.nav__link,
.footer__link {
  min-height: 44px;
  min-width: 44px;
}

/* Inline links can be smaller height */
p a, li a, span a {
  min-height: auto;
  min-width: auto;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  z-index: 10000;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* Improved color contrast */
.footer__text,
.footer__link,
.footer__contact-item {
  color: rgba(255, 255, 255, 0.8);
}

.footer__link:hover,
.footer__contact-item a:hover {
  color: #fff;
}

/* Screen reader only content */
.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;
}

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY NORMALIZATION
   ═══════════════════════════════════════════════════════════════ */

/* Ensure proper heading hierarchy */
h1 { font-size: clamp(1.75rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
h5 { font-size: clamp(1rem, 2vw, 1.25rem); }
h6 { font-size: clamp(0.9rem, 1.5vw, 1.1rem); }

/* Consistent line height */
body {
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  margin-bottom: 0.5em;
}

p {
  margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS - 360px (Small phones)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 360px) {
  body {
    font-size: 14px;
  }
  
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }
  
  .btn {
    padding: 10px 16px;
    font-size: 0.875rem;
  }
  
  .hero__title {
    font-size: 1.5rem !important;
  }
  
  .hero__subtitle {
    font-size: 0.9rem !important;
  }
  
  .footer__grid {
    gap: 1.5rem;
  }
  
  .footer__title {
    font-size: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS - 414px (iPhone Plus / Standard)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 414px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  
  .hero {
    padding: 2rem 0;
  }
  
  .hero__cta {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .hero__cta .btn {
    width: 100%;
    justify-content: center;
  }
  
  .section {
    padding: 2.5rem 0;
  }
  
  .cards-grid,
  .services-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .card {
    padding: 1.25rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS - 768px (Tablets)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  /* Footer grid - stack on mobile */
  .footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
  
  .footer__brand {
    grid-column: 1 / -1;
  }
  
  /* Hero adjustments */
  .hero {
    padding: 3rem 0;
  }
  
  .hero__title {
    font-size: 2rem !important;
  }
  
  /* Section spacing */
  .section {
    padding: 3rem 0;
  }
  
  .section__header {
    margin-bottom: 2rem;
  }
  
  /* Cards grid */
  .cards-grid,
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Hide desktop CTA, show mobile */
  .header__cta {
    display: none !important;
  }
  
  .nav-toggle {
    display: flex !important;
  }
  
  /* Mobile sticky CTA */
  .mobile-sticky-cta {
    display: flex !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET/DESKTOP - 1024px+
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
  .footer__grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  
  .cards-grid,
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .mobile-sticky-cta {
    display: none !important;
  }
  
  .header__cta {
    display: flex !important;
  }
  
  .nav-toggle {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   HEADER & NAVIGATION FIXES
   ═══════════════════════════════════════════════════════════════ */

/* Ensure header is always on top */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* Body padding for fixed header */
body {
  padding-top: var(--header-height, 80px);
}

/* Navigation toggle button accessibility */
.nav-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  min-width: 44px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: currentColor;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER FIXES
   ═══════════════════════════════════════════════════════════════ */

.footer {
  padding: 3rem 0 1.5rem;
}

.footer__grid {
  display: grid;
  gap: 2rem;
}

.footer__bottom {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

/* Footer blog posts list */
.footer-latest-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-latest-posts li {
  margin-bottom: 12px;
}

.footer-latest-posts a {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.4;
  display: block;
  transition: color 0.2s ease;
}

.footer-latest-posts a:hover {
  color: #fff;
}

.footer-post-date {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE STICKY CTA BAR
   ═══════════════════════════════════════════════════════════════ */

.mobile-sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  gap: 8px;
  padding: 10px;
  background: #1f2937;
  z-index: 998;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.mobile-sticky-cta a {
  flex: 1;
  padding: 12px;
  text-align: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 8px;
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cta-call {
  background: #10b981;
}

.cta-book {
  background: #2563eb;
}

/* Add padding to body when mobile CTA is visible */
@media (max-width: 767px) {
  body {
    padding-bottom: 70px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS & INTERACTIVE ELEMENTS
   ═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 12px 24px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  min-height: 44px;
}

.btn--primary {
  background: #2563eb;
  color: #fff;
}

.btn--primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn--outline {
  background: transparent;
  color: #2563eb;
  border: 2px solid #2563eb;
}

.btn--outline:hover {
  background: #2563eb;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS & CONTENT BLOCKS
   ═══════════════════════════════════════════════════════════════ */

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════════════════════════
   FORMS ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */

input, select, textarea {
  font-size: 16px; /* Prevents iOS zoom on focus */
  min-height: 44px;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   BLOG & SERVICE PAGE CONSISTENCY
   ═══════════════════════════════════════════════════════════════ */

/* Page header consistency */
.page-header {
  padding: 2rem 0;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

/* Breadcrumb navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* Article/Blog content */
.article-content,
.blog-content,
.service-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 0;
}

.article-content h2,
.blog-content h2,
.service-content h2 {
  margin-top: 2rem;
}

.article-content img,
.blog-content img,
.service-content img {
  border-radius: 8px;
  margin: 1.5rem 0;
}

/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════ */

@media print {
  .header,
  .footer,
  .mobile-sticky-cta,
  .nav-toggle,
  .cookie-consent {
    display: none !important;
  }
  
  body {
    padding: 0;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION PREFERENCE
   ═══════════════════════════════════════════════════════════════ */

@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;
  }
}

/* ═══════════════════════════════════════════════════════════════
   HIGH CONTRAST MODE
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-contrast: high) {
  .btn--primary {
    border: 2px solid #fff;
  }
  
  .footer__link,
  .footer-latest-posts a {
    color: #fff;
  }
  
  a {
    text-decoration: underline;
  }
}

