/* ===========================================================================
   POD / Hot trend workbench (workbench.js): selector bar, main tabs + Tools menu, POD stepper,
   segment chips, onboarding, "Recommended for you", Video tab, info tips.
   Same survey-map language as styles.css: ink on mint canvas, the blue pin marks what was observed
   or what is current, mono for codes and counts, Bricolage for titles. Tokens only, no new colours.
   =========================================================================== */

:root { --scopebar-height: 50px; }

/* ---------------------------------------------------------------------------
   Selector bar (platform, country) under the header; sticky with it on wide screens
   --------------------------------------------------------------------------- */
.scopebar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 45;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

.scopebar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  max-width: var(--page-max);
  min-height: var(--scopebar-height);
  margin: 0 auto;
  padding: 7px var(--page-pad);
}

.scope-field { display: flex; align-items: center; gap: 10px; min-width: 0; }

.scope-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.scope-select { height: 34px; font-size: 13px; }
.scope-select option:disabled { color: var(--text-muted); }

.scope-countries {
  display: flex;
  gap: 2px;
  max-width: 100%;
  padding: 2px;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  scrollbar-width: none;
}

.scope-countries::-webkit-scrollbar { display: none; }

.scope-country {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 30px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.scope-country:hover { background: var(--bg-hover); color: var(--text-primary); }
.scope-country.active { background: var(--text-primary); color: var(--on-ink); }

.scope-count { font-size: 11px; font-weight: 500; opacity: 0.78; }
.scope-count.is-zero { opacity: 0.5; }

/* ---------------------------------------------------------------------------
   Info tips (BSR, Observed, Estimate, coverage): open the shared #est-popover
   --------------------------------------------------------------------------- */
.info-tip {
  appearance: none;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font: 600 10.5px/1 var(--font-mono);
  vertical-align: middle;
  cursor: help;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.info-tip::before { content: 'i'; content: 'i' / ''; }
/* A finger-sized hit area around the small mark. */
.info-tip::after { content: ''; position: absolute; inset: -8px; }
.info-tip:hover { color: var(--pin); border-color: var(--pin-line); background: var(--pin-wash); }

.scope-country:focus-visible,
.step-btn:focus-visible,
.tools-item:focus-visible,
.onboard-card:focus-visible,
.rec-open:focus-visible,
.info-tip:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Main tabs and the Tools menu
   --------------------------------------------------------------------------- */
/* The bar itself no longer scrolls (it would clip the Tools menu); the tablist scrolls instead,
   with 3px of room below so the pin of the active tab is not cut off. */
.pillars {
  top: calc(var(--topbar-height) + var(--scopebar-height));
  overflow: visible;
}

.tablist {
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 3px;
  margin-bottom: -3px;
  scrollbar-width: none;
}

.tablist::-webkit-scrollbar { display: none; }

.tools-wrap {
  position: relative;
  display: flex;
  flex: none;
  margin-inline-start: auto;
  padding-inline-start: 10px;
  background: linear-gradient(var(--border-strong), var(--border-strong)) left center / 1px 22px no-repeat;
}

.tab-btn--tools { gap: 6px; }
.tab-btn--tools::after { left: 11px; right: 30px; }
.tab-btn--tools::before { right: 22px; }
.tab-btn--tools[aria-expanded="true"] { color: var(--text-primary); }

.tools-caret {
  width: 14px;
  height: 14px;
  transition: transform var(--transition);
}

.tab-btn--tools[aria-expanded="true"] .tools-caret { transform: rotate(180deg); }

.tools-menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  z-index: 60;
  display: grid;
  gap: 2px;
  width: min(290px, calc(100vw - 24px));
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-float);
}

.tools-menu[hidden] { display: none; }

.tools-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  text-align: start;
  cursor: pointer;
  transition: background var(--transition);
}

.tools-item:hover,
.tools-item:focus-visible { background: var(--bg-hover); }

.tools-item-title { font-size: 14px; font-weight: 600; }
.tools-item-desc { font-size: 12px; color: var(--text-muted); }

.tools-item[aria-current="page"] .tools-item-title::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-start: 8px;
  border-radius: 50%;
  background: var(--pin);
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
   POD: stepper and chips
   --------------------------------------------------------------------------- */
.pod-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 20px;
}

.stepper {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stepper li { display: flex; align-items: center; }

/* The route between steps, like a surveyed line between two pins. */
.stepper li + li::before {
  content: '';
  width: 26px;
  height: 0;
  margin-inline: 4px;
  border-top: 1.5px dashed var(--border-strong);
}

.step-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 5px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.step-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.step-btn.active { border-color: var(--text-primary); background: var(--text-primary); color: var(--on-ink); }

.step-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.step-btn.active .step-num { background: var(--pin); color: var(--on-ink); }

.seg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#hot-list-chips,
#kw-seg-chips { margin-bottom: 18px; }

.seg-chip { display: inline-flex; align-items: center; gap: 7px; }

.chip-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.chip.active .chip-count { color: inherit; opacity: 0.8; }
.chip-count.is-zero { opacity: 0.6; }

.step-title {
  font-family: var(--font-display);
  font-stretch: 86%;
  font-size: clamp(1.25rem, 1rem + 0.8vw, 1.6rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

#pod-step-products > .step-title { margin-bottom: 14px; }

.step-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.tm-step { max-width: 760px; }
.tm-step > .muted { margin-top: 8px; font-size: 14px; }
.tm-step-form { display: grid; gap: 6px; margin-top: 16px; }
.tm-step-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-step-row .search-input { flex: 1 1 260px; }

.niche-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
}

/* ---------------------------------------------------------------------------
   Onboarding (first visit)
   --------------------------------------------------------------------------- */
.onboard {
  max-width: var(--page-max);
  margin: 0 auto clamp(18px, 3vw, 30px);
  padding: 0 var(--page-pad);
}

.onboard[hidden] { display: none; }

.onboard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.onboard-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.onboard-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.onboard-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  height: 100%;
  padding: 18px 20px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--inner-glow);
  color: var(--text-primary);
  text-decoration: none;
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out), border-color var(--transition);
}

/* POD is the main path: its card carries the pin colour. */
.onboard-card--pod { border-color: var(--pin-line); background: linear-gradient(160deg, var(--pin-wash), transparent 70%), var(--bg-surface); }

.onboard-card::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 20px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pin);
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 200ms var(--ease-out), transform 260ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.onboard-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.onboard-card:hover::after,
.onboard-card:focus-visible::after { opacity: 1; transform: none; }

.onboard-num { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--pin); }

.onboard-card-title {
  font-family: var(--font-display);
  font-stretch: 84%;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.onboard-card-body { font-size: 13.5px; color: var(--text-secondary); }

/* ---------------------------------------------------------------------------
   Recommended for you (observed facts only)
   --------------------------------------------------------------------------- */
.recs {
  margin-bottom: 24px;
  padding: 16px 18px 18px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--inner-glow);
}

.recs[hidden] { display: none; }

.recs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 12px;
}

.recs-title {
  font-family: var(--font-display);
  font-stretch: 86%;
  font-size: 19px;
  font-weight: 700;
}

.recs-basis { max-width: 64ch; font-size: 12.5px; color: var(--text-muted); }
.recs-empty { font-size: 13.5px; }

.recs-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rec {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px 12px 10px;
  border-radius: var(--radius-md);
  background: var(--canvas);
}

.rec-rank {
  flex: none;
  min-width: 22px;
  font-family: var(--font-display);
  font-stretch: 75%;
  font-size: 30px;
  font-weight: 800;
  line-height: 0.9;
  color: var(--pin);
}

.rec-thumb {
  flex: none;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #fff;
}

.rec-thumb img { width: 100%; height: 100%; object-fit: contain; }

.rec-main { flex: 1; min-width: 0; }

.rec-open {
  appearance: none;
  display: -webkit-box;
  overflow: hidden;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.rec-open:hover { color: var(--pin); text-decoration: underline; text-underline-offset: 2px; }

.rec-reason {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.rec-reason .glyph { width: 10px; height: 10px; }
.rec-meta { margin-top: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   Video (YouTube)
   --------------------------------------------------------------------------- */
.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.video-kw-scope { margin: 4px 0 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.video-kw-scope:empty { display: none; }

.vkw-list { margin: 0; padding: 0; list-style: none; }

.vkw {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.vkw-term { font-weight: 600; overflow-wrap: anywhere; }
.vkw-rank { font-family: var(--font-mono); font-size: 12px; color: var(--pin); }
.vkw-time { font-size: 12px; color: var(--text-muted); }
.vkw-basis { margin-top: 12px; font-size: 12.5px; }

.nf-explainer {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 22px 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--text-primary);
  color: var(--on-ink);
}

/* Survey grid behind the copy, as in the hero. */
.nf-explainer::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(color-mix(in srgb, var(--on-ink) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--on-ink) 9%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 80% 90% at 100% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 90% at 100% 0%, #000 20%, transparent 75%);
}

.nf-explainer-title {
  font-family: var(--font-display);
  font-stretch: 84%;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.nf-explainer p { margin: 8px 0 18px; font-size: 14px; opacity: 0.86; }
.nf-explainer-cta { gap: 8px; }
.nf-explainer-cta:hover:not(:disabled) { background: var(--on-ink); color: var(--text-primary); }
.nf-explainer-cta .ui-icon { width: 16px; height: 16px; }

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .recs-list { grid-template-columns: minmax(0, 1fr); }
  .video-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  /* Small screens: only the header stays pinned; the selector bar scrolls away with the hero. */
  .scopebar { position: static; backdrop-filter: none; }
  .scopebar-inner { gap: 8px 14px; padding-block: 8px; }
  .pillars { top: var(--topbar-height); }
  .tools-wrap { padding-inline-start: 4px; }

  .onboard-cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .onboard-card { padding: 14px 16px; }
  .onboard-card-title { font-size: 19px; }
}

@media (max-width: 560px) {
  .stepper {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .stepper li + li::before { display: none; }

  .step-btn {
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: 6px 8px 6px 5px;
    font-size: 12.5px;
    line-height: 1.15;
    text-align: start;
    white-space: normal;
  }

  .step-num { flex: none; width: 24px; height: 24px; }

  .vkw { grid-template-columns: minmax(0, 1fr) auto; }
  .vkw-time { grid-column: 1 / -1; }

  .tab-btn--pillar { font-size: 16px; }

  /* The tabs scroll sideways here: fade the trailing edge so the hidden ones read as "more". */
  .tablist {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    padding-inline-end: 22px;
  }
}

@media (max-width: 420px) {
  .scope-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .scope-country { padding: 0 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .tools-menu:not([hidden]) { animation: wb-menu-in 160ms var(--ease-out) both; }
  .onboard:not([hidden]) { animation: rise 420ms var(--ease-out) both; }
}

@keyframes wb-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
}
