/* ==========================================================================
   PP ELECTRICAL & MAINTENANCE — MOBILE-FIRST RESPONSIVE STYLESHEET
   Target: 320px base -> progressive min-width enhancements -> 768px+ handoff
   Sections:
     1. Variables
     2. Base
     3. Layout
     4. Components
     5. App Behaviour
     6. Samsung & Foldables
     7. Breakpoints (320, 360, 375, 384, 390, 412, 430, 480, 600, 768)
     8. Landscape
     9. Accessibility
   ========================================================================== */

/* ==========================================================================
   1. VARIABLES
   ========================================================================== */
:root {
  color-scheme: dark;

  /* Fluid spacing scale */
  --m-space-xs: clamp(0.25rem, 1vw, 0.5rem);
  --m-space-sm: clamp(0.5rem, 2vw, 0.75rem);
  --m-space-md: clamp(0.75rem, 3vw, 1.25rem);
  --m-space-lg: clamp(1rem, 4vw, 1.75rem);
  --m-space-xl: clamp(1.5rem, 5vw, 2.5rem);

  /* Fluid typography scale (rem-based for 130%-200% text scaling support) */
  --m-fs-xs: clamp(0.75rem, 2.5vw, 0.8125rem);
  --m-fs-sm: clamp(0.875rem, 3vw, 0.9375rem);
  --m-fs-base: clamp(0.9375rem, 3.2vw, 1rem);
  --m-fs-lg: clamp(1.0625rem, 3.8vw, 1.25rem);
  --m-fs-xl: clamp(1.375rem, 5.5vw, 1.875rem);
  --m-fs-hero: clamp(1.75rem, 7vw, 2.5rem);

  /* Touch targets (44px Apple HIG / 48px Android Material minimum) */
  --m-touch-min: 44px;
  --m-touch-preferred: 48px;
  --m-touch-gap: 0.5rem;

  /* Safe-area insets + Android gesture bar clearance */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --m-gesture-clear: max(24px, var(--sab));
  --m-bottom-bar-h: calc(58px + var(--m-gesture-clear));
}

/* ==========================================================================
   2. BASE
   ========================================================================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  background-color: var(--bg);
  color: var(--text);
}

body {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow-x: clip;
  font-size: var(--m-fs-base);
  padding-bottom: var(--m-bottom-bar-h);
}

img,
svg,
video,
canvas,
iframe,
picture {
  max-width: 100%;
  height: auto;
}

/* Prevent long words, URLs, or emails from causing horizontal overflow */
h1, h2, h3, h4, p, a, li, span, td, th, label {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Ensure no text container locks height when user scales text 130%-200% */
.heroTitle,
.heroSubtitle,
.pageHeroTitle,
.pageHeroSubtitle,
.serviceCard,
.heroFeatureCard,
.statCard,
.panel,
.aboutContentCard,
.aboutMetaCard {
  height: auto;
  min-height: 0;
}

/* ==========================================================================
   3. LAYOUT
   ========================================================================== */
.wrap {
  width: min(1240px, calc(100% - 1.5rem - var(--sal) - var(--sar)));
  margin-inline: auto;
}

main {
  padding-bottom: calc(var(--m-space-xl) + var(--m-gesture-clear));
}

/* Announcement bar: compact & non-overflowing on 320px */
.publicBar {
  padding: var(--m-space-xs) var(--sar) var(--m-space-xs) var(--sal);
  font-size: var(--m-fs-xs);
}

.publicBar .wrap {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.publicBarContact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* Sticky header with notch/status-bar safe-area padding */
header {
  padding-top: var(--sat);
  padding-left: var(--sal);
  padding-right: var(--sar);
  background-color: rgba(3, 7, 18, 0.92);
}

.bar {
  min-height: 56px;
  height: auto;
  padding-block: 0.5rem;
  gap: 0.5rem;
}

.brand {
  font-size: clamp(0.75rem, 3.3vw, 1rem);
  gap: 0.4rem;
  min-width: 0;
  min-height: var(--m-touch-min);
  flex: 1 1 auto;
  overflow: hidden;
}

.brandText {
  line-height: 1.15;
  white-space: normal;
  min-width: 0;
}

/* Hero & Page Hero */
.heroFigma,
.pageHero {
  padding: var(--m-space-lg) 0 var(--m-space-lg);
  overflow-x: clip;
}

.heroTitle {
  font-size: var(--m-fs-hero);
  line-height: 1.15;
}

.pageHeroTitle {
  font-size: clamp(1.5rem, 6.2vw, 2.25rem);
  line-height: 1.18;
}

.heroSubtitle,
.pageHeroSubtitle {
  font-size: var(--m-fs-sm);
  line-height: 1.55;
}

.heroBadge {
  font-size: clamp(0.6875rem, 2.5vw, 0.75rem);
  padding: 0.45rem 0.75rem;
  max-width: 100%;
  flex-wrap: nowrap;
  align-items: center;
  text-align: left;
  gap: 0.5rem;
  border-radius: 14px;
}

.heroBadge .badgePulse {
  flex-shrink: 0;
}

.heroActions,
.pfbActions,
.aboutCtaRow {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: var(--m-space-sm);
}

.heroActions .btnHero,
.pfbActions .btnHero,
.aboutCtaRow .btn {
  width: 100%;
  justify-content: center;
}

/* Single-column mobile grids by default (320px+) */
.heroFeatureGrid,
.servicesGrid,
.cards,
.productsGridFigma,
.portfolioGrid,
.portfolioGridFigma,
.testimonialsGrid,
.footerGrid,
.statGrid,
.shopTrustStrip,
.pDetailTrustStrip,
.aboutHomeCard,
.aboutGrid,
.aboutMetaGrid,
.whyCardBox,
.areaCard,
.productDetailLayout,
.caseStudyLayout,
.productDetailGrid,
.portfolioDetailGrid,
.grid,
.challengeSolutionGrid,
.complianceStrip {
  grid-template-columns: 1fr;
  gap: var(--m-space-md);
}

.flexHeader {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--m-space-sm);
}

.row {
  flex-direction: column;
  align-items: stretch;
  gap: var(--m-space-sm);
}

/* Fix min-width: 300px in style.css that overflows 320px screens */
.sfcLeft {
  min-width: 0;
  width: 100%;
}

.sfcRight {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--m-space-sm);
}

.sfcRight .btn {
  width: 100%;
}

.shopFunnelCard,
.whyCardBox,
.areaCard,
.panel,
.portfolioFunnelBanner,
.funnelBox {
  padding: var(--m-space-md);
}

/* Tables: horizontal scroll inside table container without breaking page */
table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */
/* Touch targets >= 44px (48px preferred for Android) */
.btn,
.btnHero,
.catPill,
.mobileCartIcon,
.mobileMenuToggle,
.mobileDrawer a,
.mBarItem,
.serviceLink,
.trustPill {
  min-height: var(--m-touch-preferred);
  min-width: var(--m-touch-min);
  touch-action: manipulation;
}

.btn,
.btnHero {
  padding: 0.75rem 1.125rem;
  font-size: var(--m-fs-sm);
}

.btn.sm {
  min-height: var(--m-touch-min);
  padding: 0.625rem 0.875rem;
  font-size: var(--m-fs-xs);
}

/* Header mobile controls */
.mobileHeaderActions {
  gap: 0.5rem;
  flex-shrink: 0;
}

.mobileCartIcon {
  padding: 0.5rem 0.75rem;
  justify-content: center;
}

.mobileMenuToggle {
  width: var(--m-touch-preferred);
  height: var(--m-touch-preferred);
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Mobile drawer */
.mobileDrawer {
  max-height: calc(100dvh - 64px - var(--sat) - var(--m-bottom-bar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--m-space-md) max(var(--m-space-md), var(--sar)) var(--m-space-lg) max(var(--m-space-md), var(--sal));
  gap: var(--m-touch-gap);
  background-color: #05080e;
}

.mobileDrawer a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  font-size: var(--m-fs-sm);
}

/* Sticky mobile bottom bar — keeps actions clear of bottom ~24px gesture bar */
.mobileBottomBar {
  padding-top: 0.375rem;
  padding-left: max(0.5rem, var(--sal));
  padding-right: max(0.5rem, var(--sar));
  padding-bottom: calc(0.375rem + var(--m-gesture-clear));
  gap: 0.25rem;
  background-color: rgba(5, 8, 14, 0.96);
}

.mBarItem {
  min-height: var(--m-touch-preferred);
  padding: 0.375rem 0.25rem;
  font-size: 0.75rem;
}

/* Footer links & contact touch targets */
.footerLinks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.75rem;
  row-gap: 0.15rem;
}

.footerLinks a,
.footerContact a,
.cVal {
  display: inline-flex;
  align-items: center;
  min-width: var(--m-touch-min);
  min-height: var(--m-touch-min);
  padding-block: 0.25rem;
}

.footerBottomWrap {
  flex-direction: column;
  text-align: center;
  gap: 0.5rem;
}

/* Form inputs: >= 16px to prevent iOS Safari auto-zoom on focus */
input,
select,
textarea,
.form input,
.form select,
.form textarea,
.shopTools input,
.shopTools select {
  font-size: 16px;
  min-height: var(--m-touch-preferred);
  max-width: 100%;
}

/* !important required to override .searchInput { font-size: 15px !important; } in style.css line 1721 */
.searchInput {
  font-size: 16px !important;
  min-height: var(--m-touch-preferred);
}

.shopTools input,
.shopTools select {
  min-width: 0;
  width: 100%;
}

/* Category pill bar */
.categoryPillBar {
  overscroll-behavior-x: contain;
  gap: var(--m-touch-gap);
  padding-bottom: 0.5rem;
}

.catPill {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1rem;
  font-size: var(--m-fs-xs);
}

/* Modals */
.modal-overlay {
  padding: max(0.75rem, var(--sat)) max(0.75rem, var(--sar)) max(0.75rem, var(--m-gesture-clear)) max(0.75rem, var(--sal));
  overscroll-behavior: contain;
}

.modal-box {
  width: 100%;
  max-height: calc(100dvh - 1.5rem - var(--sat) - var(--m-gesture-clear));
  padding: var(--m-space-md);
  overscroll-behavior: contain;
}

/* ==========================================================================
   5. APP BEHAVIOUR
   ========================================================================== */
a,
button,
input,
select,
textarea,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent accidental text selection on UI chrome only */
header,
.publicBar,
.mobileDrawer,
.mobileBottomBar,
.btn,
.btnHero,
.catPill,
.mobileMenuToggle,
.mobileCartIcon {
  -webkit-user-select: none;
  user-select: none;
}

/* Smooth scrolling & scroll containment on drawers/modals */
.mobileDrawer,
.modal-overlay,
.modal-box,
.categoryPillBar {
  -webkit-overflow-scrolling: touch;
}

/* Touch devices vs pointer devices */
@media (hover: none) and (pointer: coarse) {
  .serviceCard:hover,
  .heroFeatureCard:hover,
  .btn:hover,
  .btnHero:hover {
    transform: none;
  }

  .btn:active,
  .btnHero:active,
  .mBarItem:active,
  .catPill:active {
    transform: scale(0.98);
    opacity: 0.92;
  }
}

@media (hover: hover) {
  .btn,
  .btnHero,
  .catPill,
  .mBarItem {
    transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
  }
}

/* PWA standalone mode */
@media (display-mode: standalone) {
  header {
    padding-top: max(var(--sat), 8px);
  }

  .publicBar {
    display: none;
  }

  .mobileBottomBar {
    padding-bottom: calc(0.5rem + var(--m-gesture-clear));
  }
}

/* ==========================================================================
   6. SAMSUNG & FOLDABLES
   ========================================================================== */
/* Explicit background & text colors prevent Samsung Internet forced dark mode inversion */
body,
.panel,
.serviceCard,
.heroFeatureCard,
.statCard,
.aboutContentCard,
.aboutMetaCard,
.shopFunnelCard,
.portfolioFunnelBanner,
.siteFooter {
  background-color: var(--bg);
  color: var(--text);
}

.panel,
.serviceCard,
.heroFeatureCard,
.statCard,
.aboutContentCard,
.aboutMetaCard,
.shopFunnelCard {
  background-color: #0d131f;
}

/* Dual-screen / foldable hinge awareness (Galaxy Z Fold unfolded) */
@media (horizontal-viewport-segments: 2) {
  .wrap {
    max-width: none;
    padding-inline: 1rem;
  }

  .aboutHomeCard,
  .aboutGrid,
  .whyCardBox,
  .productDetailLayout,
  .caseStudyLayout {
    display: grid;
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0));
  }
}

@media (vertical-viewport-segments: 2) {
  .heroFigma,
  .pageHero {
    min-height: env(viewport-segment-height 0 0);
  }
}

/* ==========================================================================
   7. BREAKPOINTS (Mobile-First min-width)
   ========================================================================== */

/* 320px+: Smallest supported Android, iPhone SE 1st gen */
@media (min-width: 320px) {
  .wrap {
    width: calc(100% - 1.25rem - var(--sal) - var(--sar));
  }
}

/* 360px+: Samsung Galaxy S22/S23/S24, Galaxy A13/A14/A53/A54, Galaxy S10e */
@media (min-width: 360px) {
  .wrap {
    width: calc(100% - 1.5rem - var(--sal) - var(--sar));
  }

  .brand {
    font-size: 0.9375rem;
  }
}

/* 375px+: iPhone SE (2nd/3rd gen), iPhone 12/13 mini */
@media (min-width: 375px) {
  .statGrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 384px+: Samsung Galaxy S23+ / S24+ class */
@media (min-width: 384px) {
  .brand {
    font-size: 1rem;
  }
}

/* 390px+: iPhone 12 / 13 / 14 / 15 / 16 & Pro */
@media (min-width: 390px) {
  .wrap {
    width: calc(100% - 2rem - var(--sal) - var(--sar));
  }
}

/* 412px+: Samsung Galaxy S20/S21/S23/S24 Ultra, Galaxy A54, Galaxy Z Flip, Pixel 7/8 */
@media (min-width: 412px) {
  .shopTrustStrip,
  .pDetailTrustStrip {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 430px+: iPhone 14 Plus, iPhone 15/16 Plus & Pro Max */
@media (min-width: 430px) {
  .heroActions,
  .pfbActions,
  .aboutCtaRow {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .heroActions .btnHero,
  .pfbActions .btnHero,
  .aboutCtaRow .btn {
    width: auto;
    flex: 1 1 auto;
  }
}

/* 480px+: Large phones & phablets */
@media (min-width: 480px) {
  .heroFeatureGrid,
  .aboutMetaGrid {
    grid-template-columns: repeat(2, 1fr);
  }

  .row {
    flex-direction: row;
    align-items: center;
  }
}

/* 600px+: Foldable inner screens (Galaxy Z Fold ~673px), small tablets */
@media (min-width: 600px) and (max-width: 1023px) {
  .footerGrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .servicesGrid,
  .cards,
  .productsGridFigma,
  .portfolioGrid,
  .testimonialsGrid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sfcRight {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sfcRight .btn {
    width: auto;
  }
}

/* 1024px+: Desktop grids (placed after the mobile single-column base so it wins the cascade) */
@media (min-width: 1024px) {
  .cards,
  .productsGridFigma,
  .portfolioGrid,
  .testimonialsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .servicesGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 768px+: Tablet handoff to desktop stylesheet (Galaxy Tab S9 800x1280, iPad) */
@media (min-width: 768px) {
  .publicBar .wrap {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .flexHeader {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }

  .footerBottomWrap {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* Desktop handoff (> 850px where style.css switches off mobileOnly) */
@media (min-width: 851px) {
  body {
    padding-bottom: 0;
  }

  main {
    padding-bottom: 36px;
  }

  .footerLinks {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .footerLinks a,
  .footerContact a,
  .cVal {
    min-width: auto;
    min-height: auto;
    padding-block: 0;
  }
}

@media (min-width: 1024px) {
  .footerGrid {
    grid-template-columns: 1.35fr 1fr 1fr 1.25fr;
  }
}

/* ==========================================================================
   8. LANDSCAPE (Phones in landscape with max-height: 500px)
   ========================================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  .publicBar {
    display: none;
  }

  .bar {
    min-height: 46px;
    padding-block: 0.25rem;
  }

  .heroFigma,
  .pageHero {
    padding-block: 1rem;
  }

  .mobileBottomBar {
    padding-top: 0.25rem;
    padding-bottom: max(0.25rem, var(--sab));
  }

  .mBarItem {
    flex-direction: row;
    gap: 0.35rem;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
  }

  .mobileDrawer {
    max-height: calc(100dvh - 50px - var(--sat));
  }

  .modal-box {
    max-height: calc(100dvh - 1rem);
    padding: 0.875rem;
  }
}

/* ==========================================================================
   9. ACCESSIBILITY
   ========================================================================== */
/* Focus visible ring for keyboard / switch / TalkBack navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

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

/* Dark color scheme reinforcement */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }

  body {
    background-color: var(--bg);
    color: var(--text);
  }
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --line: rgba(255, 255, 255, 0.32);
    --line-strong: rgba(255, 255, 255, 0.55);
    --muted: #D1D5DB;
  }

  .panel,
  .serviceCard,
  .heroFeatureCard,
  .statCard,
  .mobileDrawer a,
  .catPill,
  .btn.dark {
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.45);
  }
}
