/**
 * pchdeliverycountdown — styles
 * @copyright 2026 PrestaChamps
 */

/* Base label — single-line copy per v1.0.20+ (Rhys spec).
 * Whole-label green so every word reads as one cohesive delivery message,
 * matching the old estimateddelivery module's full-text green styling. */
.pchdc-label,
.pchdc-label * {
    color: #009b72 !important;
}
.pchdc-label {
    margin: 8px 0;
    padding: 6px 10px;
    font-size: 14px;
    line-height: 1.4;
}
.pchdc-label .pchdc-prefix,
.pchdc-label .pchdc-timer-label {
    margin-right: 4px;
}
/* Use !important to outrank gutter theme product-info colour rules. */
.pchdc-label .pchdc-daydate {
    color: #009b72 !important;
    font-weight: bold;
}
.pchdc-label .pchdc-timer {
    color: #009b72 !important;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    animation: pchdcPulse 1.5s ease-in-out infinite;
}
@keyframes pchdcPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.7; }
}

/* Listing-card variant: compact */
.pchdc-label.pchdc-listing-label {
    margin: 6px 0 0;
    padding: 4px 0;
    font-size: 13px;
}

/* Past-cutoff text-only mode — replaces the timer markup with a single span.
 * v1.0.32: dropped font-weight:bold per Rhys ("only the timer and the date
 * should be bold") — past-cutoff has no timer, so only the daydate stays
 * bold via <strong>. Block + no top margin so it sits on line 1 alone. */
.pchdc-label .pchdc-past-cutoff {
    color: #009b72 !important;
}

/* v1.0.32: bold the live countdown numbers (timer + date are the only bold
 * elements per Rhys's brief). Visible gap between line 1 and line 2 is
 * achieved via double <br> in the template/JS, no extra block styling so
 * the daydate stays inline with "estimated delivery" on the second line.
 * v1.0.44: !important added — gutter theme has CSS rules under `.div_delivery_times`
 * that override `<strong>` font-weight to 400 (initial), so without !important the
 * customDeliveryTimes-rendered labels (POA products like 11811) showed timer + date
 * as plain weight. */
.pchdc-label .pchdc-timer,
.pchdc-label .pchdc-daydate {
    font-weight: bold !important;
}

/* Mobile: hide timer when showMobile=false (keep daydate visible) */
@media (max-width: 576px) {
    body.pchdc-hide-mobile-timer .pchdc-label .pchdc-timer-label,
    body.pchdc-hide-mobile-timer .pchdc-label .pchdc-timer,
    body.pchdc-hide-mobile-timer .pchdc-label .pchdc-mid {
        display: none !important;
    }
}

/* Hide old modules' labels once our module rendered (gated behind body.gcdd-active).
 * Belt-and-braces — covers id form, class form, theme's `.moved` repositioned variant,
 * deliverytimes inline span, and all .ed_* containers. Prefix with `html` for higher
 * specificity than the active theme's rules. */
html body.gcdd-active #estimateddelivery,
html body.gcdd-active .estimateddelivery,
html body.gcdd-active #estimateddelivery.moved,
html body.gcdd-active .estimateddelivery.moved,
html body.gcdd-active .div_delivery_times,
html body.gcdd-active span[data-time-value],
html body.gcdd-active .ed_date_init,
html body.gcdd-active .ed_item,
html body.gcdd-active [class*="ed_"][class*="mb-0"] {
    display: none !important;
}

/* v1.0.46: synchronous (pre-paint) hide of the legacy .div_delivery_times wrapper
 * on pages/cards where our own label is also present. Uses :has() — supported in
 * all major browsers since late 2023. Removes the brief sub-100ms flicker that
 * v1.0.45's JS-driven hide still had between first-paint and DOMContentLoaded.
 *
 * Falls back gracefully on browsers without :has() — the JS init still runs and
 * hides the wrapper at DOMContentLoaded (same behavior as v1.0.45).
 *
 * Conditional design (vs. blanket hide): products with no ED/DT data anywhere
 * fall through to the legacy text — for those, our label never renders, so the
 * :has() never matches, and the legacy wrapper stays visible. */
html:has(.pchdc-label:not(.pchdc-listing-label)) .div_delivery_times,
article:has(.pchdc-listing-label) .div_delivery_times,
.product-miniature:has(.pchdc-listing-label) .div_delivery_times {
    display: none !important;
}

/* v1.0.61: EXCEPTION — keep the order-level lead-time on the one-page checkout (/order).
 * The two hides above (global body.gcdd-active and the :has(.pchdc-label) pre-paint rule)
 * also catch the legitimate "Estimated lead time for your complete order" wrapper in the
 * Delivery information block — it is the ONLY .div_delivery_times on checkout and is NOT a
 * per-line duplicate of our labels. ID-level specificity beats both hides so it stays visible
 * from FIRST PAINT (no hidden-on-load flash). Pairs with the JS guard in hideLegacyDeliveryElements(). */
body#module-thecheckout-order .div_delivery_times {
    display: flex !important;
}
