/* Portman — link hover: accent fill rises from bottom */

:root {
  --portman-link-fill-duration: 0.4s;
  --portman-link-fill-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Shared “fill from bottom” targets. Nested so the selector list (and its
   exclusions) is written once for the resting state, the accent ::before,
   and both hover variants — instead of being repeated per rule. */
@media screen and (pointer: fine) {
  :is(
      a.link,
      a.reversed-link,
      .rte a,
      .breadcrumb a,
      .footer a.link,
      .footer a.reversed-link,
      .mega-menu a.reversed-link,
      .mega-menu a.link,
      .mega-menu .mega-menu__link,
      .mega-menu a.mega-menu__nav-item,
      .mega-menu button.mega-menu__nav-item,
      .mega-menu__nav a.reversed-link,
      .dropdown__nav a.reversed-link,
      .localization a.reversed-link,
      .modal__content a.reversed-link,
      a[is='magnet-link'],
      a[is='hover-link']
    ):not(
      .button,
      .menu__item,
      .shopify-payment-button__button--unbranded,
      .social_platform,
      .cart-drawer-button,
      .search-drawer-button,
      .menu-drawer-button,
      .menu-toggle-button,
      .quick-view__button,
      .product__thumbnail,
      .indicators a,
      .pagination .page,
      .mega-menu__footer a
    ) {
    transition: color var(--portman-link-fill-duration) var(--portman-link-fill-ease);

    /* Empty-cart collection links keep the accent fill below, but use the
       theme's own pill background instead of a transparent reset. */
    &:not(:is(.drawer__empty-collections *)) {
      position: relative;
      z-index: 0;
      isolation: isolate;
      text-decoration: none !important;
      background: none !important;
    }

    &::before {
      content: '';
      position: absolute;
      z-index: -1;
      left: -0.12em;
      right: -0.12em;
      top: -0.06em;
      bottom: -0.06em;
      background-color: rgb(var(--portman-accent-rgb, 255 60 0));
      border-radius: 2px;
      transform: scaleY(0);
      transform-origin: center bottom;
      transition: transform var(--portman-link-fill-duration) var(--portman-link-fill-ease);
      pointer-events: none;
    }

    &:hover:not([aria-disabled]),
    &:focus-visible:not([aria-disabled]) {
      color: rgb(255 255 255) !important;
    }

    &:hover:not([aria-disabled])::before,
    &:focus-visible:not([aria-disabled])::before {
      transform: scaleY(1);
    }

    @media (prefers-reduced-motion: reduce) {
      &::before {
        transition: none;
      }
    }
  }

  a.link.icon-with-text:not([aria-disabled]):hover .link-text,
  a.reversed-link.icon-with-text:not([aria-disabled]):hover .link-text,
  .mega-menu a.icon-with-text:not(.mega-menu__footer a):not([aria-disabled]):hover .link-text,
  .mega-menu button.mega-menu__nav-item.icon-with-text:hover:not(:disabled) .link-text {
    color: rgb(255 255 255) !important;
    background: none !important;
  }

  /* Mega menu categories — solid white on accent fill (no faded / alpha text) */
  .mega-menu__nav :is(a.reversed-link, a.link, a.heading):hover:not([aria-disabled]),
  .mega-menu__nav :is(a.reversed-link, a.link, a.heading):focus-visible:not([aria-disabled]),
  .mega-menu__nav ul a:hover:not([aria-disabled]),
  .mega-menu__nav ul a:focus-visible:not([aria-disabled]),
  .mega-menu a.mega-menu__nav-item:hover:not([aria-disabled]),
  .mega-menu a.mega-menu__nav-item:focus-visible:not([aria-disabled]),
  .mega-menu button.mega-menu__nav-item:hover:not(:disabled),
  .mega-menu button.mega-menu__nav-item:focus-visible:not(:disabled) {
    --tw-text-opacity: 1;
    color: rgb(255 255 255 / 1) !important;
    opacity: 1 !important;
    -webkit-text-fill-color: rgb(255 255 255) !important;
    transition: color 0s !important;
  }

  .mega-menu__nav a:is(.reversed-link, .link, .heading):hover:not([aria-disabled]),
  .mega-menu__nav a:is(.reversed-link, .link, .heading):focus-visible:not([aria-disabled]),
  .mega-menu__nav ul a:hover:not([aria-disabled]),
  .mega-menu__nav ul a:focus-visible:not([aria-disabled]) {
    background-image: none !important;
  }

  .mega-menu :is(a.mega-menu__nav-item, button.mega-menu__nav-item):hover:not(:disabled) :is(.heading, .link-text, span, [data-text]),
  .mega-menu :is(a.mega-menu__nav-item, button.mega-menu__nav-item):focus-visible:not(:disabled) :is(.heading, .link-text, span, [data-text]) {
    --tw-text-opacity: 1;
    color: rgb(255 255 255 / 1) !important;
    opacity: 1 !important;
    -webkit-text-fill-color: rgb(255 255 255) !important;
    background-image: none !important;
  }
}

/* Mega menu panel — match the header bar's own resting look (frosted
   dark glass) instead of a flat opaque fill, so the dropdown reads as
   an extension of the header rather than a different surface. */
.mega-menu__container {
  background-color: rgb(var(--color-background) / 0.52) !important;
  backdrop-filter: blur(20px) saturate(1.1) !important;
  -webkit-backdrop-filter: blur(20px) saturate(1.1) !important;
}

/* Top bar nav pills — theme block / dot only (no Portman fill) */
.header .header__menu :is(a.menu__item, magnet-element.menu__item) {
  isolation: auto;
  z-index: auto;
}

.header .header__menu :is(a.menu__item, magnet-element.menu__item)::before {
  content: none !important;
  display: none !important;
}

/* Do NOT zero background on a.menu__item — plain links (OUR STORY) must
   keep the same pill fill as magnet-element triggers (ALL PRODUCTS). */

.header .header__menu a.menu__item:hover,
.header .header__menu a.menu__item:focus-visible,
.header .header__menu details[open] > summary .menu__item {
  color: inherit !important;
}

/* Main nav pills + language/currency switcher — same solid look AND
   the same hover effect as Add to cart (.button--primary): flat dark
   fill, sharp corners, and a light circle that rises to cover the
   button on hover (driven by the shared theme.js HoverButton via
   [data-fill], the exact mechanism behind .button .btn-fill — just
   applied to .menu__item instead of .button). Real spacing between
   items instead of a glued row. */
.header__menu > ul.with-block {
  gap: 0.5rem !important;
}

.header__menu > ul.with-block .menu__item,
.header__menu > ul.with-block a.menu__item,
.header__menu > ul.with-block magnet-element.menu__item {
  border-radius: 0 !important;
  color: rgb(var(--color-button-text)) !important;
  background: rgb(var(--color-button-background)) !important;
  background-color: rgb(var(--color-button-background)) !important;
}

/* Wrapper around plain nav links (OUR STORY) — no extra chrome */
.header__menu > ul > li > a.header-nav-plain-link {
  text-decoration: none !important;
  color: inherit !important;
  background: transparent !important;
  background-image: none !important;
}

.header__menu > ul > li > a.header-nav-plain-link::before {
  content: none !important;
  display: none !important;
}

.header__menu > ul.with-block .localization .menu__item {
  border: none !important;
}

/* Label stays put — never shrinks/fades, unlike the theme's default
   block-reveal (which hid it in favour of .btn-duplicate). Lifted above
   the fill with its own stacking context. */
.header__menu > ul.with-block .menu__item .btn-text:not(.btn-duplicate) {
  position: relative;
  z-index: 2;
  opacity: 1 !important;
  transform: none !important;
}

/* The theme's own duplicate label (used for its default shrink/slide
   reveal) is redundant now — replaced by the real circular fill below. */
.header__menu > ul.with-block .menu__item .btn-duplicate {
  display: none !important;
}

/* Add to cart fill: a circle tucked above the button that theme.js's
   HoverButton animates down to cover it on hover/focus (identical
   geometry to `.button .btn-fill`). Default tint is a dark grey — used
   by the localization/currency switcher and the scrollspy bar. */
.header__menu > ul.with-block .menu__item .btn-fill {
  display: block;
  position: absolute;
  z-index: 1;
  inset-block-start: -50%;
  inset-inline-start: -25%;
  width: 150%;
  height: 200%;
  border-radius: 50%;
  background-color: rgb(58 58 58);
  transform: translate3d(0, -76%, 0);
  pointer-events: none;
}

/* Main header nav (not the localization/currency switcher, not the
   scrollspy bar) gets the same accent-colored fill as Add to cart,
   with the label swapping to the dark background color for contrast
   once the accent circle covers the button. */
.header__navigation .header__menu > ul.with-block .menu__item .btn-fill {
  background-color: rgb(var(--portman-accent-rgb)) !important;
}

.header__navigation .header__menu > ul.with-block .menu__item:is(:hover, :focus-visible) .btn-text:not(.btn-duplicate),
.header__navigation .header__menu > ul.with-block .menu__item:is(:hover, :focus-visible) [data-text] {
  color: rgb(var(--color-button-background)) !important;
}

/* Theme hides [data-text] on li:hover for the duplicate-label swap — keep
   the real label visible in the main nav (btn-duplicate is disabled). */
@media screen and (pointer: fine) {
  .header__navigation .header__menu > ul.with-block > li:hover .menu__item [data-text] {
    opacity: 1 !important;
    transform: none !important;
  }
}

.header__navigation .header__menu > ul.with-block .menu__item .btn-text:not(.btn-duplicate),
.header__navigation .header__menu > ul.with-block .menu__item [data-text] {
  transition: color 0.2s ease;
}

/* Section currently in view — its scrollspy link stays lit one shade
   lighter than the resting pills, kept for as long as that section is
   active (not just on hover). */
.header__menu > ul.with-block .scrollspy-link.active {
  background-color: rgb(38 38 38) !important;
}

/* Defensive sizing for the currency switcher's country flag — keeps it
   pinned to a small square regardless of the source image's native size. */
.header__menu > ul.with-block .localization .country-flag {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0;
}

.header__menu > ul.with-block .localization .country-flag img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  object-fit: cover;
}

/* Collection/search “Sort by” — radio labels use the same accent fill
   from the bottom as .dropdown__nav a.reversed-link (currency list). */
@media screen and (pointer: fine) {
  .sort-dropdown .dropdown__nav label.reversed-link {
    position: relative;
    z-index: 0;
    isolation: isolate;
    display: block;
    width: 100%;
    cursor: pointer;
    text-decoration: none !important;
    background: none !important;
    background-image: none !important;
    transition: color var(--portman-link-fill-duration) var(--portman-link-fill-ease);

    &::before {
      content: '';
      position: absolute;
      z-index: -1;
      left: -0.12em;
      right: -0.12em;
      top: -0.06em;
      bottom: -0.06em;
      background-color: rgb(var(--portman-accent-rgb, 255 60 0));
      border-radius: 2px;
      transform: scaleY(0);
      transform-origin: center bottom;
      transition: transform var(--portman-link-fill-duration) var(--portman-link-fill-ease);
      pointer-events: none;
    }

    &:hover:not(.active),
    &:focus-visible:not(.active) {
      color: rgb(255 255 255) !important;
      background-image: none !important;
    }

    &:hover:not(.active)::before,
    &:focus-visible:not(.active)::before {
      transform: scaleY(1);
    }

    @media (prefers-reduced-motion: reduce) {
      &::before {
        transition: none;
      }
    }
  }
}

/* Slide-out drawers — links match header dropdown / mega menu */
@media screen and (pointer: fine) {
  .drawer
    :is(a.link, a.reversed-link, a[is='hover-link'], a[is='magnet-link']):not(
      .button,
      .menu__item,
      .social_platform,
      .quick-view__button
    ) {
    transition: color var(--portman-link-fill-duration) var(--portman-link-fill-ease);

    &:not(:is(.drawer__empty-collections *)) {
      position: relative;
      z-index: 0;
      isolation: isolate;
      text-decoration: none !important;
      background: none !important;
      background-image: none !important;
    }

    &::before {
      content: '';
      position: absolute;
      z-index: -1;
      left: -0.12em;
      right: -0.12em;
      top: -0.06em;
      bottom: -0.06em;
      background-color: rgb(var(--portman-accent-rgb, 255 60 0));
      border-radius: 2px;
      transform: scaleY(0);
      transform-origin: center bottom;
      transition: transform var(--portman-link-fill-duration) var(--portman-link-fill-ease);
      pointer-events: none;
    }

    &:hover:not([aria-disabled]),
    &:focus-visible:not([aria-disabled]) {
      color: rgb(255 255 255) !important;
      background-image: none !important;
    }

    &:hover:not([aria-disabled])::before,
    &:focus-visible:not([aria-disabled])::before {
      transform: scaleY(1);
    }
  }
}

/* Empty cart — theme pill (global .reversed-link reset above must not apply here) */
.cart-drawer .drawer__empty-collections :is(a.link, a.reversed-link) {
  position: relative;
  z-index: 0;
  isolation: isolate;
  text-decoration: none !important;
  background-color: rgb(var(--color-foreground) / 0.025) !important;
  transition: background-color var(--animation-primary);
}

/* Product list + mega-menu media — swap image on hover, don't zoom it */
@media screen and (pointer: fine) {
  .product-card__media:hover > .media > img,
  .product-card__media:hover .product-card__model > img,
  .product-card__media:hover .product-card__secondary > img,
  .product-card__media:hover video-media > img,
  .horizontal-product__media:hover img,
  .media-card__link:hover .media img {
    transform: none !important;
  }

  .portman-mega-products__link:hover .portman-mega-products__image,
  .portman-mega-products__link:focus-visible .portman-mega-products__image {
    transform: none !important;
  }
}
