/* Bottom Sheet Component - Mobile-only slide-up modal for article details */
/* Only activates on mobile devices (≤768px) */

/* =============================================================================
   BACKDROP OVERLAY
   ============================================================================= */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.bottom-sheet-backdrop.active {
    opacity: 1;
    visibility: visible;
}

[data-theme="dark"] .bottom-sheet-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* =============================================================================
   SHEET CONTAINER
   ============================================================================= */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 90vh;
    min-height: 200px;
    border-radius: 1.5rem 1.5rem 0 0;
    transform: translateY(100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: none; /* Prevent browser scroll during drag */
    /* Removed will-change: transform - causes compositor layer issues on iPad PWA */

    /* Frutiger Aero glassmorphism */
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 255, 255, 0.85) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-bottom: none;
    box-shadow:
        0 -8px 32px rgba(0, 0, 0, 0.15),
        0 -2px 8px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.bottom-sheet.active {
    transform: translateY(0);
}

/* Half-expanded state (snap point at 50%) */
.bottom-sheet.half-expanded {
    transform: translateY(50%);
}

/* Dragging state - disable transitions for smooth drag */
.bottom-sheet.dragging {
    transition: none;
}

[data-theme="dark"] .bottom-sheet {
    background: linear-gradient(
        180deg,
        rgba(30, 30, 35, 0.98) 0%,
        rgba(25, 25, 30, 0.95) 100%
    );
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 -8px 32px rgba(0, 0, 0, 0.4),
        0 -2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* =============================================================================
   DRAG HANDLE
   ============================================================================= */
.bottom-sheet-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 0;
    cursor: grab;
}

.bottom-sheet-handle:active {
    cursor: grabbing;
}

.bottom-sheet-handle-bar {
    width: 36px;
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    transition: background 150ms ease, width 150ms ease;
}

.bottom-sheet-handle:hover .bottom-sheet-handle-bar {
    background: rgba(0, 0, 0, 0.35);
    width: 48px;
}

[data-theme="dark"] .bottom-sheet-handle-bar {
    background: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .bottom-sheet-handle:hover .bottom-sheet-handle-bar {
    background: rgba(255, 255, 255, 0.4);
}

/* =============================================================================
   HEADER
   ============================================================================= */
.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .bottom-sheet-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.bottom-sheet-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary, #1f2937);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    padding-right: 1rem;
}

.bottom-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-secondary, #6b7280);
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, transform 150ms ease;
    flex-shrink: 0;
}

.bottom-sheet-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-text-primary, #1f2937);
}

.bottom-sheet-close:active {
    transform: scale(0.95);
}

[data-theme="dark"] .bottom-sheet-close {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .bottom-sheet-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary, #f9fafb);
}

/* =============================================================================
   CONTENT AREA
   ============================================================================= */
.bottom-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
    max-height: calc(90vh - 100px); /* Account for handle + header */
}

/* Custom scrollbar for bottom sheet */
.bottom-sheet-body::-webkit-scrollbar {
    width: 6px;
}

.bottom-sheet-body::-webkit-scrollbar-track {
    background: transparent;
}

.bottom-sheet-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.bottom-sheet-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .bottom-sheet-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .bottom-sheet-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   SNAP INDICATOR (visual feedback during drag)
   ============================================================================= */
.bottom-sheet-snap-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: rgba(var(--primary-rgb), 0.5);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 150ms ease;
    pointer-events: none;
}

.bottom-sheet-snap-indicator.top {
    top: -12px;
}

.bottom-sheet-snap-indicator.middle {
    top: 50%;
}

.bottom-sheet.dragging .bottom-sheet-snap-indicator {
    opacity: 1;
}

/* =============================================================================
   MOBILE-ONLY ACTIVATION
   ============================================================================= */
/* Hide on desktop - desktop uses inline expansion */
@media (min-width: 769px) {
    .bottom-sheet,
    .bottom-sheet-backdrop {
        display: none !important;
    }
}

/* =============================================================================
   SAFE AREA INSETS (for notched devices)
   ============================================================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-sheet-body {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* =============================================================================
   REDUCED MOTION
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
    .bottom-sheet,
    .bottom-sheet-backdrop {
        transition: none;
    }

    .bottom-sheet-handle-bar {
        transition: none;
    }

    .bottom-sheet-close {
        transition: none;
    }
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes sheetSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

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

/* Spring-like bounce effect for opening (optional enhancement) */
.bottom-sheet.spring-open {
    animation: springSlideUp 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes springSlideUp {
    0% {
        transform: translateY(100%);
    }
    60% {
        transform: translateY(-3%);
    }
    100% {
        transform: translateY(0);
    }
}
