/* ==========================================================================
   All categories (all-categories.html)
   Design system: uses the shared tokens from /css/tokens.css, matching
   the redesign pass already done on the about/post/contact pages.
   ========================================================================== */

html,
body {
  height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==========================================================================
   Home button (mobile navbar)
   ========================================================================== */
.home-btn {
  width: 56px;
  height: 56px;
  background: #dedfe0;
  border-radius: 50%;
  color: #000;
  text-decoration: none;
  margin-left: -5px;
  transition: all 0.2s ease;
}

.home-btn:hover {
  background-color: #e9ecef;
  color: #000;
  transform: scale(1.05);
}

.home-btn:active {
  transform: scale(0.95);
}

.home-btn i {
  font-size: 1.5rem;
  line-height: 1;
}

.home-text {
  font-size: 10px;
  line-height: 1;
  margin-top: 2px;
  color: #1f2937;
}

/* ==========================================================================
   Search header
   ========================================================================== */
.category-search-section {
  background: linear-gradient(180deg, var(--surface-alt) 0%, #ffffff 100%);
  padding: var(--space-8) 0 var(--space-6);
  text-align: center;
}

.category-search-section h1 {
  margin: 0;
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--dark);
}

.category-search-intro {
  max-width: 480px;
  margin: var(--space-2) auto 0;
  color: var(--text-muted);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
}

.category-search-wrapper {
  position: relative;
  max-width: 420px;
  margin: var(--space-6) auto 0;
}

/* input[type="text"] in style.css (element+attribute selector) otherwise
   beats a plain class selector on specificity and collapses this padding
   down to its own generic form-control value -- which is what was making
   the search icon sit on top of the input text. */
input[type="text"].category-search-input {
  width: 100%;
  padding: var(--space-3) var(--space-8) var(--space-3) 2.75rem;
  font-size: var(--font-size-base);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-position: 1rem 50%;
  background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.category-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

#clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-full);
  user-select: none;
}

#clear-search img {
  width: 20px;
  height: 20px;
  display: block;
  opacity: 0.6;
}

#clear-search:hover img {
  opacity: 1;
}

/* ==========================================================================
   Category grid
   ========================================================================== */
.category-grid-section {
  background: #ffffff;
  padding: var(--space-6) var(--space-4) var(--space-8);
}

@media (max-width: 768px) {
  .category-grid-section {
    padding: var(--space-7) var(--space-3);
  }

  /* Search results get a tighter section padding on mobile -- matches
     body.is-searching, toggled in js/all-categories.js */
  body.is-searching .category-grid-section {
    padding: 0 var(--space-3);
  }
}

/* "Browse All Services" pill link shown above the grouped grid */
.category-browse-all-wrap {
  display: flex;
  justify-content: center;
  margin: var(--space-2) 0 var(--space-6);
}

.category-browse-all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-7);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    background-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.category-browse-all:hover {
  background: var(--primary-dark);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.category-group {
  max-width: 1100px;
  margin: 0 auto var(--space-7);
}

.category-group-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--dark);
  margin-bottom: var(--space-4);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-4);
}

.category-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--dark);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

@media (min-width: 769px) {
  .category-tile:hover {
    border-color: rgba(var(--primary-rgb), 0.4);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
}

.category-tile .tile-img {
  height: 75%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
}

.category-tile .tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.category-tile .tile-label {
  height: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-2);
  text-align: center;
}

.category-tile .tile-label span {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.15;
  margin: 0;
}

@media (max-width: 768px) {
  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--space-2);
  }

  .category-group-title {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-3);
  }

  .category-tile .tile-label span {
    font-size: var(--font-size-sm);
  }
}

/* ==========================================================================
   Search results -- single-column row layout on mobile
   ========================================================================== */
@media (max-width: 768px) {
  body.is-searching .category-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-3) !important;
  }

  body.is-searching .category-tile {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: 56px !important;
  }

  body.is-searching .category-tile .tile-img {
    height: 100% !important;
    width: 72px !important;
    min-height: 0 !important;
    flex: 0 0 72px;
  }

  body.is-searching .category-tile .tile-img img {
    width: 120%;
    height: 120%;
    object-fit: cover;
  }

  body.is-searching .category-tile .tile-label {
    height: auto !important;
    flex: 1 1 auto;
    justify-content: flex-start !important;
    padding: 0 var(--space-4) !important;
    text-align: left !important;
  }

  body.is-searching .category-tile .tile-label span {
    -webkit-line-clamp: 1 !important;
    font-size: var(--font-size-sm) !important;
    line-height: 1.2;
  }
}

/* ==========================================================================
   Footer tweak (in addition to the shared .footer .logo-container rules
   in css/style.css)
   ========================================================================== */
@media (max-width: 768px) {
  #footer-div {
    width: 50%;
    padding-right: 8px !important;
  }
}
