/* Mat Peg Rail — Capillary Mat nav
   Fixes: crushed long labels · invisible pegs without motion ·
   overflow wrap · hamburger centering · panel width · sticky height. */

.mp-rail {
  position: relative;
  z-index: 900;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(243, 251, 248, 0.98), rgba(214, 244, 238, 0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(14, 124, 116, 0.2);
  box-shadow: 0 8px 24px rgba(18, 35, 30, 0.06);
}

.mp-inner {
  width: var(--a105-wrap);
  max-width: 100%;
  margin: 0 auto;
  min-height: calc(var(--a105-nav-h) - 6px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(0.5rem, 1.6vw, 1.1rem);
  padding: 0.55rem 0;
}

.mp-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--a105-ink);
  min-width: 0;
  flex-shrink: 0;
}

.mp-brand:focus-visible {
  outline: 2px solid var(--a105-mat);
  outline-offset: 3px;
  border-radius: 8px;
}

.mp-mark {
  width: 2.2rem;
  height: 2.2rem;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 4px;
  border-radius: 10px;
  background: var(--a105-mat);
  box-shadow: 3px 3px 0 var(--a105-plug);
}

.mp-mark-cell {
  border-radius: 999px;
  background: var(--a105-sprout);
  animation: mp-cell-wet 2.8s ease-in-out infinite;
}

.mp-mark-cell:nth-child(2) { background: var(--a105-sun); animation-delay: 0.2s; }
.mp-mark-cell:nth-child(3) { background: var(--a105-plug); animation-delay: 0.4s; }
.mp-mark-cell:nth-child(4) { background: #fff; animation-delay: 0.6s; }

@keyframes mp-cell-wet {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(0.86); filter: brightness(1.12); }
}

.mp-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.mp-brand-copy small {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--a105-mat-deep);
  font-weight: 700;
}

.mp-brand-copy strong {
  font-family: var(--a105-font-display);
  font-size: clamp(1.05rem, 2.2vw, 1.28rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

@media (min-width: 1100px) {
  .mp-brand-copy strong {
    white-space: nowrap;
    overflow-wrap: normal;
  }
}

.mp-pegs {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 8px), transparent);
}

.mp-pegs::-webkit-scrollbar { display: none; }

.mp-peg {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--a105-ink);
  padding: 0.42rem 0.62rem 0.42rem 0.45rem;
  border-radius: 999px;
  font-size: clamp(0.72rem, 1.05vw, 0.84rem);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 1;
  transform: none;
  transition: background 0.18s ease, color 0.18s ease;
}

.mp-peg:focus-visible {
  outline: 2px solid var(--a105-mat);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .mp-peg {
    opacity: 0;
    transform: translateY(6px);
    animation: mp-peg-in 0.4s ease forwards;
    animation-delay: calc(var(--mp-i, 0) * 45ms);
  }
}

@keyframes mp-peg-in {
  to { opacity: 1; transform: none; }
}

.mp-peg-dot {
  width: 0.68rem;
  height: 0.68rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--a105-mat);
  box-shadow: 0 0 0 0 rgba(14, 124, 116, 0.3);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.mp-peg--sprout .mp-peg-dot { background: var(--a105-sprout); }
.mp-peg--sun .mp-peg-dot { background: var(--a105-sun); }
.mp-peg--plug .mp-peg-dot { background: var(--a105-plug); }

.mp-peg:hover {
  background: rgba(14, 124, 116, 0.08);
}

.mp-peg:hover .mp-peg-dot,
.mp-peg.is-active .mp-peg-dot {
  transform: scale(1.22);
  box-shadow: 0 0 0 5px rgba(14, 124, 116, 0.16);
}

.mp-peg.is-active {
  background: rgba(14, 124, 116, 0.14);
  color: var(--a105-mat-deep);
}

.mp-peg-label {
  line-height: 1.1;
}

.mp-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.mp-tool {
  border: 1.5px solid rgba(14, 124, 116, 0.28);
  background: #fff;
  color: var(--a105-ink);
  border-radius: 999px;
  padding: 0.42rem 0.72rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}

.mp-tool:hover,
.mp-tool[aria-expanded="true"] {
  border-color: var(--a105-mat);
  color: var(--a105-mat-deep);
  background: var(--a105-mist);
}

.mp-tool:focus-visible {
  outline: 2px solid var(--a105-mat);
  outline-offset: 2px;
}

.mp-cart {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--a105-on-loam);
  background: var(--a105-loam);
  border-radius: 999px;
  padding: 0.42rem 0.7rem 0.42rem 0.48rem;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
  max-width: 11rem;
}

.mp-cart:hover {
  background: #1c1611;
}

.mp-cart:focus-visible {
  outline: 2px solid var(--a105-sun);
  outline-offset: 2px;
}

.mp-cart-cell {
  width: 0.8rem;
  height: 0.8rem;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--a105-sprout);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.mp-cart-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-cart-count {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--a105-plug);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.68rem;
  line-height: 1;
  animation: mp-pop 0.35s ease;
}

.mp-cart-count.is-empty,
.mp-cart-count[hidden] {
  display: none !important;
}

@keyframes mp-pop {
  from { transform: scale(0.4); }
  to { transform: scale(1); }
}

.mp-join {
  display: none;
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 10px;
  background: var(--a105-mat);
  cursor: pointer;
  place-content: center;
  place-items: center;
  gap: 4px;
  padding: 0;
  flex-shrink: 0;
}

.mp-join span {
  display: block;
  width: 1.05rem;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  margin: 0;
}

.mp-join[aria-expanded="true"] {
  background: var(--a105-plug);
}

.mp-join:focus-visible {
  outline: 2px solid var(--a105-sun);
  outline-offset: 2px;
}

.mp-capillary {
  height: 6px;
  background:
    repeating-linear-gradient(90deg, rgba(14, 124, 116, 0.32) 0 10px, transparent 10px 18px),
    linear-gradient(90deg, var(--a105-mist), #fff, var(--a105-mist));
  overflow: hidden;
  pointer-events: none;
}

.mp-cap-line {
  display: block;
  height: 100%;
  width: 28%;
  background: linear-gradient(90deg, transparent, var(--a105-sprout), var(--a105-plug), transparent);
  animation: mp-flow 4.5s linear infinite;
  will-change: transform;
}

@keyframes mp-flow {
  from { transform: translateX(-120%); }
  to { transform: translateX(420%); }
}

.mp-panel {
  width: var(--a105-wrap);
  max-width: calc(100% - 2rem);
  margin: 0 auto 0.7rem;
  min-width: 0;
  box-sizing: border-box;
  background: #fff;
  border: 1.5px solid rgba(14, 124, 116, 0.2);
  border-radius: 14px;
  padding: 0.75rem;
  box-shadow: 4px 4px 0 rgba(14, 124, 116, 0.1);
  overflow-wrap: anywhere;
}

.mp-panel[hidden] {
  display: none !important;
}

.mp-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: stretch;
}

.mp-search input {
  width: 100%;
  min-width: 0;
  border: 1.5px solid rgba(14, 124, 116, 0.25);
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  background: var(--a105-paper);
  color: var(--a105-ink);
  font: inherit;
}

.mp-search input:focus {
  outline: 2px solid var(--a105-mat);
  outline-offset: 1px;
  border-color: var(--a105-mat);
}

.mp-search button {
  border: 0;
  border-radius: 999px;
  background: var(--a105-plug);
  color: #fff;
  font-weight: 700;
  padding: 0.65rem 1.05rem;
  cursor: pointer;
  white-space: nowrap;
}

.mp-search button:hover {
  background: var(--a105-plug-deep);
}

.mp-more-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.4rem;
  min-width: 0;
}
@media (min-width: 401px) {
  .mp-more-list {
    grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr));
  }
}

.mp-more-list a {
  display: block;
  text-decoration: none;
  padding: 0.58rem 0.72rem;
  border-radius: 10px;
  background: var(--a105-mist);
  font-weight: 600;
  color: var(--a105-ink);
  line-height: 1.25;
}

.mp-more-list a:hover {
  background: var(--a105-sprout);
  color: var(--a105-sprout-ink);
}

.mp-scrim {
  position: fixed;
  inset: 0;
  background: rgba(18, 35, 30, 0.48);
  z-index: 950;
}

.mp-scrim[hidden],
.mp-sheet[hidden] {
  display: none !important;
}

.mp-sheet {
  position: fixed;
  top: 0;
  right: 0;
  width: min(88vw, 340px);
  height: 100%;
  height: 100dvh;
  background: var(--a105-paper);
  z-index: 960;
  padding: 1rem 1rem 1.5rem;
  box-shadow: -8px 0 0 rgba(14, 124, 116, 0.16);
  overflow: auto;
  overscroll-behavior: contain;
}

.mp-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mp-sheet-head strong {
  font-family: var(--a105-font-display);
  font-size: 1.15rem;
  line-height: 1.15;
}

.mp-sheet-head button {
  border: 0;
  background: var(--a105-mist);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--a105-ink);
  flex-shrink: 0;
}

.mp-sheet-nav {
  display: grid;
  gap: 0.4rem;
}

.mp-sheet-nav a {
  text-decoration: none;
  padding: 0.78rem 0.9rem;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid rgba(14, 124, 116, 0.16);
  font-weight: 600;
  color: var(--a105-ink);
}

.mp-sheet-nav a:hover {
  border-color: var(--a105-mat);
  background: var(--a105-mist);
}

.mp-sheet-nav a[aria-current="page"] {
  background: var(--a105-mat);
  color: #fff;
  border-color: var(--a105-mat);
}

html.mp-lock {
  overflow: hidden;
}

/* Compact desktop before mobile sheet */
@media (max-width: 1100px) {
  .mp-peg {
    padding-inline: 0.48rem 0.5rem;
    font-size: 0.74rem;
  }

  .mp-tool {
    padding-inline: 0.58rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 920px) {
  .mp-pegs,
  .mp-tool {
    display: none;
  }

  .mp-join {
    display: grid;
  }

  .mp-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mp-cart-label {
    display: none;
  }

  .mp-cart {
    padding: 0.45rem 0.55rem;
    max-width: none;
  }

  .mp-panel {
    max-width: calc(100% - 1.5rem);
  }

  .mp-brand-copy strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .mp-inner {
    padding-block: 0.45rem;
  }

  .mp-mark {
    width: 2rem;
    height: 2rem;
  }

  .mp-search {
    grid-template-columns: 1fr;
  }

  .mp-search button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mp-peg,
  .mp-mark-cell,
  .mp-cap-line,
  .mp-cart-count {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
