/* Shared site chrome: header + footer (no Tailwind preflight) */

/* Global alert — top of page, scrolls away (not sticky) */
#qm-global-alert {
  position: absolute;
  z-index: 110;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0.75rem;
  background-color: rgb(0 0 0 / 0.5);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

#qm-global-alert p {
  margin: 0;
  text-transform: uppercase;
  line-height: 1;
  height: 16px;
}

body.single-product #qm-global-alert,
body.single-product #qm-global-alert p {
  background-color: #fff;
  color: #1b1815;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.site-header {
  color: #fff;
  isolation: isolate;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to top, transparent, rgb(0 0 0 / 0.5));
}

.site-header .nav-link {
  position: relative;
  border-radius: 0.375rem;
  padding: 0.65rem 0.85rem;
  opacity: 0.8;
  transition:
    opacity 0.3s ease-out,
    background-color 0.3s ease-out;
}

/* Nav items wait for logo assemble, then reveal L→R (desktop only).
   First visit only — boot adds html.qm-nav-intro; without that class the header stays visible. */
@media (min-width: 1024px) {
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(1),
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(2),
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(4),
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(5) {
    opacity: 0;
    pointer-events: none;
    will-change: opacity, transform;
  }

  /* Shop */
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(1) {
    transform: translateX(1rem);
    animation: nav-item-in-from-right 0.5s ease-out 2.75s forwards;
  }

  /* Inspiration */
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(2) {
    transform: translateX(0.75rem);
    animation: nav-item-in-from-right 0.5s ease-out 2.95s forwards;
  }

  /* About us */
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(4) {
    transform: translateX(-0.75rem);
    animation: nav-item-in-from-left 0.5s ease-out 3.15s forwards;
  }

  /* Support */
  html.qm-nav-intro:not(.qm-nav-intro-done) .site-header .site-header__nav > li:nth-child(5) {
    transform: translateX(-1rem);
    animation: nav-item-in-from-left 0.5s ease-out 3.35s forwards;
  }
}

@keyframes nav-item-in-from-right {
  from {
    opacity: 0;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }
}

@keyframes nav-item-in-from-left {
  from {
    opacity: 0;
    transform: translateX(-1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }
}

.site-header__cart-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.45rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: 0.35rem;
  border-radius: 9999px;
  background-color: #dc2626;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.site-header__cart-badge[hidden] {
  display: none !important;
}

.site-header .nav-link:hover {
  opacity: 1;
  background-color: rgb(255 255 255 / 0.1);
}

.site-header__logo-link {
  position: relative;
  display: block;
  overflow: visible;
}

.site-header__logo {
  display: block;
  width: auto;
  overflow: visible;
  transition:
    filter 0.45s ease,
    height 0.35s ease;
}

/* Medium — default top size on most pages */
body.qm-logo-size-md .site-header__logo {
  height: 6.5rem;
}

@media (min-width: 768px) {
  body.qm-logo-size-md .site-header__logo {
    height: 8rem;
  }
}

/* Large — homepage + about us at the top */
body.qm-logo-size-lg .site-header__logo {
  height: 9rem;
}

@media (min-width: 768px) {
  body.qm-logo-size-lg .site-header__logo {
    height: 11.5rem;
  }
}

/* Small — shared scrolled size on every page */
.site-header.is-scrolled .site-header__logo,
body.qm-logo-size-md .site-header.is-scrolled .site-header__logo,
body.qm-logo-size-lg .site-header.is-scrolled .site-header__logo {
  height: 5.5rem;
}

@media (min-width: 768px) {
  .site-header.is-scrolled .site-header__logo,
  body.qm-logo-size-md .site-header.is-scrolled .site-header__logo,
  body.qm-logo-size-lg .site-header.is-scrolled .site-header__logo {
    height: 6.75rem;
  }
}

.site-header__logo .logo-layer {
  transform-box: fill-box;
  transform-origin: center;
  will-change: opacity, transform;
}

html.qm-nav-intro:not(.qm-nav-intro-done) .site-header__logo .logo-layer--bg {
  opacity: 0;
  transform: scale(0);
  animation: logo-layer-bg-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

html.qm-nav-intro:not(.qm-nav-intro-done) .site-header__logo .logo-layer--wordmark {
  opacity: 0;
  transform: scale(1.075);
  animation: logo-layer-wordmark-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) 1.05s forwards;
}

html.qm-nav-intro:not(.qm-nav-intro-done) .site-header__logo .logo-layer--bar {
  opacity: 0;
  transform: scale(0.15);
  animation: logo-layer-bar-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) 1.7s forwards;
}

html.qm-nav-intro:not(.qm-nav-intro-done) .site-header__logo .logo-layer--detail {
  opacity: 0;
  animation: logo-layer-detail-in 0.45s ease-out 2.15s forwards;
}

@keyframes logo-layer-bg-in {
  from {
    opacity: 0;
    transform: scale(0);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logo-layer-wordmark-in {
  from {
    opacity: 0;
    transform: scale(1.075);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logo-layer-bar-in {
  from {
    opacity: 0;
    transform: scale(0.15);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logo-layer-detail-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Light reflection — clipped to the hexagon background layer */
.site-header__logo-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgb(255 255 255 / 0) 40%,
    rgb(255 255 255 / 0.32) 50%,
    rgb(255 236 200 / 0.16) 58%,
    transparent 78%
  );
  background-size: 240% 100%;
  background-position: 160% 0;
  opacity: 0;
  mix-blend-mode: screen;
  -webkit-mask-image: url(../src/images/logo-quarrymill-bg.svg);
  mask-image: url(../src/images/logo-quarrymill-bg.svg);
  -webkit-mask-source-type: alpha;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  will-change: background-position, opacity;
}

html.qm-nav-intro:not(.qm-nav-intro-done) .site-header:not(.is-scrolled) .site-header__logo-link::before {
  /* Tucks in right as the bg scale settles; wordmark follows closely */
  animation: site-header-logo-shimmer 1.6s ease-in-out 0.4s 1 forwards;
}

.site-header.is-scrolled .site-header__logo-link::before {
  animation: none;
  opacity: 0;
}

@keyframes site-header-logo-shimmer {
  0%,
  14% {
    background-position: 160% 0;
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  42% {
    background-position: -160% 0;
    opacity: 1;
  }

  48%,
  100% {
    background-position: -160% 0;
    opacity: 0;
  }
}


/* Site footer (chrome) */
.site-footer {
  position: relative;
  z-index: 10;
  padding-block: 4rem 2rem;
  background-color: #f5f5f5;
  color: #525252;
}

.site-footer__inner {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.site-footer__grid {
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 1024px) {
  .site-footer__grid {
    grid-template-columns: 1.8fr repeat(5, minmax(0, 0.85fr));
  }
}

.site-footer__brand {
  max-width: 24rem;
}

.site-footer__logo {
  display: block;
  width: 7rem;
  height: 7rem;
}

.site-footer__blurb {
  margin-top: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: #737373;
}

/* Mobile: nav columns + copyright/socials only (no logo/blurb) */
@media (max-width: 1023.98px) {
  .site-footer__brand {
    display: none;
  }

  /* Two nav columns on typical phones; stack only on very narrow widths */
  .site-footer__grid {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    column-gap: 1rem;
    row-gap: 2rem;
  }
}

.site-footer__heading {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: #171717;
}

.site-footer__list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: #525252;
}

.site-footer__list li + li {
  margin-top: 0.5rem;
}

.site-footer__list a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer__list a:hover {
  color: #171717;
}

.site-footer__bottom {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #d4d4d4;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: center;
}

@media (min-width: 640px) {
  .site-footer__bottom {
    flex-direction: row;
    align-items: center;
    text-align: left;
  }
}

.site-footer__copy {
  margin: 0;
  font-size: 0.75rem;
  color: #737373;
}

.site-footer__social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #171717;
}

.site-footer__social a {
  color: inherit;
  transition: opacity 0.2s ease;
}

.site-footer__social a:hover {
  opacity: 0.7;
}

.site-footer__social svg {
  display: block;
  width: 1rem;
  height: 1rem;
}

.site-footer .link-underline {
  position: relative;
  display: inline-block;
}

.site-footer .link-underline::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease-out;
}

.site-footer .link-underline:hover::after {
  transform: scaleX(1);
}

/* Header layout (replaces Tailwind utilities on the chrome header) */
.site-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  padding: 1.25rem 1.5rem 1.75rem;
}

/* Sit under the top notification until sticky kicks in */
body.qm-has-global-alert .site-header:not(.is-sticky) {
  top: 40px;
}

/* Homepage only: pin to viewport after scrolling past the notification */
.site-header.is-sticky {
  position: fixed;
  top: 0;
}

.site-header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 1rem;
  font-weight: 600;
}

@media (min-width: 768px) {
  .site-header__nav {
    gap: 3rem;
  }
}

.site-header__nav > li.site-header__logo-item {
  margin-inline: 0.25rem;
}

@media (min-width: 768px) {
  .site-header__nav > li.site-header__logo-item {
    margin-inline: 0.5rem;
  }
}

/* —— Mobile hamburger —— */
.site-header__menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0.375rem;
  /* Match the open mobile nav panel */
  background: #1b1815;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.site-header__menu-toggle:hover,
.site-header__menu-toggle:focus-visible {
  background-color: #1b1815;
  color: #fff;
  outline: none;
}

body.single-product .site-header__menu-toggle,
body.single-product .site-header__menu-toggle:hover,
body.single-product .site-header__menu-toggle:focus-visible {
  background-color: #fff;
  color: #1b1815;
}

.site-header__menu-icon {
  position: relative;
  display: block;
  width: 1.35rem;
  height: 0.875rem;
}

.site-header__menu-icon span {
  position: absolute;
  left: 0;
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition:
    transform 0.28s ease,
    opacity 0.2s ease,
    top 0.28s ease;
}

.site-header__menu-icon span:nth-child(1) {
  top: 0;
}

.site-header__menu-icon span:nth-child(2) {
  top: calc(50% - 1px);
}

.site-header__menu-icon span:nth-child(3) {
  top: calc(100% - 2px);
}

.site-header.is-menu-open .site-header__menu-icon span:nth-child(1) {
  top: calc(50% - 1px);
  transform: rotate(45deg);
}

.site-header.is-menu-open .site-header__menu-icon span:nth-child(2) {
  opacity: 0;
}

.site-header.is-menu-open .site-header__menu-icon span:nth-child(3) {
  top: calc(50% - 1px);
  transform: rotate(-45deg);
}

.site-header__drawer {
  display: none;
}

.site-header__drawer-nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

body.qm-menu-open {
  overflow: hidden;
}

/* Keep hero / blend layers from showing through the full-screen menu */
body.qm-menu-open #hero,
body.qm-menu-open .hero-effect {
  visibility: hidden;
}

body.qm-menu-open #qm-global-alert {
  visibility: hidden;
}

@media (max-width: 1023.98px) {
  .site-header {
    padding: 0.85rem 1rem 1rem;
  }

  .site-header.is-menu-open {
    z-index: 120;
    background: transparent;
  }

  .site-header.is-menu-open::before {
    opacity: 0;
  }

  .site-header__menu-toggle {
    display: flex;
    position: absolute;
    right: 0.65rem;
    top: 0.85rem;
    z-index: 5;
  }

  /* Crest only in the top bar; text links live in the drawer */
  .site-header__nav {
    gap: 0;
  }

  .site-header__nav > li:not(.site-header__logo-item) {
    display: none;
  }

  .site-header__nav-wrap {
    position: relative;
    z-index: 2;
    pointer-events: none;
  }

  .site-header__nav-wrap .site-header__logo-link {
    pointer-events: auto;
  }

  /* Crest must not steal taps from drawer links while the menu is open */
  .site-header.is-menu-open .site-header__nav-wrap,
  .site-header.is-menu-open .site-header__nav-wrap .site-header__logo-link {
    pointer-events: none;
  }

  .site-header__drawer {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: fixed;
    inset: 0;
    z-index: 4;
    isolation: isolate;
    box-sizing: border-box;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    /* Clear the crest so links never sit under it */
    padding: 10.5rem 1.75rem 2.5rem;
    background: transparent;
    color: #fff;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear 0.45s;
  }

  /* Panel fill scales out from the hamburger (top-right) */
  .site-header__drawer::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: #1b1815;
    border-radius: 1.25rem;
    transform: scale(0.02);
    transform-origin: calc(100% - 2.05rem) 2.25rem;
    transition:
      transform 0.48s cubic-bezier(0.22, 1, 0.36, 1),
      border-radius 0.42s ease;
    will-change: transform;
    pointer-events: none;
  }

  .site-header.is-menu-open .site-header__drawer {
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .site-header.is-menu-open .site-header__drawer::before {
    transform: scale(1);
    border-radius: 0;
  }

  .site-header.is-menu-open .site-header__drawer[hidden] {
    display: flex;
  }

  .site-header__drawer-nav {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 1.5rem;
    font-weight: 600;
  }

  .site-header__drawer-nav > li {
    opacity: 0;
    transform: translateY(0.75rem);
  }

  .site-header.is-menu-open .site-header__drawer-nav > li {
    animation: drawer-item-in 0.42s ease-out forwards;
  }

  /* Start after the panel has begun expanding from the icon */
  .site-header.is-menu-open .site-header__drawer-nav > li:nth-child(1) {
    animation-delay: 0.18s;
  }

  .site-header.is-menu-open .site-header__drawer-nav > li:nth-child(2) {
    animation-delay: 0.26s;
  }

  .site-header.is-menu-open .site-header__drawer-nav > li:nth-child(3) {
    animation-delay: 0.34s;
  }

  .site-header.is-menu-open .site-header__drawer-nav > li:nth-child(4) {
    animation-delay: 0.42s;
  }

  .site-header__drawer-nav .nav-link {
    position: relative;
    z-index: 2;
    display: block;
    padding: 0.95rem 0.75rem;
    opacity: 1;
    border-radius: 0.375rem;
    pointer-events: auto;
  }

  .site-header__drawer-nav .nav-link:hover,
  .site-header__drawer-nav .nav-link:focus-visible {
    opacity: 1;
    background-color: rgb(255 255 255 / 0.1);
    outline: none;
  }

  body.single-product .site-header__drawer {
    color: #1b1815;
  }

  body.single-product .site-header__drawer::before {
    background: #fff;
  }

  body.single-product .site-header__drawer-nav .nav-link:hover,
  body.single-product .site-header__drawer-nav .nav-link:focus-visible {
    background-color: rgb(0 0 0 / 0.06);
  }
}

@media (min-width: 1024px) {
  .site-header__menu-toggle,
  .site-header__drawer {
    display: none !important;
  }
}

@keyframes drawer-item-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*
  Final state when the intro has already played (or visitor prefers reduced motion).
  Boot script sets html.qm-nav-intro-done before paint; without qm-nav-intro the
  header stays at its default visible styles. prefers-reduced-motion is a backup.
*/
html.qm-nav-intro-done .site-header .site-header__nav > li:nth-child(1),
html.qm-nav-intro-done .site-header .site-header__nav > li:nth-child(2),
html.qm-nav-intro-done .site-header .site-header__nav > li:nth-child(4),
html.qm-nav-intro-done .site-header .site-header__nav > li:nth-child(5),
html.qm-nav-intro-done .site-header__logo .logo-layer--bg,
html.qm-nav-intro-done .site-header__logo .logo-layer--wordmark,
html.qm-nav-intro-done .site-header__logo .logo-layer--bar,
html.qm-nav-intro-done .site-header__logo .logo-layer--detail {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  animation: none;
  will-change: auto;
}

html.qm-nav-intro-done .site-header__logo-link::before {
  animation: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .site-header .site-header__nav > li:nth-child(1),
  .site-header .site-header__nav > li:nth-child(2),
  .site-header .site-header__nav > li:nth-child(4),
  .site-header .site-header__nav > li:nth-child(5),
  .site-header__logo .logo-layer--bg,
  .site-header__logo .logo-layer--wordmark,
  .site-header__logo .logo-layer--bar,
  .site-header__logo .logo-layer--detail {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    animation: none !important;
    will-change: auto;
  }

  .site-header__logo-link::before {
    animation: none !important;
    opacity: 0;
  }
}

/* Product pages sit on a light surface: white fade, black nav text. */
body.single-product .site-header,
body.single-product .site-header .nav-link {
  color: #1b1815;
  opacity: 1;
}

body.single-product .site-header::before {
  background: linear-gradient(
    to bottom,
    #fff 0%,
    rgb(255 255 255 / 0.92) 42%,
    rgb(255 255 255 / 0) 100%
  );
}

body.single-product .site-header .nav-link:hover {
  background-color: rgb(0 0 0 / 0.06);
}
