/* ==========================================================================
   ORIAN ROOFING AND CONSTRUCTION - RESPONSIVE & ACCESSIBILITY STYLES
   ========================================================================== */

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  :root {
    --container-width: 1320px;
  }
}

/* Desktop & Laptop (1024px to 1279px) */
@media (max-width: 1279px) {
  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }

  .footer-grid {
    grid-template-columns: 1.2fr 1fr 1fr 1fr;
    gap: var(--space-xl);
  }
}

/* ============================================================
   SERVICE AREAS GRID — Responsive Breakpoints
   ============================================================ */
@media (max-width: 1023px) {
  .sa-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .sa-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .service-area-card {
    padding: 1.1rem 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .service-area-card .sa-pin {
    width: 24px;
    height: 24px;
  }

  .sa-cta-row {
    flex-direction: column;
    gap: 0.875rem;
    text-align: center;
  }
}

/* Tablet (768px to 1023px) */
@media (max-width: 1023px) {
  .top-bar-info {
    font-size: 0.8rem;
    gap: 1rem;
  }

  .logo-img {
    height: 58px;
    width: auto;
  }

  /* Hide desktop nav, show hamburger */
  .nav-menu {
    display: none;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
  }

  /* CTA button visible & responsive on tablet */
  .site-header .btn-primary,
  .header-cta {
    display: inline-flex !important;
    padding: 0.6rem 1.15rem;
    font-size: 0.88rem;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .hero-card-stack {
    max-width: 600px;
    margin-inline: auto;
  }

  /* 2-column grids on tablet */
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }

  /* Force inline grid overrides to be responsive */
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Mobile (480px to 767px) */
@media (max-width: 767px) {
  .top-bar {
    display: none;
  }

  .site-header {
    padding-block: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #FFFFFF;
    box-shadow: var(--shadow-subtle);
  }

  /* Header layout: logo left, CTA button middle, hamburger right */
  .header-container {
    gap: 0.35rem;
    padding-inline: 0.25rem;
  }

  .logo-link {
    gap: 0.35rem;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
  }

  .logo-img {
    height: 46px;
    width: 46px;
    background: transparent;
    flex-shrink: 0;
  }

  .logo-text {
    font-size: 1rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }

  .logo-text span {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  /* Red CTA Button visible on mobile header */
  .site-header .btn-primary,
  .header-cta {
    display: inline-flex !important;
    padding: 0.48rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: var(--radius-sm);
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem;
    flex-shrink: 0;
  }

  /* All grids collapse to single column on mobile */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* Override any inline repeat() column definitions */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .trust-grid {
    flex-direction: column;
    align-items: flex-start;
    padding-inline: 1rem;
  }

  .cta-banner {
    padding: var(--space-xl) var(--space-md);
    border-radius: var(--radius-md);
  }

  .cta-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .cta-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  /* Section spacing tighter on mobile */
  .section-spacing {
    padding-block: var(--space-2xl);
  }

  /* Process grid */
  .process-grid {
    grid-template-columns: 1fr !important;
  }

  .showcased-projects-grid {
    grid-template-columns: 1fr !important;
  }

  .project-img-card.project-card-tall img {
    height: 240px;
  }

  div:has(> .why-card) {
    grid-template-columns: 1fr !important;
  }

  /* FAQ font size adjustment */
  .faq-button {
    font-size: 1rem;
    padding: 1rem 1.1rem;
  }

  /* Blog article readability */
  .blog-article h2 {
    font-size: clamp(1.4rem, 5vw, 2rem);
  }

  .blog-article h3 {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
  }

  /* Breadcrumb wrapping */
  .breadcrumb-list {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  /* Service card body padding */
  .service-card-body {
    padding: 1.25rem;
  }

  /* Hero heading size */
  h1 {
    font-size: clamp(1.9rem, 7vw, 2.8rem);
  }

  h2 {
    font-size: clamp(1.5rem, 5.5vw, 2.2rem);
  }

  /* Prevent images from overflowing */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* Small Mobile (<480px) */
@media (max-width: 479px) {
  .header-container {
    gap: 0.25rem;
  }

  .logo-img {
    height: 38px;
    width: 38px;
    background: transparent;
  }

  .logo-text {
    max-width: 125px;
    font-size: 0.88rem;
  }

  .site-header .btn-primary,
  .header-cta {
    padding: 0.42rem 0.6rem;
    font-size: 0.74rem;
  }

  .mobile-toggle {
    padding: 0.25rem;
  }

  .mobile-toggle svg {
    width: 24px;
    height: 24px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
  }

  .mobile-nav-drawer {
    width: 88%;
  }

  /* Tighter section spacing */
  .section-spacing {
    padding-block: var(--space-xl);
  }

  /* Ensure trust bar items stack properly */
  .trust-item {
    width: 100%;
  }
}

/* Global Table Responsiveness Protection */
table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

/* Prevent horizontal body overflow without breaking position: sticky */
html, body {
  overflow-x: clip;
  max-width: 100vw;
}

/* Ensure buttons in cards wrap text if container is small */
.service-card .btn,
.service-card a.btn {
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

/* High Contrast & Focus States */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* Reduced Motion Override */
@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;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

@media (max-width: 640px) {
  .grid-3 {
    grid-template-columns: 1fr !important;
  }
}
