*,
*::after,
*::before {
  box-sizing: border-box;
}

:root {
  font-size: 14px;
  --color-text: #151515;
  --color-bg: #fff;
  --color-link: #151515;
  --color-link-hover: #000000;
  --color-close: #a22d1d;
  --page-padding: 1.5rem;
  --c-gap: 0.5rem;
  --column: 80px;
  --column-count: 4;
  --aspect: 4/5;
  --font-size-l: 18px;
  --font-size-xl: clamp(2rem, 10vw, 6rem);
  --panel-gap: 1rem;
  --panel-img-size: calc((100vh - var(--page-padding) * 2) * 4 / 5 - var(--panel-gap));
}

body {
  margin: 0;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-family: 'halyard-display', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.2;
  text-transform: lowercase;
}

@media (scripting: enabled) {
  .loading {
    &::before,
    &::after {
      content: '';
      position: fixed;
      z-index: 10000;
    }

    &::before {
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--color-bg);
    }

    &::after {
      top: 50%;
      left: 50%;
      width: 100px;
      height: 1px;
      margin: 0 0 0 -50px;
      background: var(--color-link);
      animation: loaderAnim 1.5s ease-in-out infinite alternate forwards;
    }
  }
}

@keyframes loaderAnim {
  0% {
    transform: scaleX(0);
    transform-origin: 0% 50%;
  }

  50% {
    transform: scaleX(1);
    transform-origin: 0% 50%;
  }

  50.1% {
    transform: scaleX(1);
    transform-origin: 100% 50%;
  }

  100% {
    transform: scaleX(0);
    transform-origin: 100% 50%;
  }
}

a {
  text-decoration: none;
  color: var(--color-link);
  outline: none;
  cursor: pointer;

  &:hover {
    text-decoration: none;
    color: var(--color-link-hover);
  }

  &:focus {
    outline: none;
    background: lightgrey;

    &:not(:focus-visible) {
      background: transparent;
    }

    &:focus-visible {
      outline: 2px solid red;
      background: transparent;
    }
  }
}

.line {
  display: inline-block;
  overflow: hidden;
  position: relative;
  vertical-align: top;

  &::before {
    background: currentColor;
    bottom: 0;
    content: '';
    height: 1px;
    left: 0;
    position: absolute;
    transition: transform 0.4s ease;
    width: 100%;
    transform: scaleX(0);
    transform-origin: right center;
  }

  &:hover::before {
    transform: scaleX(1);
    transform-origin: left center;
  }
}

main {
  padding: var(--page-padding);
}

.frame {
  font-size: var(--font-size-l);
  font-weight: 500;
  display: grid;
  z-index: 1000;
  width: 100%;
  position: relative;
  grid-column-gap: var(--c-gap);
  grid-row-gap: 0.5rem;
  pointer-events: none;
  justify-items: start;
  grid-template-columns: auto;
  grid-template-areas:
    'title'
    'links'
    'tags'
    'sponsor';

  #cdawrap {
    justify-self: start;
    grid-area: sponsor;
  }

  a,
  button {
    pointer-events: auto;
    color: var(--color-text);
  }

  .frame__title {
    font-size: inherit;
    margin: 0;
    font-weight: inherit;
    grid-area: title;
  }

  .frame__tags,
  .frame__links {
    grid-area: tags;
    display: flex;
    gap: 0.5rem;
    align-items: start;
  }

  .frame__links {
    grid-area: links;
  }

  &.frame--footer {
    display: flex;
    min-height: 300px;
    align-items: end;
    justify-content: space-between;
  }

  @media screen and (min-width: 65em) {
    grid-template-columns: repeat(var(--column-count), minmax(var(--column), 1fr));
    grid-template-areas: 'title title links links tags tags ... sponsor';
  }
}

.heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 10rem 0 1rem;
}

.heading__title {
  font-family: 'owners-xnarrow', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--font-size-xl);
  margin: 0;
  line-height: 0.77;
}

.heading__meta::after {
  content: '\00B7';
  font-family: serif;
  font-size: 3.5rem;
  line-height: 0.2;
  vertical-align: middle;
  margin-left: 0.5rem;
  display: inline-flex;
}

.grid {
  padding: 1rem 0;
  display: grid;
  grid-template-columns: repeat(var(--column-count), minmax(var(--column), 1fr));
  grid-column-gap: var(--c-gap);
  grid-row-gap: 5rem;
}

.grid__item {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  cursor: pointer;
  will-change: transform, clip-path;
  overflow: hidden;
}

.grid__item:hover .grid__item-image {
  opacity: 0.7;
}

.grid__item-image {
  width: 100%;
  aspect-ratio: var(--aspect);
  background-size: 100%;
  background-position: 50% 50%;
  transition: opacity 0.15s cubic-bezier(0.2, 0, 0.2, 1);
}

.grid__item-caption h3 {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  text-align: right;
}

.grid__item-caption p {
  display: none;
}

.panel {
  position: fixed;
  margin: 0;
  width: 100%;
  height: 100vh;
  padding: var(--page-padding);
  top: 0;
  left: 0;
  display: grid;
  gap: var(--panel-gap);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  will-change: transform, clip-path;
  justify-content: center;
  grid-template-rows: 1fr min-content;
  grid-template-columns: 100%;
  grid-template-areas: 'panel-image' 'panel-content';
  @media screen and (min-width: 40em) {
    grid-template-columns: var(--panel-img-size) 1fr;
    grid-template-areas: 'panel-image panel-content';
    grid-template-rows: 100%;
  }
}

.panel--right {
  @media screen and (min-width: 40em) {
    grid-template-columns: 1fr var(--panel-img-size);
    grid-template-areas: 'panel-content panel-image';
  }
}

.panel__img {
  grid-area: panel-image;
  background-size: cover;
  background-position: center;
  width: 100%;
  height: auto;
  aspect-ratio: var(--aspect);
  @media screen and (min-width: 40em) {
    height: 100%;
    width: auto;
    max-width: 100%;
  }
}

.panel__content {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  text-align: end;
  width: 100%;
}

.panel--right .panel__content {
  align-items: flex-start;
  text-align: left;
  align-items: flex-start;
}

/* Media query adjustments */
@media screen and (max-width: 40em) {
  .panel {
    grid-template-rows: auto auto auto;
    grid-template-areas: 
      "panel-image"
      "product-content"
      "panel-content";
  }
  
  .panel--right {
    grid-template-areas: 
      "panel-image"
      "product-content"
      "panel-content";
  }
  
  .product-content {
    align-self: center;
  }
}

.panel__content h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  font-family: 'halyard-display', sans-serif;
}

.panel__content p {
  margin: 0;
  max-width: 150px;
  text-wrap: pretty;
}

.panel__close {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  color: var(--color-close);
  &:hover,
  &:focus {
    outline: none;
    color: var(--color-link-hover);
  }
}

.mover {
  position: fixed;
  aspect-ratio: var(--aspect);
  background-size: cover;
  background-position: 50% 50%;
  will-change: transform, clip-path;
  pointer-events: none;
}

@media screen and (min-width: 65em) {
  :root {
    --column-count: 8;
  }
}

/* Background image handler - default state before JS initialization */
[data-bg] {
  background-image: none; /* Will be set via JS */
}

/* Ensure consistent background properties for all image elements */
.grid__item-image, 
.panel__img {
  background-size: cover;
  background-position: 50% 50%;
}

/* Blend mode options for mover elements through data attributes */
.mover[data-blend-mode="hard-light"] { mix-blend-mode: hard-light; }
.mover[data-blend-mode="multiply"] { mix-blend-mode: multiply; }
.mover[data-blend-mode="overlay"] { mix-blend-mode: overlay; }
.mover[data-blend-mode="screen"] { mix-blend-mode: screen; }
.mover[data-blend-mode="difference"] { mix-blend-mode: difference; }
.mover[data-blend-mode="exclusion"] { mix-blend-mode: exclusion; }
.mover[data-blend-mode="color-dodge"] { mix-blend-mode: color-dodge; }
.mover[data-blend-mode="color-burn"] { mix-blend-mode: color-burn; }
.mover[data-blend-mode="luminosity"] { mix-blend-mode: luminosity; }

/* Panel content layout */

/* T-shirt display */
.panel__tshirt {
  position: relative;
  width: 200px;
  height: 200px;
}

.panel__tshirt-base {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.panel__tshirt-design {
  position: absolute;
  top: 30%;
  left: 30%;
  width: 40%;
  height: auto;
  object-fit: contain;
}

/* Product card */
.panel__product-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
  margin: 0;
  max-width: 340px;
  align-self: flex-end;
  text-align: end;
}

.panel--right .panel__product-card {
  align-items: flex-start;
  align-self: flex-start;
  text-align: start;
}

.panel__option-label {
  font-family: 'halyard-display', sans-serif;
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-transform: capitalize;
}

.panel__price {
  font-family: 'halyard-display', sans-serif;
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-transform: capitalize;
}

.panel--right .panel__add-to-cart {
  align-self: flex-start;
  justify-content: flex-start;
}

/* Dashed lines */
.panel__dashed-line {
  margin: 0.25rem 0;
  font-size: 0.85rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
}

.panel__dash {
  letter-spacing: 2px;
}

.panel__top-line {
  margin-top: 0;
}

.panel__bottom-line {
  margin-bottom: 0;
  color: #ff0000;
}


/* Color selection */
.panel__color-options,
.panel__size-options {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.panel--right .panel__color-options,
.panel--right .panel__size-options {
  justify-content: flex-start;
}

.panel__color-btn,
.panel__size-btn {
  display: flex;
  align-items: center;
  padding: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.panel__color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin: 0 0.15rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
}


.panel__size-btn:hover .panel__size-text::after,
.panel__size-btn.selected .panel__size-text::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background-color: currentColor;
}

.panel__color-btn:hover .panel__color-dot::after,
.panel__color-btn.selected .panel__color-dot::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background-color: #9e9a9a;
}

/* Size selection */
.panel__size-text {
  position: relative;
}

/* Colors for different sizes */
.panel__size-btn[data-size="S"] .panel__size-text {
  color: #4CAF50;
}

.panel__size-btn[data-size="M"] .panel__size-text {
  color: #2196F3;
}

.panel__size-btn[data-size="L"] .panel__size-text {
  color: #4CAF50;
}

.panel__size-btn[data-size="XL"] .panel__size-text {
  color: #2196F3;
}

.panel__size-btn[data-size="F"] .panel__size-text {
  color: #ff69b4;
}

/* Add to cart button */
.panel__add-to-cart {
  display: inline-flex;
  font-family: 'halyard-display', sans-serif;
  padding: 0.1rem;
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: #a22d1d;
  transition: background-color 0.2s ease;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  justify-content: flex-end;
}

.panel__add-to-cart:hover {
  background-color: rgba(255, 0, 0, 0.05);
}

.panel__add-to-cart .panel__bracket {
  color: #a22d1d;
}

/* Make panel scrollable if needed */
.panel {
  overflow-y: auto;
  max-height: 100vh;
}

/* Responsive adjustments */
@media screen and (max-width: 40em) {
  .panel__top-content {
    width: 100%;
    max-width: none;
  }
  
  .panel__tshirt {
    width: 160px;
    height: 180px;
  }
  
}

/* Override size (and gender) button text color to full black (#151515) */
.panel__product-card .panel__size-btn .panel__size-text {
  color: #151515 !important;
}

/* Add hover/focus effect for size (and gender) buttons */
.panel__size-btn:hover,
.panel__size-btn:focus {
  background-color: #d3d3d3;
}

/* (Optional) Add similar hover/focus effect for color buttons if needed */
.panel__color-btn:hover,
.panel__color-btn:focus {
  background-color: #d3d3d3;
}