/* ============================================================
   Pine Countdown — time engraved into premium pine wood
   Part of the Humanu "Walnut" brand system.
   Pine board (warm honey wood) framed in walnut; numerals are
   routed/carved into the grain with a lit lower lip and a dark
   inner wall for a convincing engraved finish.
   ============================================================ */

.pine-countdown {
  /* Pine tones (lighter & warmer than walnut, harmonised with the brand) */
  --pine-light:  #EFDCB4;
  --pine-base:   #E6CD9E;
  --pine-mid:    #DCBF89;
  --pine-deep:   #CFB078;
  --pine-grain:  rgba(150, 104, 56, 0.14);
  --pine-knot:   rgba(120, 78, 38, 0.18);

  /* Carving — the cut shows scorched end-grain */
  --carve-ink:    #5A3D1F;
  --carve-wall:   rgba(58, 38, 16, 0.60); /* dark upper inner wall of the groove */
  --carve-lip:    rgba(255, 248, 232, 0.70); /* light catching the lower lip */

  /* Laser burn — charred mark + heat-affected halo + beam ember */
  --char:        #241405; /* charred burn (resting) */
  --char-soft:   #3A2008; /* cooling char */
  --scorch-halo: rgba(120, 55, 18, 0.35); /* heat-darkened wood around the burn */
  --ember-core:  #FFE9C2; /* white-hot beam contact */
  --ember:       #FF7A1A; /* glowing burn */

  /* Burn darkness/contrast — overlay that scorches the wood photo inside the
     digits. Higher alpha = darker, higher contrast against the pale board.
     Tune these two values to taste (e.g. 0.80 = lighter, 0.92 = heavier). */
  --burn-top:    rgba(15, 7, 1, 0.95);
  --burn-bottom: rgba(26, 13, 4, 0.92);

  display: flex;
  flex-direction: column;
  align-items: center;
  margin-inline: auto;
  width: fit-content;
  max-width: 100%;
}

/* ---- Walnut frame around the pine board ---- */
.pine-countdown__frame {
  padding: clamp(0.55rem, 1.4vw, 1rem);
  border-radius: calc(var(--wal-radius-lg, 16px) + 6px);
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.07) 0 2px,
      rgba(255, 255, 255, 0.03) 2px 8px),
    linear-gradient(180deg, #7C5331 0%, #5E3F23 58%, #4A3322 100%);
  box-shadow:
    var(--wal-shadow-lg, 0 12px 40px rgba(46, 32, 22, 0.18)),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}

/* ---- Pine board ---- */
.pine-countdown__board {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: clamp(1rem, 2.6vw, 2rem) clamp(0.5rem, 1.8vw, 1.5rem);
  border-radius: var(--wal-radius-md, 8px);
  /* real pine photo on top; CSS wood gradient as a fallback underneath */
  background-color: var(--pine-base);
  background-image:
    url("pine-wood.jpg"),
    linear-gradient(180deg, var(--pine-light) 0%, var(--pine-base) 48%, var(--pine-mid) 78%, var(--pine-deep) 100%);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  box-shadow:
    inset 0 2px 3px rgba(255, 250, 236, 0.45),
    inset 0 -16px 28px rgba(120, 80, 40, 0.22),
    inset 0 0 0 1px rgba(74, 51, 34, 0.22);
}

/* ---- A unit (value + label) ---- */
.pine-countdown__unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: clamp(0.5rem, 1.6vw, 1.1rem) clamp(0.85rem, 2.4vw, 1.75rem);
  min-width: clamp(70px, 13vw, 132px);
}

/* Carved vertical groove between units */
.pine-countdown__unit + .pine-countdown__unit {
  border-left: 1px solid rgba(255, 248, 232, 0.45);
  box-shadow: inset 1px 0 0 rgba(74, 51, 34, 0.28);
}

/* ---- Laser-burned numerals (simple sans — Source Sans 3) ---- */
.pine-countdown__value {
  position: relative;
  display: inline-block;
  font-family: var(--wal-font-body, "Source Sans 3", system-ui, sans-serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 7.5vw, 4.75rem);
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--char);
  will-change: transform, color, text-shadow, filter;
  /* a charred burn: crisp dark edge, heat-darkened halo, faint surface lip */
  text-shadow:
    0 0 1px rgba(18, 9, 1, 0.85),
    0 0 8px var(--scorch-halo),
    0 0 2px rgba(40, 22, 8, 0.7),
    0 1px 0 rgba(255, 248, 232, 0.38);
}

/* ---- Engraved labels ---- */
.pine-countdown__label {
  font-family: var(--wal-font-body, "Source Sans 3", system-ui, sans-serif);
  text-transform: uppercase;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  color: #3D2814;
  text-shadow:
    0 1px 0 rgba(255, 250, 238, 0.75),
    0 -1px 1px rgba(58, 38, 16, 0.35);
}

/* Laser engrave animation — each changed digit is burned into the wood:
   the beam ignites a white-hot contact point, the mark glows and smokes,
   then cools through ember-orange to a settled charred burn. */
.pine-countdown__value.is-engrave {
  color: transparent;
  -webkit-text-fill-color: transparent;
  /* Three stacked fills clipped to the glyphs (top -> bottom):
     1) scan gradient — transparent over the already-burned area, a bright
        beam line, then a pale wash that reveals raw wood ahead of the beam;
     2) scorch overlay — darkens the wood photo into charred grain;
     3) the pine photo — gives the burn a real, textured wood grain. */
  background-image:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, 0) 46%,
      rgba(255, 176, 64, 0.5) 47.5%,
      rgba(255, 238, 206, 0.95) 50%,
      rgba(255, 176, 64, 0.5) 52.5%,
      rgba(228, 206, 162, 0.82) 56%,
      rgba(228, 206, 162, 0.82) 100%
    ),
    linear-gradient(var(--burn-top), var(--burn-bottom)),
    url("pine-wood.jpg");
  background-size: 100% 250%, 100% 100%, cover;
  background-position: 50% 0%, 50% 50%, 50% 50%; /* resting = fully burned */
  background-repeat: no-repeat, no-repeat, no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  animation: pine-laser 1.2s linear;
}
/* Seconds change every second — keep their burn inside the 1s tick window. */
.pine-countdown__value[data-unit="seconds"].is-engrave {
  animation-duration: 0.85s;
}
@keyframes pine-laser {
  0% {
    /* beam parked above the glyph — whole digit still raw wood */
    background-position: 50% 100%, 50% 50%, 50% 50%;
    text-shadow: none;
  }
  8% {
    /* beam switches on */
    text-shadow: 0 0 8px rgba(255, 138, 26, 0.55);
  }
  50% {
    /* mid-scan — bright line glowing as it travels down */
    text-shadow:
      0 0 11px rgba(255, 138, 26, 0.5),
      0 0 2px rgba(60, 30, 8, 0.5);
  }
  88% {
    /* beam reaches the bottom — glyph fully burned */
    background-position: 50% 0%, 50% 50%, 50% 50%;
    text-shadow:
      0 0 9px rgba(120, 55, 18, 0.42),
      0 0 2px rgba(40, 22, 8, 0.6),
      0 1px 0 rgba(255, 248, 232, 0.28);
  }
  100% {
    /* beam off, settled charred burn with scorch halo */
    background-position: 50% 0%, 50% 50%, 50% 50%;
    text-shadow:
      0 0 1px rgba(18, 9, 1, 0.85),
      0 0 8px var(--scorch-halo),
      0 0 2px rgba(40, 22, 8, 0.7),
      0 1px 0 rgba(255, 248, 232, 0.38);
  }
}

/* Laser head — a hot point that zig-zags left/right (the raster sweep)
   while it travels down the glyph, in step with the line-by-line burn. */
.pine-countdown__value.is-engrave::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 0.2em;
  height: 0.16em;
  margin-left: -0.1em;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6E2 0%, #FFD27A 38%, rgba(255, 138, 26, 0.55) 62%, rgba(255, 138, 26, 0) 78%);
  box-shadow: 0 0 6px 2px rgba(255, 138, 26, 0.7);
  filter: blur(0.3px);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  animation: pine-head 1.2s linear;
}
.pine-countdown__value[data-unit="seconds"].is-engrave::before {
  animation-duration: 0.85s;
}
@keyframes pine-head {
  0%    { opacity: 0; transform: translate(-0.55em, 0); }
  6%    { opacity: 1; }
  12.5% { transform: translate(0.55em, 0.12em); }
  25%   { transform: translate(-0.55em, 0.24em); }
  37.5% { transform: translate(0.55em, 0.36em); }
  50%   { transform: translate(-0.55em, 0.48em); }
  62.5% { transform: translate(0.55em, 0.60em); }
  75%   { transform: translate(-0.55em, 0.72em); }
  87.5% { transform: translate(0.55em, 0.84em); }
  95%   { opacity: 1; transform: translate(0, 0.92em); }
  100%  { opacity: 0; transform: translate(0, 0.95em); }
}

/* Smoke wisp rising off the burn while the laser works */
.pine-countdown__value.is-engrave::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(92, 82, 72, 0.5), rgba(92, 82, 72, 0) 70%);
  filter: blur(3px);
  pointer-events: none;
  z-index: 1;
  animation: pine-smoke 1.2s ease-out;
}
.pine-countdown__value[data-unit="seconds"].is-engrave::after {
  animation-duration: 0.85s;
}
@keyframes pine-smoke {
  0%   { opacity: 0; transform: translate(-50%, 6px) scale(0.4); }
  22%  { opacity: 0.5; }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(1.35); filter: blur(7px); }
}

/* When the countdown reaches zero */
.pine-countdown.is-complete .pine-countdown__value {
  color: var(--wal-walnut, #8B5E3C);
}

/* Phones — lay the four units out as a balanced 2×2 grid on one plank,
   instead of an awkward 3 + 1 wrap, and scale the numerals to fit. */
@media (max-width: 600px) {
  .pine-countdown__board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(0.5rem, 4vw, 1.5rem);
    row-gap: clamp(0.4rem, 3vw, 1.1rem);
    padding: clamp(1rem, 5vw, 1.6rem) clamp(0.75rem, 4vw, 1.4rem);
  }
  .pine-countdown__unit {
    min-width: 0;
    padding: clamp(0.35rem, 2vw, 0.7rem) 0.25rem;
  }
  /* drop the desktop carved grooves — the continuous wood reads better here */
  .pine-countdown__unit + .pine-countdown__unit { border-left: 0; box-shadow: none; }
  .pine-countdown__value { font-size: clamp(2.1rem, 15vw, 3.25rem); }
  .pine-countdown__label { font-size: 0.75rem; letter-spacing: 0.1em; }
}

/* Very small phones — tighten a touch more */
@media (max-width: 360px) {
  .pine-countdown__value { font-size: clamp(1.9rem, 17vw, 2.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  .pine-countdown__value.is-engrave { animation: none; background-position: 50% 0%; }
  .pine-countdown__value.is-engrave::before { display: none; }
  .pine-countdown__value.is-engrave::after { display: none; }
}
