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

:root {
  font-size: 12px;
  --color-text: #000;
  --color-bg: #fff;
  --color-link: #000;
  --color-link-hover: #333;
  --page-padding: 1.5rem;
}

body {
  margin: 0;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-family: ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@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;
  position: relative;

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

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

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

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

.frame {
  padding: 3rem var(--page-padding) 0;
  display: grid;
  z-index: 1000;
  position: relative;
  grid-row-gap: 1rem;
  grid-column-gap: 2rem;
  pointer-events: none;
  justify-items: start;
  grid-template-columns: auto auto;
  grid-template-areas:
    'title'
    'back'
    'archive'
    'github'
    'demos'
    'tags'
    'sponsor';

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

  a,
  button {
    pointer-events: auto;
  }

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

  .frame__back {
    grid-area: back;
    justify-self: start;
  }

  .frame__archive {
    grid-area: archive;
    justify-self: start;
  }

  .frame__github {
    grid-area: github;
  }

  .frame__back,
  .frame__archive,
  .frame__github {
    text-decoration: none;
  }

  .frame__back:hover,
  .frame__archive:hover,
  .frame__github:hover {
    text-decoration: none;
  }

  .frame__back::after,
  .frame__archive::after,
  .frame__github::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -3px;
    left: 0;
    background-color: var(--color-link-hover);
    transition: width 0.3s ease-in-out;
  }

  .frame__back:hover::after,
  .frame__archive:hover::after,
  .frame__github:hover::after {
    width: 100%;
  }

  .frame__tags {
    grid-area: tags;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .frame__demos {
    grid-area: demos;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }

  @media screen and (min-width: 53em) {
    padding: var(--page-padding);
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    grid-template-columns: auto auto auto auto 1fr;
    grid-template-rows: auto auto;
    align-content: space-between;
    grid-template-areas:
      'title back github archive demos'
      'tags tags tags sponsor sponsor';

    .frame__tags {
      align-self: end;
    }

    .frame__demos,
    #cdawrap {
      justify-self: end;
      text-align: right;
      max-width: 300px;
    }
  }
}

.content {
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  width: 100vw;
  position: relative;

  @media screen and (min-width: 53em) {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
  }
}

.container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: none;
    background-size: 15px 15px;
    padding: 20px;
}

/* Shirts Area */
.shirts-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.rat-center { /* Styles #centerImage */
    position: absolute;
    max-width: 18%;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    user-select: none; 
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
}

.shirt {
    position: absolute;
    max-width: 9.8%;
    height: auto;
    transition: transform 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center center;
    will-change: transform;
}

.shirt.grabbed {
    transform: scale(1.05);
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.15));
}

.shirt.dragging-right {
    transform: perspective(500px) 
              rotateY(-15deg) 
              rotateX(5deg)
              scale(0.92, 0.98) 
              skew(-5deg, 2deg);
    filter: drop-shadow(5px 5px 15px rgba(0,0,0,0.2));
}

.shirt.dragging-left {
    transform: perspective(500px) 
              rotateY(15deg) 
              rotateX(5deg)
              scale(0.92, 0.98) 
              skew(5deg, -2deg);
    filter: drop-shadow(-5px 5px 15px rgba(0,0,0,0.2));
}

.top-left { top: 20%; left: 15%; }
.middle-right { top: 45%; left: 80%; }
.bottom-left { top: 70%; left: 15%; }


/* Tooltip for Model Info */
#info-tooltip {
    position: absolute;
    top: 25%; 
    left: 55%; 
    transform: translate(-50%, -50%); 
    width: 18px; 
    height: 18px; 
    color: rgba(0, 0, 0, 0.6); 
    border: 1px solid rgba(0, 0, 0, 0.6); 
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px; 
    font-weight: bold;
    cursor: help;
    z-index: 15; 
    transition: border-color 0.2s ease, color 0.2s ease; 
    font-family: sans-serif; 
}

#info-tooltip:hover {
    color: rgba(0, 0, 0, 0.9); 
    border-color: rgba(0, 0, 0, 0.9); 
}

#info-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%; 
    left: 50%;
    transform: translateX(-50%); 
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: "Source Code Pro", monospace;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 20;
}

#info-tooltip:hover::after,
#info-tooltip.tooltip-visible::after {
    opacity: 1;
    visibility: visible;
}


/* --- Responsive Styles --- */
@media (max-width: 767px) {
    .container {
        padding-top: 120px; 
        padding-bottom: 5vh;
    }

    .shirts-container {
        padding: 0;
    }

    .shirt {
        max-width: 21%; 
        transition: transform 0.2s ease-out;
    }

    .top-left { top: 25%; left: 5%; }
    .middle-right { top: 40%; left: 75%; }
    .bottom-left { top: 50%; left: 5%; }

    .rat-center { /* Styles #centerImage */
        max-width: 70%;
        top: 45%;
        left: 50%;
        /* transform: translate(-50%, -50%); is inherited */
    }

    #info-tooltip { 
        top: 25%;
        left: 65%;
    }

}

@media (max-width: 377px) {
    #info-tooltip { 
        top: 25%;
        left: 65%;
    }
}
@media (min-width: 378px) and (max-width: 429px) {
    #info-tooltip { 
        top: 25%;
        left: 65%;
    }
}