/*
 * Mastorevo Tool Finder
 * Takes fonts, headings, buttons and product cards from the active theme / WooCommerce.
 * Only layout lives here, plus one accent colour read from the theme's buttons (--mtf-accent).
 * Rules on :where(...) have zero specificity, so the theme always wins on looks.
 */
.mtf {
  --mtf-accent: #27331F;
  --mtf-accent-ink: #ffffff;
  --mtf-line: rgba(0, 0, 0, .14);
  --mtf-soft: rgba(0, 0, 0, .04);
  --mtf-muted: rgba(0, 0, 0, .6);
  margin: 0 auto;
  max-width: 1280px;
}
.mtf *, .mtf *::before, .mtf *::after { box-sizing: border-box; }
/* never all caps in the wizard itself, whatever the theme does.
   Product cards (.mtf-wc) are left exactly as the theme draws them in the shop. */
.mtf, .mtf *:not(.mtf-wc):not(.mtf-wc *) { text-transform: none !important; }
.mtf h2:not(.mtf-wc *), .mtf h3:not(.mtf-wc *), .mtf .button:not(.mtf-wc *), .mtf button:not(.mtf-wc *), .mtf label:not(.mtf-wc *), .mtf .mtf-tab { letter-spacing: normal; }

.mtf-shell { padding: 4px 0 28px; }
.mtf-loading, .mtf-error { padding: 40px 16px; text-align: center; opacity: .7; }
.mtf-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mtf-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- headings & text (theme typography) */
.mtf .mtf-q { margin: 14px 0 6px; outline: none; }
.mtf-lead { margin: 0 0 16px; color: var(--mtf-muted); max-width: 64ch; }
.mtf-ask { font-weight: 700; margin: 20px 0 10px; }
.mtf-help { margin: -4px 0 12px; color: var(--mtf-muted); font-size: .92em; }
.mtf-muted { color: var(--mtf-muted); font-weight: 400; }
.mtf-hero { padding: 6px 0 2px; }

/* ---------- progress */
.mtf-progress { list-style: none; display: flex; gap: 4px; margin: 0 0 8px; padding: 0 0 12px; border-bottom: 1px solid var(--mtf-line); overflow-x: auto; }
.mtf-progress li { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 0; font-size: .9em; color: var(--mtf-muted); white-space: nowrap; margin: 0; }
.mtf-progress li span { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: .85em; border: 1.5px solid var(--mtf-line); }
.mtf-progress li.is-done span { background: var(--mtf-accent); border-color: var(--mtf-accent); color: var(--mtf-accent-ink); }
.mtf-progress li.is-current { color: inherit; font-weight: 700; }
.mtf-progress li.is-current span { border-color: var(--mtf-accent); color: var(--mtf-accent); border-width: 2px; }

/* ---------- tiles */
.mtf-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mtf-tiles-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 6px; }
.mtf-tiles-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mtf-tiles-volts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mtf {
  /* tints of the theme's button colour */
  --mtf-tint: color-mix(in srgb, var(--mtf-accent) 7%, #fff);
  --mtf-tint-2: color-mix(in srgb, var(--mtf-accent) 14%, #fff);
  --mtf-tint-line: color-mix(in srgb, var(--mtf-accent) 28%, #fff);
}
.mtf .mtf-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  background: var(--mtf-tint); color: inherit; border: 1.5px solid var(--mtf-tint-line); border-radius: 8px; box-shadow: none;
  padding: 12px 58px 12px 14px; min-height: 56px; cursor: pointer; font: inherit; line-height: 1.25; margin: 0; width: auto; height: auto;
}
.mtf .mtf-tile:hover { border-color: var(--mtf-accent); background: var(--mtf-tint-2); color: inherit; }
.mtf .mtf-tile.is-on { background: var(--mtf-accent); border-color: var(--mtf-accent); color: var(--mtf-accent-ink); }
.mtf .mtf-tile[disabled] { opacity: .45; cursor: not-allowed; }
.mtf .mtf-tile-big { padding: 18px 52px 18px 16px; min-height: 90px; }
.mtf-tile-title { font-weight: 700; overflow-wrap: anywhere; hyphens: auto; }
.mtf-tile-sub { font-size: .86em; opacity: .7; font-weight: 400; }
.mtf-count { font-size: .78em; font-weight: 700; background: var(--mtf-soft); border-radius: 999px; padding: 1px 8px; }
.mtf-tile .mtf-count { position: absolute; right: 10px; top: 12px; }
.mtf-tile .mtf-count { background: #fff; color: var(--mtf-accent); }
.mtf-tile.is-on .mtf-count { background: rgba(255, 255, 255, .22); color: inherit; }
.mtf .mtf-tile.is-on::after { content: "✓"; position: absolute; right: 12px; bottom: 10px; font-weight: 700; }
.mtf :focus-visible { outline: 3px solid var(--mtf-accent); outline-offset: 2px; }

.mtf-family { margin: 20px 0 0; }
.mtf .mtf-family h3 { font-size: 1em; margin: 0 0 8px; color: var(--mtf-accent); }
.mtf-search { margin: 0 0 6px; max-width: 560px; }

/* ---------- buttons: theme .button for primary actions; these are only fallbacks */
.mtf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-decoration: none; }
:where(.mtf) .mtf-btn-primary { background: var(--mtf-accent); color: var(--mtf-accent-ink); border: 0; border-radius: 4px; padding: 11px 20px; font: inherit; font-weight: 700; }
.mtf .mtf-btn-primary[disabled] { opacity: .45; cursor: not-allowed; }
.mtf .mtf-btn-ghost { background: transparent; color: inherit; border: 1.5px solid var(--mtf-line); border-radius: 4px; padding: 10px 18px; font: inherit; font-weight: 600; box-shadow: none; }
.mtf .mtf-btn-ghost:hover { border-color: var(--mtf-accent); background: transparent; color: inherit; }
.mtf .mtf-btn-sm { padding: 7px 12px; font-size: .9em; }
.mtf .mtf-link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; font-weight: 600; box-shadow: none; }
.mtf .mtf-chip { border: 1.5px solid var(--mtf-tint-line); background: var(--mtf-tint); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9em; cursor: pointer; color: inherit; margin: 0; box-shadow: none; line-height: 1.3; }
.mtf .mtf-chip.is-on { background: var(--mtf-accent); border-color: var(--mtf-accent); color: var(--mtf-accent-ink); }
.mtf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mtf .mtf-input { font: inherit; width: 100%; min-width: 0; margin: 0; }

.mtf-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; }
.mtf-nav-right { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mtf-sticky { position: sticky; bottom: 0; z-index: 5; background: #fff; border-top: 1px solid var(--mtf-line); margin-top: 22px; padding: 12px 0 10px; }
.mtf-sticky .mtf-nav { margin-top: 10px; }

/* ---------- results */
.mtf-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 18px; }
.mtf-summary .mtf-link { margin-left: 8px; }
.mtf-note { background: var(--mtf-soft); padding: 10px 14px; border-radius: 6px; }
.mtf-rec { background: var(--mtf-tint); border: 1.5px solid var(--mtf-tint-line); border-radius: 10px; padding: 18px 18px 20px; margin: 0 0 24px; }
.mtf-rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.mtf-rec-item { background: #fff; border-radius: 8px; padding: 12px; }
.mtf-rec-item .mtf-wc ul.products { margin: 0 0 6px !important; }
.mtf-rec-item .mtf-wc ul.products li.product { width: 100% !important; float: none !important; margin: 0 !important; }
.mtf .mtf-rec h3 { margin: 0 0 4px; }
.mtf-cover { font-size: .88em; margin: 2px 0 0; }
.mtf-saving { font-size: .88em; margin: 4px 0 0; font-weight: 700; color: var(--mtf-accent); }
.mtf-tabbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; padding: 0 0 12px; border-bottom: 1px solid var(--mtf-line); }
.mtf-tabs { display: flex; gap: 8px; overflow-x: auto; }
.mtf .mtf-tab { background: #f2f2f2; border: 0; border-radius: 999px; padding: 9px 16px; font: inherit; font-size: .95em; font-weight: 600; color: inherit; cursor: pointer; white-space: nowrap; margin: 0; box-shadow: none; line-height: 1.2; }
.mtf .mtf-tab:hover { background: var(--mtf-tint-2); color: inherit; }
.mtf .mtf-tab.is-on { background: var(--mtf-accent); color: var(--mtf-accent-ink); }
.mtf-results { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.mtf-side { position: sticky; top: 16px; }
.mtf-filter { padding: 0 0 14px; margin: 0 0 14px; border-bottom: 1px solid var(--mtf-line); }
.mtf-filter-h { font-weight: 700; margin: 0 0 8px; font-size: .92em; }
.mtf .mtf-check { display: flex; gap: 8px; align-items: flex-start; font-size: .92em; margin: 4px 0; cursor: pointer; font-weight: 400; }
.mtf .mtf-check input { margin: 3px 0 0; accent-color: var(--mtf-accent); width: auto; }
.mtf-price-range { display: flex; align-items: center; gap: 6px; }
.mtf-bar { display: flex; align-items: center; gap: 10px 12px; justify-content: space-between; margin: 0 0 12px; flex-wrap: wrap; }
.mtf-bar > .mtf-muted { white-space: nowrap; }
.mtf-sort { display: flex; align-items: center; gap: 8px; font-size: .92em; margin: 0 0 0 auto; }
.mtf .mtf-sort .mtf-input { width: auto; }
.mtf-filters-toggle { display: none !important; }

/* product grid: WooCommerce markup, theme styles; we only own the grid */
.mtf .woocommerce { margin: 0; }
.mtf ul.products.mtf-grid { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin: 0 !important; padding: 0 !important; list-style: none; }
.mtf ul.products.mtf-grid::before, .mtf ul.products.mtf-grid::after { display: none !important; content: none !important; }
.mtf ul.products.mtf-grid li.product { width: auto !important; float: none !important; margin: 0 !important; clear: none !important; display: flex; flex-direction: column; gap: 4px; position: relative; }
.mtf ul.products.mtf-grid li.product a img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; margin: 0 0 8px; height: auto; }
.mtf ul.products.mtf-grid li.product .woocommerce-loop-product__title { font-size: 1em; line-height: 1.3; margin: 0 0 2px; padding: 0; }
.mtf ul.products.mtf-grid li.product .price { margin: 4px 0 6px; display: block; }
.mtf ul.products.mtf-grid li.product .button { margin-top: auto; align-self: flex-start; }
.mtf ul.products li.product .added_to_cart { display: inline-block; margin-top: 6px; font-size: .9em; }
.mtf-noimg { display: block; width: 100%; aspect-ratio: 1 / 1; margin: 0 0 8px; background: repeating-linear-gradient(135deg, var(--mtf-soft) 0 8px, transparent 8px 16px); border-radius: 4px; }
.mtf-brand { font-size: .82em; color: var(--mtf-muted); font-weight: 700; }
.mtf-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0; }
.mtf-badge { font-size: .76em; background: var(--mtf-soft); border-radius: 3px; padding: 2px 6px; }
.mtf li.product.outofstock img { opacity: .55; }
.mtf-oos { font-size: .88em; color: var(--mtf-muted); margin-top: auto; }
.mtf-more { text-align: center; margin: 18px 0 0; }
.mtf-empty { padding: 20px; background: var(--mtf-soft); border-radius: 6px; text-align: center; }
.mtf-empty p { margin: 0 0 8px; }

/* ---------- email */
.mtf-email { margin: 34px 0 0; border: 1.5px solid var(--mtf-tint-line); border-radius: 10px; padding: 20px; background: var(--mtf-tint); }
.mtf .mtf-email h3 { margin: 0 0 4px; }
.mtf-email-row { display: flex; gap: 8px; max-width: 640px; margin-bottom: 10px; }
.mtf-form-msg { margin: 8px 0 0; min-height: 1.2em; font-weight: 700; color: #b32d2e; }
.mtf-email.is-done p { margin: 0; }

/* ---------- mobile */
@media (max-width: 760px) {
  .mtf-results { grid-template-columns: 1fr; }
  .mtf-side { display: none; position: static; }
  .mtf-results.filters-open .mtf-side { display: block; background: var(--mtf-soft); padding: 14px; border-radius: 6px; }
  .mtf-filters-toggle { display: inline-flex !important; }
  .mtf ul.products.mtf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mtf ul.products.mtf-grid li.product .button { align-self: stretch; text-align: center; }
  .mtf-email-row { flex-direction: column; }
  .mtf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mtf-tiles-2, .mtf-tiles-3 { grid-template-columns: 1fr; }
  .mtf-progress li:not(.is-current) { font-size: 0; gap: 0; padding-right: 2px; }
  .mtf-progress li:not(.is-current) span { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .mtf * { transition: none !important; scroll-behavior: auto !important; } }

/* theme-rendered products: only spacing + a loading placeholder */
.mtf-wc { min-height: 120px; }
.mtf-wc .woocommerce { margin: 0; }
.mtf-wc-loading { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.mtf-wc-loading span { display: block; aspect-ratio: 3 / 4; border-radius: 8px; background: var(--mtf-tint); animation: mtf-pulse 1.2s ease-in-out infinite alternate; }
@keyframes mtf-pulse { from { opacity: .55; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mtf-wc-loading span { animation: none; } }

/* theme cards loaded by us: make sure lazy-load / reveal animations never keep them hidden */
.mtf-wc li.product, .mtf-wc .product { opacity: 1 !important; visibility: visible !important; }
.mtf-wc img.mtf-img-ready { opacity: 1 !important; visibility: visible !important; }
.mtf-wc + .mtf-wc { margin-top: 16px; }

/* results header: dark band with the progress, the answers and one way to change them */
.mtf-head { position: relative; background: #222; color: #fff; border-radius: 10px; padding: 20px 24px 22px 28px; margin: 6px 0 18px; overflow: hidden; }
.mtf-head::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--mtf-accent); }
.mtf .mtf-head-step { margin: 0 0 8px; font-size: .85em; color: rgba(255,255,255,.65); }
.mtf-head-bar { display: flex; gap: 5px; max-width: 360px; margin: 0 0 14px; }
.mtf-head-bar i { flex: 1; height: 5px; border-radius: 3px; background: var(--mtf-accent); }
.mtf .mtf-head .mtf-q { color: #fff; margin: 0 0 14px; }
.mtf-head-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mtf .mtf-tag { display: inline-flex; align-items: baseline; gap: 6px; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 6px; padding: 6px 11px; font: inherit; font-size: .92em; cursor: pointer; box-shadow: none; margin: 0; line-height: 1.3; }
.mtf .mtf-tag:hover { border-color: var(--mtf-accent); background: rgba(255,255,255,.14); color: #fff; }
.mtf-tag-k { color: rgba(255,255,255,.6); font-size: .9em; }
.mtf .mtf-head-edit { background: none; border: 0; padding: 0 4px; margin: 0 0 0 4px; color: var(--mtf-accent); font: inherit; font-weight: 700; font-size: .92em; cursor: pointer; box-shadow: none; }
.mtf .mtf-head-reset { background: none; border: 0; padding: 0; margin: 0 0 0 6px; color: rgba(255,255,255,.6); font: inherit; font-size: .88em; text-decoration: underline; cursor: pointer; box-shadow: none; }
.mtf .mtf-head-edit:hover, .mtf .mtf-head-reset:hover { background: none; color: #fff; }

/* on/off switch for "show unavailable" */
.mtf .mtf-switch { display: inline-flex; align-items: center; gap: 8px; font-size: .92em; color: var(--mtf-muted); cursor: pointer; margin: 0; font-weight: 400; }
.mtf-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mtf-switch-ui { width: 36px; height: 20px; border-radius: 10px; background: #d4d4d4; position: relative; flex: none; transition: background .15s; }
.mtf-switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.mtf-switch input:checked + .mtf-switch-ui { background: var(--mtf-accent); }
.mtf-switch input:checked + .mtf-switch-ui::after { transform: translateX(16px); }
.mtf-switch input:focus-visible + .mtf-switch-ui { outline: 3px solid var(--mtf-accent); outline-offset: 2px; }
@media (max-width: 760px) { .mtf-head { padding: 16px 16px 18px 22px; } }
