/* ========================================
   HTBY MODAL OVERLAY SYSTEM
   Reusable modal/popup styles
   ======================================== 
   
   PURPOSE:
   Provides consistent modal/overlay styling that can be used
   throughout the site for privacy policies, terms, popups, etc.
   
   USAGE:
   Apply these classes to modal elements created by JavaScript:
   
   <div class="htby-modal-overlay">
     <div class="htby-modal-content">
       <button class="htby-modal-close">&times;</button>
       <div class="htby-modal-body">
         <!-- Your content here -->
       </div>
     </div>
   </div>
   
   ======================================== */

/* Modal overlay - darkens background */
.htby-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    opacity: 0;
    transition: opacity var(--transition-base);
    cursor: pointer; /* Click anywhere to close */
}

/* Show modal with fade-in */
.htby-modal-overlay.htby-modal-show {
    opacity: 1;
}

/* Modal content box */
.htby-modal-content {
    background: white;
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
    transform: scale(0.9);
    transition: transform var(--transition-base);
    cursor: auto; /* Don't close when clicking content */
}

/* Scale up modal when showing */
.htby-modal-overlay.htby-modal-show .htby-modal-content {
    transform: scale(1);
}

/* Close button */
.htby-modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: transparent;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--color-htby-text-light);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
    z-index: 10;
}

.htby-modal-close:hover {
    background: var(--color-htby-light);
    color: var(--color-htby-text);
    transform: rotate(90deg);
}

.htby-modal-close:focus {
    outline: 2px solid var(--color-htby-green);
    outline-offset: 2px;
}

/* Modal header (optional) */
.htby-modal-header {
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-md);
    border-bottom: 2px solid var(--color-htby-border);
}

.htby-modal-header h2 {
    margin: 0;
    font-size: var(--font-size-h2);
    font-weight: var(--font-weight-bold);
    color: var(--color-htby-text);
    padding-right: 50px; /* Space for close button */
}

/* Modal body - scrollable content area */
.htby-modal-body {
    padding: var(--spacing-xl);
    overflow-y: auto;
    max-height: calc(85vh - 80px); /* Account for header/footer */
}

/* Tighter typography for modal content */
.htby-modal-body h1 {
    font-size: 1.75rem !important;
    margin-top: 0 !important;
    margin-bottom: var(--spacing-md) !important;
}

.htby-modal-body h2 {
    font-size: 1.5rem !important;
    margin-top: var(--spacing-lg) !important;
    margin-bottom: var(--spacing-sm) !important;
}

.htby-modal-body h3 {
    font-size: 1.125rem !important;
    margin-top: var(--spacing-md) !important;
    margin-bottom: var(--spacing-xs) !important;
}

.htby-modal-body p {
    margin-bottom: var(--spacing-sm) !important;
    line-height: var(--line-height-normal) !important;
}

.htby-modal-body ul,
.htby-modal-body ol {
    margin-bottom: var(--spacing-md) !important;
    padding-left: var(--spacing-xl) !important;
}

.htby-modal-body li {
    margin-bottom: var(--spacing-xs) !important;
}

/* Modal footer (optional) */
.htby-modal-footer {
    padding: var(--spacing-md) var(--spacing-xl);
    border-top: 1px solid var(--color-htby-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

/* =====================================
   MOBILE RESPONSIVE
   ===================================== */

@media (max-width: 768px) {
    .htby-modal-overlay {
        padding: var(--spacing-md);
    }
    
    .htby-modal-content {
        max-height: 95vh;
    }
    
    .htby-modal-body {
        padding: var(--spacing-md);
        max-height: calc(95vh - 60px);
    }
    
    .htby-modal-header {
        padding: var(--spacing-md);
    }
    
    .htby-modal-header h2 {
        font-size: 1.5rem;
    }
    
    .htby-modal-close {
        top: var(--spacing-sm);
        right: var(--spacing-sm);
        width: 36px;
        height: 36px;
        font-size: 1.75rem;
    }
}

/* =====================================
   ACCESSIBILITY
   ===================================== */

/* Prevent body scroll when modal is open */
body.htby-modal-open {
    overflow: hidden;
}

/* Focus trap for keyboard navigation */
.htby-modal-overlay:focus {
    outline: none;
}

/* Ensure modal is announced to screen readers */
.htby-modal-content[role="dialog"] {
    /* Applied via JavaScript */
}

/* =====================================
   PRIVACY POLICY SPECIFIC STYLES
   ===================================== */

/* Style the privacy policy toggle link */
.htby-privacy-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: var(--spacing-xs) !important;
    color: var(--color-htby-green) !important;
    text-decoration: none !important;
    font-weight: var(--font-weight-medium) !important;
    cursor: pointer !important;
    transition: color var(--transition-fast) !important;
}

.htby-privacy-toggle:hover {
    color: var(--color-htby-green-dark) !important;
    text-decoration: underline !important;
}

.htby-privacy-toggle::before {
    content: "📄";
    font-size: 1.2em;
}