/* מחשבון מידות — חזית */
:root { --fsf-accent: #111; }

.fsf-launcher { margin: 0 0 14px; }

/* הכפתור נמצא בעמוד עצמו, לכן !important — כדי שעיצוב הכפתורים של התבנית לא ידרוס אותו. */
.fsf-launcher .fsf-open {
	display: inline-flex !important; align-items: center !important; gap: 8px !important; flex-wrap: wrap;
	width: auto !important; height: auto !important; min-height: 0 !important; margin: 0 !important;
	background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
	padding: 6px 0 !important; cursor: pointer; outline-offset: 4px;
	font-family: inherit !important; font-size: 15px !important; font-weight: 500 !important; line-height: 1.4 !important;
	letter-spacing: normal !important; text-transform: none !important; color: var(--fsf-accent) !important;
	text-decoration: underline !important; text-underline-offset: 4px; text-decoration-thickness: 1px;
	transition: none !important;
}
.fsf-launcher .fsf-open:hover, .fsf-launcher .fsf-open:focus-visible { text-decoration-thickness: 2px; background: transparent !important; color: var(--fsf-accent) !important; }
.fsf-launcher .fsf-open span { color: inherit !important; }
.fsf-open svg { flex: none; }
.fsf-launcher .fsf-open-size {
	font-style: normal; font-weight: 700; font-size: 13px; text-decoration: none;
	background: var(--fsf-accent); color: #fff; padding: 2px 10px; border-radius: 99px;
}

html.fsf-lock, html.fsf-lock body { overflow: hidden; }

.fsf-modal {
	--fsf-ink: #16181d; --fsf-muted: #6b7280; --fsf-line: #e7e7ea; --fsf-soft: #f6f6f7;
	--fsf-ok: #15803d; --fsf-warn: #b45309; --fsf-roomy: #1d4ed8;
	position: fixed; inset: 0; z-index: 999999;
	display: flex; align-items: center; justify-content: center;
	font-family: inherit; color: var(--fsf-ink); direction: rtl; text-align: right;
	font-size: 16px; font-weight: 400; line-height: 1.5; letter-spacing: normal; word-spacing: normal; text-transform: none;
}
.fsf-modal[hidden], .fsf-modal [hidden] { display: none !important; }
.fsf-modal *, .fsf-modal *::before, .fsf-modal *::after { box-sizing: border-box; }
/* איפוס בסיסי בעדיפות נמוכה (:where) — הכללים הספציפיים למטה גוברים עליו. */
:where(.fsf-modal) :where(button, input) { font: inherit; color: inherit; margin: 0; letter-spacing: inherit; text-transform: none; }
:where(.fsf-modal) :where(h2, p, ul, li, fieldset, legend, table) { margin: 0; letter-spacing: inherit; }

.fsf-backdrop {
	position: absolute; inset: 0; background: rgba(15, 17, 21, .55);
	backdrop-filter: blur(3px); opacity: 0; transition: opacity .22s ease;
}
.fsf-dialog {
	position: relative; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
	display: flex; flex-direction: column; overflow: hidden;
	background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.25);
	transform: translateY(16px) scale(.98); opacity: 0;
	transition: transform .26s cubic-bezier(.2,.8,.2,1), opacity .22s ease;
}
.fsf-modal.is-open .fsf-backdrop { opacity: 1; }
.fsf-modal.is-open .fsf-dialog { transform: none; opacity: 1; }

.fsf-x {
	position: absolute; top: 12px; left: 12px; width: 36px; height: 36px; border-radius: 50%;
	border: 0; background: var(--fsf-soft); color: var(--fsf-ink); font-size: 22px; line-height: 1;
	cursor: pointer; display: grid; place-items: center; padding: 0;
}
.fsf-x:hover { background: var(--fsf-line); }

.fsf-head { padding: 24px 24px 0; }
.fsf-head h2 { margin: 0 0 2px; font-size: 22px; line-height: 1.25; color: var(--fsf-ink); }
.fsf-head p { margin: 0; color: var(--fsf-muted); font-size: 14px; }

.fsf-tabs { display: flex; gap: 4px; margin-top: 16px; border-bottom: 1px solid var(--fsf-line); }
.fsf-tabs button {
	background: none; border: 0; padding: 10px 14px; margin-bottom: -1px; cursor: pointer;
	font: inherit; font-size: 15px; color: var(--fsf-muted); border-bottom: 2px solid transparent;
}
.fsf-tabs button.is-active { color: var(--fsf-ink); font-weight: 700; border-bottom-color: var(--fsf-accent); }

.fsf-body { padding: 20px 24px 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.fsf-pane[hidden] { display: none; }
.fsf-lead { margin: 0 0 16px; font-size: 14px; color: var(--fsf-muted); line-height: 1.6; }
.fsf-lead b { color: var(--fsf-ink); }

/* שדות */
.fsf-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fsf-field { animation: fsf-up .35s both; animation-delay: calc(var(--i) * 40ms); }
.fsf-field label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.fsf-info {
	width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--fsf-line); background: #fff;
	font-size: 12px; line-height: 1; color: var(--fsf-muted); cursor: pointer; padding: 0;
}
.fsf-info[aria-expanded="true"] { background: var(--fsf-accent); color: #fff; border-color: var(--fsf-accent); }
.fsf-input { position: relative; }
.fsf-input input {
	width: 100%; height: 48px; padding: 0 14px 0 52px; margin: 0;
	border: 1.5px solid var(--fsf-line); border-radius: 12px; background: #fff;
	font: inherit; font-size: 18px; font-weight: 600; color: var(--fsf-ink); direction: ltr; text-align: right;
	-moz-appearance: textfield; transition: border-color .15s, box-shadow .15s;
}
.fsf-input input::-webkit-outer-spin-button, .fsf-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fsf-input input:focus { outline: none; border-color: var(--fsf-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fsf-accent) 18%, transparent); }
.fsf-input input.is-bad { border-color: #dc2626; }
.fsf-input span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--fsf-muted); font-size: 13px; pointer-events: none; }
.fsf-hint { margin: 8px 0 0; padding: 10px 12px; background: var(--fsf-soft); border-radius: 10px; font-size: 13px; line-height: 1.55; color: var(--fsf-ink); }

/* העדפת גזרה */
.fsf-fits { border: 0; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fsf-fits legend { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.fsf-fit { position: relative; cursor: pointer; margin: 0; }
.fsf-fit input { position: absolute; opacity: 0; pointer-events: none; }
.fsf-fit span {
	display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px;
	border: 1.5px solid var(--fsf-line); border-radius: 12px; text-align: center; transition: all .15s;
}
.fsf-fit b { font-size: 15px; }
.fsf-fit small { font-size: 12px; color: var(--fsf-muted); }
.fsf-fit input:checked + span { border-color: var(--fsf-accent); background: color-mix(in srgb, var(--fsf-accent) 7%, #fff); }
.fsf-fit input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fsf-accent) 25%, transparent); }

.fsf-error { color: #dc2626; font-size: 14px; margin: 14px 0 0; }

.fsf-submit {
	display: block; width: 100%; margin-top: 20px; height: 52px; border: 0; border-radius: 14px;
	background: var(--fsf-accent); color: #fff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
	transition: transform .1s, filter .15s;
}
.fsf-submit:hover { filter: brightness(1.12); }
.fsf-submit:active { transform: scale(.985); }

/* תוצאה */
.fsf-result.is-in { animation: fsf-up .35s both; }
.fsf-badge {
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	width: 140px; height: 140px; margin: 4px auto 12px; border-radius: 50%;
	background: var(--fsf-accent); color: #fff; box-shadow: 0 14px 34px color-mix(in srgb, var(--fsf-accent) 35%, transparent);
	animation: fsf-pop .5s cubic-bezier(.2,1.4,.4,1) both .05s;
}
.fsf-badge-k { font-size: 13px; opacity: .8; }
.fsf-badge-v { font-size: 44px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; direction: ltr; }
.fsf-alt { text-align: center; margin: 0 0 14px; font-size: 14px; color: var(--fsf-muted); }
.fsf-alt b { color: var(--fsf-ink); }

.fsf-details { list-style: none; margin: 0; padding: 0; border: 1px solid var(--fsf-line); border-radius: 14px; overflow: hidden; }
.fsf-details li {
	display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "name val tag" "meta meta meta";
	gap: 2px 10px; align-items: center; padding: 10px 14px; margin: 0;
}
.fsf-details li + li { border-top: 1px solid var(--fsf-line); }
.fsf-d-name { grid-area: name; font-weight: 600; font-size: 14px; }
.fsf-d-val { grid-area: val; font-size: 14px; direction: rtl; }
.fsf-d-meta { grid-area: meta; font-size: 12px; color: var(--fsf-muted); }
.fsf-d-tag { grid-area: tag; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: #dcfce7; color: var(--fsf-ok); }
.fsf-details .is-tight .fsf-d-tag { background: #fef3c7; color: var(--fsf-warn); }
.fsf-details .is-roomy .fsf-d-tag { background: #dbeafe; color: var(--fsf-roomy); }

.fsf-notes { margin-top: 14px; padding: 12px 14px; background: var(--fsf-soft); border-radius: 12px; font-size: 13px; line-height: 1.6; }
.fsf-notes p { margin: 0; }
.fsf-notes p + p { margin-top: 6px; }

.fsf-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.fsf-result-actions .fsf-submit { flex: 1 0 100%; }
.fsf-link { background: none; border: 0; padding: 12px 4px 0; font: inherit; font-size: 14px; color: var(--fsf-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* טבלה */
.fsf-table-scroll { overflow: auto; max-height: 56vh; border: 1px solid var(--fsf-line); border-radius: 12px; }
.fsf-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.fsf-table th, .fsf-table td { padding: 10px 8px; text-align: center; border: 0; border-bottom: 1px solid var(--fsf-line); white-space: nowrap; }
.fsf-table thead th { position: sticky; top: 0; background: var(--fsf-ink); color: #fff; font-weight: 600; font-size: 13px; z-index: 1; }
.fsf-table thead th small { display: block; font-weight: 400; opacity: .7; font-size: 11px; }
.fsf-table tbody th { font-weight: 700; background: var(--fsf-soft); position: sticky; right: 0; }
.fsf-table tbody tr:last-child > * { border-bottom: 0; }
.fsf-table tr.is-pick > * { background: color-mix(in srgb, var(--fsf-accent) 12%, #fff); font-weight: 700; }
.fsf-table tr.is-pick th::after { content: " ✓"; }
.fsf-empty { color: var(--fsf-muted); }

/* הדגשת כפתור הוספה לסל אחרי בחירת מידה */
.single_add_to_cart_button.fsf-pulse { animation: fsf-pulse 1.6s ease-out; }

@keyframes fsf-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fsf-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes fsf-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fsf-accent) 55%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }

/* מובייל: חלון שעולה מלמטה */
@media (max-width: 600px) {
	.fsf-modal { align-items: flex-end; }
	.fsf-dialog { width: 100vw; max-height: 92vh; border-radius: 20px 20px 0 0; transform: translateY(100%); }
	.fsf-head { padding: 20px 16px 0; }
	.fsf-body { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
	.fsf-fields { grid-template-columns: 1fr; gap: 12px; }
	.fsf-badge { width: 120px; height: 120px; }
	.fsf-badge-v { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
	.fsf-modal *, .fsf-modal *::before, .fsf-modal *::after { animation: none !important; transition: none !important; }
}
