/* ============================================================
   zb-tools.css — Tool widget + tool page styles
   ============================================================ */

/* --- Tool page layout --- */
.zb-tool-page { padding-block: 1.5rem clamp(2rem, 4vw, 3rem); }
.zb-tool-page__head { margin-bottom: 1.5rem; }
.zb-tool-page__title { margin-bottom: 0.3em; }
.zb-tool-page__formula { font-family: var(--zb-font-mono, monospace); font-size: 1.05rem; color: var(--c-text-muted); margin: 0 0 0.6em; padding: 0.4em 0.8em; background: var(--c-bg-subtle); border-radius: 6px; display: inline-block; }
.zb-tool-page__hero { margin-bottom: 1.5rem; border-radius: 12px; overflow: hidden; }
.zb-tool-page__hero-img { width: 100%; height: auto; }

.zb-tool-page__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2rem;
    margin-top: 2rem;
}
@media (max-width: 900px) { .zb-tool-page__layout { grid-template-columns: 1fr; } }

.zb-tool-page__content { font-size: 1.05rem; line-height: 1.7; }
.zb-content-section { margin-bottom: 2.5rem; }
.zb-content-section h2 { padding-bottom: 0.3em; border-bottom: 1px solid var(--c-border); margin-top: 0; }

/* --- Sidebar widget defaults --- */
.zb-sidebar { font-size: 0.9rem; }
.zb-widget { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.25rem; }
.zb-widget__title { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-text-muted); margin: 0 0 0.6em; }
.zb-related-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4em; }
.zb-related-list__item a { display: block; padding: 0.45em 0; border-bottom: 1px solid var(--c-border); color: var(--c-text); font-size: 0.9rem; }
.zb-related-list__item:last-child a { border-bottom: 0; }
.zb-related-list__item a:hover { color: var(--c-primary); text-decoration: none; }

/* --- Tool widget (universal converter) --- */
.zb-tool-widget {
    background: linear-gradient(135deg, var(--c-bg-subtle) 0%, var(--c-surface) 100%);
    border: 1px solid var(--c-border);
    border-radius: 16px;
    padding: clamp(1.2rem, 3vw, 2rem);
    margin-bottom: 2rem;
}
.zb-tool-widget__container { min-height: 80px; }

/* The universal converter builds its UI inside .zb-converter below */
.zb-converter { display: grid; gap: 1rem; }
.zb-converter--bidirectional {
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 1rem;
}
@media (max-width: 600px) {
    .zb-converter--bidirectional { grid-template-columns: 1fr; }
    .zb-converter__swap { justify-self: center; }
}
.zb-converter__field { display: flex; flex-direction: column; gap: 0.4em; }
.zb-converter__label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); }
.zb-converter__input-group { display: flex; min-width: 0; }
.zb-converter__input {
    flex: 1;
    padding: 0.75em 0.95em;
    border: 1px solid var(--c-border);
    border-radius: 8px 0 0 8px;
    background: var(--c-surface);
    font-size: 1.1rem;
    font-family: var(--zb-font-mono, monospace);
    color: var(--c-text);
    border-right: 0;
    min-width: 0;
}
.zb-converter__input:focus { outline: none; border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary); }
.zb-converter__select {
    padding: 0.75em 0.85em;
    border: 1px solid var(--c-border);
    border-radius: 0 8px 8px 0;
    background: var(--c-bg-subtle);
    color: var(--c-text);
    font-size: 0.95rem;
    border-left: 0;
    cursor: pointer;
    min-width: 90px;
}
.zb-converter__select:focus { outline: none; border-color: var(--c-primary); }
.zb-converter__swap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: end;
    margin-bottom: 0.1em;
}
.zb-converter__swap:hover { background: var(--c-primary); color: #fff; border-color: var(--c-primary); transform: rotate(180deg); }
.zb-converter__result { font-size: 1.5rem; font-family: var(--zb-font-mono, monospace); color: var(--c-primary); font-weight: 600; padding: 0.4em 0; }
.zb-converter__result-unit { font-size: 0.95rem; color: var(--c-text-muted); margin-left: 0.3em; font-weight: 400; }

.zb-converter--multi .zb-converter__results-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.zb-converter--multi .zb-converter__results-table th { text-align: left; padding: 0.5em 0.6em; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); background: var(--c-bg-subtle); }
.zb-converter--multi .zb-converter__results-table td { padding: 0.6em; font-family: var(--zb-font-mono, monospace); border-top: 1px solid var(--c-border); min-width: 0; overflow-wrap: break-word; }
.zb-converter--multi .zb-converter__results-table tr:hover td { background: var(--c-bg-subtle); }

/* Native <select> elements ignore flex-shrink and refuse to compress
   below the width their widest <option> text needs, regardless of
   min-width - at 390px viewport this pushed the select (and anything
   after it) far past the screen edge (measured right: 449px against
   innerWidth: 390px). Stacking the input and select vertically below
   ~480px sidesteps the native-control sizing quirk entirely instead
   of fighting it. */
@media (max-width: 480px) {
    .zb-converter__input-group { flex-direction: column; }
    .zb-converter__input { border-radius: 8px 8px 0 0; border-right: 1px solid var(--c-border); border-bottom: 0; }
    .zb-converter__select { border-radius: 0 0 8px 8px; border-left: 1px solid var(--c-border); border-top: 0; width: 100%; }
}

/* --- Health/BMI result cards (used by zb-health.js) --- */
.zb-result-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px; padding: 1.2rem; margin-top: 1rem; }
.zb-result-card__label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-text-muted); }
.zb-result-card__value { font-size: 2rem; font-weight: 700; color: var(--c-primary); font-family: var(--zb-font-mono, monospace); margin: 0.2em 0; }
.zb-result-card__category { display: inline-block; padding: 0.3em 0.8em; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.zb-result-card__category--underweight { background: #fef3c7; color: #92400e; }
.zb-result-card__category--normal       { background: #d1fae5; color: #065f46; }
.zb-result-card__category--overweight  { background: #fed7aa; color: #9a3412; }
.zb-result-card__category--obese        { background: #fecaca; color: #991b1b; }

/* --- Percentage calculator --- */
.zb-percentage-grid { display: grid; gap: 1rem; }
.zb-percentage-grid .zb-converter__field { padding: 1rem; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px; }

/* --- Cooking converter (ingredient picker) --- */
.zb-converter__ingredient-select { display: block; margin: 0.5rem 0; padding: 0.6em 0.85em; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); font-size: 0.95rem; width: 100%; }

/* --- Fraction to decimal --- */
.zb-fraction-input { display: flex; gap: 0.4em; align-items: center; }
.zb-fraction-input input { width: 70px; padding: 0.6em 0.85em; border: 1px solid var(--c-border); border-radius: 8px; text-align: center; font-family: var(--zb-font-mono, monospace); font-size: 1.05rem; }
.zb-fraction-input span { font-size: 1.4rem; color: var(--c-text-muted); }

/* --- Noscript fallback --- */
.zb-noscript { background: #fef3c7; color: #92400e; padding: 0.85em 1em; border-radius: 8px; border: 1px solid #fcd34d; }

/* --- Tool CTA shortcode --- */
.zb-tool-cta { margin: 1.5em 0; }
