/* =========================================================================
   DUAL · components — nav, mega-menu, buttons, cards, AI panel, floating UI
   ========================================================================= */

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0.85rem 1.4rem;
  border-radius: var(--r-2);
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: var(--fs-base);
  line-height: 1;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    transform var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn--primary {
  background: var(--red-600);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.16);
}
.btn--primary:hover {
  background: #c70511;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px -10px rgba(227, 6, 19, 0.6), inset 0 1px 0 rgba(255,255,255,0.16);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-900);
  border-color: var(--line);
}
.btn--ghost:hover {
  border-color: var(--ink-900);
}
.btn--ghost.btn--on-dark {
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}
.btn--ghost.btn--on-dark:hover {
  background: rgba(255,255,255,0.08);
  border-color: #fff;
}

.btn--sm { padding: 0.55rem 0.9rem; font-size: var(--fs-sm); border-radius: var(--r-2); }
.btn--xs { padding: 0.45rem 0.7rem; font-size: var(--fs-xs); border-radius: var(--r-1); letter-spacing: 0; }
.btn--lg { padding: 1.05rem 1.7rem; font-size: var(--fs-lg); }

/* Signal-ripple on primary CTA hover */
.btn--primary::after {
  content: "";
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle, rgba(255,255,255,0.25), transparent 60%);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease-out);
  z-index: -1;
}
.btn--primary:hover::after { opacity: 1; }

/* ============ NAV ============ */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  transition:
    background var(--t-med) var(--ease-out),
    box-shadow var(--t-med) var(--ease-out),
    height var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out);
  border-bottom: 1px solid transparent;
}

.nav[data-state="transparent"] { background: transparent; color: #fff; }
.nav[data-state="solid"] {
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  color: var(--ink-900);
  border-bottom-color: var(--line);
  box-shadow: var(--shadow-nav);
  height: var(--nav-h-compact);
}

.nav__inner {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--s-6);
}

.nav__brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform var(--t-fast) var(--ease-out);
}
.nav__brand:hover { transform: scale(1.02); }
.nav__brand img {
  height: 32px;
  width: auto;
  transition: filter var(--t-med) var(--ease-out);
}
/* On transparent state over dark hero, invert logo to white for legibility */
.nav[data-state="transparent"] .nav__brand img {
  filter: brightness(0) invert(1);
}

.nav__links {
  display: none;
}
@media (min-width: 980px) {
  .nav__links { display: block; flex: 1; }
  .nav__links > ul {
    display: flex;
    gap: var(--s-2);
    justify-content: center;
  }
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--r-2);
  position: relative;
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.nav__link:hover,
.nav__link[aria-expanded="true"] { background: rgba(255,255,255,0.08); }
.nav[data-state="solid"] .nav__link:hover,
.nav[data-state="solid"] .nav__link[aria-expanded="true"] { background: var(--bg-tint); }

.nav__link[data-current]::after {
  content: "";
  position: absolute;
  left: var(--s-4); right: var(--s-4);
  bottom: 6px;
  height: 2px;
  background: currentColor;
  opacity: 0.6;
}

.nav__chev {
  width: 10px; height: 6px;
  transition: transform var(--t-fast) var(--ease-out);
}
.nav__mega-btn[aria-expanded="true"] .nav__chev { transform: rotate(180deg); }

.nav__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

/* Shared icon-only nav button (cart + account) */
.nav-iconbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  color: inherit;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.nav-iconbtn:hover { background: rgba(255,255,255,0.08); }
.nav[data-state="solid"] .nav-iconbtn { border-color: var(--line); }
.nav[data-state="solid"] .nav-iconbtn:hover { background: var(--bg-tint); border-color: var(--ink-400); }

/* Cart badge — small chip in upper-right corner of the icon */
.nav__cart-badge {
  position: absolute;
  top: -6px; right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--red-600);
  color: #fff;
  font-family: var(--ff-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  transform: scale(0.95);
  transition: transform var(--t-fast) var(--ease-out);
  pointer-events: none;
  border: 1.5px solid #fff;
}
.nav[data-state="transparent"] .nav__cart-badge { border-color: var(--ink-900); }
.nav__cart-badge.is-bump { animation: cart-bump 480ms var(--ease-out); }
@keyframes cart-bump {
  0% { transform: scale(0.95); }
  40% { transform: scale(1.3); }
  100% { transform: scale(0.95); }
}

/* Account icon — generic person icon when logged out, avatar circle when logged in */
.nav__account {
  /* uses .nav-iconbtn base */
}
.nav__account-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
}
.nav__account.is-logged-in .nav__account-ic {
  width: 26px; height: 26px;
  border-radius: var(--r-full);
  background: var(--signal);
  color: #fff;
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow: 0 0 0 2px rgba(62, 64, 149, 0.18);
}
.nav__account.is-logged-in .nav__account-ic svg { display: none; }

.nav__burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  border-radius: var(--r-2);
  margin-left: var(--s-2);
}
.nav__burger span {
  display: block;
  height: 1.5px;
  width: 22px;
  background: currentColor;
  margin: 0 auto;
  transition: transform var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}
.nav__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (min-width: 980px) {
  .nav__burger { display: none; }
}

/* ============ MEGA MENU ============ */

.megamenu {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.megamenu[data-open="true"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.megamenu[hidden] { display: none; }

.megamenu__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding: var(--s-8) var(--gutter);
  display: grid;
  grid-template-columns: repeat(4, 1fr) 1.1fr;
  gap: var(--s-7);
}

.megamenu__col ul { display: flex; flex-direction: column; gap: var(--s-1); }
.megamenu__col li a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: var(--fs-sm);
  color: var(--ink-700);
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), padding var(--t-fast) var(--ease-out);
}
.megamenu__col li a:hover {
  color: var(--red-600);
  border-bottom-color: var(--line);
  padding-left: 4px;
}
.megamenu__col li a .mono {
  color: var(--ink-400);
  font-size: var(--fs-xs);
}

.megamenu__eyebrow {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  color: var(--blue-700);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--s-3);
}

.megamenu__feature {
  background: var(--bg-tint);
  border-radius: var(--r-3);
  padding: var(--s-6);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.megamenu__feature::before {
  content: "";
  position: absolute;
  inset: auto -40% -60% auto;
  width: 220px; height: 220px;
  background: var(--signal);
  filter: blur(40px);
  opacity: 0.25;
  z-index: -1;
}
.megamenu__feature-h {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: var(--fs-2xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: var(--s-2) 0 var(--s-3);
  color: var(--ink-900);
}
.megamenu__feature-sub {
  font-size: var(--fs-sm);
  color: var(--ink-600);
  margin-bottom: var(--s-5);
}

@media (max-width: 1100px) {
  .megamenu__inner { grid-template-columns: repeat(4, 1fr); }
  .megamenu__feature { grid-column: 1 / -1; }
}

/* ============ MOBILE MENU ============ */

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: #fff;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--t-med) var(--ease-out);
  padding-top: var(--nav-h);
}
.mobile-menu[data-open="true"] { transform: translateX(0); }
.mobile-menu[hidden] { display: block; pointer-events: none; }
.mobile-menu[data-open="true"][hidden] { pointer-events: auto; }

.mobile-menu__inner {
  padding: var(--s-6) var(--gutter) var(--s-9);
}

.mobile-menu__eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue-700);
  margin-bottom: var(--s-5);
}

.mobile-menu__list { display: flex; flex-direction: column; gap: var(--s-2); }
.mobile-menu__list > li > a,
.mobile-menu__list > li > details > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-4) 0;
  font-family: var(--ff-display);
  font-size: var(--fs-2xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
}
.mobile-menu__list > li > details > summary::-webkit-details-marker { display: none; }
.mobile-menu__list > li > details > summary::after {
  content: "+";
  font-family: var(--ff-mono);
  color: var(--ink-400);
  transition: transform var(--t-fast) var(--ease-out);
}
.mobile-menu__list > li > details[open] > summary::after { transform: rotate(45deg); }

.mobile-menu__sub {
  padding: var(--s-3) 0;
  display: flex; flex-direction: column;
  gap: var(--s-1);
}
.mobile-menu__sub li a {
  display: flex; justify-content: space-between;
  padding: var(--s-2) 0;
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  color: var(--ink-700);
}
.mobile-menu__sub li a .mono {
  color: var(--ink-400);
  font-size: var(--fs-xs);
}

.mobile-menu__foot {
  margin-top: var(--s-8);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  color: var(--ink-600);
  font-size: var(--fs-sm);
  display: flex; flex-direction: column; gap: var(--s-2);
}

@media (min-width: 980px) {
  .mobile-menu { display: none !important; }
}

/* ============ AI ASSISTANT ============ */

.ai-launcher {
  position: fixed;
  left: var(--s-5);
  bottom: var(--s-5);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  height: 56px;
  padding: 0 var(--s-5) 0 var(--s-3);
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-3), 0 0 0 4px rgba(62,64,149,0.08);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px -16px rgba(14,16,32,0.5), 0 0 0 6px rgba(62,64,149,0.14);
}

.ai-launcher svg {
  width: 40px; height: 40px;
  padding: 8px;
  border-radius: var(--r-full);
  background: var(--signal);
  color: #fff;
}

.ai-launcher__dot {
  position: absolute;
  top: 8px; right: 16px;
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: #25C26B;
  box-shadow: 0 0 0 0 rgba(37,194,107,0.6);
  animation: ai-pulse 2400ms var(--ease-out) infinite;
}
@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37,194,107,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(37,194,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,194,107,0); }
}

.ai-launcher__lbl {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: -0.005em;
  display: none;
}
@media (min-width: 640px) { .ai-launcher__lbl { display: inline; } }

.ai-panel {
  position: fixed;
  left: var(--s-5);
  bottom: calc(var(--s-5) + 72px);
  z-index: 41;
  width: min(380px, calc(100vw - 2 * var(--s-5)));
  max-height: min(640px, calc(var(--vh) * 100 - 100px));
  background: #fff;
  border-radius: var(--r-4);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px -10px rgba(14,16,32,0.30);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
  overflow: hidden;
}
.ai-panel[data-open="true"] { opacity: 1; transform: translateY(0) scale(1); }
.ai-panel[hidden] { display: none; }

@media (max-width: 640px) {
  .ai-panel {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 85svh;
    border-radius: var(--r-4) var(--r-4) 0 0;
  }
}

.ai-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-4) var(--s-5);
  background: var(--ink-900);
  color: #fff;
  border-bottom: 1px solid var(--line);
}
.ai-panel__title {
  font-family: var(--ff-display);
  font-weight: 600;
  font-size: var(--fs-base);
  letter-spacing: -0.01em;
}
.ai-panel__status {
  font-size: var(--fs-xs);
  color: rgba(255,255,255,0.7);
  display: inline-flex; align-items: center; gap: var(--s-2);
  margin-top: 2px;
}
.ai-panel__pulse {
  width: 6px; height: 6px; border-radius: var(--r-full);
  background: #25C26B;
  box-shadow: 0 0 0 0 rgba(37,194,107,0.6);
  animation: ai-pulse 2400ms var(--ease-out) infinite;
}
.ai-panel__close {
  width: 32px; height: 32px;
  border-radius: var(--r-2);
  color: rgba(255,255,255,0.8);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.ai-panel__close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ai-panel__close svg { width: 18px; height: 18px; }

.ai-panel__log {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  background: var(--bg-tint);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.ai-msg {
  max-width: 86%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-3);
  font-size: var(--fs-sm);
  line-height: 1.55;
  word-wrap: break-word;
  animation: ai-msg-in 360ms var(--ease-out);
}
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink-900);
  border: 1px solid var(--line);
  border-bottom-left-radius: var(--r-1);
}
.ai-msg--user {
  align-self: flex-end;
  background: var(--ink-900);
  color: #fff;
  border-bottom-right-radius: var(--r-1);
}

.ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.ai-typing span {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--blue-400);
  animation: ai-typing 1100ms var(--ease-in-out) infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 160ms; }
.ai-typing span:nth-child(3) { animation-delay: 320ms; }
@keyframes ai-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ai-panel__chips {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: #fff;
  scrollbar-width: none;
}
.ai-panel__chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--bg-tint);
  color: var(--ink-700);
  font-size: var(--fs-xs);
  font-weight: 500;
  transition: border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.chip:hover {
  border-color: var(--blue-700);
  color: var(--blue-700);
  background: #fff;
}

.ai-panel__form {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4);
  border-top: 1px solid var(--line);
  background: #fff;
}
.ai-panel__form input {
  flex: 1;
  height: 40px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--ink-900);
  background: var(--bg-tint);
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.ai-panel__form input:focus {
  outline: none;
  border-color: var(--blue-700);
  background: #fff;
}
.ai-panel__form button {
  width: 40px; height: 40px;
  border-radius: var(--r-2);
  background: var(--ink-900);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease-out);
}
.ai-panel__form button:hover { background: var(--blue-700); }
.ai-panel__form button svg { width: 16px; height: 16px; }

/* ============ BACK TO TOP ============ */

.to-top {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 40;
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  background: #fff;
  color: var(--ink-900);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.to-top[hidden] { display: none; }
.to-top[data-visible="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.to-top:hover {
  background: var(--ink-900);
  color: #fff;
}
.to-top svg { width: 24px; height: 24px; }

/* Stack offset on mobile so AI and to-top do not overlap */
@media (max-width: 560px) {
  .ai-launcher { height: 48px; padding-right: var(--s-3); }
  .ai-launcher svg { width: 32px; height: 32px; padding: 6px; }
  .to-top { width: 40px; height: 40px; bottom: calc(var(--s-5) + 56px); }
}

/* ============ CARDS (shared) ============ */

.cat-card,
.prod-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  transition:
    transform var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out),
    box-shadow var(--t-med) var(--ease-out);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.cat-card:hover,
.prod-card:hover {
  transform: translateY(-3px);
  border-color: var(--blue-400);
  box-shadow: var(--shadow-2);
}

/* Signal arc ripple on cat-card hover */
.cat-card::before {
  content: "";
  position: absolute;
  inset: auto -30% -50% auto;
  width: 180px; height: 180px;
  background: var(--signal);
  filter: blur(48px);
  opacity: 0;
  z-index: -1;
  transition: opacity var(--t-med) var(--ease-out);
}
.cat-card:hover::before { opacity: 0.35; }
