/*
 * HBTH home v2
 * Page-scoped styles: existing tool pages are intentionally unaffected.
 */

body.home-page {
  --bg: var(--ds-color-canvas);
  --surface: var(--ds-color-surface);
  --surface-2: var(--ds-color-surface-subtle);
  --text: var(--ds-color-text);
  --text-rgb: 25, 27, 31;
  --muted: var(--ds-color-text-secondary);
  --primary: var(--ds-color-brand);
  --primary-rgb: 230, 195, 0;
  --accent: var(--ds-color-positive);
  --border: var(--ds-color-border);
  --chip: var(--ds-color-surface-subtle);
  --shadow: var(--ds-shadow-sm);
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 4%, color-mix(in srgb, var(--ds-color-brand) 10%, transparent) 0, transparent 28rem),
    var(--ds-color-canvas);
  color: var(--ds-color-text);
  font-family: var(--ds-font-sans);
  letter-spacing: -0.012em;
}

html[data-theme="dark"] body.home-page {
  --text-rgb: 245, 246, 242;
  --primary-rgb: 240, 211, 41;
  background:
    radial-gradient(circle at 10% 2%, rgba(240, 211, 41, 0.08) 0, transparent 30rem),
    var(--ds-color-canvas);
}

.home-page a,
.home-page button,
.home-page input {
  -webkit-tap-highlight-color: transparent;
}

.home-page .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.home-page a:focus-visible,
.home-page button:focus-visible,
.home-page input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ds-color-focus) 55%, transparent);
  outline-offset: 3px;
}

/* Layout */
.home-shell {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: var(--ds-space-24);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: end;
  gap: clamp(48px, 7vw, 96px);
  padding: clamp(72px, 9vw, 124px) 0 clamp(64px, 8vw, 100px);
}

.home-hero__content {
  min-width: 0;
}

.home-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-sm);
  font-weight: 720;
  letter-spacing: -0.01em;
}

.home-eyebrow__mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ds-color-brand);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--ds-color-brand) 16%, transparent);
}

.home-hero #hero-title {
  max-width: 830px;
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-text-display);
  font-weight: 820;
  line-height: 0.99;
  letter-spacing: -0.065em;
  text-align: left;
  text-wrap: balance;
  white-space: pre-line;
}

.home-hero #hero-desc {
  max-width: 660px;
  margin: 28px 0 0;
  color: var(--ds-color-text-secondary);
  font-size: clamp(1.05rem, 1.5vw, 1.22rem);
  font-weight: 470;
  line-height: 1.7;
  text-align: left;
  text-wrap: pretty;
}

.home-search {
  position: relative;
  width: min(100%, 690px);
  margin-top: 38px;
}

.home-search__icon {
  position: absolute;
  top: 50%;
  left: 22px;
  z-index: 1;
  color: var(--ds-color-text);
  font-size: 1.05rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.home-page .home-search .main-search-input {
  min-height: 64px;
  padding: 0 108px 0 54px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-surface);
  color: var(--ds-color-text);
  box-shadow: var(--ds-shadow-md);
  font-size: 1rem;
  font-weight: 560;
  transition:
    border-color var(--ds-duration-fast),
    box-shadow var(--ds-duration-fast),
    transform var(--ds-duration-fast);
}

.home-page .home-search .main-search-input::placeholder {
  color: var(--ds-color-text-tertiary);
  opacity: 1;
}

.home-page .home-search .main-search-input:focus {
  border-color: var(--ds-color-focus);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--ds-color-focus) 14%, transparent),
    var(--ds-shadow-lg);
  transform: translateY(-1px);
}

.home-search__shortcut {
  position: absolute;
  top: 50%;
  right: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  border: 1px solid var(--ds-color-border);
  border-radius: 8px;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text-secondary);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-text-xs);
  font-weight: 700;
  transform: translateY(-50%);
  pointer-events: none;
}

.home-page .home-search .search-clear-btn {
  right: 60px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

/* Quick launch */
.quick-panel {
  position: relative;
  padding: 26px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-xl);
  background: color-mix(in srgb, var(--ds-color-surface) 88%, transparent);
  box-shadow: var(--ds-shadow-md);
  overflow: hidden;
}

.quick-panel::before {
  position: absolute;
  top: -52px;
  right: -44px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--ds-color-brand);
  content: "";
  opacity: 0.18;
  filter: blur(2px);
  pointer-events: none;
}

.quick-panel__heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.quick-panel__label {
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-text-lg);
  font-weight: 760;
}

.quick-panel__signal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ds-color-positive);
  font-size: var(--ds-text-xs);
  font-weight: 720;
}

.quick-panel__signal::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.quick-tools {
  position: relative;
  display: grid;
  gap: 8px;
}

.quick-tool {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  text-decoration: none;
  transition:
    background var(--ds-duration-fast),
    border-color var(--ds-duration-fast),
    transform var(--ds-duration-fast);
}

.quick-tool:hover {
  border-color: var(--ds-color-border);
  background: var(--ds-color-surface);
  transform: translateX(3px);
}

.quick-tool__icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text);
  font-size: 1rem;
}

.quick-tool__title {
  overflow: hidden;
  font-size: var(--ds-text-sm);
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-tool > .bi-arrow-up-right,
.quick-tool > .bi-arrow-right {
  color: var(--ds-color-text-tertiary);
  font-size: 0.85rem;
}

/* Directory */
.tool-directory {
  scroll-margin-top: 96px;
}

.home-hero,
.coming-soon-section {
  scroll-margin-top: 96px;
}

.tool-directory__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--ds-color-border);
}

.tool-directory__copy h2 {
  margin: 0;
  color: var(--ds-color-text);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.045em;
}

.tool-directory__copy p {
  margin: 10px 0 0;
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-md);
  line-height: 1.55;
}

.tool-results {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-surface);
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-sm);
  font-weight: 650;
}

.tool-results__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-color-positive);
}

.home-page .tool-results__count {
  color: var(--ds-color-text);
  font-size: inherit;
  font-weight: 720;
}

.home-page .filter-bar {
  position: sticky;
  top: 72px;
  z-index: 20;
  display: block;
  margin: 0 0 30px;
  padding: 18px 0;
  background: color-mix(in srgb, var(--ds-color-canvas) 90%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
}

.home-page .category-scroll {
  display: flex;
  justify-content: flex-start;
  gap: 7px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scroll-behavior: smooth;
  scroll-padding-inline: 16px;
}

.home-page .category-chip {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-full);
  background: color-mix(in srgb, var(--ds-color-surface) 72%, transparent);
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-sm);
  font-weight: 650;
  scroll-margin-inline: 16px;
}

.home-page .category-chip:hover {
  border-color: var(--ds-color-border-strong);
  background: var(--ds-color-surface);
  color: var(--ds-color-text);
}

.home-page .category-chip.is-active {
  border-color: var(--ds-color-surface-strong);
  background: var(--ds-color-surface-strong);
  color: var(--ds-color-on-strong);
  box-shadow: none;
}

.home-page .category-chip.is-active i {
  color: var(--ds-color-brand);
}

.home-page .tool-grid-modern {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.home-page .tool-card-modern {
  min-height: 232px;
  padding: 22px;
  gap: 22px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-lg);
  background: color-mix(in srgb, var(--ds-color-surface) 94%, transparent);
  box-shadow: var(--ds-shadow-sm);
  color: var(--ds-color-text);
  isolation: isolate;
  transition:
    border-color var(--ds-duration-base),
    box-shadow var(--ds-duration-base),
    transform var(--ds-duration-base) var(--ds-ease-out);
  animation: home-card-in 520ms var(--ds-ease-out) both;
  animation-delay: min(calc(var(--card-index, 0) * 28ms), 280ms);
}

.home-page .tool-card-modern::before {
  position: absolute;
  right: -62px;
  bottom: -72px;
  z-index: -1;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--ds-color-brand);
  content: "";
  opacity: 0;
  transform: scale(0.72);
  transition:
    opacity var(--ds-duration-base),
    transform 360ms var(--ds-ease-out);
}

.home-page .tool-card-modern:hover {
  border-color: var(--ds-color-border-strong);
  background: var(--ds-color-surface);
  box-shadow: var(--ds-shadow-md);
  transform: translateY(-5px);
}

.home-page .tool-card-modern:hover::before {
  opacity: 0.12;
  transform: scale(1);
}

.tool-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.home-page .tool-icon-wrapper {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0;
  place-items: center;
  border: 1px solid var(--ds-color-border);
  border-radius: 14px;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text);
  font-size: 1.2rem;
  transition:
    background var(--ds-duration-base),
    color var(--ds-duration-base),
    transform var(--ds-duration-base) var(--ds-ease-out);
}

.home-page .tool-card-modern:hover .tool-icon-wrapper {
  border: 1px solid var(--ds-color-brand);
  background: var(--ds-color-brand);
  color: var(--ds-color-on-brand);
  transform: rotate(-4deg) scale(1.04);
}

.tool-card__category {
  color: var(--ds-color-text-tertiary);
  font-size: var(--ds-text-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.home-page .tool-info {
  gap: 9px;
}

.home-page .tool-card-modern:hover .tool-info {
  filter: none;
}

.home-page .tool-title {
  color: var(--ds-color-text);
  font-size: var(--ds-text-lg);
  font-weight: 760;
  letter-spacing: -0.025em;
}

.home-page .tool-desc {
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-sm);
  line-height: 1.6;
}

.home-page .card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0;
  color: var(--ds-color-text-secondary);
  opacity: 1;
  transform: none;
}

.tool-card__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--ds-text-xs);
  font-weight: 650;
}

.tool-card__metrics {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.tool-card__visits {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--ds-color-text-tertiary);
  font-size: var(--ds-text-xs);
  font-weight: 650;
  white-space: nowrap;
}

.tool-card__visits i {
  color: var(--ds-color-brand);
  font-size: 0.72rem;
}

.tool-card__status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-color-positive);
  content: "";
}

.home-page .card-action > i {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text);
  font-size: 0.9rem;
  transition:
    background var(--ds-duration-base),
    color var(--ds-duration-base),
    transform var(--ds-duration-base) var(--ds-ease-out);
}

.home-page .tool-card-modern:hover .card-action {
  opacity: 1;
  transform: none;
}

.home-page .tool-card-modern:hover .card-action > i {
  background: var(--ds-color-surface-strong);
  color: var(--ds-color-on-strong);
  transform: translate(2px, -2px);
}

.home-empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 300px;
  padding: 48px 24px;
  place-items: center;
  border: 1px dashed var(--ds-color-border-strong);
  border-radius: var(--ds-radius-xl);
  background: color-mix(in srgb, var(--ds-color-surface) 60%, transparent);
  text-align: center;
}

.home-empty-state__icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 16px;
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text-secondary);
  font-size: 1.35rem;
}

.home-empty-state h3 {
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-text-xl);
}

.home-empty-state p {
  margin: 8px 0 20px;
  color: var(--ds-color-text-secondary);
  line-height: 1.55;
}

.home-empty-state__reset {
  min-height: 42px;
  padding: 0 17px;
  border: 0;
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-surface-strong);
  color: var(--ds-color-on-strong);
  font: 700 var(--ds-text-sm) / 1 var(--ds-font-sans);
  cursor: pointer;
}

/* Coming soon */
.coming-soon-section {
  position: relative;
  margin-top: clamp(84px, 10vw, 132px);
  padding: clamp(30px, 5vw, 52px);
  border: 1px solid color-mix(in srgb, var(--ds-color-brand) 30%, var(--ds-color-border));
  border-radius: var(--ds-radius-xl);
  background:
    radial-gradient(circle at 92% 0, color-mix(in srgb, var(--ds-color-brand) 22%, transparent), transparent 260px),
    var(--ds-color-brand-soft);
  overflow: hidden;
}

.coming-soon-section__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 30px;
}

.coming-soon-section__kicker {
  margin: 0 0 10px;
  color: var(--ds-color-brand-ink);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
}

.coming-soon-section h2 {
  margin: 0;
  color: var(--ds-color-text);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 820;
  letter-spacing: -0.05em;
}

.coming-soon-section__header p:last-child {
  margin: 10px 0 0;
  color: var(--ds-color-text-secondary);
  font-size: var(--ds-text-md);
  line-height: 1.55;
}

.coming-soon-section__count {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--ds-color-brand) 38%, var(--ds-color-border));
  border-radius: var(--ds-radius-full);
  background: color-mix(in srgb, var(--ds-color-surface) 68%, transparent);
  color: var(--ds-color-brand-ink);
  font-size: var(--ds-text-sm);
  font-weight: 730;
}

.coming-soon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.coming-soon-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--ds-color-border) 78%, transparent);
  border-radius: var(--ds-radius-md);
  background: color-mix(in srgb, var(--ds-color-surface) 72%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ds-color-surface) 80%, transparent) inset;
}

.coming-soon-card__icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ds-color-brand) 16%, var(--ds-color-surface));
  color: var(--ds-color-brand-ink);
  font-size: 1rem;
}

.coming-soon-card__copy {
  min-width: 0;
}

.coming-soon-card__title {
  display: block;
  overflow: hidden;
  margin: 0;
  color: var(--ds-color-text);
  font-size: var(--ds-text-sm);
  font-weight: 720;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coming-soon-card__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: var(--ds-color-text-secondary);
  font-size: 0.68rem;
  font-weight: 650;
}

.coming-soon-card__meta span + span::before {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 7px 2px 0;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.55;
}

@keyframes home-card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .home-hero {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 40px;
  }

  .quick-panel {
    width: min(100%, 690px);
  }

  .quick-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-page .tool-grid-modern {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .coming-soon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .home-shell {
    width: min(100% - 32px, 1200px);
    padding-bottom: var(--ds-space-16);
  }

  .home-hero {
    padding: 60px 0 68px;
  }

  .home-hero #hero-title {
    padding: 0;
    font-size: clamp(2.65rem, 13vw, 4.25rem) !important;
    line-height: 1.02;
    word-break: keep-all;
  }

  .home-hero #hero-desc {
    padding: 0;
    font-size: 1rem !important;
  }

  .home-search {
    margin-top: 30px;
  }

  .home-page .home-search .main-search-input {
    min-height: 58px;
  }

  .quick-tools {
    grid-template-columns: 1fr;
  }

  .home-page .filter-bar {
    top: 66px;
    margin-right: -16px;
    margin-left: -16px;
    padding: 14px 16px;
  }

  .home-page .category-scroll {
    padding-right: 16px;
  }
}

@media (max-width: 620px) {
  .home-eyebrow {
    margin-bottom: 18px;
  }

  .tool-directory__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .home-page .tool-grid-modern {
    grid-template-columns: 1fr;
  }

  .home-page .tool-card-modern {
    min-height: 210px;
  }

  .coming-soon-section {
    margin-right: -4px;
    margin-left: -4px;
    padding: 26px 20px;
    border-radius: var(--ds-radius-lg);
  }

  .coming-soon-section__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .coming-soon-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-page *,
  .home-page *::before,
  .home-page *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
