/* ==========================================================================
   HoundSquare — Base / Primitives
   Reset, typography defaults, and shared page primitives consumed by the SSR
   markup so pages look intentional BEFORE any web component upgrades. Every
   value references a --hs-* token from tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--hs-font-sans);
  font-size: var(--hs-font-size-base);
  line-height: var(--hs-line-height-base);
  color: var(--hs-color-foreground-body);
  background: var(--hs-color-background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  color: var(--hs-color-foreground);
  font-family: var(--hs-font-display);
  font-weight: var(--hs-font-weight-semibold);
  margin: 0 0 var(--hs-space-3);
  line-height: var(--hs-line-height-xl);
}
h1 { font-size: var(--hs-font-size-3xl); line-height: var(--hs-line-height-3xl); font-weight: var(--hs-font-weight-bold); }
h2 { font-size: var(--hs-font-size-2xl); line-height: var(--hs-line-height-2xl); }
h3 { font-size: var(--hs-font-size-xl); line-height: var(--hs-line-height-xl); }
p  { margin: 0 0 var(--hs-space-4); }

a { color: var(--hs-color-primary); text-decoration: none; }
a:hover { color: var(--hs-color-primary-hover); text-decoration: underline; }

img, svg { max-width: 100%; height: auto; }

/* --- Layout container --- */
.hs-container {
  width: 100%;
  max-width: var(--hs-content-max);
  margin-inline: auto;
  padding-inline: var(--hs-space-5);
}

/* --- Buttons --- */
.hs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--hs-space-2);
  padding: var(--hs-space-3) var(--hs-space-5);
  font-family: inherit;
  font-size: var(--hs-font-size-sm);
  font-weight: var(--hs-font-weight-semibold);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--hs-radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--hs-duration-fast) var(--hs-ease-standard),
              color var(--hs-duration-fast) var(--hs-ease-standard),
              border-color var(--hs-duration-fast) var(--hs-ease-standard);
}
.hs-btn:hover { text-decoration: none; }
.hs-btn--primary { background: var(--hs-color-primary); color: var(--hs-color-on-primary); }
.hs-btn--primary:hover { background: var(--hs-color-primary-hover); color: var(--hs-color-on-primary); }
.hs-btn--accent { background: var(--hs-color-accent); color: var(--hs-color-on-accent); }
.hs-btn--accent:hover { background: var(--hs-color-accent-hover); color: var(--hs-color-on-accent); }
.hs-btn--ghost {
  background: transparent;
  color: var(--hs-color-foreground);
  border-color: var(--hs-color-border-strong);
}
.hs-btn--ghost:hover { background: var(--hs-color-surface-raised); color: var(--hs-color-foreground); }
.hs-btn--lg { padding: var(--hs-space-4) var(--hs-space-8); font-size: var(--hs-font-size-base); }
.hs-btn[disabled], .hs-btn.is-disabled {
  opacity: 0.55; cursor: not-allowed; pointer-events: none;
}

/* --- Cards --- */
.hs-card {
  background: var(--hs-color-surface);
  border: 1px solid var(--hs-color-border);
  border-radius: var(--hs-radius-md);
  box-shadow: var(--hs-elevation-1);
  padding: var(--hs-space-6);
  transition: box-shadow var(--hs-duration-base) var(--hs-ease-standard);
}
.hs-card:hover { box-shadow: var(--hs-elevation-2); }

/* --- Badges / pills --- */
.hs-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--hs-space-1);
  padding: 2px var(--hs-space-2);
  font-size: var(--hs-font-size-xs);
  font-weight: var(--hs-font-weight-medium);
  border-radius: var(--hs-radius-full);
  background: var(--hs-color-surface-raised);
  color: var(--hs-color-foreground-muted);
}
.hs-badge--success { background: var(--hs-color-success-tint); color: var(--hs-color-success-text); }
.hs-badge--warning { background: var(--hs-color-warning-tint); color: var(--hs-color-warning-text); }
.hs-badge--danger  { background: var(--hs-color-danger-tint);  color: var(--hs-color-danger-text); }
.hs-badge--info    { background: var(--hs-color-info-tint);    color: var(--hs-color-info-text); }
.hs-badge--promoted{ background: var(--hs-color-amber-100); color: var(--hs-color-amber-800); }

/* --- Tag chips (clickable) --- */
.hs-tag-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--hs-space-2) var(--hs-space-4);
  font-size: var(--hs-font-size-sm);
  font-weight: var(--hs-font-weight-medium);
  border-radius: var(--hs-radius-full);
  background: var(--hs-color-surface);
  border: 1px solid var(--hs-color-border);
  color: var(--hs-color-foreground-body);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--hs-duration-fast) var(--hs-ease-standard),
              border-color var(--hs-duration-fast) var(--hs-ease-standard);
}
.hs-tag-chip:hover, .hs-tag-chip[aria-selected="true"] {
  background: var(--hs-color-amber-50);
  border-color: var(--hs-color-primary);
  color: var(--hs-color-amber-800);
  text-decoration: none;
}

/* Horizontal-scroll chip rail (mobile-first tag clouds / filters) */
.hs-chip-rail {
  display: flex;
  gap: var(--hs-space-2);
  overflow-x: auto;
  padding-bottom: var(--hs-space-2);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.hs-chip-rail::-webkit-scrollbar { height: 6px; }
.hs-chip-rail::-webkit-scrollbar-thumb { background: var(--hs-color-border); border-radius: var(--hs-radius-full); }
@media (min-width: 720px) {
  .hs-chip-cloud { flex-wrap: wrap; overflow-x: visible; }
}

/* --- Form fields --- */
.hs-field { display: block; margin-bottom: var(--hs-space-5); }
.hs-label {
  display: block;
  font-size: var(--hs-font-size-sm);
  font-weight: var(--hs-font-weight-medium);
  color: var(--hs-color-foreground);
  margin-bottom: var(--hs-space-2);
}
.hs-input, .hs-select, .hs-textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--hs-font-size-base);
  color: var(--hs-color-foreground);
  background: var(--hs-color-surface);
  border: 1px solid var(--hs-color-border);
  border-radius: var(--hs-radius-sm);
  padding: var(--hs-space-3) var(--hs-space-4);
  transition: border-color var(--hs-duration-fast) var(--hs-ease-standard),
              box-shadow var(--hs-duration-fast) var(--hs-ease-standard);
}
.hs-textarea { min-height: 120px; resize: vertical; }
.hs-input:focus, .hs-select:focus, .hs-textarea:focus {
  outline: none;
  border-color: var(--hs-color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hs-color-primary) 25%, transparent);
}
.hs-help { font-size: var(--hs-font-size-xs); color: var(--hs-color-foreground-muted); margin-top: var(--hs-space-1); }
.hs-error { font-size: var(--hs-font-size-xs); color: var(--hs-color-danger); margin-top: var(--hs-space-1); }

/* --- Skeletons (loading) --- */
.hs-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--hs-color-surface-raised);
  border-radius: var(--hs-radius-md);
}
.hs-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg,
    transparent 0%,
    color-mix(in srgb, var(--hs-color-border) 60%, transparent) 50%,
    transparent 100%);
  animation: hs-shimmer var(--hs-duration-slow) linear infinite;
}
.hs-skeleton--text { height: 0.9em; margin-bottom: var(--hs-space-2); border-radius: var(--hs-radius-sm); }
.hs-skeleton--line { height: 14px; margin-bottom: var(--hs-space-2); border-radius: var(--hs-radius-sm); }
.hs-skeleton--card { height: 180px; }
@keyframes hs-shimmer { 100% { transform: translateX(100%); } }

/* --- Empty state --- */
.hs-empty-state {
  text-align: center;
  padding: var(--hs-space-8);
  color: var(--hs-color-foreground-muted);
}
.hs-empty-state h3 { font-size: var(--hs-font-size-lg); color: var(--hs-color-foreground); margin-bottom: var(--hs-space-2); }
.hs-empty-state p { margin-bottom: var(--hs-space-5); }

/* --- Hero --- */
.hs-hero { padding: var(--hs-space-12) 0 var(--hs-space-10); text-align: center; }
.hs-hero__lede { font-size: var(--hs-font-size-lg); color: var(--hs-color-foreground-muted); max-width: 44ch; margin-inline: auto; }

/* --- Grid helpers --- */
.hs-grid { display: grid; gap: var(--hs-space-6); }
.hs-grid--auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hs-grid--cards-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* --- Section rhythm --- */
.hs-section { padding-block: var(--hs-space-10); }
.hs-section__title { text-align: center; margin-bottom: var(--hs-space-8); }

/* --- Tabs (underline) --- */
.hs-tabs { display: flex; gap: var(--hs-space-6); border-bottom: 1px solid var(--hs-color-border); margin-bottom: var(--hs-space-6); }
.hs-tab {
  padding: var(--hs-space-3) 0;
  font-size: var(--hs-font-size-base);
  font-weight: var(--hs-font-weight-medium);
  color: var(--hs-color-foreground-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none; border-top: 0; border-left: 0; border-right: 0;
  transition: color var(--hs-duration-fast) var(--hs-ease-standard),
              border-color var(--hs-duration-fast) var(--hs-ease-standard);
}
.hs-tab:hover { color: var(--hs-color-foreground); text-decoration: none; }
.hs-tab[aria-selected="true"], .hs-tab.is-active {
  color: var(--hs-color-foreground);
  border-bottom-color: var(--hs-color-primary);
}

/* --- Utility --- */
.hs-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hs-muted { color: var(--hs-color-foreground-muted); }
.hs-stack > * + * { margin-top: var(--hs-space-4); }
.hs-notice {
  padding: var(--hs-space-4) var(--hs-space-5);
  border-radius: var(--hs-radius-md);
  background: var(--hs-color-info-tint);
  color: var(--hs-color-info-text);
  font-size: var(--hs-font-size-sm);
}
.hs-notice--muted { background: var(--hs-color-surface-raised); color: var(--hs-color-foreground-muted); }

/* Un-upgraded custom-element placeholders: keep them from collapsing to 0
   height before their bundle registers. Each page provides a skeleton inside. */
hs-search-bar:not(:defined),
hs-search-results:not(:defined),
hs-i-want-form:not(:defined),
hs-quote-request-form:not(:defined),
hs-consumer-inbox:not(:defined),
hs-consumer-appointments:not(:defined),
hs-consumer-favorites:not(:defined),
hs-consumer-event-rsvp:not(:defined),
hs-community-feed:not(:defined),
hs-consumer-profile-form:not(:defined),
hs-consumer-nav:not(:defined) {
  display: block;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
