* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Verdana, Arial, sans-serif;
}

.insta-link {
  position: absolute;
  right: 2.5%;                    /* Moves top-left corner to parent's center */
  top: 5%;                /* Moves top-left corner to parent's center */
  transform: translate(-50%, -50%);
  z-index: 10;
  display: block;
  width: 40px;
  height: 40px;
}

.insta-link img {
  display: block;
  width: clamp(50px, 7vw, 100px);
  height: clamp(50px, 7vh, 100px);
  object-fit: contain;
}

.page {
  width: 100%;
  min-height: 100vh;
  background-image: url("../IMAGES/background.avif");
  background-size: contain;
  background-repeat: repeat;
  background-position: center;
  background-attachment: scroll;
  display: flex;
  align-items: center;
  justify-content: center;
  
}

.gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-evenly;
  gap: 2.5rem;
  width: fit-content;
  margin: 0 auto;
  padding: max(20px, 5%);
}

@media (max-width: 900px) {
  .frame-slot {
    width: 240px;
  }
}

@media (max-width: 480px) {
  .frame-slot {
    width: 100%;
    max-width: 360px;
  }
}

.frame-slot {
  position: relative;
  width: 300px;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  transition: opacity 2s ease, transform 0.5s ease-in-out;
}

.frame-slot:hover {
  transform: scale(1.05);
}

.frame-slot.gallery-hidden {
  opacity: 0;
  pointer-events: none;
}

.frame-slot .frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 3;
  pointer-events: none;
}

.frame-slot .doll-window {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
}

/* Sits between the photo (behind) and the frame's ink linework (in front),
   filling the ring between the photo opening and the frame's outer edge
   with a white mat. The drop-shadow (not box-shadow, so it follows the
   mask's actual traced shape rather than the element's rectangular box)
   reads as light coming from the top-right, giving the frame some depth.
   The filter lives on this wrapper, not the masked element itself - Chromium
   silently drops a drop-shadow filter when it's on the same element as a
   mask-image, so the shadow has to be applied one level up. */
.frame-slot .frame-ring-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  filter: drop-shadow(-12px 6px 8px rgba(0, 0, 0, 0.35));
}

.frame-slot .frame-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
}

.doll-window .doll-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateX(0);
  transition: transform 2s ease-in-out;
}

.doll-window .doll-img.incoming {
  transform: translateX(100%);
  transition: none;
}

.doll-window .doll-img.outgoing {
  transform: translateX(-100%);
}

/* Modal */

/* The frame growing into the module uses a named View Transition; this
   controls its speed/easing and suppresses the browser's default full-page
   crossfade so only the tagged frame itself morphs - everything else (the
   background zoom, sibling frames fading out, the overlay fade-in) keeps
   animating via its own normal CSS transitions, running at the same time. */
::view-transition-group(expanding-frame) {
  animation-duration: 2000ms;
  animation-timing-function: ease;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  padding: 1%;
  opacity: 0;
  overflow: hidden;
  transition: opacity 2s ease;
}

.modal-overlay.open {
  opacity: 1;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-bg {
  position: absolute;
  inset: 0;
  left: 0;
  z-index: 0;
  background-image: url("../IMAGES/background.avif");
  background-size: 100%;
  background-repeat: repeat;
  background-position: center;
  transform: translate(0, 0) scale(1);
  transition: transform 2s ease;
}

.modal-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 4.5rem;
  height: 4.5rem;
  border: none;
  border-radius: 50%;
  background-image: url("../IMAGES/sewing button.png");
  background-size: cover;
  background-position: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-size: 2.8rem;
  line-height: 1;
  cursor: pointer;
  z-index: 102;
}

.modal-close:hover {
  filter: brightness(0.9);
}

.modal-scroll {
  position: relative;
  z-index: 101;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  /* "safe" falls back to start-aligned once content is taller than the
     viewport, so the top of the frame can't get clipped above an
     unreachable scroll position on short phones - plain "center" above is
     the fallback for browsers that don't understand the safe keyword. */
  align-items: safe center;
  justify-content: center;
}

.modal-content {
  position: relative;
  width: fit-content;
  height: fit-content;
}

.modal-frame-wrap {
  position: relative;
  height: 90vh;
  aspect-ratio: 3 / 4;
  transform-origin: center center;
  flex-shrink: 0;
}

.modal-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 3;
  pointer-events: none;
}

.modal-doll-window {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
}

.modal-frame-ring-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  filter: drop-shadow(-6px 6px 8px rgba(0, 0, 0, 0.35));
}

.modal-frame-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
}

.modal-doll-window .modal-doll-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateX(0);
  transition: transform 2s ease-in-out;
}

.modal-doll-window .modal-doll-img.incoming {
  transform: translateX(100%);
  transition: none;
}

.modal-doll-window .modal-doll-img.outgoing {
  transform: translateX(-100%);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 75px;
  height: 75px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-image: url("../IMAGES/sewing button.png");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
}

.modal-nav-left {
  left: 20px;
}

.modal-nav-right {
  right: 20px;
}

.modal-nav i {
  color: #fff;
  font-size: 3rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.modal-info-box {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: space-around;
  background-image: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)), url("../IMAGES/wood.avif");
  background-size: cover, cover;
  background-position: center, center;
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  width: 80%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

/* Mobile: constrain the frame to at most 95% of the viewport width and 60%
   of its height (it was sizing itself from height:90vh alone and overflowing
   narrow screens) while keeping the 3:4 aspect ratio - min() picks whichever
   cap is tighter so the frame never busts through either edge. Also center
   the info box under it - it defaults to flush-left since it's only 80% wide. */
@media (max-width: 1299px) {
  .modal-frame-wrap {
    width: min(95vw, calc(60vh * 3 / 4));
    height: min(60vh, calc(95vw * 4 / 3));
    margin-left: auto;
    margin-right: auto;
  }

  .modal-info-box {
    margin-left: auto;
    margin-right: auto;
  }

  .modal-nav {
    width: 56.25px;
    height: 56.25px;
  }
}

/* From tablet up to just before the side-by-side desktop layout: maximize
   the frame within generous width AND height budgets together (a proper
   "contain" fit, like object-fit:contain) rather than deriving one
   dimension from a fixed fraction of the other - driving it from width
   alone left a lot of empty height above/below on tall viewports, and the
   old fixed 60vh height cap left a lot of empty width on short ones.
   Whichever budget is tighter for a given viewport wins, and the 3:4
   ratio is preserved either way since both dimensions are computed from
   the same two candidates. */
@media (min-width: 600px) and (max-width: 1299px) {
  .modal-frame-wrap {
    width: min(90vw, calc(85vh * 3 / 4));
    height: min(85vh, calc(90vw * 4 / 3));
  }
}

/* Desktop: image on the right, title/description/button on the left.
   Mobile keeps the info box overlaid on the frame above. */
@media (min-width: 1300px) {
  .modal-content {
    width: auto;
    height: auto;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 2.5rem;
    
  }

  .modal-frame-wrap {
    height: 90vh;
    max-width: min(55vw, 1200px);
  }

  .modal-info-box {
    position: static;
    transform: none;
    flex-shrink: 0;
    width: 25vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    box-shadow: none;
    box-shadow: -8px 8px 12px 0px rgba(0, 0, 0, 0.3);
  }
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 2rem;
}

.modal-desc {
  margin: 0 0 2rem;
  color: #555;
  font-size: 1.2rem;
  line-height: 1.5;
}

.etsy-btn {
  display: inline-block;
  background: #f1641e;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.15rem;
  padding: 1rem 2.25rem;
  border-radius: 999px;
  transition: background 0.2s ease;
}
@media (max-width: 1300px) {
  .modal-title {
    font-size: clamp(0.8rem, 1.25vw, 1.5rem);
  }
  .modal-desc {
    font-size: clamp(0.8rem, 1.25vw, 1.5rem);
  }
  .etsy-btn {
    font-size: clamp(0.8rem, 1.25vw, 1.5rem);
    padding: 1.25rem 2.5rem;
  }
  .modal-close {
    width: clamp(2.5rem, 5vw, 3.5rem);
    height: clamp(2.5rem, 5vw, 3.5rem);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
  }
  .modal-nav {
    width: clamp(2.5rem, 5vw, 3.5rem);
    height: clamp(2.5rem, 5vw, 3.5rem);
  }
  .modal-nav i {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
  }

}
.etsy-btn:hover {
  background: #d4560f;
}
