/**
 * Breakpoint UI & Messaging Styles
 * Story 11.3
 *
 * Trauma-informed design principles:
 * - Soft, non-alarming colors
 * - Smooth transitions
 * - Clear visual hierarchy
 * - Accessible touch targets
 */

/* === Animations === */

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.animate-fade-in {
    animation: fade-in 0.4s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

.animate-fade-out {
    animation: fade-out 0.3s ease-out;
}

/* === Breakpoint Message Container === */

.breakpoint-message-container {
    margin: 1rem 0;
}

.breakpoint-message {
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay for depth */
.breakpoint-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 1;
}

.breakpoint-message > * {
    position: relative;
    z-index: 2;
}

/* === Intervention Cards === */

.intervention-card {
    position: relative;
    transition: all 0.2s ease-in-out;
}

.intervention-card:hover {
    transform: translateY(-2px);
}

.intervention-card.faded {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === Intervention Detail Modal === */

.intervention-modal {
    transition: opacity 0.3s ease-out;
}

.intervention-modal.show {
    display: flex !important;
}

.intervention-modal .modal-overlay {
    transition: opacity 0.3s ease-out;
}

.intervention-modal .modal-content {
    transition: all 0.3s ease-out;
    transform-origin: center;
}

/* Smooth scrolling in modal */
.modal-body {
    scroll-behavior: smooth;
}

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

/* === Temporary Message (Toast) === */

.temporary-message {
    transition: opacity 0.3s ease-out;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* === Button States === */

.intervention-action-btn {
    position: relative;
    overflow: hidden;
}

.intervention-action-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.intervention-action-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Loading state for buttons */
.intervention-action-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* === Mobile Responsive Adjustments === */

/* Mobile: Full-width cards, larger touch targets */
@media (max-width: 640px) {
    .breakpoint-message {
        border-radius: 1rem;
        padding: 1.25rem;
    }

    .intervention-card {
        border-radius: 0.75rem;
        padding: 1rem;
    }

    /* Ensure buttons are touch-friendly */
    .intervention-action-btn {
        min-height: 44px;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Stack buttons vertically on mobile */
    .intervention-card .flex.gap-2 {
        flex-direction: column;
    }

    .intervention-card button {
        width: 100%;
    }

    /* Modal takes full screen on mobile */
    .intervention-modal .modal-content {
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .intervention-modal .flex.min-h-full {
        padding: 0;
        align-items: flex-start;
    }
}

/* Tablet: Optimize spacing */
@media (min-width: 641px) and (max-width: 1024px) {
    .breakpoint-message {
        padding: 1.5rem;
    }

    .intervention-card {
        padding: 1.25rem;
    }
}

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

/* Focus states for keyboard navigation */
.intervention-action-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .breakpoint-message {
        border-width: 3px;
    }

    .intervention-card {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .intervention-card:hover {
        transform: none;
    }
}

/* === Print Styles === */
/* Hide interactive elements when printing */
@media print {
    .intervention-action-btn,
    .intervention-modal,
    .temporary-message {
        display: none !important;
    }

    .breakpoint-message,
    .intervention-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* === Dark Mode Support (Future Enhancement) === */
@media (prefers-color-scheme: dark) {
    /* Adjust colors for dark mode if needed */
    /* Currently using light theme for trauma-informed design */
}

/* === Smooth Scroll Behavior === */
.interventions-container {
    scroll-behavior: smooth;
}

/* === Loading Spinner === */
.intervention-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Utility Classes === */

.pointer-events-none {
    pointer-events: none;
}

.cursor-not-allowed {
    cursor: not-allowed;
}

/* Truncate text with ellipsis */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Z-Index Management === */
.intervention-modal {
    z-index: 9999;
}

.temporary-message {
    z-index: 10000;
}
