/* Global Variables & Resets */
:root {
    --primary-color: #d19592; /* Soft Peony Pink */
    --accent-color: #ffb6b9;
    --text-color: #333;
    --envelope-color: #f7e1d7;
    --envelope-pocket: #ecd0c3;
    --envelope-inside: #d4a373;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    overflow-x: hidden;
    background: url('medya/arkaplan.jpg') center/cover no-repeat fixed;
    background-color: #fae4df; /* Fallback flat color if image is missing */
    min-height: 100vh;
}

/* Fallback subtle pattern if image doesn't load */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(255,255,255,0.4) 100%);
    pointer-events: none;
    z-index: -1;
}

/* Screens Utility */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-in-out, visibility 0.8s;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 10;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 40px;
    text-align: center;
}

/* --- 1. Login Screen --- */
.login-box {
    width: 90%;
    max-width: 400px;
    animation: fadeIn 1s ease-out;
}

.login-box h1 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2rem;
}

.login-box p {
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.input-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

input[type="text"] {
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 30px;
    outline: none;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s;
    width: 60%;
    text-align: center;
}

input[type="text"]:focus {
    border-color: var(--primary-color);
}

#submit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#submit-btn:hover {
    background: var(--accent-color);
    transform: scale(1.05);
}

.error-text {
    color: #e74c3c !important;
    font-size: 0.9rem !important;
    opacity: 0;
    transition: opacity 0.3s;
    margin-bottom: 0 !important;
}

.error-text.show {
    opacity: 1;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}


/* --- 2. Envelope Screen --- */
.envelope-wrapper {
    position: relative;
    cursor: pointer;
    perspective: 1000px;
}

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background: var(--envelope-inside);
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    transition: transform 0.4s ease;
}

.envelope:hover {
    transform: translateY(-5px);
}

/* Envelope Flap (Top part that opens) */
.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-top: 100px solid var(--envelope-color);
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 100px solid transparent;
    transform-origin: top;
    transition: transform 0.8s ease-in-out;
    z-index: 4;
}

/* Envelope Pocket (Bottom/Sides) */
.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-bottom: 100px solid var(--envelope-pocket);
    border-left: 150px solid var(--envelope-color);
    border-right: 150px solid var(--envelope-color);
    border-top: 100px solid transparent;
    z-index: 3;
}

/* The small paper sticking out before it grows */
.letter-preview {
    position: absolute;
    bottom: 10px;
    width: 260px;
    height: 160px;
    background: #fff;
    border-radius: 5px;
    z-index: 2;
    transition: transform 1.2s ease-in-out, height 1.2s ease-in-out, opacity 1s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.to-text {
    font-family: 'Dancing Script', cursive;
    font-size: 2rem;
    color: var(--primary-color);
    transform: translateY(-10px);
}

.hint-text {
    text-align: center;
    font-family: 'Dancing Script', cursive;
    font-size: 1.5rem;
    color: #555;
    animation: pulse 2s infinite;
    background: rgba(255,255,255,0.7);
    padding: 5px 15px;
    border-radius: 20px;
    display: inline-block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -40px;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; transform: translateX(-50%) translateY(-3px); }
    100% { opacity: 0.6; }
}

/* Classes applied by JS to trigger envelope opening */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 1; /* Move behind paper */
}

.envelope.open .letter-preview {
    transform: translateY(-120px) scale(1.1);
    height: 200px;
}


/* --- 3. Main Letter Content --- */
#letter-screen {
    align-items: flex-start; /* So it can scroll */
    padding: 40px 220px;
    overflow-y: auto;
}

.letter-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 40px;
    /* Extra styling for letter look */
    background: rgba(255, 255, 255, 0.85); /* Slightly more opaque for readability */
    border-radius: 12px;
    position: relative;
    z-index: 2; /* Sit above film rolls */
}

.romantic-title {
    font-family: 'Dancing Script', cursive;
    font-size: 3rem;
    color: var(--primary-color);
    line-height: 1.4;
    margin-bottom: 50px;
    text-align: center;
}

/* --- Side Film Rolls Feature --- */
.side-film-roll {
    position: fixed;
    top: -50px;
    bottom: -50px;
    width: 200px;
    background-color: #0c0c0c;
    overflow: hidden;
    z-index: 1; /* Behind main glass panel */
    padding: 0 15px;
    border-left: 2px solid #111;
    border-right: 2px solid #111;
    box-shadow: 0 0 20px rgba(0,0,0,0.9);
    /* opacity removed to prevent background bleeding through the gaps */
}

.left-roll {
    left: 2%; 
}

.right-roll {
    right: 2%;
}

/* Sprocket Holes */
.side-film-roll::before,
.side-film-roll::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    background-image: linear-gradient(to bottom, #0c0c0c 4px, #ddd 4px, #ddd 14px, #0c0c0c 14px);
    background-size: 100% 26px;
    z-index: 2;
}

.side-film-roll::before {
    left: 4px;
}

.side-film-roll::after {
    right: 4px;
}

.film-track {
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: scrollSideFilm 120s linear infinite;
    padding-top: 12px;
}

.reverse-track {
    animation-direction: reverse;
}

.side-film-img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    margin-bottom: 20px;
    border-radius: 2px;
    display: block;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

@keyframes scrollSideFilm {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-50%);
    }
}

.media-gallery {
    display: flex;
    flex-direction: column;
    gap: 40px;
    align-items: center;
}

.media-item {
    width: 100%;
    max-width: 600px;
    position: relative;
}

.gallery-img, .gallery-video {
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 8px solid white;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    object-fit: contain;
    max-height: 85vh; /* Increased max-height slightly to allow vertical photos to be larger */
}

.gallery-img {
    cursor: zoom-in;
}

.gallery-img:hover {
    transform: scale(1.03);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.signature {
    margin-top: 60px;
    text-align: right;
    font-family: 'Dancing Script', cursive;
    font-size: 2rem;
    color: #555;
    padding-right: 20px;
}


/* --- Lightbox --- */
.lightbox {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.close-lightbox {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-lightbox:hover {
    color: var(--primary-color);
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 5px;
    animation: zoom 0.3s;
}

@keyframes zoom {
    from {transform: scale(0)}
    to {transform: scale(1)}
}

/* ===== MOBILE: Convert side film rolls to horizontal strips ===== */
@media (max-width: 768px) {
    /* --- Film Rolls: vertical → horizontal --- */
    .side-film-roll {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto !important;
        right: auto !important;
        width: 100%;
        height: 130px;
        padding: 8px 0;
        border-left: none;
        border-right: none;
        border-top: 2px solid #111;
        border-bottom: 2px solid #111;
        box-shadow: 0 0 10px rgba(0,0,0,0.7);
    }

    /* Position: left-roll on top, letter in middle, right-roll at bottom */
    .left-roll {
        order: -1;
    }
    .right-roll {
        order: 1;
    }
    .letter-content {
        order: 0;
    }

    /* Sprocket holes → horizontal (top & bottom instead of left & right) */
    .side-film-roll::before,
    .side-film-roll::after {
        top: auto;
        bottom: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: 6px;
        background-image: linear-gradient(to right, #0c0c0c 4px, #ddd 4px, #ddd 10px, #0c0c0c 10px);
        background-size: 20px 100%;
    }
    .side-film-roll::before { top: 2px; bottom: auto; }
    .side-film-roll::after { bottom: 2px; top: auto; }

    /* Film track → horizontal flex row */
    .film-track {
        flex-direction: row;
        height: 100%;
        width: max-content;
        padding-top: 0;
        padding: 10px 0;
        animation: scrollHorizontalFilm 60s linear infinite;
    }

    .reverse-track {
        animation: scrollHorizontalFilm 60s linear infinite reverse;
    }

    .side-film-img {
        width: 120px;
        height: 100%;
        min-height: 100px;
        margin-bottom: 0;
        margin-right: 10px;
        flex-shrink: 0;
        object-fit: cover;
        border-radius: 3px;
    }

    /* Letter screen: flex column for ordering */
    #letter-screen {
        padding: 0 12px;
        flex-direction: column;
        display: flex;
        flex-wrap: wrap;
    }

    .glass-panel {
        padding: 30px 20px;
    }

    .letter-content {
        padding: 30px 18px;
        border-radius: 10px;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    .romantic-title {
        font-size: 1.8rem;
        margin-bottom: 25px;
    }

    .envelope {
        width: 260px;
        height: 173px;
    }
    
    .flap {
        border-top-width: 86px;
        border-right-width: 130px;
        border-bottom-width: 87px;
        border-left-width: 130px;
    }
    
    .pocket {
        border-top-width: 86px;
        border-right-width: 130px;
        border-bottom-width: 87px;
        border-left-width: 130px;
    }
    
    .letter-preview {
        width: 225px;
        height: 140px;
    }

    .envelope.open .letter-preview {
        transform: translateY(-100px) scale(1.05);
    }

    .hint-text {
        font-size: 1.2rem;
        bottom: -35px;
    }

    .signature {
        font-size: 1.6rem;
        margin-top: 35px;
        padding-right: 10px;
    }

    .gallery-img, .gallery-video {
        border-width: 5px;
        border-radius: 10px;
        max-height: 70vh;
    }

    .media-gallery {
        gap: 25px;
    }

    .close-lightbox {
        top: 15px;
        right: 20px;
        font-size: 32px;
    }

    .login-box h1 {
        font-size: 1.7rem;
    }

    .login-box p {
        font-size: 1rem;
        margin-bottom: 18px;
    }
}

/* Horizontal film scroll animation */
@keyframes scrollHorizontalFilm {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* ===== MOBILE PHONES ===== */
@media (max-width: 480px) {
    .side-film-roll {
        height: 110px;
    }

    .side-film-img {
        width: 100px;
        min-height: 85px;
        margin-right: 8px;
    }

    .glass-panel {
        padding: 24px 16px;
        border-radius: 14px;
    }

    .login-box {
        width: 92%;
    }

    .login-box h1 {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }

    .login-box p {
        font-size: 0.95rem;
        margin-bottom: 16px;
    }

    input[type="text"] {
        padding: 10px 16px;
        font-size: 0.9rem;
        width: 65%;
    }

    #submit-btn {
        padding: 10px 16px;
        font-size: 1rem;
    }

    .envelope {
        width: 220px;
        height: 146px;
    }

    .flap {
        border-top-width: 73px;
        border-right-width: 110px;
        border-bottom-width: 73px;
        border-left-width: 110px;
    }

    .pocket {
        border-top-width: 73px;
        border-right-width: 110px;
        border-bottom-width: 73px;
        border-left-width: 110px;
    }

    .letter-preview {
        width: 190px;
        height: 115px;
    }

    .to-text {
        font-size: 1.5rem;
    }

    .envelope.open .letter-preview {
        transform: translateY(-85px) scale(1.05);
        height: 150px;
    }

    .hint-text {
        font-size: 1rem;
        bottom: -30px;
        padding: 4px 12px;
    }

    .romantic-title {
        font-size: 1.4rem;
        line-height: 1.5;
        margin-bottom: 20px;
    }

    #letter-screen {
        padding: 0 8px;
    }

    .letter-content {
        padding: 24px 14px;
    }

    .gallery-img, .gallery-video {
        border-width: 4px;
        border-radius: 8px;
        max-height: 60vh;
    }

    .gallery-img:hover {
        transform: none;
    }

    .media-gallery {
        gap: 20px;
    }

    .signature {
        font-size: 1.3rem;
        margin-top: 25px;
        padding-right: 5px;
        text-align: center;
    }

    .close-lightbox {
        top: 10px;
        right: 15px;
        font-size: 28px;
    }

    .lightbox-content {
        max-width: 95%;
        max-height: 85%;
    }
}

/* ===== VERY SMALL PHONES ===== */
@media (max-width: 360px) {
    .side-film-roll {
        height: 90px;
    }

    .side-film-img {
        width: 80px;
        min-height: 70px;
        margin-right: 6px;
    }

    .envelope {
        width: 190px;
        height: 126px;
    }

    .flap {
        border-top-width: 63px;
        border-right-width: 95px;
        border-bottom-width: 63px;
        border-left-width: 95px;
    }

    .pocket {
        border-top-width: 63px;
        border-right-width: 95px;
        border-bottom-width: 63px;
        border-left-width: 95px;
    }

    .letter-preview {
        width: 160px;
        height: 100px;
    }

    .to-text {
        font-size: 1.3rem;
    }

    .envelope.open .letter-preview {
        transform: translateY(-75px) scale(1.05);
        height: 130px;
    }

    .romantic-title {
        font-size: 1.2rem;
    }

    .login-box h1 {
        font-size: 1.3rem;
    }
}
