@layer components {
    .official-letter {
        background: #fffef0; /* Mierne zažltnutý papier */
        padding: 3rem;
        box-shadow: var(--shadow-md);
        border: 1px solid var(--color-border);
        transform: rotate(-2deg);
        position: relative;
        z-index: 1;
        width: 100%;
        max-width: 500px;
        aspect-ratio: 1.6 / 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        font-family: "Courier New", Courier, monospace;
        color: #333;

        [data-theme="dark"] & {
            background: #e0ddd0; /* Tmavší papier pre dark mode, aby nepálil oči */
            color: #1a1a1a;
        }

        /* Start animation immediately */
        animation: letterArrival 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
        animation-delay: 0.1s;
        will-change: transform, opacity;
        transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.6s ease;

        & .official-letter__sender {
            font-size: 0.85rem;
            line-height: 1.2;
            align-self: flex-start;
            position: relative;
            z-index: 2;
        }

        & .official-letter__flap {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 40%;
            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
            clip-path: polygon(0 0, 100% 0, 100% 40%, 50% 100%, 0 40%);
            background: rgba(0, 0, 0, 0.05);
            z-index: 1;
            pointer-events: none;

            [data-theme="dark"] & {
                border-bottom-color: rgba(0, 0, 0, 0.2);
                background: rgba(0, 0, 0, 0.1);
            }
        }

        & .official-letter__stamp {
            position: absolute;
            top: 20%;
            right: 10%;
            border: 3px double #a93226;
            color: #a93226;
            padding: 0.5rem 1rem;
            font-weight: bold;
            text-transform: uppercase;
            transform: rotate(15deg) scale(2);
            opacity: 0;
            mix-blend-mode: multiply;
            animation: stampSlam 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
            animation-delay: 1.3s;
            pointer-events: none;
        }

        & .official-letter__recipient {
            font-size: 1.2rem;
            line-height: 1.4;
            align-self: flex-end;
            margin-right: 10%;
            margin-bottom: 1rem;
            position: relative;
            z-index: 2;
            overflow-wrap: break-word;
            word-break: break-word;
            max-width: 80%;
        }

        & .official-letter__cta {
            position: absolute;
            bottom: -1.5rem;
            left: 50%;
            transform: translateX(-50%);
            background: var(--color-secondary);
            color: var(--color-on-secondary);
            padding: 0.5rem 1.5rem;
            font-family: var(--font-sans); /* Späť k systémovému fontu pre CTA */
            font-weight: bold;
            font-size: 0.9rem;
            box-shadow: var(--shadow-sm);
            border-radius: 4px;
            width: max-content;
            max-width: 90%;
            text-align: center;
        }

        &:hover {
            transform: rotate(0deg) translateY(-10px) scale(1.02);
            box-shadow: var(--shadow-lg);
        }

        @media (max-width: 480px) {
            padding: 2rem 1.5rem;
            aspect-ratio: auto;
            min-height: 250px;

            & .official-letter__recipient {
                margin-right: 0;
                max-width: 100%;
                font-size: 1.1rem;
            }

            & .official-letter__cta {
                width: 90%;
                font-size: 0.8rem;
                bottom: -1rem;
            }

            & .official-letter__stamp {
                transform: rotate(15deg) scale(1.2);
                right: 5%;
                top: 25%;
            }
        }
    }
}

@keyframes letterArrival {
    from {
        opacity: 0;
        transform: translateY(100px) rotate(-10deg) rotateX(-30deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(-2deg) rotateX(0);
    }
}

@keyframes stampSlam {
    0% {
        opacity: 0;
        transform: rotate(45deg) scale(3);
        filter: blur(5px);
    }
    70% {
        opacity: 1;
        transform: rotate(15deg) scale(0.9);
    }
    100% {
        opacity: 0.6;
        transform: rotate(15deg) scale(1);
    }
}

/* Disabled scroll-timeline because it might conflict with initial animation in some browsers */
/*
@supports (animation-timeline: view()) {
  .official-letter {
    animation-timeline: none, view();
    animation-name: letterArrival, letterFloat;
  }

  @keyframes letterFloat {
    from { transform: rotate(-2deg) translateY(0); }
    to { transform: rotate(5deg) translateY(-100px); }
  }
}
*/
