/* ═══════════════════════════════════════════════════════════
   El Couzina — Mobile Shell
   Bottom nav, FAB, scroll progress, back-to-top — mobile only
   ═══════════════════════════════════════════════════════════ */

/* ─── Scroll progress bar (top of page) ──────────────── */
.scroll-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    z-index: var(--z-progress);
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 0.1s linear;
    pointer-events: none;
    will-change: transform;
}

/* Progressive enhancement: scroll-driven */
@supports (animation-timeline: scroll()) {
    .scroll-progress {
        transition: none;
        animation: scrollFill linear both;
        animation-timeline: scroll();
    }
    @keyframes scrollFill {
        from { transform: scaleX(0); }
        to { transform: scaleX(1); }
    }
}

/* ─── Bottom Navigation (mobile only) ────────────────── */
.bottom-nav {
    display: none;
}

@media (max-width: 1023px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0;
        bottom: 0;
        height: calc(var(--bottom-nav-height) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
        background: var(--glass-bg);
        backdrop-filter: blur(var(--glass-blur)) saturate(1.8);
        -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.8);
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -8px 24px rgba(15, 44, 68, 0.1);
        z-index: var(--z-bottom-nav);
        align-items: stretch;
    }

    body {
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
    }

    .site-footer {
        padding-bottom: calc(var(--space-8) + var(--bottom-nav-height) + var(--safe-bottom));
    }
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: color var(--duration) var(--ease);
    padding: 8px 4px;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    transition: transform 0.35s var(--ease-elastic), color var(--duration) var(--ease);
}

.bottom-nav-item:hover,
.bottom-nav-item:active {
    color: var(--primary);
}

.bottom-nav-item.is-active {
    color: var(--primary);
}

.bottom-nav-item.is-active svg {
    transform: translateY(-3px) scale(1.12);
}

.bottom-nav-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 48px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: translateX(0);
    transition: transform 0.5s var(--ease-elastic), width 0.5s var(--ease-elastic), opacity var(--duration) var(--ease);
    pointer-events: none;
    opacity: 0;
}

.bottom-nav-indicator.is-ready { opacity: 1; }

/* ─── Floating Action Button (FAB) ───────────────────── */
.fab,
.fab-menu,
.fab-action {
    display: none;
}

@media (max-width: 1023px) {
    .fab {
        display: grid;
        place-items: center;
        position: fixed;
        right: calc(var(--mobile-gutter) + var(--safe-right));
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
        width: var(--fab-size);
        height: var(--fab-size);
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
        box-shadow: var(--shadow-float), 0 0 0 4px rgba(255, 255, 255, 0.1);
        z-index: var(--z-fab);
        cursor: pointer;
        transition: transform 0.4s var(--ease-elastic), box-shadow var(--duration) var(--ease);
        border: none;
        -webkit-tap-highlight-color: transparent;
    }

    .fab::before {
        content: '';
        position: absolute;
        inset: -4px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        opacity: 0;
        z-index: -1;
        animation: fabPulse 2.4s var(--ease) infinite;
    }

    @keyframes fabPulse {
        0%, 100% { opacity: 0; transform: scale(1); }
        50% { opacity: 0.3; transform: scale(1.15); }
    }

    .fab svg {
        width: 26px;
        height: 26px;
        stroke-width: 2.2;
        transition: transform 0.35s var(--ease-elastic);
    }

    .fab.is-open {
        transform: rotate(45deg);
        background: linear-gradient(135deg, var(--secondary) 0%, var(--accent-dark) 100%);
    }

    .fab-menu {
        display: grid;
        gap: var(--space-3);
        position: fixed;
        right: calc(var(--mobile-gutter) + var(--safe-right));
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--fab-size) + var(--space-6));
        z-index: var(--z-fab);
        pointer-events: none;
        opacity: 0;
        transform: translateY(16px) scale(0.8);
        transform-origin: bottom right;
        transition: all 0.35s var(--ease-elastic);
    }

    .fab-menu.is-open {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }

    .fab-action {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        justify-self: end;
        padding: 10px 16px 10px 10px;
        background: var(--bg-card);
        color: var(--text);
        text-decoration: none;
        border-radius: 999px;
        box-shadow: var(--shadow-float);
        font-size: 14px;
        font-weight: 600;
        border: 1px solid var(--border);
        transition: transform 0.2s var(--ease);
    }

    .fab-action:hover,
    .fab-action:active {
        transform: translateX(-3px);
        color: var(--primary);
    }

    .fab-action-icon {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), var(--primary-light));
        color: white;
        display: grid;
        place-items: center;
        flex-shrink: 0;
    }

    .fab-action-icon svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
    }

    /* Staggered entry */
    .fab-menu.is-open .fab-action {
        animation: fabActionIn 0.4s var(--ease-elastic) both;
    }

    .fab-menu.is-open .fab-action:nth-child(1) { animation-delay: 0.04s; }
    .fab-menu.is-open .fab-action:nth-child(2) { animation-delay: 0.08s; }
    .fab-menu.is-open .fab-action:nth-child(3) { animation-delay: 0.12s; }
    .fab-menu.is-open .fab-action:nth-child(4) { animation-delay: 0.16s; }

    @keyframes fabActionIn {
        from { opacity: 0; transform: translateY(12px) scale(0.7); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }
}

/* ─── Back to top ────────────────────────────────────── */
.back-to-top {
    display: none;
}

@media (max-width: 1023px) {
    .back-to-top {
        display: grid;
        place-items: center;
        position: fixed;
        left: calc(var(--mobile-gutter) + var(--safe-left));
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--glass-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--glass-border);
        color: var(--primary);
        box-shadow: var(--shadow);
        z-index: var(--z-fab);
        opacity: 0;
        visibility: hidden;
        transform: translateY(12px);
        transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease), visibility var(--duration) var(--ease);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .back-to-top.is-visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .back-to-top svg {
        width: 20px;
        height: 20px;
        stroke-width: 2.2;
    }
}

/* ─── Auto-hide header on scroll ─────────────────────── */
@media (max-width: 1023px) {
    .site-header.is-hidden {
        transform: translateY(-100%);
    }

    .site-header {
        transition: transform 0.4s var(--ease-out-expo), background var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    }
}

/* ─── Bottom sheet (category picker) ─────────────────── */
.sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-sheet);
    pointer-events: none;
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 26, 40, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}

.sheet-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85dvh;
    background: var(--bg-card);
    border-radius: 24px 24px 0 0;
    padding: var(--space-4) var(--space-6) calc(var(--space-8) + var(--safe-bottom));
    box-shadow: 0 -16px 48px rgba(15, 44, 68, 0.25);
    transform: translateY(100%);
    transition: transform 0.45s var(--ease-out-expo);
    overscroll-behavior: contain;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sheet.is-open {
    pointer-events: auto;
}

.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet.is-open .sheet-panel { transform: translateY(0); }

.sheet-grip {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 0 auto var(--space-4);
    touch-action: none;
}

.sheet-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: var(--space-5);
    text-align: center;
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.sheet-grid a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease);
    min-height: 56px;
}

.sheet-grid a:hover,
.sheet-grid a:active {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    border-color: var(--primary);
}

.sheet-grid-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.sheet-grid-count {
    margin-left: auto;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 28px;
    text-align: center;
}

.sheet-grid a:hover .sheet-grid-count,
.sheet-grid a:active .sheet-grid-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ─── Ripple effect ──────────────────────────────────── */
.ripple {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.25;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1);
    animation: rippleOut 0.65s var(--ease-out) forwards;
    mix-blend-mode: lighten;
}

@keyframes rippleOut {
    to { transform: translate(-50%, -50%) scale(28); opacity: 0; }
}

/* Elements with ripple need overflow:hidden and position:relative */
.btn, .menu-tab, .bottom-nav-item, .fab-action, .category-card {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* ─── Tap feedback (press scale) ─────────────────────── */
@media (hover: none) {
    .tappable,
    .btn:active,
    .menu-item:active,
    .category-card:active,
    .bottom-nav-item:active {
        transition: transform 0.08s var(--ease-out);
    }

    .btn:active {
        transform: scale(0.96);
    }
}

/* ─── Theme toggle button ────────────────────────────── */
.theme-toggle {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    border: 1.5px solid var(--primary);
    transition: all var(--duration) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    transform: rotate(15deg);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

:root[data-theme="dark"] .theme-toggle {
    color: var(--secondary);
    border-color: var(--secondary);
}

:root[data-theme="dark"] .theme-toggle:hover {
    background: var(--secondary);
    color: var(--bg-dark);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.5s var(--ease-elastic);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

:root[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
:root[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
