/* Shoe Finder — scoped, mobile-first, RTL-ready.
   Everything is namespaced under #sf-root to avoid theme collisions. */

#sf-root {
	--sf-accent: #c9a227;
	--sf-ink: #1c1c1c;
	--sf-muted: #6b6b6b;
	--sf-line: #e7e7e7;
	--sf-bg: #ffffff;
	--sf-soft: #f6f5f2;
	--sf-radius: 16px;
	--sf-shadow: 0 20px 60px rgba(0, 0, 0, .22);
	font-family: inherit;
	box-sizing: border-box;
}
#sf-root *,
#sf-root *::before,
#sf-root *::after { box-sizing: border-box; }

/* ---------- Floating action button ---------- */
.sf-fab {
	position: fixed;
	inset-block-end: 18px;
	inset-inline-end: 18px;
	z-index: 99990;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border: 0;
	border-radius: 0;
	background: var(--sf-ink);
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
	transition: transform .18s ease, box-shadow .18s ease;
}
.sf-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0, 0, 0, .34); }
.sf-fab__icon { font-size: 20px; line-height: 1; }
.sf-fab__text { white-space: nowrap; }
.sf-fab::after {
	content: "";
	position: absolute;
	inset-block-start: 6px;
	inset-inline-end: 6px;
	width: 9px; height: 9px;
	border-radius: 50%;
	background: var(--sf-accent);
	box-shadow: 0 0 0 0 rgba(201, 162, 39, .6);
	animation: sf-pulse 2.2s infinite;
}
@keyframes sf-pulse {
	0% { box-shadow: 0 0 0 0 rgba(201, 162, 39, .55); }
	70% { box-shadow: 0 0 0 12px rgba(201, 162, 39, 0); }
	100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0); }
}

/* ---------- Overlay + modal ---------- */
#sf-root { display: none; }
#sf-root.sf-has-fab { display: block; }     /* fab always visible when present */
#sf-root.sf-open { display: block; }

.sf-overlay {
	position: fixed;
	inset: 0;
	z-index: 99991;
	background: rgba(20, 18, 16, .55);
	backdrop-filter: blur(3px);
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s ease;
}
#sf-root.sf-open .sf-overlay { opacity: 1; pointer-events: auto; }

.sf-modal {
	position: fixed;
	z-index: 99992;
	inset-inline: 0;
	inset-block-end: 0;
	margin-inline: auto;
	width: 100%;
	max-width: 720px;
	max-height: 92vh;
	background: var(--sf-bg);
	border-start-start-radius: var(--sf-radius);
	border-start-end-radius: var(--sf-radius);
	box-shadow: var(--sf-shadow);
	transform: translateY(100%);
	transition: transform .32s cubic-bezier(.2, .8, .2, 1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
#sf-root.sf-open .sf-modal { transform: translateY(0); }

.sf-close {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	z-index: 3;
	/* Force an equal square that fits the X snugly; !important beats the
	   theme's global button min-width/padding that was stretching it. */
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 34px !important;
	height: 34px !important;
	min-width: 34px !important;
	max-width: 34px !important;
	min-height: 34px !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0;
	border-radius: 50% !important; /* circular background around the X */
	background: rgba(0, 0, 0, .06);
	color: var(--sf-ink);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}
.sf-close:hover { background: rgba(0, 0, 0, .12); }

.sf-modal__inner {
	flex: 1 1 auto;
	min-height: 0; /* allow the flex child to actually scroll */
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 26px 20px 18px;
}

/* Footer pinned to the bottom of the modal, outside the scroll area. */
.sf-modal__foot {
	flex: 0 0 auto;
	padding: 12px 20px;
	background: var(--sf-bg);
	border-top: 1px solid var(--sf-line);
}
.sf-modal__foot:empty { display: none; }

/* ---------- Intro / launch ---------- */
.sf-intro { text-align: center; padding: 14px 6px 8px; }
.sf-intro__emoji { font-size: 42px; }
.sf-intro__title {
	margin: 12px 0 6px;
	font-size: 22px;
	font-weight: 800;
	color: var(--sf-ink);
	line-height: 1.3;
}
.sf-intro__title small { display: block; font-size: 13px; font-weight: 600; color: var(--sf-muted); margin-top: 4px; }
.sf-intro__sub { margin: 0 auto 20px; max-width: 460px; font-size: 15px; color: var(--sf-muted); line-height: 1.6; }
.sf-intro__sub small { display: block; font-size: 12.5px; opacity: .8; margin-top: 4px; }

/* ---------- Header / progress ---------- */
.sf-head { margin-top: 6px; margin-bottom: 18px; }
/* Reserve room on the close-button side so the step counter never sits under the X. */
.sf-head__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-inline-end: 46px; }
.sf-head__title { font-size: 19px; font-weight: 800; color: var(--sf-ink); margin: 0; }
.sf-head__title small { font-weight: 600; font-size: 12.5px; color: var(--sf-muted); margin-inline-start: 6px; }
.sf-head__count { font-size: 12.5px; color: var(--sf-muted); white-space: nowrap; }
.sf-head__hint { margin: 4px 0 0; font-size: 13.5px; color: var(--sf-muted); }
.sf-progress { margin-top: 12px; height: 6px; border-radius: 99px; background: var(--sf-soft); overflow: hidden; }
.sf-progress__bar { height: 100%; width: 0; border-radius: 99px; background: var(--sf-accent); transition: width .3s ease; }

/* ---------- Option grids ---------- */
.sf-grid { display: grid; gap: 10px; }
.sf-grid--sizes { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.sf-grid--types { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sf-grid--colors { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.sf-grid--uses { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.sf-opt {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 14px 10px;
	border: 1.5px solid var(--sf-line);
	border-radius: 2px; /* match the squared size-swatch on the single product page */
	background: #fff;
	color: var(--sf-ink);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.sf-opt:hover { border-color: #c9c9c9; transform: translateY(-1px); }
.sf-opt.is-active {
	border-color: var(--sf-accent);
	background: color-mix(in srgb, var(--sf-accent) 12%, #fff);
	box-shadow: inset 0 0 0 1px var(--sf-accent);
}
.sf-opt.is-active::after {
	content: "✓";
	position: absolute;
	inset-block-start: 6px;
	inset-inline-end: 8px;
	font-size: 12px;
	color: var(--sf-accent);
	font-weight: 800;
}
.sf-opt__size { font-size: 18px; font-weight: 800; }
.sf-opt__icon { font-size: 24px; }
.sf-opt__en { font-size: 14px; font-weight: 700; }
.sf-opt__ar { font-size: 12px; font-weight: 600; color: var(--sf-muted); }
.sf-opt.is-active .sf-opt__ar { color: inherit; }
.sf-opt__count { font-size: 11px; color: var(--sf-muted); font-weight: 500; }

/* Keep option text readable on hover/active — defeats the theme's
   global button:hover { color:#fff } that was washing the labels out. */
.sf-opt,
.sf-opt:hover,
.sf-opt:focus,
.sf-opt:active,
.sf-opt.is-active,
.sf-opt.is-active:hover { color: var(--sf-ink) !important; }
.sf-opt .sf-opt__ar,
.sf-opt:hover .sf-opt__ar,
.sf-opt .sf-opt__count,
.sf-opt:hover .sf-opt__count { color: var(--sf-muted) !important; }
.sf-opt.is-active .sf-opt__ar,
.sf-opt.is-active:hover .sf-opt__ar { color: var(--sf-ink) !important; }

/* color swatch option */
.sf-swatch { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
.sf-opt--color .sf-opt__en { font-size: 12.5px; }

/* ---------- Footer nav (lives inside the pinned .sf-modal__foot) ---------- */
.sf-foot {
	display: flex;
	align-items: center;
	gap: 10px;
}
.sf-btn {
	appearance: none;
	border: 0;
	border-radius: 0;
	padding: 12px 18px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease, transform .12s ease;
}
.sf-btn:active { transform: translateY(1px); }
.sf-btn--primary { background: var(--sf-ink); color: #fff; flex: 1; }
.sf-btn--primary:hover { background: #000; }
.sf-btn--primary[disabled] { opacity: .45; cursor: not-allowed; }
.sf-btn--ghost { background: transparent; color: var(--sf-muted); }
.sf-btn--ghost:hover { color: var(--sf-ink); }
.sf-btn--outline { background: #fff; color: var(--sf-ink); border: 1.5px solid var(--sf-line); }
.sf-btn--outline:hover { border-color: #bbb; }
.sf-foot__spacer { flex: 1; }

/* Lock button text colours across hover/focus/active/visited so the theme's
   global a:hover / button:hover rules can't recolour them (e.g. the primary
   "تصفّحي كل المنتجات" link). */
.sf-btn--primary,
.sf-btn--primary:hover,
.sf-btn--primary:focus,
.sf-btn--primary:active,
.sf-btn--primary:visited { color: #fff !important; }
.sf-btn--outline,
.sf-btn--outline:hover,
.sf-btn--outline:focus,
.sf-btn--outline:active,
.sf-btn--outline:visited { color: var(--sf-ink) !important; }
.sf-btn--ghost,
.sf-btn--ghost:visited { color: var(--sf-muted) !important; }
.sf-btn--ghost:hover,
.sf-btn--ghost:focus,
.sf-btn--ghost:active { color: var(--sf-ink) !important; }

/* ---------- Loading ---------- */
.sf-loading { text-align: center; padding: 48px 10px; color: var(--sf-muted); }
.sf-spinner {
	width: 40px; height: 40px; margin: 0 auto 16px;
	border: 3px solid var(--sf-soft);
	border-top-color: var(--sf-accent);
	border-radius: 50%;
	animation: sf-spin .8s linear infinite;
}
@keyframes sf-spin { to { transform: rotate(360deg); } }

/* ---------- Results ---------- */
.sf-results__note {
	margin: 0 0 16px;
	padding: 12px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.5;
}
.sf-results__note small { display: block; font-size: 12px; opacity: .85; margin-top: 3px; }
.sf-results__note.is-exact { background: #eef7ee; color: #1f6b34; }
.sf-results__note.is-closest { background: #fff5e0; color: #8a5a00; }
.sf-results__note.is-empty { background: #fdecec; color: #9b2c2c; }

.sf-cards {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}
.sf-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--sf-line);
	border-radius: 14px;
	overflow: hidden;
	text-decoration: none;
	color: var(--sf-ink);
	background: #fff;
	transition: box-shadow .18s ease, transform .18s ease;
}
.sf-card:hover { box-shadow: 0 10px 26px rgba(0,0,0,.12); transform: translateY(-2px); }

/* "Show more" button row */
.sf-more { display: flex; justify-content: center; margin-top: 16px; }
.sf-more .sf-btn { min-width: 220px; }
.sf-more .sf-btn[disabled] { opacity: .6; cursor: wait; }
.sf-card__media { position: relative; aspect-ratio: 1 / 1; background: var(--sf-soft); overflow: hidden; }
.sf-card__media img, .sf-card__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sf-badge {
	position: absolute;
	inset-block-start: 8px;
	inset-inline-start: 8px;
	font-size: 11px;
	font-weight: 700;
	padding: 3px 8px;
	border-radius: 99px;
	color: #fff;
}
.sf-badge--sale { background: #c0392b; }
.sf-badge--oos { background: #555; inset-inline-start: auto; inset-inline-end: 8px; }
.sf-card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.sf-card__title { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sf-card__price { font-size: 14px; font-weight: 800; color: var(--sf-ink); }
.sf-card__price del { color: var(--sf-muted); font-weight: 500; font-size: 12px; }
.sf-card__price ins { text-decoration: none; }
.sf-card__cta { margin-top: 2px; font-size: 12.5px; font-weight: 700; color: var(--sf-accent); }
.sf-card__rating { line-height: 1; }
.sf-stars { --sf-rate: 0%; display: inline-block; font-size: 13px; letter-spacing: 2px; position: relative; }
.sf-stars::before { content: "★★★★★"; color: #e0e0e0; }
.sf-stars::after { content: "★★★★★"; color: #f5b301; position: absolute; inset-inline-start: 0; top: 0; width: var(--sf-rate); overflow: hidden; white-space: nowrap; }

/* RTL: clip stars from the right */
[dir="rtl"] .sf-stars::after { inset-inline-start: auto; inset-inline-end: 0; }

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
	.sf-modal {
		/* Center vertically and let height follow the content (no stretch).
		   Caps at 88vh; the inner area scrolls only when a step is taller. */
		inset-block-start: 50%;
		inset-block-end: auto;
		margin-block: 0;
		height: auto;
		border-radius: var(--sf-radius);
		max-height: 88vh;
		transform: translateY(-50%) scale(.96);
		opacity: 0;
		transition: transform .3s ease, opacity .3s ease;
	}
	#sf-root.sf-open .sf-modal { transform: translateY(-50%) scale(1); opacity: 1; }
	.sf-modal__inner { padding: 32px 30px 18px; }
	.sf-modal__foot { padding: 14px 30px; }
	.sf-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
	.sf-fab::after { animation: none; }
	.sf-modal, .sf-overlay, .sf-opt, .sf-card { transition: none; }
}
