/**
 * Mobile Modal System Styles
 *
 * Full-screen modals for ingredients and recipe steps on mobile devices
 */

/* ==========================================================================
   Modal Backdrop & Base
   ========================================================================== */

.recipe-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.recipe-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.recipe-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--vv-color-bg-primary);
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.recipe-modal-backdrop.active .recipe-modal {
    transform: translateY(0);
}

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

/* ==========================================================================
   Modal Header
   ========================================================================== */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--vv-color-bg-primary);
    border-bottom: 1px solid var(--vv-color-border);
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 60px;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--vv-color-text-primary);
    flex: 1;
    text-align: center;
}

.modal-back,
.modal-close {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--vv-color-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.modal-back:hover,
.modal-close:hover {
    background: #f5f5f5;
}

.modal-back:active,
.modal-close:active {
    background: var(--vv-color-border);
}

/* ==========================================================================
   Modal Content
   ========================================================================== */

.modal-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
}

/* ==========================================================================
   Ingredients Modal
   ========================================================================== */

/* Category sections */
.ingredient-category-section {
    margin-bottom: 2rem;
}

.ingredient-category-section:last-child {
    margin-bottom: 0;
}

.ingredient-category-section .category-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--vv-color-primary);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--vv-color-primary);
}

.ingredients-list-large {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ingredient-item {
    display: flex;
    align-items: baseline;
    padding: 1rem 0;
    border-bottom: 1px solid var(--vv-color-border);
    font-size: 1.125rem;
    line-height: 1.6;
}

.ingredient-item:last-child {
    border-bottom: none;
}

.ingredient-amount {
    font-weight: 700;
    color: var(--vv-color-primary);
    margin-right: 0.75rem;
    min-width: 80px;
    flex-shrink: 0;
}

.ingredient-name {
    color: var(--vv-color-text-primary);
    flex: 1;
}

/* ==========================================================================
   Steps Modal
   ========================================================================== */

.step-content-large {
    max-width: 100%;
}

.step-image-large {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
}

.step-image-large img {
    width: 100%;
    height: auto;
    display: block;
}

.step-title-large {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--vv-color-text-primary);
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.step-description-large {
    font-size: 1.125rem;
    line-height: 1.7;
    color: #555555;
    margin-bottom: 1.5rem;
}

.step-description-large p {
    margin: 0 0 1rem 0;
}

.step-description-large p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Timer
   ========================================================================== */

.step-timer-container {
    margin-top: 1.5rem;
}

.start-timer {
    width: 100%;
    padding: 1rem;
    background: var(--vv-color-success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
}

.start-timer:hover {
    background: var(--vv-color-success-hover);
}

.start-timer:active {
    background: #3d8b40;
}

.start-timer.timer-active {
    background: #FF9800;
    cursor: default;
}

.start-timer.timer-active:hover {
    background: #FF9800;
}

.start-timer.timer-finished {
    background: var(--vv-color-success);
    cursor: default;
}

.start-timer:disabled {
    opacity: 1;
}

/* ==========================================================================
   Modal Footer (Navigation)
   ========================================================================== */

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--vv-color-bg-primary);
    border-top: 1px solid var(--vv-color-border);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.step-nav {
    flex: 1;
    padding: 1rem;
    background: var(--vv-color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
}

.step-nav:hover {
    background: var(--vv-color-primary-hover);
}

.step-nav:active {
    background: var(--vv-color-primary-active);
}

.step-nav:disabled {
    background: #cccccc;
    color: #888888;
    cursor: not-allowed;
}

.step-nav svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Mobile Trigger Buttons
   ========================================================================== */

.mobile-only {
    display: none;
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }
}

.recipe-ingredients-trigger,
.recipe-steps-trigger {
    width: 100%;
    padding: 1.25rem 1.5rem;
    background: var(--vv-color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: background 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.recipe-ingredients-trigger:hover,
.recipe-steps-trigger:hover {
    background: var(--vv-color-primary-hover);
}

.recipe-ingredients-trigger:active,
.recipe-steps-trigger:active {
    background: var(--vv-color-primary-active);
    transform: translateY(1px);
}

/* ==========================================================================
   Desktop: Hide mobile elements
   ========================================================================== */

@media (min-width: 768px) {
    .recipe-ingredients-trigger,
    .recipe-steps-trigger {
        display: none !important;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ==========================================================================
   Safe Area (iPhone notch support)
   ========================================================================== */

@supports (padding: max(0px)) {
    .modal-header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .modal-content {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .modal-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles */
.modal-back:focus,
.modal-close:focus,
.start-timer:focus,
.step-nav:focus {
    outline: 2px solid var(--vv-color-primary);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .recipe-modal-backdrop,
    .recipe-modal,
    .modal-back,
    .modal-close,
    .start-timer,
    .step-nav {
        transition: none;
    }
}
