/* 
===========================================
  LUXURY DESIGN SYSTEM & RESETS
=========================================== 
*/
:root {
    --bg-dark: #12051c;
    --bg-wine: #280b30;
    --bg-glow: #42124d;
    
    --gold-solid: #c9933b;
    --gold-light: #fbeec1;
    --gold-border: rgba(201, 147, 59, 0.35);
    
    --envelope-color: #f7ede2;
    --envelope-dark: #e8d8c8;
    --liner-color: #5c0f28;
    --wax-gold: #c98b2c;
    --wax-shadow: #78480b;
    
    --paper-bg: #fffefb;
    --text-primary: #2b231d;
    --text-secondary: #5a5047;
    --accent-red: #8b1e3f;
    
    --shadow-soft: 0 20px 50px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 30px 70px rgba(10, 2, 15, 0.65);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at 50% 35%, var(--bg-glow) 0%, var(--bg-wine) 50%, var(--bg-dark) 100%);
    font-family: 'Montserrat', sans-serif;
    color: #ffffff;
}

/* 
===========================================
  AMBIENT CANVAS
=========================================== 
*/
#ambient-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* 
===========================================
  APP CONTAINER
=========================================== 
*/
.app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* 
===========================================
  INTRO VIEW (ENVELOPE + PROMPT)
=========================================== 
*/
.intro-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 1s cubic-bezier(0.19, 1, 0.22, 1);
}

.intro-view.hidden-state {
    transform: translateY(80px) scale(0.85);
    opacity: 0;
    pointer-events: none;
}

.header-prompt {
    text-align: center;
    margin-bottom: 24px;
    max-width: 400px;
    transition: opacity 0.5s ease;
}

.sparkle-icon {
    font-size: 1.5rem;
    display: inline-block;
    animation: sparkleSpin 3s infinite ease-in-out;
}

@keyframes sparkleSpin {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.85; }
    50% { transform: scale(1.3) rotate(15deg); opacity: 1; }
}

.prompt-subtitle {
    font-size: 0.76rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-top: 6px;
    font-weight: 500;
}

.prompt-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.4rem, 4.5vw, 1.8rem);
    font-weight: 600;
    margin-top: 6px;
    color: #ffffff;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.tap-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
    letter-spacing: 1px;
    animation: hintPulse 2s infinite ease-in-out;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; color: var(--gold-light); }
}

/* 
===========================================
  ENVELOPE
=========================================== 
*/
.envelope-container {
    position: relative;
    width: 320px;
    height: 215px;
    perspective: 1000px;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--envelope-color);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    animation: floatEnvelope 4s ease-in-out infinite;
}

@keyframes floatEnvelope {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.envelope:hover {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.envelope-liner {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--liner-color);
    border-radius: 8px;
    z-index: 1;
}

.envelope-liner::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle, rgba(201, 147, 59, 0.18) 10%, transparent 11%);
    background-size: 16px 16px;
    opacity: 0.6;
}

.envelope-pocket {
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 100%;
    z-index: 3;
    pointer-events: none;
}

.envelope-pocket::before {
    content: "";
    position: absolute;
    bottom: 0; left: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 108px 0 108px 160px;
    border-color: transparent transparent var(--envelope-dark) var(--envelope-color);
    border-bottom-left-radius: 8px;
}

.envelope-pocket::after {
    content: "";
    position: absolute;
    bottom: 0; right: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 108px 160px 108px 0;
    border-color: transparent var(--envelope-color) var(--envelope-dark) transparent;
    border-bottom-right-radius: 8px;
}

.envelope::after {
    content: "";
    position: absolute;
    bottom: 0; left: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 0 160px 115px 160px;
    border-color: transparent transparent var(--envelope-color) transparent;
    z-index: 4;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.envelope-flap {
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 120px 160px 0 160px;
    border-color: var(--envelope-dark) transparent transparent transparent;
    transform-origin: top center;
    z-index: 5;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.2s 0.3s;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.12));
}

.envelope-container.opened .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
}

/* Wax Seal */
.wax-seal {
    position: absolute;
    top: 108px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: radial-gradient(circle at 35% 35%, #e6b24d 0%, var(--wax-gold) 50%, var(--wax-shadow) 100%);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.5);
    transition: transform 0.3s ease, opacity 0.4s ease;
    outline: none;
}

.wax-seal:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.seal-inner {
    width: 42px;
    height: 42px;
    border: 1.5px dashed rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seal-letter {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: #4a2c00;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4), -1px -1px 0 rgba(0, 0, 0, 0.3);
}

.seal-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(246, 226, 122, 0.6) 0%, transparent 70%);
    animation: sealAura 2.2s infinite ease-in-out;
    pointer-events: none;
}

@keyframes sealAura {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 0.9; }
}

.envelope-container.opened .wax-seal {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
    pointer-events: none;
}

/* 
===========================================
  THE REVEALED LETTER MODAL (PERFECT CENTER)
=========================================== 
*/
.letter-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease 0.4s;
}

.letter-modal.show {
    opacity: 1;
    pointer-events: all;
}

.letter-card {
    width: 100%;
    max-width: 410px;
    max-height: 90vh;
    background: var(--paper-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    transform: translateY(40px) scale(0.85);
    transition: transform 1.1s cubic-bezier(0.19, 1, 0.22, 1) 0.4s;
    display: flex;
    flex-direction: column;
}

.letter-modal.show .letter-card {
    transform: translateY(0) scale(1);
}

.card-inner {
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gold-filigree-border {
    border: 2px solid var(--gold-solid);
    border-radius: 12px;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    background: radial-gradient(circle at 50% 15%, #ffffff 0%, var(--paper-bg) 100%);
    position: relative;
    overflow-y: auto;
    gap: 10px;
}

.gold-filigree-border::before {
    content: "";
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border: 1px dashed var(--gold-border);
    border-radius: 8px;
    pointer-events: none;
}

.card-ornament {
    color: var(--gold-solid);
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.85;
}

.date-badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--accent-red);
    font-weight: 600;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.5rem, 5vw, 1.9rem);
    color: var(--accent-red);
    font-weight: 700;
    line-height: 1.15;
    margin: 0;
}

.gold-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 2px;
    background: var(--gold-solid);
    margin: 2px auto;
    position: relative;
    flex-shrink: 0;
}

.gold-divider span {
    position: absolute;
    background: var(--paper-bg);
    padding: 0 4px;
    color: var(--gold-solid);
    font-size: 0.65rem;
}

.letter-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.letter-para {
    font-size: clamp(0.83rem, 2.9vw, 0.92rem);
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-weight: 400;
}

.letter-para.highlight {
    color: var(--text-primary);
    font-weight: 500;
}

.signature-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 4px;
}

.sign-prefix {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
}

.signature-name {
    font-family: 'Alex Brush', 'Great Vibes', cursive;
    font-size: clamp(2rem, 6.5vw, 2.5rem);
    color: var(--accent-red);
    line-height: 1.1;
    margin-top: 2px;
}

/* 
===========================================
  CARD ACTIONS
=========================================== 
*/
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.action-btn {
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.25s ease;
}

.celebrate-btn {
    background: linear-gradient(135deg, var(--accent-red) 0%, #b83359 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(139, 30, 63, 0.35);
}

.celebrate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 30, 63, 0.45);
}

.replay-btn {
    background: #f0e6da;
    color: var(--text-secondary);
}

.replay-btn:hover {
    background: #e5d8c8;
    color: var(--text-primary);
}

/* 
===========================================
  MOBILE ADJUSTMENTS
=========================================== 
*/
@media (max-width: 360px) {
    .envelope-container {
        width: 280px;
        height: 190px;
    }
    .envelope-pocket::before { border-width: 95px 0 95px 140px; }
    .envelope-pocket::after { border-width: 95px 140px 95px 0; }
    .envelope::after { border-width: 0 140px 105px 140px; }
    .envelope-flap { border-width: 108px 140px 0 140px; }
    .wax-seal { top: 95px; width: 48px; height: 48px; }
    .seal-inner { width: 36px; height: 36px; }
    .seal-letter { font-size: 1.4rem; }
    .gold-filigree-border { padding: 16px 12px; gap: 8px; }
    .card-title { font-size: 1.4rem; }
    .signature-name { font-size: 1.9rem; }
}

@media (max-height: 620px) {
    .header-prompt { margin-bottom: 12px; }
    .prompt-subtitle { display: none; }
    .gold-filigree-border { padding: 14px 12px; gap: 6px; }
    .letter-body { gap: 4px; }
    .letter-para { font-size: 0.78rem; line-height: 1.45; }
    .card-title { font-size: 1.35rem; }
    .signature-name { font-size: 1.8rem; }
}
