/* ============================================
   CUORE DI LUNA - Final Polish
   Typography effects, tooltips, mobile menu, accessibility
   ============================================ */

/* ==================== SKIP LINK (Accessibility) ==================== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    background: var(--accent-gold);
    color: white;
    font-weight: 500;
    z-index: 10000;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    transition: top 0.3s ease;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    outline: none;
}

/* ==================== TYPING EFFECT ==================== */
.typing-text {
    display: inline;
}

.typing-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background: var(--accent-gold);
    margin-left: 4px;
    animation: cursorBlink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Hero title animation enhancement */
.hero-title .title-line {
    overflow: hidden;
}

.hero-title .title-line span {
    display: inline-block;
    animation: revealText 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
    transform: translateY(100%);
}

@keyframes revealText {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-title .title-line:nth-child(1) span { animation-delay: 0.3s; }
.hero-title .title-line:nth-child(2) span { animation-delay: 0.5s; }

/* ==================== ENHANCED MOBILE MENU ==================== */
@media (max-width: 991px) {
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 350px;
        height: 100vh;
        background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
        flex-direction: column;
        padding: 100px 2rem 2rem;
        gap: 0;
        box-shadow: -10px 0 40px rgba(45, 41, 38, 0.15);
        transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        overflow-y: auto;
        z-index: 999;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-menu li {
        opacity: 0;
        transform: translateX(20px);
        transition: all 0.3s ease;
    }

    .nav-menu.active li {
        opacity: 1;
        transform: translateX(0);
    }

    .nav-menu.active li:nth-child(1) { transition-delay: 0.1s; }
    .nav-menu.active li:nth-child(2) { transition-delay: 0.15s; }
    .nav-menu.active li:nth-child(3) { transition-delay: 0.2s; }
    .nav-menu.active li:nth-child(4) { transition-delay: 0.25s; }
    .nav-menu.active li:nth-child(5) { transition-delay: 0.3s; }
    .nav-menu.active li:nth-child(6) { transition-delay: 0.35s; }
    .nav-menu.active li:nth-child(7) { transition-delay: 0.4s; }

    .nav-menu a {
        display: block;
        padding: 1rem 0;
        font-size: 1.1rem;
        border-bottom: 1px solid rgba(212, 165, 116, 0.1);
    }

    .nav-menu a::after {
        display: none;
    }

    .nav-cta {
        margin-top: 1rem;
        text-align: center;
    }

    /* Overlay */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(45, 41, 38, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 998;
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Hamburger animation */
    .nav-toggle {
        z-index: 1001;
    }

    .nav-toggle span {
        transition: all 0.3s ease;
        transform-origin: center;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Close button in menu */
    .nav-close {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-secondary);
        border-radius: 50%;
        cursor: pointer;
    }

    .nav-close svg {
        width: 20px;
        height: 20px;
        stroke: var(--text-primary);
    }
}

/* ==================== ACTIVE SECTION INDICATOR ==================== */
.nav-menu a {
    position: relative;
}

.nav-menu a.active {
    color: var(--accent-gold);
}

.nav-menu a.active::after {
    width: 100%;
}

/* Desktop indicator dot */
@media (min-width: 992px) {
    .nav-menu a.active::before {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 6px;
        background: var(--accent-gold);
        border-radius: 50%;
    }
}

/* ==================== TOOLTIPS ==================== */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

.tooltip::before {
    content: attr(data-tooltip);
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    padding: 0.5rem 0.75rem;
    background: var(--text-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.tooltip::after {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
    margin-bottom: -4px;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

.tooltip:hover::before {
    transform: translateX(-50%) translateY(0);
}

/* Chakra dot tooltips */
.chakra-dot {
    position: relative;
    cursor: help;
}

.chakra-dot::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    padding: 4px 8px;
    background: var(--text-primary);
    color: white;
    font-size: 0.7rem;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.chakra-dot:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* ==================== FORM SUCCESS ANIMATION ==================== */
.form-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(253, 251, 247, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.form-success-overlay.active {
    opacity: 1;
    visibility: visible;
}

.success-checkmark {
    width: 100px;
    height: 100px;
    background: var(--chakra-heart);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-checkmark svg {
    width: 50px;
    height: 50px;
    stroke: white;
    stroke-width: 3;
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: drawCheck 0.5s ease 0.3s forwards;
}

@keyframes successPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.success-message {
    text-align: center;
}

.success-message h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.success-message p {
    color: var(--text-secondary);
}

/* ==================== QUIZ SHARE ==================== */
.share-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bg-secondary);
}

.share-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.share-btn:hover {
    transform: translateY(-3px);
}

.share-btn.whatsapp:hover { background: #25D366; }
.share-btn.facebook:hover { background: #1877F2; }
.share-btn.twitter:hover { background: #1DA1F2; }
.share-btn.copy:hover { background: var(--accent-gold); }

.share-btn:hover svg {
    stroke: white;
}

.share-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: stroke 0.3s ease;
}

/* Copy feedback */
.copy-feedback {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--text-primary);
    color: white;
    font-size: 0.7rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-feedback.show {
    opacity: 1;
}

/* ==================== PLACEHOLDER SHINE EFFECT ==================== */
.image-placeholder {
    position: relative;
    overflow: hidden;
}

.image-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: placeholderShine 3s ease-in-out infinite;
}

@keyframes placeholderShine {
    0% { left: -100%; }
    50%, 100% { left: 150%; }
}

/* Camera icon pulse */
.image-placeholder svg {
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* ==================== ENHANCED SCROLL INDICATOR ==================== */
.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.scroll-text {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-light);
    animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ==================== FOCUS STATES (Accessibility) ==================== */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 3px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 3px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

/* ==================== COOKIE BANNER ==================== */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}

.cookie-banner.active {
    transform: translateY(0);
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.cookie-banner-text h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.cookie-banner-text p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.cookie-banner-text a {
    color: var(--accent-gold);
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.cookie-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.cookie-btn.primary {
    background: var(--accent-gold);
    color: white;
    border: 2px solid var(--accent-gold);
}

.cookie-btn.primary:hover {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.cookie-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--bg-secondary);
}

.cookie-btn.secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .cookie-banner-content {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem 1rem;
        gap: 1rem;
    }

    .cookie-banner-actions {
        width: 100%;
        justify-content: center;
    }

    .cookie-btn {
        flex: 1;
        padding: 0.6rem 1rem;
    }
}

/* Footer Legal Links */
.footer-legal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-legal a,
.manage-cookies-btn {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color var(--transition-base);
}

.footer-legal a:hover,
.manage-cookies-btn:hover {
    color: var(--accent-gold);
}

.manage-cookies-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.footer-separator {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ==================== MAILTO CONFIRMATION ==================== */
.form-mailto-confirmation {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.form-mailto-confirmation.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.form-mailto-confirmation .confirmation-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-mailto-confirmation svg {
    width: 32px;
    height: 32px;
    stroke: var(--accent-gold);
    flex-shrink: 0;
}

.form-mailto-confirmation p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ==================== IMAGE PLACEHOLDER ACCESSIBILITY ==================== */
.image-placeholder[role="img"] {
    cursor: default;
}

.image-placeholder.has-image {
    background: none;
}

.image-placeholder.has-image::after {
    display: none;
}

.placeholder-replaced-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* Lazy loading fade-in for real images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img[loading="lazy"].loaded,
img.placeholder-replaced-image {
    opacity: 1;
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
    .typing-cursor,
    .image-placeholder::after,
    .image-placeholder svg {
        animation: none;
    }

    .hero-title .title-line span {
        animation: none;
        opacity: 1;
        transform: none;
    }

    img[loading="lazy"],
    .placeholder-replaced-image {
        transition: none;
        opacity: 1;
    }
}
