/* Shared input fields for the health tools: the TDEE / BAC "pill" number input + matching range slider.
   Markup (see tdee-calculator.blade.php):
     <div class="flex justify-between items-center mb-1">
         <label for="x" class="...">Age</label>
         <div class="ht-pill max-w-[85px]"><input type="number" id="x" class="ht-pill-input" value="30"><span class="ht-pill-unit">yrs</span></div>
     </div>
     <input type="range" class="ht-range" data-ht-sync="#x" min="15" max="80" value="30" aria-label="Age slider">
   public/js/tools/shared/health-fields.js keeps the slider and the number box in sync (and fires "input" so live calculators update). */
.ht-pill {
    display: inline-flex; align-items: center; height: 32px; padding: .15rem .5rem; border-radius: .75rem;
    background: rgba(244, 244, 245, .9); border: 1.5px solid #d4d4d8; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .03);
    overflow: hidden; transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.dark .ht-pill { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .14); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2); }
.ht-pill:hover { border-color: #a1a1aa; }
.ht-pill:focus-within { background: #fff; border-color: #f43f5e; box-shadow: 0 0 0 3px rgba(244, 63, 94, .2); }
.dark .ht-pill:focus-within { background: rgba(24, 24, 27, .95); box-shadow: 0 0 0 3px rgba(244, 63, 94, .25); }
.ht-pill[hidden], .ht-pill.hidden { display: none !important; }
/* neutralise the global mobile input rules (44px min-height, padding, white box) inside the pill */
.ht-pill .ht-pill-input {
    width: 100%; min-width: 0; min-height: 0 !important; height: 100% !important; padding: 0 !important; margin: 0;
    background: transparent !important; border: 0 !important; box-shadow: none !important; outline: none !important;
    font-size: .875rem !important; font-weight: 700; line-height: 1.2 !important; text-align: right;
    color: #18181b; font-variant-numeric: tabular-nums; font-family: inherit; -moz-appearance: textfield; appearance: textfield;
}
.dark .ht-pill .ht-pill-input { color: #f4f4f5; }
.ht-pill .ht-pill-input::-webkit-inner-spin-button, .ht-pill .ht-pill-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ht-pill-unit { margin-left: .25rem; font-size: 11px; font-weight: 700; color: #a1a1aa; user-select: none; white-space: nowrap; }
@media (pointer: coarse), (max-width: 640px) { .ht-pill .ht-pill-input { font-size: 16px !important; } .ht-pill { height: 36px; } }

.ht-range {
    -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 5px; margin: .65rem 0 .2rem;
    border-radius: 9999px; outline: none; cursor: pointer; background: rgba(0, 0, 0, .08); transition: background .2s;
}
.dark .ht-range { background: rgba(255, 255, 255, .1); }
.ht-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #f43f5e; border: 2.5px solid #fff; box-shadow: 0 1.5px 4px rgba(0, 0, 0, .25); cursor: grab;
    transition: transform .15s cubic-bezier(.34, 1.56, .64, 1), background-color .15s, box-shadow .15s;
}
.ht-range::-webkit-slider-thumb:hover { transform: scale(1.2); background: #e11d48; box-shadow: 0 0 0 4px rgba(244, 63, 94, .25), 0 2px 5px rgba(0, 0, 0, .3); }
.ht-range::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }
.ht-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #f43f5e; border: 2.5px solid #fff; box-shadow: 0 1.5px 4px rgba(0, 0, 0, .25); cursor: grab; }
.ht-range:focus-visible { outline: 2px solid #f43f5e; outline-offset: 4px; }
.ht-range-scale { display: flex; justify-content: space-between; margin-top: .35rem; margin-bottom: .15rem; font-size: 10px; font-weight: 500; color: #a1a1aa; }

/* The global input[type=range] rules in app.css colour the thumb with currentColor; win with higher specificity so the thumb stays rose. */
input[type="range"].ht-range { color: #f43f5e; }
input[type="range"].ht-range::-webkit-slider-thumb { background: #f43f5e; border: 2.5px solid #fff; }
input[type="range"].ht-range::-webkit-slider-thumb:hover { background: #e11d48; }
input[type="range"].ht-range::-moz-range-thumb { background: #f43f5e; border: 2.5px solid #fff; }

/* Accessible Field Tooltips */
.ht-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.ht-tooltip-wrap:hover,
.ht-tooltip-wrap:focus-within,
.ht-tooltip-wrap.ht-open {
    z-index: 100;
}
.ht-tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 9999px;
    font-size: 11px;
    line-height: 1;
    transition: color 0.15s ease, transform 0.15s ease;
}
.ht-tooltip-btn:hover,
.ht-tooltip-btn:focus-visible {
    color: #f43f5e;
    outline: none;
    transform: scale(1.15);
}
.dark .ht-tooltip-btn {
    color: #71717a;
}
.dark .ht-tooltip-btn:hover,
.dark .ht-tooltip-btn:focus-visible {
    color: #fb7185;
}
.ht-tooltip-box {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 260px;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    line-height: 1.4;
    font-weight: 400;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    color: #ffffff;
    background: rgba(24, 24, 27, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 60;
}
.ht-tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--ht-arrow-x, 50%);
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(24, 24, 27, 0.96) transparent transparent transparent;
}
.ht-tooltip-box.ht-placement-bottom {
    bottom: auto;
    top: calc(100% + 8px);
}
.ht-tooltip-box.ht-placement-bottom::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent rgba(24, 24, 27, 0.96) transparent;
}
.ht-tooltip-wrap:hover .ht-tooltip-box,
.ht-tooltip-wrap:focus-within .ht-tooltip-box,
.ht-tooltip-wrap.ht-open .ht-tooltip-box {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.ht-tooltip-box.align-left {
    left: 0;
    transform: translateX(0) translateY(4px);
}
.ht-tooltip-box.align-left::after {
    left: var(--ht-arrow-x, 12px);
    transform: none;
}
.ht-tooltip-wrap:hover .ht-tooltip-box.align-left,
.ht-tooltip-wrap:focus-within .ht-tooltip-box.align-left,
.ht-tooltip-wrap.ht-open .ht-tooltip-box.align-left {
    transform: translateX(0) translateY(0);
}
.ht-tooltip-box.align-right {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(4px);
}
.ht-tooltip-box.align-right::after {
    left: auto;
    right: var(--ht-arrow-x, 12px);
    transform: none;
}
.ht-tooltip-wrap:hover .ht-tooltip-box.align-right,
.ht-tooltip-wrap:focus-within .ht-tooltip-box.align-right,
.ht-tooltip-wrap.ht-open .ht-tooltip-box.align-right {
    transform: translateX(0) translateY(0);
}
@media (max-width: 640px) {
    .ht-tooltip-box,
    .ht-tooltip-box.align-left,
    .ht-tooltip-box.align-right {
        max-width: min(260px, calc(100vw - 28px));
        font-size: 0.68rem;
        padding: 0.45rem 0.65rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(4px);
    }
    .ht-tooltip-wrap:hover .ht-tooltip-box,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box,
    .ht-tooltip-wrap:hover .ht-tooltip-box.align-left,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box.align-left,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box.align-left,
    .ht-tooltip-wrap:hover .ht-tooltip-box.align-right,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box.align-right,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box.align-right {
        transform: translateX(-50%) translateY(0);
    }
    .ht-tooltip-box::after,
    .ht-tooltip-box.align-left::after,
    .ht-tooltip-box.align-right::after {
        left: var(--ht-arrow-x, 50%);
        right: auto;
        transform: translateX(-50%);
    }
}
