/* Tobias Electric - Main Stylesheet */

/* Global Styles */
:root {
  /* Colors */
  --primary-color: #001a4f; /* Dark blue from logo */
  --secondary-color: #ee8c21; /* Orange from logo */
  --accent-color: #9d9fa2; /* Gray from logo */
  --light-color: #f5f5f5;
  --dark-color: #001a4f;
  
  /* Typography */
  --body-font: 'Arial', sans-serif;
  --heading-font: 'Arial', sans-serif;
  
  /* Effects */
  --box-shadow: 0 0.3125rem 0.9375rem rgba(0, 26, 79, 0.2);
  --transition: all 0.3s ease;
  --spark-glow: 0 0 0.9375rem #ee8c21, 0 0 1.5625rem #ee8c21;
  
  /* Base font size - adjust for fluid typography */
  font-size: 18px; /* Increased base size for calculations */
  
  /* Responsive font scaling */
  @media (max-width: 992px) {
    font-size: calc(16px + 0.5vw);
  }
  
  @media (max-width: 480px) {
    font-size: calc(15px + 0.5vw);
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Ensure smooth scaling */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden; /* Prevent horizontal scrolling at document level */
  width: 100%; /* Ensure HTML element doesn't exceed viewport width */
  position: relative; /* Establish positioning context */
}

body {
  font-family: var(--body-font);
  line-height: 1.6;
  color: var(--dark-color);
  background-color: var(--light-color);
  overflow-x: hidden;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%; /* Ensure body is constrained to viewport width */
  position: relative; /* Establish stacking context */
  max-width: 100vw; /* Explicitly constrain to viewport width */
}

.container {
  width: 100%; /* Changed from 90% to ensure full width containment */
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 max(1rem, 4%); /* Use percentage-based side padding */
  overflow: hidden; /* Contain child elements within their parent */
  box-sizing: border-box; /* Ensure padding is included in width calculation */
}

section {
  padding: clamp(3rem, 8vh, 5rem) 0;
  width: 100%; /* Ensure sections don't exceed viewport width */
  max-width: 100%; /* Redundant constraint to prevent overflow */
  overflow: hidden; /* Contain elements within sections */
}

h1, h2, h3, h4 {
  font-family: var(--heading-font);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: clamp(0.75rem, 2vw, 0.9375rem);
  color: var(--primary-color);
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  text-align: center;
  margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
  text-transform: uppercase;
  letter-spacing: 0.125rem;
}

h3 {
  font-size: clamp(1.125rem, 3vw, 1.5rem);
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
}

p {
  margin-bottom: 0.9375rem;
}

a {
  text-decoration: none;
  color: var(--primary-color);
  transition: var(--transition);
}

a:hover {
  color: var(--secondary-color);
}

.btn {
  display: inline-block;
  background-color: #222;
  color: white;
  padding: clamp(0.625rem, 2vw, 0.75rem) clamp(1rem, 3vw, 1.5rem);
  border-radius: 0.25rem;
  border: 1px solid #444;
  cursor: pointer;
  font-weight: bold;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  font-size: clamp(0.8125rem, 2vw, 0.875rem);
}

.btn:hover {
  box-shadow: var(--spark-glow);
  color: white;
  border-color: var(--secondary-color);
  transform: translateY(-0.1875rem);
}

img {
  max-width: 100%;
  height: auto;
  display: block; /* Prevent white space under images */
}

/* Header Styles */
header {
  background-color: white;
  box-shadow: var(--box-shadow);
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden; /* Contain any overflowing elements */
}

header.scrolled {
  background-color: rgba(255, 255, 255, 0.95);
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2vw, 0.9375rem) 0;
  width: 100%; /* Ensure full width */
  max-width: 100%; /* Prevent overflow */
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(0.625rem, 2vw, 0.9375rem);
  width: 100%;
  text-align: center; /* Center logo as fallback */
}

.logo img {
  /* Changed from fixed height to aspect-ratio */
  max-height: clamp(85px, 18vw, 140px);
  width: auto;
  object-fit: contain;
  transition: all 0.3s ease;
  display: inline-block; /* Prevent stretching */
}

.main-nav {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping for small screens */
  justify-content: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  width: 100%;
  padding: 0 1rem; /* Add horizontal padding */
}

.main-nav a {
  color: black;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  font-size: clamp(1rem, 2.5vw, 1.2rem); /* Further increased font size */
  font-weight: bold;
  transition: all 0.3s ease;
  padding: 0.4rem 0.8rem; /* Increased padding for larger touch targets */
  white-space: nowrap; /* Prevent line breaks in nav items */
}

.main-nav a:hover, 
.main-nav a.active {
  color: var(--secondary-color);
  text-shadow: var(--spark-glow);
}

/* Hero Section */
.hero {
  background: linear-gradient(rgba(0, 26, 79, 0.8), rgba(0, 26, 79, 0.9)), url('../images/hero-bg.jpg');
  background-size: cover;
  background-position: center;
  color: white;
  text-align: center;
  /* Calculate top padding to accommodate header dynamically */
  padding: max(180px, 30vh) 0 clamp(60px, 10vh, 100px);
  border-bottom: 3px solid var(--secondary-color);
  width: 100%; /* Ensure full width */
  max-width: 100%; /* Prevent overflow */
  overflow: hidden; /* Contain child elements */
}

.hero h1 {
  color: white;
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: clamp(1rem, 3vw, 1.25rem);
  text-transform: uppercase;
  letter-spacing: 0.125rem;
  padding: 0 1rem; /* Add side padding to prevent text overflow */
  word-wrap: break-word; /* Allow long words to break */
  overflow-wrap: break-word; /* Modern property for word wrapping */
  hyphens: auto; /* Enable hyphenation for long words */
}

.hero p {
  font-size: clamp(1rem, 3vw, 1.2rem);
  max-width: min(700px, 90%);
  margin: 0 auto clamp(1.25rem, 4vw, 1.875rem);
  padding: 0 1rem; /* Add side padding */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.license-badge {
  display: inline-block;
  background-color: #222;
  padding: clamp(0.5rem, 1.5vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
  border-radius: 0.25rem;
  font-weight: bold;
  margin-top: clamp(0.75rem, 2vw, 0.9375rem);
  border: 1px solid #555;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
}

/* Services Section */
.services {
  background-color: #111;
  color: white;
  border-bottom: 2px solid #333;
}

.services h2 {
  color: white;
}

.services-container {
  display: grid;
  /* Adjust minmax to prevent overflow */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(1rem, 3vw, 1.875rem);
  width: 100%;
  max-width: 100%;
}

.service-card {
  background-color: #222;
  border: 1px solid #444;
  border-radius: 0.25rem;
  overflow: hidden;
  box-shadow: var(--box-shadow);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  width: 100%; /* Ensure cards take full width of their grid cell */
  max-width: 100%; /* Prevent overflow */
}

.service-card:hover, .service-card.in-view-effect {
  transform: translateY(-0.3125rem);
  box-shadow: var(--spark-glow);
}

.service-icon {
  background-color: black;
  color: white;
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.service-icon i {
  font-size: clamp(1.875rem, 6vw, 2.5rem);
}

.service-content {
  padding: clamp(1rem, 3vw, 1.25rem);
  flex-grow: 1; /* Allow content to expand */
  width: 100%;
}

.service-content h3 {
  margin-bottom: clamp(0.625rem, 1.5vw, 0.75rem);
  color: white;
  text-transform: uppercase;
  font-size: clamp(1rem, 3vw, 1.3rem);
  letter-spacing: 0.0625rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto; /* Enable hyphenation */
}

/* About Section */
.about {
  background-color: white;
  color: black;
}

.about h2 {
  color: black;
}

.about-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  align-items: center;
}

.about-content {
  padding-right: clamp(0rem, 3vw, 1.25rem);
}

.about-content h3 {
  color: black;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
}

.about-image {
  display: flex;
  justify-content: center;
}

.about-image img {
  border-radius: 0.25rem;
  box-shadow: var(--box-shadow);
  border: 1px solid #ddd;
  padding: 0.3125rem;
  background: white;
  max-width: min(100%, 350px);
  height: auto;
}

.family-owned {
  font-weight: bold;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  margin-bottom: clamp(1rem, 3vw, 1.25rem);
  border-left: 0.25rem solid var(--secondary-color);
  padding-left: clamp(0.625rem, 2vw, 0.9375rem);
}

/* Featured Brands Section */
.featured-brands {
  background-color: #222;
  color: white;
  border-top: 1px solid #333;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.featured-brands h2 {
  color: white;
}

.brands-container {
  display: grid;
  /* Adjust minmax to prevent overflow */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(1rem, 3vw, 1.875rem);
  width: 100%;
  max-width: 100%;
}

.brand-card {
  background-color: white;
  border: 1px solid #444;
  border-radius: 0.25rem;
  overflow: hidden;
  box-shadow: var(--box-shadow);
  transition: var(--transition);
  position: relative;
  /* Use min-height instead of aspect-ratio for better compatibility */
  min-height: 150px;
  height: clamp(150px, 30vw, 250px); /* Responsive height */
  width: 100%; /* Ensure full width */
  max-width: 100%; /* Prevent overflow */
  /* Disable text selection */
  -webkit-user-select: none;  /* Safari */
  -ms-user-select: none;      /* IE 10+ and Edge */
  user-select: none;          /* Standard syntax */
  cursor: pointer; /* Show pointer cursor to indicate interactivity */
}

.brand-card:hover {
  transform: translateY(-0.3125rem);
  box-shadow: var(--spark-glow);
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 1.5625rem);
}

.brand-logo img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  margin: auto; /* Center image properly */
}

/* Special styling for Lutron logo to make it span more width */
.lutron-logo img {
  transform: scale(clamp(1.3, 1.5vw, 1.6)); /* Adjust scale to prevent overflow */
  max-width: 100%;
  max-height: 90%;
}

.brand-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(51, 51, 51, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 1.25rem);
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(3px);
  /* Improve accessibility */
  z-index: 2;
  overflow: auto; /* Allow scrolling if content exceeds container */
  /* Disable text selection */
  -webkit-user-select: none;  /* Safari */
  -ms-user-select: none;      /* IE 10+ and Edge */
  user-select: none;          /* Standard syntax */
}

.brand-card:hover .brand-content,
.brand-card:focus .brand-content,
.brand-card:active .brand-content {
  opacity: 1;
}

/* Add touch support for mobile */
@media (max-width: 992px) {
  .brand-content {
    transition: opacity 0.4s ease;
  }
}

.brand-content h3 {
  margin-bottom: clamp(0.5rem, 1.5vw, 0.625rem);
  color: white;
  text-transform: uppercase;
  font-size: clamp(1rem, 3vw, 1.3rem);
  letter-spacing: 0.0625rem;
  text-align: center;
}

.brand-content p {
  color: white;
  text-align: center;
  font-size: clamp(0.875rem, 2.2vw, 1rem);
  padding: 0 clamp(0.5rem, 2vw, 1rem);
}

/* Contact Section */
.contact {
  background-color: #111;
  color: white;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.contact h2 {
  color: white;
}

.contact-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(1.5rem, 4vw, 2.5rem);
  width: 100%;
  max-width: 100%;
}

.contact-info {
  width: 100%;
  max-width: 100%;
}

.contact-info h3 {
  margin-bottom: clamp(1rem, 3vw, 1.25rem);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  width: 100%;
}

.contact-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(0.9375rem, 3vw, 1.25rem);
  margin-bottom: clamp(1.25rem, 4vw, 1.875rem);
  align-items: flex-start;
  width: 100%;
}

.contact-button {
  display: flex;
  background-color: #222;
  color: white;
  padding: clamp(0.75rem, 2vw, 0.9375rem) clamp(1rem, 3vw, 1.5625rem);
  border: 1px solid #444;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  font-weight: bold;
  text-align: center;
  transition: all 0.3s ease;
  width: 100%; /* Full width */
  max-width: min(300px, 100%);
  /* Improve touch target */
  min-height: 3rem;
  align-items: center;
  justify-content: center;
}

.contact-button:hover {
  box-shadow: var(--spark-glow);
  color: white;
  border-color: var(--secondary-color);
}

.contact-info .info-item {
  display: flex;
  align-items: center; /* Center align items vertically */
  margin-bottom: clamp(0.75rem, 2vw, 0.9375rem);
}

.contact-info .info-item i {
  color: white;
  margin-right: clamp(0.5rem, 1.5vw, 0.625rem);
  font-size: clamp(1.125rem, 3vw, 1.25rem);
  min-width: 1.25rem;
  display: flex; /* Ensure icon is properly centered */
  align-items: center;
  justify-content: center;
}

.map {
  height: clamp(200px, 40vh, 300px);
  background-color: #222;
  border: 1px solid #444;
  border-radius: 0.25rem;
  overflow: hidden;
  box-shadow: 0 0 0.9375rem rgba(238, 140, 33, 0.3); /* Subtle orange glow to match spark effect */
  transition: box-shadow 0.3s ease;
}

.map:hover {
  box-shadow: 0 0 1.25rem rgba(238, 140, 33, 0.5); /* Enhanced glow on hover */
}

.map iframe {
  width: 100%;
  height: 100%;
  border: none;
  filter: contrast(1.1); /* Slightly increase contrast for better visibility */
}

.dark-map {
  border: none;
}

/* Footer */
footer {
  background-color: var(--primary-color);
  color: white;
  padding: clamp(1.875rem, 5vh, 2.5rem) 0 clamp(1rem, 2vh, 1.25rem);
  border-top: 2px solid var(--secondary-color);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(1rem, 3vw, 1.25rem);
  flex-wrap: wrap;
  gap: clamp(0.9375rem, 3vw, 1.25rem);
}

.footer-logo {
  display: flex;
  align-items: center;
}

.footer-logo img {
  max-height: clamp(60px, 12vw, 105px);
  width: auto;
  object-fit: contain;
}

.footer-nav a {
  color: white;
  margin: 0 clamp(0.5rem, 1.5vw, 0.625rem);
  text-transform: uppercase;
  letter-spacing: 0.0625rem;
  font-size: clamp(0.85rem, 2.2vw, 1rem); /* Increased font size */
}

.footer-nav a:hover {
  text-shadow: var(--spark-glow);
}

.footer-bottom {
  text-align: center;
  padding-top: clamp(1rem, 3vw, 1.25rem);
  border-top: 1px solid #333;
}

/* Media Queries */
@media (max-width: 992px) {
  /* Adjust hero section to account for fixed header on mobile */
  .hero {
    padding-top: max(240px, 36vh); /* Increased padding for mobile devices */
  }
  
  .about-container {
    grid-template-columns: 1fr;
    text-align: center; /* Center all text in about section */
  }
  
  .about-content {
    padding-right: 0; /* Remove padding */
    width: 100%;
  }
  
  .about-image {
    order: -1;
    display: flex;
    justify-content: center; /* Center logo in about section on mobile */
    width: 100%;
  }
  
  .contact-info {
    text-align: center; /* Center contact info on mobile */
    width: 100%;
  }
  
  .contact-info h3 {
    text-align: center;
    width: 100%;
  }
  
  .contact-buttons {
    align-items: center; /* Center contact buttons */
    width: 100%;
  }
  
  .info-item {
    justify-content: center; /* Center info items */
    width: 100%;
  }
  
  .family-owned {
    text-align: center;
    border-left: none; /* Remove left border */
    border-bottom: 0.25rem solid var(--secondary-color); /* Add bottom border instead */
    padding-left: 0;
    padding-bottom: 0.625rem;
    margin-left: auto;
    margin-right: auto;
    max-width: 80%;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
    width: 100%;
  }
  
  .footer-logo {
    justify-content: center;
    margin-bottom: clamp(0.9375rem, 3vw, 1.25rem);
    width: 100%;
  }
  
  /* Prevent horizontal scrolling on mobile */
  .container, 
  section, 
  .services-container,
  .brands-container,
  .contact-container {
    padding-left: max(1rem, 4%);
    padding-right: max(1rem, 4%);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
  .main-nav {
    gap: clamp(0.5rem, 1.5vw, 0.75rem); /* Smaller gap on very small screens */
    flex-wrap: wrap;
    padding: 0 0.5rem;
  }
  
  .main-nav a {
    font-size: clamp(0.95rem, 2.4vw, 1.1rem); /* Further increased font size on small screens */
    padding: 0.35rem 0.7rem;
  }
  
  /* Ensure container padding is appropriate for very small screens */
  .container {
    padding: 0 max(0.75rem, 3%);
  }
  
  /* Adjust grid items for extremely small screens */
  .services-container,
  .brands-container,
  .contact-container {
    grid-template-columns: 1fr; /* Force single column on very small screens */
  }
  
  /* Ensure proper text wrapping on small screens */
  h1, h2, h3, p {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* Additional accessibility considerations */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Fix for increased display size settings */
@media screen and (max-resolution: 96dpi) {
  /* Adjust for browsers with increased display sizes */
  html {
    zoom: 0.9; /* Slight zoom out to help with large display settings */
  }
  
  .container {
    width: 95%;
  }
}
