/**
 * iOS Touch Feedback & Scroll Physics
 * Native-like interactions for Capacitor app
 *
 * @version 1.0.0
 */

/* ========================================
   Scroll Physics - iOS Momentum Scrolling
   ======================================== */

/* Prevent body double-bounce */
html, body {
    overscroll-behavior: none;
    overscroll-behavior-y: none;
}

/* iOS momentum scrolling for containers */
.ios-scroll-container,
.page-content,
.modal-body,
.list-container,
.card-list,
.scroll-area {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
    transform: translateZ(0); /* Hardware acceleration */
    touch-action: pan-y; /* Enable vertical scrolling */
}

/* Scrollable containers auto-detection */
[style*="overflow: auto"],
[style*="overflow-y: auto"],
[style*="overflow-y: scroll"],
.overflow-auto,
.overflow-y-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* ========================================
   Touch Feedback - Tappable Elements
   ======================================== */

/* Base tappable class - for all interactive elements */
.ios-tappable {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.1s ease;
    will-change: transform;
}

.ios-tappable:active {
    transform: scale(0.97);
    opacity: 0.8;
}

/* Prevent flash on rapid taps */
.ios-tappable:focus {
    outline: none;
}

/* ========================================
   Card Interactions
   ======================================== */

/* Cards that navigate/are clickable */
.ios-card-interactive {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.2s ease,
                background-color 0.15s ease;
    will-change: transform;
}

.ios-card-interactive:active {
    transform: scale(0.98);
    background-color: rgba(255, 255, 255, 0.02);
}

/* Subtle press effect for cards */
.ios-card-press {
    transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ios-card-press:active {
    transform: scale(0.985) translateY(1px);
}

/* ========================================
   List Item Interactions
   ======================================== */

/* List items with highlight feedback */
.ios-list-item-tappable {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

.ios-list-item-tappable:active {
    background-color: rgba(255, 255, 255, 0.08);
}

/* List item with chevron indicator */
.ios-list-item-tappable.has-chevron::after {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary, #636366);
    font-size: 12px;
    opacity: 0.5;
}

/* ========================================
   Button Enhancements
   ======================================== */

/* Primary button with bounce */
.btn-primary.ios-tappable:active,
.btn.btn-primary:active {
    transform: scale(0.96);
}

/* Destructive/danger button */
.btn-danger.ios-tappable:active,
.btn.btn-danger:active {
    transform: scale(0.96);
}

/* Icon buttons (circular) */
.ios-icon-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background-color 0.15s ease;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.ios-icon-btn:active {
    transform: scale(0.9);
    background-color: rgba(255, 255, 255, 0.1);
}

/* ========================================
   Navigation Tab Feedback
   ======================================== */

.ios-tab-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

.ios-tab-item:active {
    transform: scale(0.92);
    opacity: 0.7;
}

/* ========================================
   Form Element Feedback
   ======================================== */

/* Checkbox/Radio tap area */
.ios-checkbox-wrapper,
.ios-radio-wrapper {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 8px 0;
}

/* Toggle switch feedback */
.ios-toggle-wrapper {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

.ios-toggle-wrapper:active .ios-toggle {
    transform: scale(0.95);
}

/* Input focus enhancement */
input.ios-input:focus,
textarea.ios-input:focus,
select.ios-input:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
    border-color: var(--ios-blue, #0A84FF);
}

/* ========================================
   Modal/Sheet Interactions
   ======================================== */

/* Modal backdrop tap */
.ios-modal-backdrop {
    -webkit-tap-highlight-color: transparent;
}

/* Sheet drag handle */
.ios-sheet-handle {
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    cursor: grab;
}

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

/* ========================================
   Swipe Action Hints
   ======================================== */

.ios-swipeable {
    touch-action: pan-x pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* ========================================
   Pull to Refresh Zone
   ======================================== */

.ios-pull-zone {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   Ripple Effect (subtle, iOS-appropriate)
   ======================================== */

.ios-ripple {
    position: relative;
    overflow: hidden;
}

.ios-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.ios-ripple:active::after {
    width: 200%;
    height: 200%;
    opacity: 1;
}

/* ========================================
   Disabled State
   ======================================== */

.ios-tappable:disabled,
.ios-tappable.disabled,
.ios-card-interactive:disabled,
.ios-card-interactive.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   Reduced Motion Support
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .ios-tappable,
    .ios-card-interactive,
    .ios-card-press,
    .ios-list-item-tappable,
    .ios-icon-btn,
    .ios-tab-item {
        transition: none !important;
    }

    .ios-tappable:active,
    .ios-card-interactive:active,
    .ios-card-press:active,
    .ios-icon-btn:active,
    .ios-tab-item:active {
        transform: none !important;
    }
}
