/* Slice 20: factory and program pages, wave 2 (touch and interaction).
   Builds on 10-factory.css. Scoped to the factory routes or to ef20-* hooks used only in those
   templates. Shared behavior is NOT repeated here: 20-system owns .btn and .chip press states,
   the button ripple and 44px chips on touch; 20-footer owns tap feedback on .steps4 li and .process li.
   Only things that act get a press or hover response: static spec cards stay still.
   Motion is transform/opacity only and is switched off for prefers-reduced-motion at the end.
   JS hooks live in assets/js/parts/20-factory.js. */

:is(.route-about, .route-how-we-make-it, .route-quality-control, .route-certifications, .route-compliance,
    .route-sampling, .route-production-calendar, .route-who-we-serve, .route-private-label,
    .route-white-label, .route-shipping) main {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- press states for the controls this slice adds ---------- */
:is(.ef20-pick, .ef20-copy, .ef20-filter button) {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform .14s var(--ease), background-color .15s, border-color .15s, color .15s;
}
:is(.ef20-pick, .ef20-copy, .ef20-filter button):active {
  transform: scale(.96);
  transition-duration: .06s;
}

/* Tap ripple (span injected by 20-factory.js on the controls above and on link cards). */
.ef20-ripple {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: rgba(31, 79, 209, .16);
  pointer-events: none;
  transform: scale(0);
  animation: ef20-ripple .55s var(--ease) forwards;
}
:is(.ef20-pick[aria-pressed="true"], .ef20-filter button[aria-pressed="true"], .ef20-copy.is-done) .ef20-ripple { background: rgba(255, 255, 255, .35); }
@keyframes ef20-ripple { to { transform: scale(16); opacity: 0; } }

/* Touch targets: inline links in the contact list reach 44px on coarse pointers. */
@media (pointer: coarse) {
  :is(.route-about, .route-how-we-make-it, .route-quality-control, .route-certifications, .route-compliance,
      .route-sampling, .route-production-calendar, .route-who-we-serve, .route-private-label,
      .route-white-label, .route-shipping) main :is(.text-link, .kv a) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ---------- sampling: whole card is the tap target ---------- */
.ef20-linkcard {
  position: relative;
  overflow: hidden;
  transition: transform .25s var(--ease), border-color .2s;
}
.ef20-linkcard .text-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.ef20-linkcard:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.ef20-linkcard .text-link:focus-visible { outline: none; }
.ef20-linkcard .text-link .icon,
.ef20-linkcard .text-link svg { transition: transform .2s var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .ef20-linkcard:hover { transform: translateY(-3px); border-color: var(--accent); }
  .ef20-linkcard:hover .text-link :is(.icon, svg) { transform: translateX(4px); }
}
.ef20-linkcard:active { transform: scale(.985); transition-duration: .08s; }

/* ---------- who we serve: sticky, swipeable buyer-type nav with scrollspy ---------- */
.ef20-segnav {
  position: sticky;
  top: var(--head-h);
  z-index: 5;
  margin: 0 0 18px;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.ef20-segnav .chip { white-space: nowrap; }
.ef20-segnav .chip[aria-current="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
@media (hover: hover) { .ef20-segnav .chip:not([aria-current="true"]):hover { border-color: var(--accent); } }
@media (max-width: 860px) {
  .ef20-segnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    /* Bleed to the screen edge, matching the .wrap gutter (16px, 32px from 720px). */
    margin-inline: -16px;
    padding-inline: 16px;
    scroll-padding-inline: 16px;
  }
  .ef20-segnav::-webkit-scrollbar { display: none; }
  .ef20-segnav .chip { scroll-snap-align: start; flex: none; }
}
@media (min-width: 720px) and (max-width: 860px) {
  .ef20-segnav { margin-inline: -32px; padding-inline: 32px; scroll-padding-inline: 32px; }
}
.route-who-we-serve .segment { scroll-margin-top: calc(var(--head-h) + 80px); }

/* ---------- swipeable steps (private label, quality control) ---------- */
.ef20-dots { display: none; }
@media (max-width: 860px) {
  .steps4.ef20-swipe {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(78%, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 4px 0 6px;
  }
  .steps4.ef20-swipe::-webkit-scrollbar { display: none; }
  .steps4.ef20-swipe li { scroll-snap-align: start; }
  .steps4.ef20-swipe:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .ef20-dots {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 6px;
  }
  .ef20-dots button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    touch-action: manipulation;
  }
  .ef20-dots button::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rule-strong);
    transition: transform .2s var(--ease), background-color .2s;
  }
  .ef20-dots button[aria-current="true"]::before { background: var(--accent); transform: scale(1.4); }
}
@media (min-width: 481px) and (max-width: 860px) {
  .steps4.ef20-swipe { grid-auto-columns: minmax(46%, 1fr); }
}

/* ---------- how we make it: sign-off filter and current step ---------- */
.ef20-filter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
}
.ef20-filter button {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: 500 .78rem/1.2 var(--f-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.ef20-filter button[aria-pressed="true"] { background: var(--navy); color: #fff; }
@media (hover: hover) { .ef20-filter button[aria-pressed="false"]:hover { color: var(--accent-ink); } }
.make-steps.ef20-gates-only .make-step:not(.is-gate) { display: none; }
.make-step { transition: border-color .25s; }
.make-step .n { transition: background-color .25s, color .25s, transform .25s var(--ease); }
.make-step.is-current { border-color: var(--accent); }
.make-step.is-current .n { background: var(--accent); color: #fff; transform: scale(1.06); }

/* ---------- shipping: method table becomes stacked cards on phones ---------- */
@media (max-width: 640px) {
  .ef20-ship { overflow: visible; background: none; border: 0; box-shadow: none; }
  .ef20-ship table, .ef20-ship tbody, .ef20-ship tr, .ef20-ship td { display: block; width: 100%; }
  .ef20-ship thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ef20-ship tr {
    margin: 0 0 12px;
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-top: 3px solid var(--navy);
    border-radius: var(--radius);
  }
  .ef20-ship td { padding: 10px 16px; border: 0; border-top: 1px solid var(--rule); text-align: left; }
  .ef20-ship td:first-child { border-top: 0; font-size: 1.1rem; }
  .ef20-ship td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font: 500 .66rem/1.3 var(--f-mono);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-2);
  }
}

/* ---------- production calendar: next closure and quick date picks ---------- */
.closures li.is-next { position: relative; background: var(--accent-soft); margin-inline: -10px; padding-inline: 10px; border-radius: 6px; }
.closures li.is-next span::after {
  content: "Next";
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: 500 .62rem/1.4 var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.ef20-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.ef20-picks-label { width: 100%; margin: 0 0 2px; font: 500 .68rem/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.ef20-pick {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: .86rem;
  cursor: pointer;
}
.ef20-pick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .ef20-pick[aria-pressed="false"]:hover { border-color: var(--accent); } }
.planner-result.ef20-flash b { animation: ef20-flash .45s var(--ease); }
@keyframes ef20-flash { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- about: copy email ---------- */
.ef20-copy {
  position: relative;
  overflow: hidden;
  margin-left: 8px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 500 .66rem/1 var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  vertical-align: middle;
}
.ef20-copy.is-done { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .ef20-copy:not(.is-done):hover { border-color: var(--accent); color: var(--accent-ink); } }
@media (pointer: coarse) { .ef20-copy { min-height: 44px; padding-inline: 14px; } }

/* ---------- keyboard focus, visible on every interactive piece we add ---------- */
:is(.ef20-filter button, .ef20-pick, .ef20-copy, .ef20-dots button, .ef20-segnav .chip):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ef20-ripple { display: none; }
  :is(.ef20-pick, .ef20-copy, .ef20-filter button, .ef20-linkcard, .ef20-linkcard .text-link .icon,
      .ef20-linkcard .text-link svg, .make-step .n) {
    transition: none;
    transform: none !important;
  }
  .ef20-dots button::before { transition: none; }
  .planner-result.ef20-flash b { animation: none; }
}
