/**
 * Modal Styles
 * Contains modal overlay, content, and animation styles
 */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden; /* Prevent page scrolling when modal is open */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: block;
    opacity: 1;
}

.modal-content {
    background-color: white;
    max-width: 600px;
    margin: 60px auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    overflow: hidden;
    max-height: calc(100vh - 120px); /* Prevent modal from exceeding viewport */
    display: flex;
    flex-direction: column;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    background: var(--primary-color);
    padding: 20px 25px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 2.2rem;
    margin: 0;
    color: white;
    font-family: var(--heading-font);
}

#preview-result h4 {
    color: #666;
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.close-modal {
    color: white;
    font-size: 36px;
    cursor: pointer;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid white;
}

button.close-modal {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    margin: 0;
    line-height: 1;
    font-family: inherit;
}

.close-modal:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-body {
    padding: 25px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.modal-section {
    margin-bottom: 30px;
}

.modal-section h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--dark-color);
    font-family: var(--subheading-font);
}

.modal-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.modal-step {
    text-align: center;
    padding: 15px;
    background-color: #f9f7fd;
    border-radius: var(--border-radius);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.modal-step:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.modal-step .step-icon {
    width: 60px;
    height: 60px;
    background-color: var(--burgundy-soft);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--burgundy);
    margin-bottom: 15px;
    position: relative;
}

.modal-form {
    margin-top: 20px;
}

.modal-form input[type="text"],
.modal-form select {
    width: 100%;
    padding: 12px 15px;
    min-height: 44px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    font-family: var(--body-font);
    font-size: 1rem; /* 16px to prevent iOS zoom on focus */
    transition: var(--transition);
    box-sizing: border-box;
}

.modal-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
}

.modal-form input:focus,
.modal-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--burgundy-rgb, 247, 139, 120), 0.2);
}

.modal-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-note {
    color: var(--gray-color);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* Body scroll lock when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Preview content scrollable area */
.preview-content {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    padding: 25px;
    -webkit-overflow-scrolling: touch;
}

/* Collapsible TTS Pronunciation Section */
.tts-toggle-btn {
    background: none;
    border: none;
    padding: 8px 0;
    color: var(--primary-color, #666);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    transition: color 0.2s ease;
    margin-bottom: 0;
}

.tts-toggle-btn:hover {
    color: var(--burgundy, #8b2635);
    text-decoration: underline;
}

.tts-toggle-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

.tts-toggle-text {
    flex: 1;
}

.tts-toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.tts-toggle-btn[aria-expanded="true"] .tts-toggle-icon {
    transform: rotate(180deg);
}

.tts-collapsible {
    margin-top: 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out, margin-top 0.3s ease-out;
}

.tts-collapsible.expanded {
    max-height: 420px;
    opacity: 1;
    margin-top: 12px;
}

.tts-collapsible label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
}

.tts-collapsible .form-control {
    margin-bottom: 8px;
}

.tts-collapsible .form-text {
    margin-top: 0;
}

#preview-tts-regenerate-btn {
    width: 100%;
    margin-top: 8px;
}

@media (max-width: 480px) {
    #preview-tts-regenerate-btn {
        min-height: 44px;
    }
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5vh auto;
    }
    
    .modal-steps {
        flex-direction: column;
    }
    
    .modal-step {
        flex: none;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 0;
        align-items: stretch;
        overflow: hidden; /* Prevent page scrolling */
    }
    .modal.show {
        display: flex;
        flex-direction: column;
    }
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        max-height: 100vh;
        /* biome-ignore lint/style/noDuplicateDeclaration: intentional 100dvh fallback for mobile viewport */
        max-height: 100dvh;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        overflow: hidden;
    }
}

/* Shake Animation for Modal Attention */
.modal.shake-attention {
    animation: shake 0.6s ease;
}

/* Wiggle Animation for Call-to-Action */
.modal.wiggle-attention {
    animation: wiggle 0.5s ease infinite;
}
