/*!
 * app.css — shared interaction styles for the reference site (task T1).
 *
 * Injected by site/assets/js/app.js: build.py owns <head> and only links
 * per-page stylesheets, so this file is loaded from the one place we can add.
 * Everything below is additive; site.css is never modified.
 */

/* ------------------------------------------------------------------ *
 * 1. Visible focus ring for every clickable element.
 *    .btn already ships its own 4px ring in site.css, so it is excluded.
 * ------------------------------------------------------------------ */
:where(a[href], button, [role='button'], summary, [tabindex]:not([tabindex='-1'])):not(.btn):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* pill inputs already light up their container; a second rectangle looks noisy */
.ctcg-search-input:focus-visible,
.ctcg-menu-search input:focus-visible {
  outline: none;
}

/* ------------------------------------------------------------------ *
 * 2. Sticky header: shadow only.
 *    A slimmer padding used to run a 300ms layout animation on every
 *    scroll-state flip; crossing the threshold back and forth made the
 *    hairline under the nav jitter, so the header height is now constant.
 * ------------------------------------------------------------------ */
.ctcg-header.is-scrolled {
  box-shadow: 0 12px 32px -18px rgba(23, 28, 39, 0.45);
}

/* ------------------------------------------------------------------ *
 * 3. Quote-cart badge on the header bag link.
 * ------------------------------------------------------------------ */
.ctcg-cart-link {
  position: relative;
}

.ctcg-cart-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: linear-gradient(118deg, #1b9cff 0%, #52b5ff 36%, #ffe4cc 50%, #ff8d42 64%, #ff6a1f 100%);
  box-shadow: 0 0 0 2px var(--color-surface), 0 2px 6px rgba(23, 28, 39, 0.28);
  color: var(--color-ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.ctcg-cart-badge[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
 * 4. Screen-reader-only helper (live region for the cart).
 * ------------------------------------------------------------------ */
.ctcg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ *
 * 5. Mobile menu: sheet under the header + dimmed backdrop.
 *    The link/button styling comes from the site's own utility classes
 *    (same classes the original React menu renders), so the panel keeps
 *    the site's visual language.
 * ------------------------------------------------------------------ */
.ctcg-menu-toggle {
  position: relative;
}

.ctcg-menu-toggle .ctcg-icon-close {
  display: none;
}

.ctcg-menu-toggle.is-open {
  background: var(--color-surface-container);
  color: var(--color-ink);
}

.ctcg-menu-toggle.is-open .ctcg-icon-menu {
  display: none;
}

.ctcg-menu-toggle.is-open .ctcg-icon-close {
  display: block;
}

.ctcg-menu-backdrop {
  position: fixed;
  z-index: 55;
  top: var(--ctcg-header-h, 73px);
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(23, 28, 39, 0.38);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: ctcg-fade-in 0.18s ease-out;
}

.ctcg-menu {
  position: fixed;
  z-index: 60;
  top: var(--ctcg-header-h, 73px);
  right: 0;
  left: 0;
  max-height: calc(100vh - var(--ctcg-header-h, 73px));
  max-height: calc(100dvh - var(--ctcg-header-h, 73px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.5rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid rgba(23, 28, 39, 0.14);
  box-shadow: 0 28px 48px -28px rgba(23, 28, 39, 0.5);
  animation: ctcg-menu-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ctcg-menu[hidden],
.ctcg-menu-backdrop[hidden] {
  display: none !important;
}

.ctcg-menu-inner {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.ctcg-menu-link {
  display: block;
}

.ctcg-menu-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.375rem 0.5rem 0.375rem 1rem;
  border-radius: 9999px;
  background: var(--color-surface-container);
  transition: box-shadow 0.2s ease;
}

.ctcg-menu-search:focus-within {
  box-shadow: 0 0 0 4px rgba(21, 89, 201, 0.16);
}

.ctcg-menu-search > svg {
  flex: none;
  color: var(--color-outline);
}

.ctcg-menu-search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: var(--color-on-surface);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
}

.ctcg-menu-search input::placeholder {
  color: var(--color-outline);
}

.ctcg-menu-search-submit {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: linear-gradient(118deg, #1b9cff 0%, #52b5ff 36%, #ffe4cc 50%, #ff8d42 64%, #ff6a1f 100%);
  box-shadow: 0 1px 2px rgba(23, 28, 39, 0.16), 0 6px 14px -8px rgba(255, 106, 31, 0.6);
  color: var(--color-ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.ctcg-menu-search-submit:hover {
  transform: translateY(-1px);
}

.ctcg-menu-search-submit:active {
  transform: scale(0.95);
}

@keyframes ctcg-menu-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes ctcg-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* the panel only exists below the md breakpoint, same as the original */
@media (min-width: 768px) {
  .ctcg-menu,
  .ctcg-menu-backdrop {
    display: none !important;
  }
}

/* ------------------------------------------------------------------ *
 * 6. Scroll lock while the mobile menu is open.
 *    --ctcg-sbw compensates the scrollbar so the page does not jump.
 * ------------------------------------------------------------------ */
html.ctcg-scroll-lock {
  overflow: hidden;
  padding-right: var(--ctcg-sbw, 0px);
}

html.ctcg-scroll-lock body {
  overflow: hidden;
}

/* ------------------------------------------------------------------ *
 * 7. Reduced motion: no entrance animation, no hover lift, no badge pop.
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .ctcg-menu,
  .ctcg-menu-backdrop,
  .ctcg-cart-badge {
    animation: none !important;
    transition: none !important;
  }

  .ctcg-menu-search,
  .ctcg-menu-search-submit,
  .ctcg-header,
  .ctcg-header > div:first-child {
    transition: none !important;
  }

  .ctcg-menu-search-submit:hover,
  .ctcg-menu-search-submit:active {
    transform: none;
  }
}
