/* ==========================================================================
   Design Polish — Flooring Contractor Directory
   Appended to existing styles. No HTML changes required.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Custom Properties (extensions)
   -------------------------------------------------------------------------- */
:root {
  --primary-dark: hsl(25, 50%, 24%);
  --accent-light: hsl(38, 85%, 62%);
  --accent-glow: hsla(38, 85%, 52%, 0.25);
  --ring: hsl(38, 85%, 52%);
  --ring-offset: 2px;
  --shimmer-from: hsl(30, 15%, 90%);
  --shimmer-to: hsl(30, 15%, 96%);
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 1px 3px hsla(20, 20%, 12%, 0.06), 0 1px 2px hsla(20, 20%, 12%, 0.04);
  --shadow-card-hover: 0 10px 25px hsla(20, 20%, 12%, 0.1), 0 4px 10px hsla(20, 20%, 12%, 0.06);
  --shadow-btn: 0 1px 3px hsla(20, 20%, 12%, 0.12), 0 1px 2px hsla(20, 20%, 12%, 0.08);
  --shadow-btn-hover: 0 6px 16px hsla(25, 50%, 33%, 0.3), 0 2px 6px hsla(25, 50%, 33%, 0.15);
  --shadow-search: 0 4px 20px hsla(20, 20%, 12%, 0.08), 0 2px 8px hsla(20, 20%, 12%, 0.04);
  --shadow-search-focus: 0 8px 30px hsla(38, 85%, 52%, 0.15), 0 4px 12px hsla(20, 20%, 12%, 0.06);
}

/* --------------------------------------------------------------------------
   1. Visual Star Ratings
   -------------------------------------------------------------------------- */
.rating-stars {
  display: inline-block;
  width: 5.6em;
  height: 1.1em;
  vertical-align: middle;
  position: relative;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23d4a843'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
  background-size: 1.12em 1.1em;
  background-repeat: repeat-x;
}

.rating-stars[data-rating="4.5"],
.rating-stars[data-rating="4"] {
  position: relative;
}

.card-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.card-rating .rating-value {
  position: relative;
  font-weight: 700;
  font-size: 0.9em;
  color: var(--foreground);
}

.card-rating .rating-value::before {
  content: "";
  display: inline-block;
  width: 5em;
  height: 1em;
  margin-right: 0.35em;
  vertical-align: -0.1em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23d4a843'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
  background-size: 1em 1em;
  background-repeat: repeat-x;
}

/* --------------------------------------------------------------------------
   2. Hero Section Enhancement
   -------------------------------------------------------------------------- */
.hero {
  padding: 5rem 1.5rem 6rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      87deg,
      hsla(25, 40%, 30%, 0.02) 0px,
      transparent 1px,
      transparent 6px,
      hsla(25, 40%, 30%, 0.015) 7px
    ),
    linear-gradient(
      175deg,
      hsla(25, 50%, 33%, 0.92) 0%,
      hsla(25, 55%, 26%, 0.96) 50%,
      hsla(20, 50%, 20%, 1) 100%
    );
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-shadow: 0 2px 8px hsla(0, 0%, 0%, 0.15);
}

.hero p {
  font-size: clamp(1rem, 2vw, 1.2rem);
  opacity: 0.92;
}

/* Search form — pill shape with prominent shadow */
.hero .search-form,
.hero form {
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-search);
  overflow: hidden;
  transition: box-shadow 0.3s var(--transition-smooth);
}

.hero .search-form:focus-within,
.hero form:focus-within {
  box-shadow: var(--shadow-search-focus);
}

.hero .search-form input,
.hero form input[type="text"],
.hero form input[type="search"] {
  border: none;
  background: transparent;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
}

.hero .search-form input:focus,
.hero form input[type="text"]:focus,
.hero form input[type="search"]:focus {
  outline: none;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   3. Card Photo Placeholder
   -------------------------------------------------------------------------- */
.card-placeholder {
  background:
    repeating-linear-gradient(
      92deg,
      hsla(25, 30%, 55%, 0.08) 0px,
      transparent 1px,
      transparent 4px,
      hsla(25, 30%, 55%, 0.05) 5px
    ),
    linear-gradient(
      160deg,
      hsl(30, 25%, 82%) 0%,
      hsl(25, 20%, 75%) 40%,
      hsl(20, 25%, 68%) 100%
    );
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  position: relative;
  overflow: hidden;
}

.card-placeholder::before {
  content: "";
  display: block;
  width: 48px;
  height: 48px;
  border: 3px solid hsla(25, 50%, 33%, 0.35);
  border-radius: 4px;
  position: relative;
  background:
    linear-gradient(135deg, transparent 40%, hsla(25, 50%, 33%, 0.15) 40%, hsla(25, 50%, 33%, 0.15) 60%, transparent 60%),
    linear-gradient(45deg, transparent 40%, hsla(25, 50%, 33%, 0.15) 40%, hsla(25, 50%, 33%, 0.15) 60%, transparent 60%);
}

.card-placeholder::after {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    hsla(25, 50%, 33%, 0.3) 0px,
    hsla(25, 50%, 33%, 0.3) 8px,
    transparent 8px,
    transparent 12px
  );
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   4. Header Modernization
   -------------------------------------------------------------------------- */
header,
.site-header,
.header {
  background: hsla(25, 35%, 22%, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--accent);
  transition: background 0.3s var(--transition-smooth);
}

.site-header .logo::before,
.header .logo::before,
header .logo::before {
  content: "";
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  margin-right: 0.4em;
  vertical-align: -0.15em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d4a843' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='6' width='20' height='12' rx='1'/%3E%3Cline x1='8' y1='6' x2='8' y2='18'/%3E%3Cline x1='14' y1='6' x2='14' y2='18'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   5. Button Refinements
   -------------------------------------------------------------------------- */
.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: 1px solid hsla(0, 0%, 0%, 0.1);
  box-shadow: var(--shadow-btn), inset 0 1px 0 hsla(0, 0%, 100%, 0.1);
  transition:
    transform 0.2s var(--transition-smooth),
    box-shadow 0.2s var(--transition-smooth),
    background 0.2s var(--transition-smooth);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn-hover), inset 0 1px 0 hsla(0, 0%, 100%, 0.12);
  background: linear-gradient(180deg, hsl(25, 50%, 36%) 0%, var(--primary-dark) 100%);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn);
}

/* Full width only for standalone CTAs, not inline pairs */
@media (max-width: 640px) {
  .btn-primary:only-child,
  .cta-standalone .btn-primary,
  .hero .btn-primary {
    width: 100%;
  }

  .btn-group .btn-primary,
  .card-actions .btn-primary,
  .inline-buttons .btn-primary {
    width: auto;
  }
}

/* --------------------------------------------------------------------------
   6. Card Hover Enhancement
   -------------------------------------------------------------------------- */
.card,
.contractor-card,
.listing-card,
.state-card {
  transition:
    transform 0.3s var(--transition-smooth),
    box-shadow 0.3s var(--transition-smooth),
    border-color 0.3s var(--transition-smooth);
  border: 1px solid var(--border);
}

.card:hover,
.contractor-card:hover,
.listing-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent-light);
}

/* Photo zoom on hover */
.card img,
.contractor-card img,
.listing-card img {
  transition: transform 0.4s var(--transition-smooth);
}

.card:hover img,
.contractor-card:hover img,
.listing-card:hover img {
  transform: scale(1.05);
}

/* Overflow hidden on image containers to contain zoom */
.card-image,
.card-photo,
.card-thumbnail,
.card .image-wrapper {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   7. Footer Improvement
   -------------------------------------------------------------------------- */
footer,
.site-footer,
.footer {
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, transparent 5%, var(--accent) 30%, var(--accent) 70%, transparent 95%) 1;
  padding-top: 3rem;
}

footer .footer-columns,
footer .footer-grid,
.footer .footer-columns {
  gap: 2.5rem;
}

footer .footer-column,
.footer .footer-column {
  padding: 0 0.5rem;
}

/* Social icons */
footer .social-links a,
.footer .social-links a,
.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: hsla(0, 0%, 100%, 0.08);
  transition:
    background 0.25s var(--transition-smooth),
    color 0.25s var(--transition-smooth),
    transform 0.25s var(--transition-smooth);
}

footer .social-links a:hover,
.footer .social-links a:hover,
.social-icon:hover {
  background: var(--accent);
  color: var(--foreground);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   8. States Page Grid
   -------------------------------------------------------------------------- */
.state-card {
  position: relative;
  padding-left: 1rem;
  overflow: hidden;
}

.state-card::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1.2em;
  margin-right: 0.4em;
  vertical-align: -0.15em;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23704214' stroke='%23704214' stroke-width='0'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.state-card:hover {
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 2px);
}

/* Top 20 / View All buttons */
.state-card .btn,
.state-card a.btn,
.state-buttons .btn {
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  transition:
    background 0.2s var(--transition-smooth),
    box-shadow 0.2s var(--transition-smooth);
}

.state-card .btn:hover,
.state-buttons .btn:hover {
  box-shadow: 0 2px 8px hsla(25, 50%, 33%, 0.2);
}

/* --------------------------------------------------------------------------
   9. Typography Polish
   -------------------------------------------------------------------------- */
h1, h2 {
  letter-spacing: -0.02em;
}

h3 {
  letter-spacing: -0.01em;
}

.card-description,
.listing-description,
.card-body p {
  line-height: 1.65;
  color: var(--muted-foreground);
}

.card-meta,
.card-info,
.secondary-text,
.meta-text {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   10. Spacing & Whitespace
   -------------------------------------------------------------------------- */
section,
.section {
  padding-block: 4rem;
}

.card-body,
.card-content {
  padding: 1.25rem 1.5rem;
}

.grid,
.card-grid,
.listings-grid {
  gap: 1.5rem;
}

main > section + section,
main > .section + .section {
  margin-top: 1rem;
}

/* --------------------------------------------------------------------------
   11. Loading / Transition States
   -------------------------------------------------------------------------- */

/* Smooth page fade-in */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main {
  animation: fadeInUp 0.35s var(--transition-smooth) both;
}

/* Image loading shimmer placeholder */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: 400px 0;
  }
}

.card-image.loading,
.card-photo.loading,
img[data-loading="true"],
.image-shimmer {
  background: linear-gradient(
    90deg,
    var(--shimmer-from) 0%,
    var(--shimmer-to) 50%,
    var(--shimmer-from) 100%
  );
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite linear;
}

/* Button loading state */
@keyframes spinLoader {
  to {
    transform: rotate(360deg);
  }
}

.btn.loading,
.btn-primary.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after,
.btn-primary.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.1em;
  height: 1.1em;
  margin: -0.55em 0 0 -0.55em;
  border: 2px solid hsla(0, 0%, 100%, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinLoader 0.6s linear infinite;
}

/* --------------------------------------------------------------------------
   12. Accessibility
   -------------------------------------------------------------------------- */

/* Focus ring — visible and clear */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: var(--ring-offset);
  border-radius: 2px;
}

/* Remove default browser outline when custom ring applies */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: var(--ring-offset);
}

/* Skip-link style (if present) */
.skip-link:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 9999;
  background: var(--accent);
  color: var(--foreground);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}

/* Reduced motion — disable animations and transitions */
@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;
  }

  .card:hover,
  .contractor-card:hover,
  .listing-card:hover {
    transform: none;
  }

  .card:hover img,
  .contractor-card:hover img,
  .listing-card:hover img {
    transform: none;
  }

  main {
    animation: none;
  }
}

/* High contrast mode improvements */
@media (forced-colors: active) {
  .btn-primary {
    border: 2px solid ButtonText;
  }

  .card,
  .contractor-card,
  .listing-card,
  .state-card {
    border: 1px solid CanvasText;
  }
}

/* Ensure interactive elements have sufficient contrast */
.btn-primary {
  color: #fff;
}

a:not([class]) {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:not([class]):hover {
  text-decoration-thickness: 2px;
}
