/* =========================================================================
   TSBF Environmental Impact Counters
   Component stylesheet — fully scoped to .tsbf-counters
   -------------------------------------------------------------------------
   NOTHING in this file uses a bare/global selector. Every rule is prefixed
   with .tsbf-counters, so the component cannot leak styles into the theme.
   Typography is set explicitly on every text element so the surrounding
   theme cannot bleed IN (fonts, colours, line-heights). See HANDOFF.md.
   ========================================================================= */

/* ---- Scoped reset --------------------------------------------------------- */
.tsbf-counters,
.tsbf-counters *,
.tsbf-counters *::before,
.tsbf-counters *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- Component root ------------------------------------------------------- */
.tsbf-counters {
  /* Defensive typography base — theme styles cannot override these */
  font-family: "Karla", sans-serif;
  font-size: 16px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  color: #3a2e1e;
  text-align: left;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  max-width: 1160px;
  position: relative;
  z-index: 20;
  margin-left: auto;
  margin-right: auto;
  /* padding: 24px 24px 0; */
}

/* ---- Card grid ----------------------------------------------------------- */
.tsbf-counters__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* ---- Card ---------------------------------------------------------------- */
.tsbf-counters__card {
  background: #f8f3eb;
  border: 1px solid #e0d5c0;
  border-radius: 5px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.07);
  padding: 16px 14px 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Tan accent bar */
.tsbf-counters__card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #c8a96e;
  border-radius: 5px 5px 0 0;
}

/* ---- Label --------------------------------------------------------------- */
.tsbf-counters__label {
  font-family: "futura-pt", sans-serif;
  font-size: 14px;
  font-weight: 700;
  font-style: normal;
  color: #3a2e1e;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.4;
  margin: 4px 0 12px;
}

/* ---- Odometer ------------------------------------------------------------ */
.tsbf-counters__odo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

/* Individual digit cell — fixed width so the row never reflows as digits change */
.tsbf-counters__digit {
  width: 18px;
  height: 26px;
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1612;
  border: 1px solid #3a3020;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 700;
  font-style: normal;
  color: #f0ede0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  position: relative;
  overflow: hidden;
  transition: color 0.12s ease;
  background-image: linear-gradient(to bottom,
      transparent 0%,
      transparent calc(50% - 0.5px),
      rgba(0, 0, 0, 0.55) calc(50% - 0.5px),
      rgba(0, 0, 0, 0.55) calc(50% + 0.5px),
      transparent calc(50% + 0.5px),
      transparent 100%);
}

/* Highlight on the fastest digit during catch-up */
.tsbf-counters__digit--rolling {
  color: #c8a96e;
}

/* Comma separator */
.tsbf-counters__sep {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: rgba(100, 90, 75, 0.5);
  line-height: 1;
  margin-bottom: 2px;
}

/* ---- Unit + daily rate --------------------------------------------------- */
.tsbf-counters__unit {
  font-size: 13px;
  font-weight: 400;
  color: #888;
  letter-spacing: 0.03em;
  line-height: 1.4;
  margin-top: 8px;
}

.tsbf-counters__rate {
  font-size: 16px;
  font-weight: 700;
  color: #c8a96e;
  line-height: 1.4;
  margin-top: 4px;
}

/* ---- Live indicator: pulsing corner dot (Option 2C) ---------------------- */
.tsbf-counters__corner-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7bcf8a;
  opacity: 0;
  /* hidden until catch-up completes */
  transition: opacity 0.6s ease;
}

.tsbf-counters__corner-dot--visible {
  opacity: 1;
  animation: tsbf-pulse 2s ease-in-out infinite;
}

@keyframes tsbf-pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.25;
    transform: scale(0.55);
  }
}

/* ---- Screen-reader-only summary ------------------------------------------ */
.tsbf-counters__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================================
   STYLE VARIANT 1 — HERO OVERLAP
   Cards float up over the bottom of the homepage hero image.
   The overlap depth is set per-instance via the block's "Hero overlap"
   field (inline margin-top). Default -36px. See HANDOFF.md for dial-in.
   ========================================================================= */
.tsbf-counters--hero {
  /* margin-top supplied inline by the block render template */
}

/* =========================================================================
   STYLE VARIANT 2 — INLINE BAND
   A normal in-flow section. No hero overlap. For interior pages.
   ========================================================================= */
.tsbf-counters--inline {
  margin-top: 0;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* =========================================================================
   STYLE VARIANT 3 — COMPACT GRID
   2 x 2 layout with smaller cards/digits. For narrow contexts.
   ========================================================================= */
.tsbf-counters--compact {
  margin-top: 0;
  padding-top: 24px;
  padding-bottom: 24px;
  max-width: 620px;
}

.tsbf-counters--compact .tsbf-counters__grid {
  grid-template-columns: repeat(2, 1fr);
}

.tsbf-counters--compact .tsbf-counters__digit {
  width: 15px;
  height: 23px;
  flex-basis: 15px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .tsbf-counters {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .tsbf-counters--hero .tsbf-counters__grid,
  .tsbf-counters--inline .tsbf-counters__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .tsbf-counters--hero .tsbf-counters__grid,
  .tsbf-counters--inline .tsbf-counters__grid,
  .tsbf-counters--compact .tsbf-counters__grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tsbf-counters {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ---- Reduced motion ------------------------------------------------------ */
/* Correct selector (the original brief code targeted a class that did not
   exist). Dot stays solid green; no pulse, no digit transition. */
@media (prefers-reduced-motion: reduce) {
  .tsbf-counters__corner-dot--visible {
    animation: none;
    opacity: 1;
  }

  .tsbf-counters__digit {
    transition: none;
  }
}