/**
 * =============================================================================
 * BLOCK: Solution Finder (.finder)
 * =============================================================================
 * Interactive 3-step product recommendation widget.
 * Tokens aligned with design-system-tokens.json.
 * =============================================================================
 */

/* --- Finder variables (scoped) ---
 * All --sf-* aliases point to canonical design system tokens. The only
 * local definitions left are values intentionally outside the global scale
 * (e.g. ultra-tight 8px radius for trait icons). */
.finder {
  --sf-dark:        var(--color-teal-800);
  --sf-dark-deep:   var(--color-teal-900);
  --sf-accent:      var(--color-light-green);
  --sf-accent-dim:  var(--color-glass-lime-15);
  --sf-accent-glow: var(--color-glass-lime-35);
  --sf-white:       var(--color-white);
  --sf-grayish:     var(--color-gray-200);
  --sf-glass-bg:    var(--color-white-04);
  --sf-glass-border: var(--color-white-10);
  --sf-r-sm:        8px; /* tighter than --radius-sm (12px) — kept local */
  --sf-r-md:        var(--radius-sm);  /* 12px */
  --sf-r-lg:        var(--radius-lg);  /* 20px */
  --sf-r-xl:        var(--radius-2xl); /* 28px */
  --sf-ease:        cubic-bezier(.4,0,.2,1);
  --sf-t:           200ms; /* duration only (--transition-fast is duration+ease, can't compose) */
  --sf-font:        var(--font-gilroy);
  --sf-fw-r:        var(--fw-regular);
  --sf-fw-sb:       var(--fw-semibold);
}

/* Container pattern (mirrors .container / the other blocks): the +2*padding-x
   in max-width keeps the inner content at --container-content (1200px) on
   desktop, while padding-inline stops the card bleeding to the screen edges
   on narrower viewports. */
.finder {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: calc(var(--container-content) + 2 * var(--padding-x));
  margin: 0 auto;
  padding-inline: var(--padding-x);
}

@media (max-width: 1023px) {
  .finder { padding-inline: var(--padding-x-md); }
}
.finder__header { display: none; }

/* --- Card container ---
 * 4-column layout: 3 question columns + 1 recommendation panel.
 * The 4 columns stay visible as long as possible — `minmax(0, 1fr)` lets the
 * question columns shrink down freely while the recommendation panel is
 * allowed to flex between 220px (tight tablet) and 290px (desktop). The
 * layout collapses directly to 1 column at the mobile breakpoint — no
 * intermediate 2-column stage. */
.finder .card {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 1fr)
    minmax(0, 1fr)
    minmax(220px, 290px);
  border-radius: var(--sf-r-xl);
  overflow: hidden;
  position: relative;
  background: var(--sf-glass-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--sf-glass-border);
  /* Dual shadow: ambient drop + 1px inset highlight (glass top edge) */
  box-shadow: 0 8px 56px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.07) inset;
}
.finder .card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.16) 30%, var(--color-glass-lime-28) 65%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}

/* --- Columns ---
 * Fluid horizontal padding via clamp() so the 4-col layout survives down
 * to ~720px viewport before collapsing to 1 col at the mobile breakpoint.
 * Wider columns (desktop) keep the original 20px gutter; narrower columns
 * (tablet) tighten to 12px so the choice text still has room. */
.finder .col {
  padding: 22px clamp(12px, 1.6vw, 20px) 18px;
  border-right: 1px solid var(--color-white-10);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.finder .col__step {
  font-size: 9.5px; /* Figma-exact micro-label */
  font-weight: var(--sf-fw-sb);
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(205,214,217,.33); /* gray-200 at 33% — not tokenized (rare opacity) */
  margin-bottom: var(--space-1); /* 2px */
  white-space: nowrap;
}
.finder .col__title {
  font-size: 12.5px; /* Figma-exact */
  font-weight: var(--sf-fw-sb);
  color: rgba(255,255,255,.88); /* white at 88% — close to --color-white-90 */
  letter-spacing: -.01em;
  margin-bottom: var(--space-6); /* 12px */
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-white-10);
  white-space: nowrap;
}
.finder .col__choices { flex: 1; display: flex; flex-direction: column; gap: var(--space-3); /* 6px */ }

/* --- Progress bar --- */
.finder .col__progress { display: flex; gap: var(--space-2); margin-top: var(--space-7); flex-shrink: 0; }
.finder .col__progress-dot {
  height: 3px; flex: 1; border-radius: 2px;
  background: var(--color-white-10);
  transition: all var(--sf-t) var(--sf-ease);
}
.finder .col__progress-dot.on {
  background: var(--sf-accent);
  box-shadow: 0 0 6px var(--color-glass-lime-50);
}

/* --- Choice items --- */
.finder .choice {
  display: flex; align-items: center; gap: 9px;
  padding: var(--space-4) var(--space-5); /* 8px 10px */
  border-radius: var(--sf-r-md);
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--sf-t) var(--sf-ease), border-color var(--sf-t) var(--sf-ease), transform var(--sf-t) var(--sf-ease), opacity var(--sf-t) var(--sf-ease);
  user-select: none;
}
.finder .choice:hover { background: var(--color-white-04); transform: translateX(2px); }
.finder .choice.active {
  background: var(--sf-accent-dim);
  border-color: var(--color-glass-lime-28);
  box-shadow: 0 0 0 1px var(--color-glass-lime-12) inset;
}
/* Disabled state — kept as a low-level primitive. Step 3 no longer uses it
   (incompatible UCs are filtered out of the DOM instead of greyed in place),
   but the rule remains in case any future variant of the finder needs it. */
.finder .choice.disabled { opacity: .22; pointer-events: none; }

.finder .choice__icon {
  width: 28px; height: 28px; border-radius: var(--sf-r-sm);
  background: var(--color-white-04);
  border: 1px solid var(--color-white-04);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); /* 13px */ flex-shrink: 0;
}
.finder .choice.active .choice__icon {
  background: var(--color-glass-lime-18);
  border-color: var(--color-glass-lime-28);
}
.finder .choice__text {
  font-size: var(--text-xs); /* 12px */
  font-weight: var(--sf-fw-r);
  color: var(--color-text-secondary-72);
  line-height: 1.3;
  flex: 1; min-width: 0;
  /* Allow long labels (e.g. "Plant Breeders & Seed Producers") to wrap
     onto multiple lines when the 4-col layout gets tight on tablet. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.finder .choice.active .choice__text { color: var(--sf-accent); font-weight: var(--sf-fw-sb); }

.finder .choice__dot {
  width: 15px; height: 15px; border-radius: var(--radius-circle);
  border: 1.5px solid rgba(205,214,217,.18); /* gray-200 at 18% — rare opacity, kept */
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--sf-t) var(--sf-ease);
}
.finder .choice.active .choice__dot {
  background: var(--sf-accent); border-color: var(--sf-accent);
  box-shadow: 0 0 8px var(--sf-accent-glow);
}
.finder .choice.active .choice__dot::after {
  content: ''; width: 4px; height: 7px;
  border: 1.5px solid var(--sf-dark-deep);
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-0.5px,-1px);
  display: block;
}

/* --- Recommendation panel --- */
.finder .rec {
  padding: 26px clamp(14px, 1.6vw, 20px);
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
  background: linear-gradient(145deg, var(--color-glass-lime-12) 0%, rgba(9,132,70,.07) 45%, rgba(255,255,255,.03) 100%);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border-left: 1px solid var(--color-glass-lime-18);
}
.finder .rec::before {
  content: ''; position: absolute; top: -80px; right: -80px;
  width: 260px; height: 260px; border-radius: var(--radius-circle);
  background: radial-gradient(circle, var(--color-glass-lime-18) 0%, transparent 68%);
  pointer-events: none; z-index: 0;
}
.finder .rec::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 60px;
  background: linear-gradient(180deg, rgba(255,255,255,.07) 0%, transparent 100%);
  pointer-events: none; border-radius: 0 var(--sf-r-xl) 0 0; z-index: 0;
}

.finder .rec__label {
  font-size: 9.5px; font-weight: var(--sf-fw-sb);
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--sf-accent); margin-bottom: var(--space-8);
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  position: relative; z-index: 1; text-align: center; flex-shrink: 0;
}
.finder .rec__label::before {
  content: ''; width: 5px; height: 5px; border-radius: var(--radius-circle);
  background: var(--sf-accent); box-shadow: 0 0 8px var(--sf-accent);
  display: inline-block;
}

.finder .rec__empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: var(--space-6); position: relative; z-index: 1; padding: var(--space-10) 0;
}
.finder .rec__empty-ring {
  width: 62px; height: 62px; border-radius: var(--radius-circle);
  border: 1.5px solid var(--color-glass-lime-22);
  background: rgba(143,191,72,.05); /* lime at 5% — too rare to tokenize */
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; position: relative;
}
.finder .rec__empty-ring::after {
  content: ''; position: absolute; inset: -7px;
  border-radius: var(--radius-circle);
  border: 1px solid rgba(143,191,72,.08); /* lime at 8% — too rare to tokenize */
}
.finder .rec__empty-text {
  font-size: 11.5px; font-weight: var(--sf-fw-r);
  color: var(--color-text-secondary-42);
  line-height: var(--lh-loose); /* 1.6 */
  max-width: 180px;
}

.finder .rec__product { display: none; flex-direction: column; position: relative; z-index: 1; }
.finder .rec__product.visible { display: flex; animation: sfFadeUp .3s var(--sf-ease) forwards; }

.finder .rec__contact {
  display: none; flex-direction: column; align-items: center;
  text-align: center; gap: var(--space-8); position: relative; z-index: 1; padding: var(--space-10) 0;
}
.finder .rec__contact.visible { display: flex; animation: sfFadeUp .3s var(--sf-ease) forwards; }
.finder .rec__contact-icon { font-size: 36px; }
.finder .rec__contact-text {
  font-size: var(--text-sm); /* 13px */
  font-weight: var(--sf-fw-r);
  color: var(--color-white-70);
  line-height: var(--lh-loose); /* 1.6 */
  max-width: 200px;
}
.finder .rec__contact-cta {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px var(--space-10); /* 11px 20px */
  border-radius: 40px; /* compact pill — between --radius-2xl (28) and --radius-full (50) */
  font-size: var(--text-sm); /* 13px */ font-weight: var(--sf-fw-sb);
  color: var(--color-white); text-decoration: none; width: 100%; cursor: pointer;
  background: var(--color-white-10);
  border: 1px solid var(--color-white-20);
  transition: all var(--sf-t) var(--sf-ease);
}
.finder .rec__contact-cta:hover { background: rgba(255,255,255,.18); transform: translateY(-1px); }

@keyframes sfFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.finder .rec__block { width: 100%; border-radius: var(--sf-r-lg); overflow: hidden; margin-bottom: var(--space-7); flex-shrink: 0; }
.finder .rec__block-img { width: 100%; height: auto; display: block; border-radius: var(--sf-r-lg); }
.finder .rec__desc {
  font-size: var(--text-xs); /* 12px */
  font-weight: var(--sf-fw-r);
  color: rgba(205,214,217,.68); /* gray-200 at 68% — close to --color-text-secondary-72 */
  line-height: 1.65;
  margin-bottom: var(--space-7); /* 14px */
  text-align: center;
}
.finder .rec__cta {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: var(--space-5) 18px; /* 10px 18px */
  border-radius: 40px;
  font-family: var(--sf-font); font-size: var(--text-base); /* 14px */
  font-weight: var(--sf-fw-sb);
  color: var(--color-white); text-decoration: none; width: 100%; cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform var(--sf-t) var(--sf-ease), box-shadow var(--sf-t) var(--sf-ease);
  /* Brand CTA: aligned with --gradient-radial-green palette. Linear here
     to match the original Figma rendering of this specific pill. */
  background: var(--gradient-cta);
  border: 1px solid rgba(255,255,255,.36);
  box-shadow: 0 4px 20px var(--color-glass-lime-35), 0 1px 0 rgba(255,255,255,.44) inset;
}
.finder .rec__cta::before {
  content: ''; position: absolute; top: 0; left: -70%; width: 45%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.32), transparent);
  transform: skewX(-18deg); transition: left .5s var(--sf-ease);
}
.finder .rec__cta:hover { transform: translateY(-2px); box-shadow: 0 8px 28px var(--color-glass-lime-50); }
.finder .rec__cta:hover::before { left: 140%; }
.finder .rec__cta svg { width: 13px; height: 13px; flex-shrink: 0; }

/* --- Responsive ---
 * The 4-column layout (3 questions + recommendation) is preserved as long
 * as possible. Below 768px viewport the card collapses **directly** to a
 * single column — no intermediate 2-column stage. The recommendation
 * panel becomes the 4th row, separated by a top border instead of the
 * left border it carries in 4-col layout.
 */
@media (max-width: 767px) {
  .finder { padding-inline: var(--padding-x-sm); }

  .finder .card {
    grid-template-columns: 1fr;
  }

  /* Question columns lose their right border (now a bottom border of the
     stacked row) and gain a divider so the 4 rows read as steps. */
  .finder .col {
    border-right: none;
    border-bottom: 1px solid var(--color-white-10);
  }

  /* Recommendation panel sits at the bottom of the stack — top border in
     the lime accent, no left border. */
  .finder .rec {
    border-left: none;
    border-top: 1px solid var(--color-glass-lime-18);
    grid-column: 1;
  }
}
