.cf-tool.cf-tool{box-sizing:border-box;max-width:1152px;margin:0 auto;padding:28px 32px;border-radius:14px;background:#1C1B19;color:#F6F3EC;font-family:'Public Sans',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;font-size:17px;line-height:1.5;display:flex;flex-direction:column;gap:20px;text-align:left}
.cf-tool.cf-tool *{box-sizing:border-box}
.cf-tool.cf-tool h3{margin:0;padding:0;font-family:'Fraunces',Georgia,serif;font-size:30px;font-weight:600;line-height:1.15;color:#F6F3EC;letter-spacing:0;text-transform:none}
.cf-tool.cf-tool p{margin:0}
.cf-tool.cf-tool label{margin:0;font-weight:400;color:inherit}
.cf-tool .cf-head{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:8px}
.cf-tool .cf-sub,.cf-tool .cf-note{font-size:15px;color:#D9D3C7}
.cf-tool .cf-label{font-size:14px;color:#D9D3C7}
.cf-tool .cf-mono{font-family:'IBM Plex Mono',ui-monospace,Menlo,Consolas,monospace}
.cf-tool .cf-peach{color:#F2B880}
.cf-tool .cf-col{display:flex;flex-direction:column;gap:6px}
.cf-tool .cf-row{display:flex;flex-wrap:wrap;gap:8px}
.cf-tool.cf-tool button.cf-pill{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:48px;padding:0 12px;border-radius:8px;border:1.5px solid #F2B880;background:transparent;color:#F6F3EC;font-family:'IBM Plex Mono',ui-monospace,Menlo,Consolas,monospace;font-size:15px;font-weight:600;line-height:1;cursor:pointer}
.cf-tool.cf-tool button.cf-pill[aria-pressed="true"]{background:#F2B880;color:#1C1B19}
.cf-tool.cf-tool button.cf-pill:focus-visible{outline:2px solid #F6F3EC;outline-offset:2px}
.cf-tool.cf-tool input[type=range]{width:100%;min-height:44px;margin:0;padding:0;background:transparent;border:0;accent-color:#F2B880}
.cf-lens .cf-controls{display:flex;flex-wrap:wrap;gap:20px 28px;align-items:flex-end}
.cf-lens .cf-grow{flex:1 1 260px}
.cf-lens .cf-b17{font-size:17px}
.cf-lens .cf-stick{position:relative;height:92px;margin:4px 6px 0}
.cf-lens .cf-wood{position:absolute;left:0;right:0;top:48px;height:22px;border-radius:3px;background:#E3C48E;border:1px solid #A9824C}
.cf-lens .cf-ticks{position:absolute;left:0;right:0;top:48px;height:10px;background:repeating-linear-gradient(to right,#1C1B19 0 1px,transparent 1px 10%)}
.cf-lens .cf-mark{position:absolute;top:0;transform:translateX(-50%);display:flex;flex-direction:column;align-items:center;gap:2px}
.cf-lens .cf-tag{font-size:12px;line-height:1.4}
.cf-lens .cf-blue{color:#9FC6D3}
.cf-lens .cf-red{color:#FF8A6A}
.cf-lens .cf-bar{display:block;width:4px;height:26px;border-radius:2px}
.cf-lens .cf-bar-obj{background:#F2B880}
.cf-lens .cf-bar-lens{width:10px;border-radius:50%;background:#9FC6D3}
.cf-lens .cf-bar-img{background:#FF8A6A}
.cf-lens .cf-num{position:absolute;top:74px;font-family:'IBM Plex Mono',ui-monospace,Menlo,Consolas,monospace;font-size:12px;color:#D9D3C7}
.cf-lens .cf-result{font-size:19px;font-weight:600;color:#F2B880}
@media (max-width:600px){.cf-tool.cf-tool{padding:22px 18px}.cf-tool.cf-tool h3{font-size:26px}}
(function () {
var roots = document.querySelectorAll('.cf-lens:not([data-cf-ready])');
Array.prototype.forEach.call(roots, function (root) {
root.setAttribute('data-cf-ready', '1');
var q = function (k) { return root.querySelector('[data-cf="' + k + '"]'); };
var focalList = [50, 100, 150, 200];
var state = { f: 100, d: 300 };
var fButtons = focalList.map(function (v) {
var b = document.createElement('button');
b.type = 'button';
b.className = 'cf-pill';
b.textContent = v + ' mm';
b.addEventListener('click', function () { state.f = v; render(); });
q('focals').appendChild(b);
return b;
});
q('do').addEventListener('input', function (e) { state.d = Number(e.target.value); render(); });
function render() {
var f = state.f, d = state.d;
fButtons.forEach(function (b, i) { b.setAttribute('aria-pressed', focalList[i] === f ? 'true' : 'false'); });
q('doOut').textContent = d + ' mm';
q('obj').style.left = (50 - d / 10) + '%';
var img = q('img');
var line, note, show = false, pct = 50;
if (d === f) {
line = 'No image: the rays leave parallel';
note = 'The object sits exactly at the focal point.';
} else {
var di = 1 / (1 / f - 1 / d);
var M = -di / d;
line = 'dᵢ = ' + di.toFixed(0) + ' mm M = ' + (M > 0 ? '+' : '−') + Math.abs(M).toFixed(2);
pct = 50 + di / 10;
if (di > 0) {
show = pct = 0;
note = 'No picture on a screen: look through the lens. Upright, ' + M.toFixed(2) + '× the size.';
q('imgTag').textContent = 'virtual';
q('imgBar').style.opacity = 0.5;
}
}
img.style.display = show ? 'flex' : 'none';
img.style.left = pct + '%';
q('line').textContent = line;
q('note').textContent = note;
}
render();
});
})();