/* ============================================================
   ENVELOPE NOTE SYSTEM — Pihu Designs
   ============================================================ */

.env-wrapper {
  position: relative;
  display: inline-block;
  z-index: 100;
}

/* ── ENVELOPE SVG ── */
.env-icon {
  width: 105px;
  height: 78px;
  cursor: pointer;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(36,35,35,0.13));
}
.env-icon:hover {
  filter: drop-shadow(0 4px 12px rgba(36,35,35,0.12))
          drop-shadow(0 0 20px rgba(103,15,12,0.32));
}
.env-icon:hover .env-seal-group {
  transform: scale(1.08);
}

/* ── WIGGLE ── */
@keyframes envWiggle {
  0%   { transform: rotate(0deg)   translateY(0px);  }
  10%  { transform: rotate(-7deg)  translateY(-4px); }
  20%  { transform: rotate(7deg)   translateY(3px);  }
  30%  { transform: rotate(-6deg)  translateY(-3px); }
  40%  { transform: rotate(5deg)   translateY(2px);  }
  55%  { transform: rotate(-3deg)  translateY(-1px); }
  70%  { transform: rotate(2deg)   translateY(1px);  }
  85%  { transform: rotate(-1deg)  translateY(0px);  }
  100% { transform: rotate(0deg)   translateY(0px);  }
}
.env-icon.wiggle {
  animation: envWiggle 0.85s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ── NOTE CARD — default opens below, centred ── */
.env-note {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) scaleY(0) translateY(-8px);
  transform-origin: top center;
  width: 300px;
  max-width: calc(100vw - 40px);
  background: #F8F1E8;
  border: 1px solid rgba(103,15,12,0.08);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(36,35,35,0.1), 0 2px 8px rgba(36,35,35,0.06);
  padding: 26px 24px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 350ms ease, transform 450ms cubic-bezier(0.22,1,0.36,1);
  z-index: 9999;
}
.env-wrapper.open .env-note {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) scaleY(1) translateY(0);
}

/* Hero envelope — note opens LEFT-anchored so it never bleeds off right edge */
.env-hero-anchor .env-note {
  left: auto;
  right: 0;
  transform: scaleY(0) translateY(-8px);
  transform-origin: top right;
}
.env-hero-anchor .env-wrapper.open .env-note {
  transform: scaleY(1) translateY(0);
}

/* Fixed right-side envelopes (work + services) — note opens LEFT */
.env-fixed-right .env-note {
  left: auto;
  right: 0;
  transform: scaleY(0) translateY(-8px);
  transform-origin: top right;
}
.env-fixed-right.open .env-note {
  opacity: 1;
  pointer-events: all;
  transform: scaleY(1) translateY(0);
}

/* Paper line texture */
.env-note::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 12px;
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 22px,
    rgba(103,15,12,0.025) 22px, rgba(103,15,12,0.025) 23px
  );
  pointer-events: none;
}

/* Close */
.env-close {
  position: absolute; top: 10px; right: 13px;
  font-size: 17px; color: rgba(103,15,12,0.3);
  cursor: pointer; background: none; border: none;
  font-family: sans-serif; line-height: 1;
  transition: color 200ms ease; padding: 2px 4px;
}
.env-close:hover { color: rgba(103,15,12,0.65); }

/* Text */
.env-greeting {
  font-family: 'Libre Baskerville', serif;
  font-style: italic; font-size: 14px;
  color: rgba(103,15,12,0.65);
  display: block; margin-bottom: 10px;
}
.env-body-text {
  font-family: 'Libre Baskerville', serif;
  font-size: 13px; line-height: 1.8;
  color: #3a3535; display: block;
  min-height: 3.5em; white-space: pre-wrap;
}
.env-heart {
  display: block; color: #670F0C;
  font-size: 12px; margin: 8px 0 2px;
}
.env-sig {
  font-family: 'Libre Baskerville', serif;
  font-style: italic; font-size: 12px;
  color: rgba(103,15,12,0.6);
  display: block; margin-bottom: 14px;
}
.env-cta {
  display: inline-block; padding: 8px 18px;
  background: #670F0C; color: #FFF6EA;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.04em; border-radius: 100px;
  text-decoration: none;
  transition: background 200ms ease, opacity 200ms ease;
  opacity: 0;
}
.env-cta.visible { opacity: 1; }
.env-cta:hover { background: #8B1510; }

/* Hero anchor */
.env-hero-anchor {
  position: absolute;
  right: 5%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

/* ── TABLET / IPAD ── */
/* Hero envelope on iPad sits in the right margin, smaller, lower
   than vertical-centre so it never collides with the headline */
@media (max-width: 1024px) and (min-width: 821px) {
  .env-icon { width: 84px; height: 62px; }
  .env-hero-anchor {
    right: 3%;
    top: auto;
    bottom: 14%;
    transform: none;
  }
  .env-note { width: 280px; }
  /* Fixed right envelopes slightly smaller too */
  #env-fixed-work .env-icon,
  #env-fixed-services .env-icon { width: 90px; height: 67px; }
}

/* ── MOBILE ── */
@media (max-width: 820px) {
  /* Smaller envelope so it never overlaps text */
  .env-icon { width: 72px; height: 53px; }

  /* Show envelope on mobile — moved below headline, never overlapping */
  .env-hero-anchor {
    position: relative;
    right: auto; left: auto; top: auto; bottom: auto;
    transform: none;
    display: flex;
    justify-content: center;
    margin-top: 24px;
  }
  .env-hero-anchor .env-note {
    left: 50%;
    right: auto;
    transform: translateX(-50%) scaleY(0) translateY(-8px);
    transform-origin: top center;
    width: min(280px, calc(100vw - 32px));
  }
  .env-hero-anchor .env-wrapper.open .env-note {
    transform: translateX(-50%) scaleY(1) translateY(0);
  }

  /* Note card: never wider than screen, always fully visible */
  .env-note {
    width: min(260px, calc(100vw - 24px));
    padding: 18px 16px 14px;
  }
  /* Fixed-right envelopes on mobile: note opens UPWARD so it never
     gets cut off by bottom of screen */
  #env-fixed-work .env-note,
  #env-fixed-services .env-note {
    top: auto !important;
    bottom: calc(100% + 10px) !important;
    left: auto !important;
    right: 0 !important;
    transform: scaleY(0) translateY(8px) !important;
    transform-origin: bottom right !important;
    transition: opacity 350ms ease, transform 450ms cubic-bezier(0.22,1,0.36,1) !important;
  }
  #env-fixed-work.open .env-note,
  #env-fixed-services.open .env-note,
  #env-fixed-work .env-wrapper.open .env-note,
  #env-fixed-services .env-wrapper.open .env-note {
    transform: scaleY(1) translateY(0) !important;
    opacity: 1 !important;
    pointer-events: all !important;
  }

  /* Fixed right envelopes — smaller, bottom-right corner */
  #env-fixed-work, #env-fixed-services {
    right: 8px !important;
    top: auto !important;
    bottom: 80px !important;
    transform: none !important;
  }
  #env-fixed-work .env-icon,
  #env-fixed-services .env-icon { width: 64px; height: 47px; }
}

@media (prefers-reduced-motion: reduce) {
  .env-icon.wiggle { animation: none !important; }
  .env-note { transition: opacity 150ms ease; }
}
