/*
 * Homepage hero animation: drawing -> AI-found scope -> price library -> estimate.
 * Markup: index.html #hero (#hc). Script: js/hero-animation.js.
 */

:root {
  --tb-ink: #292630;
  --tb-ink-soft: #6e6878;
  --tb-paper: #ffffff;
  --tb-line: #dbd7e1;
  --tb-brand: #4a2973;
  --tb-brand-2: #6b47a0;
  --tb-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tb-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Drawing ------------------------------------------------------------ */
.tb-drawing {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  font-family: var(--tb-font, "Libre Franklin", system-ui, sans-serif);
}
.tb-drawing .ln,
.tb-drawing .ln-thin,
.tb-drawing .ln-heavy,
.tb-drawing .ln-heavy-thin,
.tb-drawing .ln-hood,
.tb-drawing .ln-dash,
.tb-drawing .ln-hidden,
.tb-drawing .ln-handle,
.tb-drawing .dim,
.tb-drawing .leader {
  fill: none;
  stroke: var(--tb-ink);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tb-drawing .ln { stroke-width: 1.2; }
.tb-drawing .ln-thin { stroke-width: 0.7; }
.tb-drawing .ln-heavy { stroke-width: 2; }
.tb-drawing .ln-heavy-thin { stroke-width: 1.2; fill: #fff; }
.tb-drawing .ln-hood { stroke-width: 1.6; fill: #fff; }
.tb-drawing .ln-dash { stroke-width: 0.55; stroke-dasharray: 3 2.4; stroke: #686273; }
.tb-drawing .ln-hidden { stroke-width: 0.7; stroke-dasharray: 3 2; stroke: #686273; }
.tb-drawing .ln-handle { stroke-width: 1.6; }
.tb-drawing .dim { stroke-width: 0.55; stroke: #4e4958; }
.tb-drawing .dim-t {
  font-size: 8.5px;
  fill: #3e3947;
  text-anchor: middle;
  font-weight: 500;
}
.tb-drawing .leader { stroke-width: 0.55; stroke: #4e4958; }
.tb-drawing .leader-dot { fill: var(--tb-ink); }
.tb-drawing .hex { fill: #fff; stroke: var(--tb-ink); stroke-width: 0.9; }
.tb-drawing .hex-t { font-size: 9px; font-weight: 600; text-anchor: middle; fill: var(--tb-ink); }
.tb-drawing .sheet-t { font-size: 9px; font-weight: 700; letter-spacing: 0.06em; fill: var(--tb-ink); }
.tb-drawing .sheet-s { font-size: 9px; font-weight: 600; fill: #686273; text-anchor: end; }

/* Detection overlays */
.tb-drawing .det {
  opacity: 0;
  transform: scale(0.94);
  transform-box: fill-box;
  transform-origin: center;
  transition:
    opacity 0.35s var(--tb-ease),
    transform 0.5s var(--tb-spring),
    filter 0.3s ease;
}
.tb-drawing .det.on {
  opacity: 1;
  transform: none;
}
.tb-drawing .det-box {
  fill: var(--c);
  fill-opacity: 0.13;
  stroke: var(--c);
  stroke-width: 1.3;
  transition: fill-opacity 0.3s ease, stroke-width 0.3s ease;
}
.tb-drawing .det-code {
  font-size: 7.5px;
  font-weight: 700;
  fill: var(--c);
}
.tb-drawing .det.hl .det-box {
  fill-opacity: 0.32;
  stroke-width: 2.2;
}
.tb-drawing .det.hl {
  filter: drop-shadow(0 0 5px var(--c));
}
.tb-drawing .det.dim-out {
  opacity: 0.25;
}

/* ---- Hero layout: centred copy, full-width three-panel stage underneath -- */
/* .section.hero zeroes the bottom padding and clips overflow; the stage needs
   room below for its shadow and the hero-right slide-in. */
.hero--anim.hero--simple {
  padding-top: 8.5rem;
  padding-bottom: 5rem;
}
.hero--anim > .container {
  align-items: center;
  row-gap: 1.25rem;
}
.hero--anim .hero-headline {
  text-align: center;
  margin-bottom: 0;
}
.hero--anim .hero-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-height: 0;
  /* Fill the container (don't shrink-wrap the wider stage), so the stage
     overhangs both sides equally and everything shares one centre line. */
  width: 100%;
}
.hero--anim .hero-left {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem 1.25rem;
  /* a little wider than the container on tablets so the CTAs fit one row */
  width: min(1040px, calc(100vw - 48px));
  text-align: center;
}
.hero--anim .hero-left .large-paragraph {
  flex: 0 0 100%;
  /* full row so the CTAs wrap below, text kept to ~660px */
  padding-inline: max(0px, calc((100% - 660px) / 2));
  margin: 0 0 1rem;
}
.hero--anim .hero-cta-primary {
  order: 1;
  margin-top: 0;
  align-items: center;
}
.hero--anim .hero-secondary-actions {
  order: 2;
  margin-top: 0;
  justify-content: center;
}
.hero--anim .hero-right {
  width: min(1180px, calc(100vw - 80px));
  margin-top: 3.25rem;
  align-items: stretch;
}
@media (max-width: 991px) {
  .hero--anim.hero--simple {
    padding-top: 7rem;
  }
  .hero--anim .hero-right {
    width: 100%;
  }
}
@media (max-width: 600px) {
  .hero--anim.hero--simple {
    min-height: 0;
    display: block;
    padding-bottom: 2.5rem;
  }
  .hero--anim .hero-left {
    flex-direction: column;
    align-items: center;
  }
  .hero--anim .hero-left .large-paragraph {
    flex: none;
    padding-inline: 0;
  }
  .hero--anim .hero-video-thumb {
    width: 100%;
  }
  .hero--anim .hero-right {
    margin-top: 2.5rem;
  }
}

/* ---- Stage --------------------------------------------------------------- */
.hc {
  position: relative;
  width: 100%;
  font-family: var(--font-sans);
  color: var(--tb-ink);
}
.hc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 44px;
  align-items: stretch;
  transition: opacity 0.5s ease;
}
.hc.is-fading .hc-grid {
  opacity: 0.0;
}
.hc-col {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(41, 23, 64, 0.08);
  box-shadow: 0 24px 60px -28px rgba(10, 4, 20, 0.7);
  padding: 16px;
  min-width: 0;
  transition:
    box-shadow 0.4s ease,
    border-color 0.4s ease,
    transform 0.5s var(--tb-ease);
}
/* The active step gets a Signal Yellow callout ring */
.hc-col.is-active {
  border-color: transparent;
  box-shadow:
    0 0 0 3px #edff3d,
    0 30px 70px -26px rgba(10, 4, 20, 0.8);
  transform: translateY(-3px);
}
/* Between columns: the lilac directional triangle from the brand mark */
.hc-col + .hc-col::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 50%;
  width: 14px;
  height: 28px;
  margin-top: -14px;
  background: #bf99c9;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transition: background 0.3s ease;
}
.hc-col.is-active + .hc-col::before,
.hc-col.is-done + .hc-col::before {
  background: #edff3d;
}

.hc-h {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.hc-n {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--tb-brand);
  background: #efebf5;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}
.hc-col.is-active .hc-n,
.hc-col.is-done .hc-n {
  background: #291740;
  color: #edff3d;
}
.hc-h b {
  display: block;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  color: #291740;
}
.hc-h small {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--tb-ink-soft);
}

/* 1 - Drawing */
.hc-paper {
  position: relative;
  flex: 1;
  min-height: 280px;
  border-radius: 10px;
  border: 1px solid #eeecf1;
  background:
    radial-gradient(circle at 1px 1px, #e8e5ed 1px, transparent 0) 0 0 /
      16px 16px,
    #fcfdfe;
  overflow: hidden;
}
.hc-draw {
  position: absolute;
  inset: 10px;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition:
    opacity 0.5s ease,
    transform 0.7s var(--tb-ease);
}
.hc-draw.in {
  opacity: 1;
  transform: none;
}
.hc-found {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  background: #291740;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.3s ease,
    transform 0.4s var(--tb-ease);
}
.hc-found.on {
  opacity: 1;
  transform: none;
}
.hc-found i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #edff3d;
  box-shadow: 0 0 0 3px rgba(237, 255, 61, 0.25);
}

/* 2 - Library */
.hc-lib {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.hc-lib li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid #eeecf1;
  background: #faf9fb;
  font-size: 12.5px;
  transition:
    border-color 0.3s ease,
    background 0.3s ease,
    transform 0.4s var(--tb-spring),
    box-shadow 0.3s ease;
}
.hc-lib li.hit {
  border-color: var(--c);
  background: #fff;
  transform: scale(1.03);
  box-shadow: 0 6px 18px -8px var(--c);
}
.hc-lib li.used {
  background: #fff;
}
.hc-sw {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}
.hc-lib__name {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hc-lib__rate {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--tb-ink-soft);
  white-space: nowrap;
}
.hc-lib li.used .hc-lib__rate,
.hc-lib li.hit .hc-lib__rate {
  color: var(--tb-ink);
}

/* 3 - Estimate */
.hc-receipt {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.hc-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hc-lines li {
  position: relative;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px dashed #e4e0e9;
  font-size: 12.5px;
  transition:
    border-color 0.3s ease,
    background 0.3s ease;
}
.hc-lines li > * {
  opacity: 0;
  transform: translateX(-6px);
  transition:
    opacity 0.3s ease,
    transform 0.4s var(--tb-ease);
}
.hc-lines li.on {
  border-style: solid;
  border-color: #eeecf1;
  background: #fff;
}
.hc-lines li.on > * {
  opacity: 1;
  transform: none;
}
.hc-lines__name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hc-lines__name small {
  color: var(--tb-ink-soft);
  font-weight: 500;
  margin-left: 4px;
}
.hc-lines__amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hc-total {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #291740;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hc-total__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.hc-total small {
  font-size: 12px;
  color: #ccc2de;
  font-weight: 600;
}
.hc-total b {
  font-size: 24px;
  font-weight: 900;
  color: #edff3d;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: inline-block;
}
.hc-total b.pop {
  animation: hcPop 0.6s var(--tb-spring);
}
@keyframes hcPop {
  40% {
    transform: scale(1.12);
  }
}
.hc-mult {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.5s var(--tb-ease);
}
.hc-mult > div {
  overflow: hidden;
}
.hc-mult.on {
  grid-template-rows: 1fr;
}
.hc-mult__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 12px;
}
.hc-mult__badge {
  flex: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #edff3d;
  color: #291740;
  font-weight: 800;
  font-size: 12px;
}
.hc-mult__note {
  color: rgba(255, 255, 255, 0.85);
  text-align: right;
  font-size: 11.5px;
  line-height: 1.3;
}

/* Flying chips */
.hc-fly {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.hc-chip {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  background: var(--c);
  box-shadow:
    0 8px 20px -6px var(--c),
    0 0 0 2px rgba(255, 255, 255, 0.9);
  font-variant-numeric: tabular-nums;
}
.hc-chip::after {
  content: attr(data-label);
}
.hc-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}
.hc-chip--money {
  background: #291740;
  color: #edff3d;
  box-shadow:
    0 8px 20px -6px rgba(41, 23, 64, 0.6),
    0 0 0 2px rgba(255, 255, 255, 0.9);
}
.hc-chip--money i {
  background: var(--c);
}

@media (max-width: 991px) {
  .hc-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
  }
  .hc-col--draw {
    grid-column: 1 / -1;
  }
  .hc-col + .hc-col::before {
    display: none;
  }
  .hc-paper {
    min-height: 0;
    aspect-ratio: 1.55;
    flex: none;
  }
}
@media (max-width: 600px) {
  .hc-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .hc-col {
    padding: 12px;
  }
}

/* ---- Dark theme (the drawing itself stays on white paper) --------------- */
html[data-theme="dark"] .hc {
  color: var(--dark-text-primary);
}
html[data-theme="dark"] .hc-col {
  background: var(--dark-bg-secondary);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .hc-col.is-active {
  border-color: rgba(174, 142, 210, 0.5);
}
/* the Deep Purple swatch (tall pantry) needs an edge on dark cards */
html[data-theme="dark"] .hc-sw {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
html[data-theme="dark"] .hc-h b {
  color: #fff;
}
html[data-theme="dark"] .hc-col.is-active .hc-n,
html[data-theme="dark"] .hc-col.is-done .hc-n {
  background: #edff3d;
  color: #291740;
}
html[data-theme="dark"] .hc-h small {
  color: var(--dark-text-tertiary);
}
html[data-theme="dark"] .hc-n {
  background: rgba(174, 142, 210, 0.15);
  color: #c4b5db;
}
html[data-theme="dark"] .hc-lib li,
html[data-theme="dark"] .hc-lines li.on {
  background: var(--dark-bg-tertiary);
  border-color: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .hc-lines li {
  border-color: rgba(255, 255, 255, 0.12);
}
html[data-theme="dark"] .hc-lib li.hit,
html[data-theme="dark"] .hc-lib li.used {
  background: #2a2731;
}
html[data-theme="dark"] .hc-lib__rate,
html[data-theme="dark"] .hc-lines__name small {
  color: var(--dark-text-tertiary);
}
html[data-theme="dark"] .hc-lib li.used .hc-lib__rate,
html[data-theme="dark"] .hc-lib li.hit .hc-lib__rate {
  color: var(--dark-text-primary);
}
html[data-theme="dark"] .hc-col + .hc-col::before {
  background-color: var(--dark-bg-tertiary);
  border-color: rgba(255, 255, 255, 0.12);
}
