/* חוק הוגן · תפריט מובייל (2.0.85). Phones and tablets only (up to 860px); desktop keeps the mega menu.
   Uses the theme's own tokens and button tiers (.b .t1 .t2o .ib .sunk). */
.fm { display: none; }

@media (max-width: 860px) {
	html.fm-ready .main-nav { display: none !important; }
	html.fm-open { overflow: hidden; }
	html.fm-open .head-search-btn { visibility: hidden; }

	/* Phones: menu button on the right edge, logo on the left (2.0.67) */
	.site-head .wrap, .site-head .head-actions { flex-direction: row-reverse; }

	.menu-toggle svg path { transform-box: fill-box; transform-origin: center; transition: transform .15s ease-out, opacity .15s ease-out; }
	html.fm-open .menu-toggle svg path:nth-child(1) { transform: translateY(5px) rotate(45deg); }
	html.fm-open .menu-toggle svg path:nth-child(2) { opacity: 0; }
	html.fm-open .menu-toggle svg path:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

	.fm {
		--k: 1;
		display: flex; flex-direction: column;
		position: fixed; inset: 64px 0 0 0; z-index: 49;
		background: var(--paper); color: var(--ink);
		font-size: 17px; line-height: 1.3; outline: 0;
		visibility: hidden;
		clip-path: circle(0px at var(--fm-x, 38px) var(--fm-y, -32px));
		transition: clip-path .15s ease-out, visibility 0s linear .15s;
	}
	html.fm-open .fm { visibility: visible; clip-path: circle(150vmax at var(--fm-x, 38px) var(--fm-y, -32px)); transition-delay: 0s; }
	.fm.fm-big { --k: 1.14; }
	.fm a { color: var(--ink); text-decoration: none; }
	.fm button { font-family: inherit; }
	.fm p { margin: 0; }
	.fm :focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

	/* Search */
	.fm-search { position: relative; flex: 0 0 auto; margin: 0; padding: 10px 16px 8px; }
	.fm-search svg { position: absolute; inset-inline-start: 30px; top: 27px; color: var(--navy); pointer-events: none; }
	.fm-search input { display: block; width: 100%; box-sizing: border-box; min-height: 52px; margin: 0; padding: 0 16px; padding-inline-start: 46px; font-size: 17px; -webkit-appearance: none; appearance: none; }

	/* Sliding panes */
	.fm-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
	.fm-track { display: flex; height: 100%; transition: transform .38s var(--ease); }
	.fm-track.fm-drill { transform: translateX(100%); }
	.fm-pane, .fm-results { box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
	.fm-pane { flex: 0 0 100%; min-width: 0; }
	.fm-results { position: absolute; inset: 0; z-index: 2; background: var(--paper); }
	.fm-results[hidden] { display: none; }

	.fm-h { margin: 6px 2px 0 !important; font-size: calc(19px * var(--k)); font-weight: 500; }

	/* What happened? */
	.fm-sits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.fm .fm-sit { min-height: 60px; padding: 8px 12px; justify-content: flex-start; gap: 10px; text-align: start; font-weight: 400; }
	.fm-sit svg { flex: 0 0 auto; color: var(--navy); }
	.fm-sit span { display: flex; flex-direction: column; min-width: 0; }
	.fm-sit small { font-size: calc(14px * var(--k)); line-height: 1.25; color: var(--soft); }
	.fm-sit b { font-size: calc(17.5px * var(--k)); font-weight: 600; line-height: 1.25; }
	.fm .fm-sit[aria-pressed="true"], .fm .fm-tile[aria-pressed="true"] { background: var(--sand); box-shadow: inset 0 0 0 2px var(--navy), inset 0 3px 5px rgba(27, 36, 48, .18); }

	.fm-answer { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 18px; background: var(--navy); color: var(--on-dark); border-radius: var(--r-card); animation: fm-rise .28s var(--ease) both; }
	.fm-answer[hidden] { display: none; }
	.fm-answer small { font-size: calc(14px * var(--k)); color: var(--on-dark-2); }
	.fm-answer strong { font-size: calc(20px * var(--k)); font-weight: 500; line-height: 1.3; }
	.fm-answer div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; }
	.fm .fm-answer .t1 { min-height: 46px; padding: 0 20px; color: var(--ink); }
	.fm .fm-answer .fm-tool { display: inline-flex; align-items: center; min-height: 44px; font-size: calc(16px * var(--k)); color: var(--on-dark); text-decoration: underline; text-underline-offset: 4px; }

	/* Lists */
	.fm-card { display: flex; flex-direction: column; padding: 0 14px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); }
	.fm .fm-row { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; min-height: 60px; margin: 0; padding: 8px 0; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); text-align: start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
	.fm .fm-row:last-child { border-bottom: 0; }
	.fm .fm-row:active { background: var(--paper); }
	.fm .fm-guide { min-height: 54px; }
	.fm-t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
	.fm-row b { font-size: calc(18px * var(--k)); font-weight: 600; line-height: 1.3; }
	.fm-guide b { font-weight: 500; }
	.fm-row small { font-size: calc(14px * var(--k)); line-height: 1.3; color: var(--soft); }
	.fm-count { flex: 0 0 auto; min-width: 26px; height: 24px; box-sizing: border-box; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; background: #E6EAF1; color: var(--navy); border-radius: var(--r-tag); font-size: 14px; font-weight: 600; }
	.fm-chev { flex: 0 0 auto; display: flex; color: var(--navy); }
	.fm .fm-wide { min-height: 48px; width: 100%; box-sizing: border-box; font-size: calc(16px * var(--k)); }

	/* Topic screen */
	.fm .fm-back { align-self: flex-start; min-height: 44px; padding: 0 16px; padding-inline-start: 12px; gap: 6px; font-weight: 500; color: var(--navy); }
	.fm-sub-h { margin: 6px 2px 0 !important; font-size: calc(24px * var(--k)); font-weight: 500; line-height: 1.25; }
	.fm-sub-s { margin: -6px 2px 2px !important; font-size: calc(15px * var(--k)); color: var(--soft); }
	.fm .fm-nav { min-height: 50px; padding: 0 20px; font-size: calc(17px * var(--k)); color: var(--on-dark); background: linear-gradient(var(--navy2), var(--navy)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 0 1px var(--navy3), 0 1px 1px rgba(27, 36, 48, .2), 0 3px 6px -1px rgba(27, 36, 48, .25); }
	.fm .fm-nav:active { translate: 0 1px; scale: .985; background: var(--navy3); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35), 0 0 0 1px var(--navy3); }

	/* Search results */
	.fm-rcount { padding: 4px 2px 0; font-size: 14px; color: var(--soft); }
	.fm-empty { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); }
	.fm-empty b { font-size: calc(18px * var(--k)); font-weight: 500; }
	.fm-empty span { font-size: calc(16px * var(--k)); color: var(--soft); line-height: 1.5; }

	/* Bottom bar */
	.fm-bar { flex: 0 0 auto; display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--sand); border-top: 1px solid var(--line); }
	.fm .fm-tile { flex-direction: column; gap: 3px; min-height: 58px; padding: 4px 2px; font-size: 14px; font-weight: 500; line-height: 1.2; }
	.fm-tile svg { color: var(--navy); }
	.fm-aa { font-size: 19px; font-weight: 700; line-height: 1.15; color: var(--navy); }

	@keyframes fm-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
	.fm, .fm-track, .menu-toggle svg path { transition: none; }
	.fm-answer { animation: none; }
}

/* Compact main screen and button rule (2.0.68).
   Rule: one raised group per screen (the "what happened" tiles), secondary buttons flat with a press state,
   saffron depth only for the single main action. The main screen fits a phone screen without scrolling. */
@media (max-width: 860px) {
	.fm-body { container-type: size; }
	.fm-pane > * { flex-shrink: 0; }
	.fm-search { padding: 8px 16px 6px; }
	.fm-search svg { top: 22px; }
	.fm-search input { min-height: 48px; }
	.fm-main { gap: 6px; padding-bottom: 6px; }
	.fm-h { margin-top: 2px !important; font-size: calc(18px * var(--k)); }
	.fm-hrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 2px; }
	.fm-hrow .fm-h { margin: 0 2px !important; }
	.fm .fm-more { padding: 4px 2px; font-size: calc(15px * var(--k)); font-weight: 600; color: var(--navy); white-space: nowrap; text-decoration: underline; text-underline-offset: 4px; }
	.fm .fm-sit { min-height: 46px; padding: 4px 12px; }
	.fm-sit small { font-size: calc(13.5px * var(--k)); line-height: 1.2; }
	.fm-sit b { font-size: calc(17px * var(--k)); line-height: 1.2; }
	.fm-main .fm-row { min-height: 44px; padding: 4px 0; }
	.fm-main .fm-row small { display: none; }
	.fm-main .fm-row b { font-size: calc(17.5px * var(--k)); }

	/* Flat secondary buttons */
	.fm-bar { padding: 6px 16px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
	.fm .fm-tile, .fm .fm-tile:hover, .fm .fm-back, .fm .fm-back:hover { background: transparent; box-shadow: none; }
	.fm .fm-tile { min-height: 48px; gap: 2px; }
	.fm .fm-tile:active, .fm .fm-back:active { background: rgba(27, 36, 48, .08); box-shadow: none; }
	.fm .fm-back { padding: 0 10px; padding-inline-start: 4px; }

	@container (min-height: 610px) {
		.fm .fm-sit { min-height: 54px; padding: 6px 12px; }
		.fm-main .fm-row { min-height: 56px; padding: 6px 0; }
		.fm-main .fm-row small { display: block; }
	}
}

/* "Coming soon" topic row (2.0.69) */
@media (max-width: 860px) {
	.fm .fm-soon { cursor: default; }
	.fm .fm-soon:active { background: transparent; }
	.fm-soon b { color: var(--soft); }
	.fm-tag { flex: 0 0 auto; padding: 3px 8px; font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--note-ink); background: var(--note-bg); border: 1px solid var(--note-line); border-radius: var(--r-tag); }
}

/* "All guides" link under the topic list, tighter spacing (2.0.72) */
@media (max-width: 860px) {
	.fm-search { padding: 6px 16px 4px; }
	.fm-search svg { top: 20px; }
	.fm-main { gap: 4px; padding-top: 0; padding-bottom: 2px; }
	.fm-h { margin-top: 0 !important; }
	.fm-sits { margin-bottom: 2px; }
	.fm .fm-sit { min-height: 42px; padding: 3px 12px; }
	.fm .fm-more { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 2px; text-decoration: none; }
	.fm-more .fm-chev svg { width: 16px; height: 16px; }
}

/* "All guides" as the card's footer strip, like the desktop menu (2.0.74) */
@media (max-width: 860px) {
	.fm .fm-foot { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; margin: 0 -14px; background: var(--paper); border-radius: 0 0 7px 7px; color: var(--navy); font-size: calc(15.5px * var(--k)); font-weight: 600; -webkit-tap-highlight-color: transparent; }
	.fm .fm-foot:active { background: var(--sand); }
	.fm .fm-foot svg { transition: transform .15s ease-out; }
	.fm .fm-foot:active svg { transform: translateX(-3px); }
}

/* 2.0.79: quieter frames and clearer hierarchy.
   Only the search field keeps a frame; tiles and lists are plain white surfaces. Section headings are small labels.
   Topic rows show their description instead of a count. Text size key sits beside the search field; the bar holds destinations only. */
@media (max-width: 860px) {
	.fm .fm-sit { background: var(--white); box-shadow: none; }
	.fm .fm-sit:active { background: var(--sand); box-shadow: none; }
	.fm-sit small { font-size: calc(14px * var(--k)); }
	.fm-card, .fm-empty { border: 0; }
	html.tb-ready.fm-open .site-head .menu-toggle { background: transparent; border-color: transparent; box-shadow: none; }

	.fm-h { font-size: calc(15px * var(--k)); color: var(--soft); }

	.fm-main .fm-row { min-height: 46px; padding: 3px 0; }
	.fm-main .fm-row small { display: block; line-height: 1.2; }
	.fm-main .fm-row b { line-height: 1.25; }

	.fm .fm-all { width: 100%; box-sizing: border-box; min-height: 44px; margin-top: 2px; padding: 0 20px; font-size: calc(16.5px * var(--k)); }

	.fm-search { display: flex; align-items: center; gap: 6px; }
	.fm-search input { flex: 1 1 0; width: auto; min-width: 0; }
	.fm .fm-aab { flex: 0 0 48px; width: 48px; height: 48px; padding: 0; background: transparent; color: var(--navy); font-size: 18px; font-weight: 700; line-height: 1; }
	.fm .fm-aab:active { background: rgba(27, 36, 48, .08); }
	.fm .fm-aab[aria-pressed="true"] { background: var(--sand); box-shadow: inset 0 0 0 2px var(--navy); }

	@container (min-height: 610px) {
		.fm .fm-sit { min-height: 54px; padding: 6px 12px; }
		.fm-main .fm-row { min-height: 56px; padding: 6px 0; }
		.fm .fm-all { min-height: 48px; margin-top: 6px; }
	}
}

/* 2.0.80: second polish round.
   "All guides" is the saffron button again, with air above it (2.0.81). Spacing groups each label with its own block.
   The text size key reads as a button, tiles get a hairline shadow, the search hint is darker. */
@media (max-width: 860px) {
	.fm .fm-all { width: 100%; box-sizing: border-box; min-height: 44px; margin-top: 8px; padding: 0 20px; font-size: calc(16.5px * var(--k)); }
	.fm .fm-all svg { transition: transform .15s ease-out; }
	.fm .fm-all:active svg { transform: translateX(-3px); }

	.fm-main { gap: 0; }
	.fm-h { margin: 10px 2px 5px !important; }
	.fm-main > .fm-h:first-child { margin-top: 4px !important; }
	.fm-sits { margin-bottom: 0; }
	.fm-answer { margin-top: 8px; }
	.fm-main .fm-t { gap: 2px; }

	.fm .fm-aab { flex-basis: 44px; width: 44px; height: 44px; border-radius: 50%; background: var(--sand); }
	.fm .fm-aab:active { background: #DDD8CC; }

	.fm .fm-sit { box-shadow: 0 1px 0 rgba(27, 36, 48, .1), 0 1px 2px rgba(27, 36, 48, .05); }
	.fm .fm-sit:active { box-shadow: none; }
	.fm-card { box-shadow: 0 1px 0 rgba(27, 36, 48, .08); }

	.fm-search input::placeholder { color: var(--soft); opacity: 1; }

	@container (min-height: 610px) {
		.fm .fm-all { min-height: 48px; margin-top: 10px; }
		.fm-h { margin-top: 16px !important; }
	}
}

/* 2.0.82: the main screen fits a phone screen again with the saffron button (about 20px tighter), and the button keeps air below it. */
@media (max-width: 860px) {
	.fm-main { padding-bottom: 6px; }
	.fm-main > .fm-h:first-child { margin-top: 2px !important; }
	.fm-sits { gap: 6px; }
	.fm-main .fm-row { min-height: 44px; padding: 2px 0; }
	.fm .fm-all { min-height: 42px; margin-top: 10px; }

	@container (min-height: 610px) {
		.fm-sits { gap: 8px; }
		.fm-main .fm-row { min-height: 56px; padding: 6px 0; }
		.fm .fm-all { min-height: 48px; margin-top: 10px; }
	}
}

/* 2.0.84: topic and calculators screens follow the main screen.
   The closing button is the same saffron button with an arrow (was navy), and the back key sits closer to the title. */
@media (max-width: 860px) {
	.fm-sub { gap: 8px; padding-top: 0; }
	.fm .fm-back { min-height: 40px; margin-bottom: -7px; }
	.fm-sub-h { margin-top: 0 !important; }
	.fm-sub-s { margin-top: -4px !important; }
	.fm-sub .fm-guide { min-height: 52px; }
	.fm-sub .fm-all { min-height: 46px; margin-top: 2px; }
}
