/* ==========================================================
   Świąteczny Fluttermeet - Zaktualizowany Układ Wireframe
   Pełna responsywność (Komputer & Telefon)
   Fluttershy zawsze w centralnym punkcie strony (50% X, 50% Y)
   ========================================================== */

:root {
  --color-fs-yellow: #fff9c4;
  --color-fs-yellow-card: #fff59d;
  --color-fs-yellow-border: #fbc02d;
  --color-fs-yellow-dark: #f57f17;
  --color-fs-pink: #f48fb1;
  --color-text-dark: #2c2538;
  --color-text-red: #c62828;
  --font-festive: 'Mountains of Christmas', cursive;
  --font-main: 'Comfortaa', 'Nunito', sans-serif;
  --shadow-paper: 0 8px 18px rgba(0, 0, 0, 0.16), 0 2px 5px rgba(0, 0, 0, 0.1);
  --shadow-lift: 0 16px 30px rgba(0, 0, 0, 0.24), 0 4px 10px rgba(0, 0, 0, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #fffdf4 0%, #fcf7e8 60%, #f6eedb 100%);
  font-family: var(--font-main);
  color: var(--color-text-dark);
}

/* ==========================================================
   RAMA EKRANU (PEŁNA RESPONSYWNOŚĆ: KOMPUTER I TELEFON)
   ========================================================== */
.screen-frame {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

/* ==========================================================
   1. GÓRA: FLUTTERMEET ŚWIĄTECZNY
   ========================================================== */
.header {
  position: relative;
  text-align: center;
  padding: clamp(14px, 2.6vh, 28px) 16px clamp(2px, 0.8vh, 8px);
  z-index: 30;
  width: 100%;
}

.title {
  font-family: var(--font-festive);
  font-size: clamp(2.3rem, 5.2vw, 4.3rem);
  letter-spacing: clamp(1px, 0.3vw, 3px);
  color: var(--color-text-red);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  line-height: 1.05;
}

.subtitle {
  font-family: var(--font-festive);
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  color: #ad1457;
  margin-top: -4px;
}

/* ==========================================================
   2. LAMPKA / GŁOŚNIK DO ODTWARZANIA MUZYKI
   ========================================================== */
.lamp-speaker-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2px;
  z-index: 25;
}

.lamp-speaker {
  position: relative;
  width: clamp(62px, 5.5vw, 76px);
  height: clamp(62px, 5.5vw, 76px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffde7 0%, #fff176 50%, #fbc02d 100%);
  border: 3px solid #f57f17;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5d4037;
  box-shadow: 
    0 0 24px rgba(255, 235, 59, 0.7),
    0 6px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 28;
}

.lamp-speaker:hover {
  transform: scale(1.08);
  box-shadow: 
    0 0 35px rgba(255, 235, 59, 0.95),
    0 8px 22px rgba(0, 0, 0, 0.25);
}

.lamp-speaker:active {
  transform: scale(0.95);
}

.speaker-icon {
  z-index: 5;
}

/* Fale dźwiękowe wokół lampki */
.speaker-waves {
  position: absolute;
  inset: -10px;
  pointer-events: none;
}

.wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(251, 192, 45, 0.75);
  opacity: 0;
}

.lamp-speaker.playing .w1 {
  animation: pulse-wave 2s infinite 0s ease-out;
}
.lamp-speaker.playing .w2 {
  animation: pulse-wave 2s infinite 0.6s ease-out;
}
.lamp-speaker.playing .w3 {
  animation: pulse-wave 2s infinite 1.2s ease-out;
}

@keyframes pulse-wave {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* ==========================================================
   ŚWIATEŁKO DO GÓRY - BEZPOŚREDNIO POD LAMPKĄ/GŁOŚNIKIEM
   OŚWIETLA CENTRALNY PUNKT STRONY (FLUTTERSHY)
   ========================================================== */
.light-beam {
  position: absolute;
  top: clamp(48px, 4.5vw, 62px);
  left: 50%;
  transform: translateX(-50%);
  width: clamp(320px, 48vw, 800px);
  height: clamp(540px, 78vh, 920px);
  background: radial-gradient(
    ellipse at 50% 0%, 
    rgba(255, 249, 196, 0.62) 0%, 
    rgba(255, 238, 88, 0.24) 42%, 
    rgba(255, 238, 88, 0.05) 74%, 
    transparent 88%
  );
  clip-path: polygon(44% 0%, 56% 0%, 96% 100%, 4% 100%);
  pointer-events: none;
  z-index: 8;
  filter: blur(2px);
  animation: lamp-shimmer 4s ease-in-out infinite alternate;
}

@keyframes lamp-shimmer {
  0% { opacity: 0.85; transform: translateX(-50%) scaleX(0.97); }
  100% { opacity: 1; transform: translateX(-50%) scaleX(1.03); }
}

/* ==========================================================
   3. GŁÓWNA SCENA - ROZPIĘTA NA CAŁY EKRAN
   ========================================================== */
.scene-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 1300px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  overflow: visible;
  perspective: 1200px;
  transform-style: preserve-3d;
}

@media (max-width: 767px) {
  .scene-stage {
    left: 0;
    transform: none;
    max-width: 100%;
  }
}

/* ==========================================================
   KOPERTY: ODWRÓCONE DO GÓRY, ROZRZEDZONE, O ZMIENNYCH KĄTACH
   WYŚRODKOWANE W PIONIE (TOP: 50%) WZGŁĘDEM FLUTTERSHY
   ========================================================== */
.envelopes-stack {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  z-index: 18;
  pointer-events: auto;
  transform-style: preserve-3d;
}

/* Domyślnie na telefonie: przy krawędziach */
.stack-left {
  left: -12px;
}

.stack-right {
  right: -12px;
}

/* Pojedynczy żółty prostokąt koperty */
.envelope-rect {
  position: relative;
  width: clamp(105px, 28vw, 130px);
  height: clamp(64px, 17vw, 80px);
  background: linear-gradient(135deg, #fffde7 0%, var(--color-fs-yellow-card) 100%);
  border: 2px solid var(--color-fs-yellow-border);
  border-radius: 8px;
  box-shadow: var(--shadow-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  
  /* Rozrzedzone nachodzenie - widoczne napisy na każdej kopercie */
  margin-top: -16px;
  
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.envelope-rect:first-child {
  margin-top: 0;
}

/* Klapa koperty */
.envelope-rect::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: rgba(251, 192, 45, 0.18);
  border-bottom: 1.5px solid rgba(245, 127, 23, 0.35);
  pointer-events: none;
}

.env-text {
  font-family: var(--font-festive);
  font-size: clamp(1.1rem, 3.2vw, 1.3rem);
  font-weight: 700;
  color: #b71c1c;
  letter-spacing: 0.8px;
  margin-top: 10px;
  z-index: 2;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

/* ==========================================================
   LEWA STRONA: ODWRÓCONE DO GÓRY (KĄTY UJEMNE) + NIERÓWNE KĄTY
   ========================================================== */
.stack-left .envelope-rect {
  transform-origin: center left;
  z-index: calc(10 + var(--i));
}

.stack-left .env-left-1 { transform: rotate(-28deg); }
.stack-left .env-left-2 { transform: rotate(-36deg); }
.stack-left .env-left-3 { transform: rotate(-24deg); }
.stack-left .env-left-4 { transform: rotate(-33deg); }
.stack-left .env-left-5 { transform: rotate(-26deg); }

.stack-left .envelope-rect:hover {
  transform: rotate(-18deg) scale(1.08) translateX(12px) !important;
  box-shadow: var(--shadow-lift);
  z-index: 35 !important;
}

/* ==========================================================
   PRAWA STRONA: ODWRÓCONE DO GÓRY (KĄTY DODATNIE) + NIERÓWNE KĄTY
   ========================================================== */
.stack-right .envelope-rect {
  transform-origin: center right;
  z-index: calc(10 + var(--i));
}

.stack-right .env-right-1 { transform: rotate(30deg); }
.stack-right .env-right-2 { transform: rotate(23deg); }
.stack-right .env-right-3 { transform: rotate(37deg); }
.stack-right .env-right-4 { transform: rotate(28deg); }
.stack-right .env-right-5 { transform: rotate(34deg); }

.stack-right .envelope-rect:hover {
  transform: rotate(18deg) scale(1.08) translateX(-12px) !important;
  box-shadow: var(--shadow-lift);
  z-index: 35 !important;
}

/* ==========================================================
   ŚRODEK: FLUTTERSHY ZAWSZE W CENTRALNYM PUNKCIE STRONY
   (X: 50%, Y: 50%)
   ========================================================== */
.center-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 12;
  pointer-events: auto;
}

.fluttershy-placeholder {
  position: relative;
  width: clamp(125px, 32vw, 155px);
  height: clamp(165px, 43vw, 210px);
  background: linear-gradient(180deg, #fff9c4 0%, #fff176 60%, #ffd54f 100%);
  border: 3px solid #fbc02d;
  border-radius: 16px;
  box-shadow: 
    0 16px 32px rgba(0, 0, 0, 0.16), 
    0 0 28px rgba(255, 235, 59, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: float-gentle 4s ease-in-out infinite alternate;
}

.fluttershy-placeholder:hover {
  transform: translateY(-6px);
  box-shadow: 
    0 22px 42px rgba(0, 0, 0, 0.22), 
    0 0 38px rgba(255, 235, 59, 0.75);
}

@keyframes float-gentle {
  0% { transform: translateY(0px); }
  100% { transform: translateY(-8px); }
}

.placeholder-label {
  font-family: var(--font-festive);
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 700;
  color: #795548;
  letter-spacing: 1px;
}

/* ==========================================================
   WIDOK KOMPUTERA (DESKTOP: min-width: 768px)
   Dostosowanie do dużych rozdzielczości ekranu
   ========================================================== */
@media (min-width: 768px) {
  .stack-left {
    left: clamp(20px, 4vw, 80px);
  }

  .stack-right {
    right: clamp(20px, 4vw, 80px);
  }

  .envelope-rect {
    width: clamp(160px, 13vw, 210px);
    height: clamp(96px, 8vw, 126px);
    border-radius: 12px;
    margin-top: -20px;
  }

  .env-text {
    font-size: clamp(1.35rem, 1.4vw, 1.7rem);
    margin-top: 14px;
  }

  .fluttershy-placeholder {
    width: clamp(190px, 16vw, 260px);
    height: clamp(260px, 22vw, 350px);
    border-radius: 22px;
    border-width: 4px;
  }

  .placeholder-label {
    font-size: clamp(2rem, 2vw, 2.6rem);
  }
}

/* Duże ekrany (Full HD i wyżej: min-width: 1280px) */
@media (min-width: 1280px) {
  .stack-left {
    left: 80px;
  }

  .stack-right {
    right: 80px;
  }
}

/* Zabezpieczenie przed ściśnięciem przy bardzo małej wysokości (np. telefon poziomo) */
@media (max-height: 520px) {
  html, body {
    overflow-y: auto;
  }
  .screen-frame {
    min-height: 540px;
    height: auto;
  }
}

/* ==========================================================
   4. MODAL OTWIERANEJ KOPERTY 3D Z ANIMACJĄ
   Zero przeźroczystości w kopercie i liście (100% krycia)
   Kartka animuje na środek strony całkowicie zasłaniając kopertę
   ========================================================== */
.envelope-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
}

.envelope-modal.active {
  visibility: visible;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: #1a141d;
  cursor: pointer;
  opacity: 0.85;
}

.modal-stage {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1200px;
}

/* KOPERTA 3D - 100% KRYCIA, ZERO PRZEŹROCZYSTOŚCI */
.modal-envelope-3d {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: min(340px, 90vw);
  height: 230px;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: visible;
}

.envelope-modal.active .modal-envelope-3d {
  transform: translate(-50%, -50%) scale(1);
}

/* TYLNA ŚCIANKA KOPERTY */
.env-back-panel {
  position: absolute;
  inset: 0;
  background: #fff9c4;
  background: linear-gradient(145deg, #fffde7 0%, #fff59d 100%);
  border: 3px solid #fbc02d;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

/* GÓRNA KLAPA KOPERTY (OTWIERA SIĘ W 3D) */
.env-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: #fff59d;
  background: linear-gradient(180deg, #fffde7 0%, #fff176 100%);
  border-bottom: 2px solid #f57f17;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 18;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.envelope-modal.flap-open .env-top-flap {
  transform: rotateX(180deg);
}

.envelope-modal.letter-rising .env-top-flap,
.envelope-modal.letter-centered .env-top-flap {
  z-index: 4;
}

/* PIECZĘĆ LAKOWA */
.wax-seal {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #b71c1c;
  background: radial-gradient(circle at 35% 35%, #e53935 0%, #b71c1c 65%, #7f0000 100%);
  border: 2px solid #ffd54f;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* PRZEDNIA KIESZEŃ KOPERTY - PEŁNE KRYCIE (BEZ PRZEŹROCZYSTOŚCI) */
.env-front-pocket {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.pocket-fold {
  position: absolute;
  inset: 0;
}

.pocket-bottom {
  clip-path: polygon(0 100%, 50% 44%, 100% 100%);
  background: #fff176;
  background: linear-gradient(0deg, #fff59d 0%, #fff9c4 100%);
  border-bottom: 3px solid #fbc02d;
  border-radius: 0 0 14px 14px;
}

.pocket-left {
  clip-path: polygon(0 0, 0 100%, 50% 64%);
  background: #ffecb3;
  border-left: 3px solid #fbc02d;
  border-radius: 14px 0 0 14px;
}

.pocket-right {
  clip-path: polygon(100% 0, 100% 100%, 50% 64%);
  background: #ffe082;
  border-right: 3px solid #fbc02d;
  border-radius: 0 14px 14px 0;
}

/* CANVAS PRAWDZIWEGO 3D (THREE.JS / WEBGL) */
.three-envelope-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ==========================================================
   KARTKA / LIST:
   - 100% KRYCIA (ZERO PRZEŹROCZYSTOŚCI)
   - LĄDUJE NA ŚRODKU STRONY (TOP: 50%, LEFT: 50%, TRANSLATE -50%, -50%)
   - CAŁKOWICIE ZASŁANIA KOPERTĘ 3D W TLE
   ========================================================== */
.env-letter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.15);
  opacity: 0;
  pointer-events: none;
  width: min(380px, 94vw);
  height: min(540px, 84vh);
  background: #ffffff;
  border: 3px solid #fbc02d;
  border-radius: 14px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
  z-index: 40;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 
    transform 0.4s cubic-bezier(0.34, 1.25, 0.64, 1),
    opacity 0.3s ease;
}

/* Stan gdy kartka ląduje na środku i zasłania kopertę 3D */
.envelope-modal.letter-centered .env-letter {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* WNĘTRZE KARTKI - 100% KRYCIA */
.letter-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 20px 16px;
  background: #ffffff;
  overflow: hidden;
}

.letter-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #f57f17;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.letter-tag {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #880e4f;
  background: #f8bbd0;
  padding: 4px 10px;
  border-radius: 20px;
}

.letter-close-icon {
  background: none;
  border: none;
  font-size: 1.4rem;
  font-weight: 800;
  color: #5d4037;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.letter-close-icon:hover {
  background: #ffebee;
  color: #c62828;
}

.letter-title {
  font-family: var(--font-festive);
  font-size: clamp(1.8rem, 4.5vw, 2.3rem);
  color: #b71c1c;
  text-align: center;
  margin: 4px 0 2px;
  line-height: 1.15;
}

.letter-divider {
  text-align: center;
  color: #fbc02d;
  font-size: 0.9rem;
  margin-bottom: 10px;
  letter-spacing: 6px;
}

.letter-content {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #3e2723;
  overflow-y: auto;
  padding-right: 4px;
}

.letter-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.letter-content li {
  position: relative;
  padding: 8px 10px 8px 28px;
  margin-bottom: 8px;
  background: #fff9c4;
  border-left: 4px solid #fbc02d;
  border-radius: 6px;
}

.letter-content li::before {
  content: '✦';
  position: absolute;
  left: 10px;
  color: #e65100;
  font-weight: bold;
}

.letter-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px dashed #f57f17;
  padding-top: 12px;
  margin-top: 12px;
}

.letter-sign {
  font-family: var(--font-festive);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ad1457;
}

.letter-action-btn {
  background: #c62828;
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(183, 28, 28, 0.35);
  transition: transform 0.2s, background 0.2s;
}

.letter-action-btn:hover {
  transform: translateY(-2px);
  background: #d32f2f;
}

/* WIDOK DLA EKRANU KOMPUTERA (DESKTOP) */
@media (min-width: 768px) {
  .modal-envelope-3d {
    width: 500px;
    height: 310px;
  }

  .env-letter {
    width: 440px;
    height: 210px;
  }

  .envelope-modal.letter-rising .env-letter {
    transform: translate(-50%, -150px) scale(0.96);
  }

  .envelope-modal.letter-centered .env-letter {
    width: min(620px, 90vw);
    height: min(640px, 84vh);
  }

  .letter-inner {
    padding: 24px 28px 20px;
  }

  .letter-title {
    font-size: 2.5rem;
  }

  .letter-content {
    font-size: 1.05rem;
  }
}
