/**
 * Ceska Kuchyne - Mobile Styles
 * Mobile-first optimizations for food blog
 */

/* ===========================================
   MOBILE BASE
   =========================================== */

@media (max-width: 768px) {
    :root {
        --ck-header-height: var(--ck-mobile-header);
    }

    body {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
    }

    .container {
        padding: 0 var(--ck-space-4);
    }

    /* Sections */
    .section {
        padding: var(--ck-space-6) 0;
    }

    .section-sm {
        padding: var(--ck-space-4) 0;
    }
}

/* ===========================================
   MOBILE HEADER
   =========================================== */

@media (max-width: 768px) {
    .site-header {
        height: var(--ck-mobile-header);
    }

    .header-inner {
        padding: 0 var(--ck-space-3);
    }

    .site-logo {
        font-size: 1.25rem;
    }

    .site-logo img {
        height: 36px;
    }

    .search-toggle,
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
}

/* ===========================================
   MOBILE PROMO BAR - News Article Promotion
   =========================================== */

.mobile-promo-bar {
    display: none;
}

@media (max-width: 768px) {
    .mobile-promo-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: var(--ck-space-3);
        padding-bottom: calc(var(--ck-space-3) + env(safe-area-inset-bottom, 0));
        background: var(--ck-paper-pure);
        border-top: 1px solid var(--ck-paper-cream);
        box-shadow: 0 -4px 20px rgba(45, 37, 32, 0.1);
        z-index: 1000;
        transform: translateY(0);
        transition: transform 0.3s ease;
    }

    .mobile-promo-bar.is-hidden {
        transform: translateY(100%);
    }

    .mobile-promo-bar__close {
        position: absolute;
        top: var(--ck-space-2);
        right: var(--ck-space-2);
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--ck-paper-cream);
        border: none;
        border-radius: var(--ck-radius-full);
        color: var(--ck-ink-muted);
        cursor: pointer;
        z-index: 10;
        transition: all 0.2s ease;
    }

    .mobile-promo-bar__close:active {
        background: var(--ck-ink-subtle);
        color: white;
    }

    .mobile-promo-bar__close svg {
        width: 14px;
        height: 14px;
    }

    .mobile-promo-bar__link {
        display: flex;
        align-items: center;
        gap: var(--ck-space-3);
        width: 100%;
        text-decoration: none;
        color: inherit;
    }

    .mobile-promo-bar__image {
        flex-shrink: 0;
        width: 56px;
        height: 56px;
        border-radius: var(--ck-radius-md);
        overflow: hidden;
        background: var(--ck-paper-cream);
    }

    .mobile-promo-bar__image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-promo-bar__placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--ck-ink-subtle);
    }

    .mobile-promo-bar__placeholder svg {
        width: 24px;
        height: 24px;
    }

    .mobile-promo-bar__content {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding-right: var(--ck-space-2);
    }

    .mobile-promo-bar__label {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--ck-accent-dark);
    }

    .mobile-promo-bar__label svg {
        color: var(--ck-gold);
    }

    .mobile-promo-bar__title {
        font-family: var(--ck-font-display);
        font-size: 0.9375rem;
        font-weight: 600;
        color: var(--ck-ink);
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-promo-bar__arrow {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--ck-accent);
        border-radius: var(--ck-radius-full);
        color: white;
    }

    .mobile-promo-bar__arrow svg {
        width: 18px;
        height: 18px;
    }

    /* Dark mode */
    .dark-mode .mobile-promo-bar {
        background: var(--ck-paper);
        border-color: var(--ck-paper-cream);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .dark-mode .mobile-promo-bar__close {
        background: var(--ck-paper-warm);
    }
}

/* ===========================================
   MOBILE RECIPE CARDS
   =========================================== */

@media (max-width: 768px) {
    /* Simplified cards for mobile */
    .recipe-card {
        border-radius: var(--ck-radius-md);
    }

    .recipe-card__content {
        padding: var(--ck-space-3);
    }

    .recipe-card__title {
        font-size: 1rem;
        -webkit-line-clamp: 2;
    }

    .recipe-card__category {
        font-size: 0.6875rem;
        padding: 3px var(--ck-space-2);
    }

    .recipe-card__meta {
        gap: var(--ck-space-3);
        font-size: 0.75rem;
    }

    /* Always show save button on mobile */
    .recipe-card__save {
        opacity: 1;
        transform: scale(1);
        width: 36px;
        height: 36px;
    }

    .recipe-card__save svg {
        width: 18px;
        height: 18px;
    }
}

/* ===========================================
   MOBILE FEATURED CARD
   =========================================== */

@media (max-width: 768px) {
    .recipe-card-featured {
        aspect-ratio: 4/5;
        border-radius: var(--ck-radius-lg);
    }

    .recipe-card-featured__content {
        padding: var(--ck-space-4);
    }

    .recipe-card-featured__title {
        font-size: 1.5rem;
    }

    .recipe-card-featured__meta {
        gap: var(--ck-space-3);
        font-size: 0.8125rem;
    }
}

/* ===========================================
   MOBILE CATEGORY PILLS
   =========================================== */

@media (max-width: 768px) {
    .category-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: var(--ck-space-2) 0;
        margin: 0 calc(var(--ck-space-4) * -1);
        padding-left: var(--ck-space-4);
        gap: var(--ck-space-2);
        justify-content: flex-start;
        scrollbar-width: none;
    }

    .category-pills::-webkit-scrollbar {
        display: none;
    }

    .category-pill {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: var(--ck-space-2) var(--ck-space-3);
        font-size: 0.8125rem;
    }

    .category-pill:last-child {
        margin-right: var(--ck-space-4);
    }
}

/* ===========================================
   MOBILE SECTION HEADERS
   =========================================== */

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--ck-space-2);
        margin-bottom: var(--ck-space-4);
    }

    .section-header__title {
        font-size: 1.375rem;
    }

    .section-header__link {
        font-size: 0.875rem;
    }
}

/* ===========================================
   READING PROGRESS BAR
   =========================================== */

.reading-progress {
    position: fixed;
    top: var(--ck-mobile-header);
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ck-paper-cream);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reading-progress.is-visible {
    opacity: 1;
}

.reading-progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ck-accent) 0%, var(--ck-gold) 100%);
    width: 0%;
    transition: width 0.1s ease-out;
}

@media (min-width: 769px) {
    .reading-progress {
        display: none;
    }
}

/* ===========================================
   STICKY RECIPE ACTIONS
   =========================================== */

.recipe-actions-sticky {
    display: none;
}

@media (max-width: 768px) {
    .recipe-actions-sticky {
        display: flex;
        position: fixed;
        bottom: calc(70px + env(safe-area-inset-bottom, 0));
        left: var(--ck-space-4);
        right: var(--ck-space-4);
        gap: var(--ck-space-2);
        padding: var(--ck-space-3);
        background: var(--ck-paper-pure);
        border-radius: var(--ck-radius-lg);
        box-shadow: 0 4px 20px rgba(45, 37, 32, 0.15);
        z-index: 500;
        opacity: 0;
        transform: translateY(20px);
        transition: all 0.3s ease;
        pointer-events: none;
    }

    .recipe-actions-sticky.is-visible {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .recipe-action-sticky-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--ck-space-2);
        padding: var(--ck-space-3);
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--ck-ink-muted);
        background: var(--ck-paper-cream);
        border: none;
        border-radius: var(--ck-radius-md);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .recipe-action-sticky-btn:active {
        transform: scale(0.98);
    }

    .recipe-action-sticky-btn.is-saved,
    .recipe-action-sticky-btn--primary {
        background: var(--ck-accent);
        color: white;
    }

    .recipe-action-sticky-btn svg {
        width: 20px;
        height: 20px;
    }

    .recipe-action-sticky-btn.is-saved svg {
        fill: currentColor;
    }

    .dark-mode .recipe-actions-sticky {
        background: var(--ck-paper-warm);
    }
}

/* ===========================================
   MOBILE TOAST NOTIFICATIONS
   =========================================== */

.mobile-toast {
    position: fixed;
    bottom: calc(140px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: var(--ck-space-3) var(--ck-space-5);
    background: var(--ck-ink);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--ck-radius-full);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    pointer-events: none;
}

.mobile-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mobile-toast--success {
    background: var(--ck-green);
}

.mobile-toast--error {
    background: var(--ck-red);
}

/* ===========================================
   AD SLOTS
   =========================================== */

.ck-ad {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    background: var(--ck-paper-warm);
    border-radius: var(--ck-radius-lg);
}

/* In-feed ads */
.ck-ad--in-feed {
    min-height: 250px;
    margin: var(--ck-space-4) 0;
    padding: var(--ck-space-4);
}

@media (max-width: 768px) {
    .ck-ad--in-feed {
        margin: var(--ck-space-3) 0;
        border-radius: var(--ck-radius-md);
    }
}

/* In-article ads */
.ck-ad--in-article {
    min-height: 280px;
    margin: var(--ck-space-8) auto;
    max-width: 100%;
}

@media (max-width: 768px) {
    .ck-ad--in-article {
        margin: var(--ck-space-6) calc(var(--ck-space-4) * -1);
        width: calc(100% + var(--ck-space-4) * 2);
        max-width: none;
        border-radius: 0;
    }
}

/* After post ads */
.ck-ad--after-post {
    min-height: 250px;
    margin: var(--ck-space-8) 0;
    padding: var(--ck-space-5);
}

@media (max-width: 768px) {
    .ck-ad--after-post {
        margin: var(--ck-space-6) calc(var(--ck-space-4) * -1);
        width: calc(100% + var(--ck-space-4) * 2);
        border-radius: 0;
    }
}

/* Sticky footer ad */
.ck-ad--sticky {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom, 0));
    left: 0;
    right: 0;
    min-height: 50px;
    max-height: 100px;
    z-index: 350;
    background: var(--ck-paper-pure);
    border-top: 1px solid var(--ck-paper-cream);
    border-radius: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.ck-ad--sticky.is-visible {
    transform: translateY(0);
}

/* Ad placeholder */
.ck-ad__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: inherit;
    background: repeating-linear-gradient(
        45deg,
        var(--ck-paper-cream),
        var(--ck-paper-cream) 10px,
        var(--ck-paper-warm) 10px,
        var(--ck-paper-warm) 20px
    );
    border: 2px dashed var(--ck-paper-cream);
    border-radius: inherit;
}

.ck-ad__label {
    padding: var(--ck-space-2) var(--ck-space-4);
    background: var(--ck-paper-pure);
    border-radius: var(--ck-radius-md);
    font-size: 12px;
    font-weight: 600;
    color: var(--ck-ink-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===========================================
   MOBILE SEARCH OVERLAY
   =========================================== */

.search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--ck-paper-pure);
    z-index: 2000;
    padding: var(--ck-space-4);
}

.search-overlay.is-open {
    display: flex;
    flex-direction: column;
}

.search-overlay__header {
    display: flex;
    align-items: center;
    gap: var(--ck-space-3);
    margin-bottom: var(--ck-space-4);
}

.search-overlay__close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ck-paper-cream);
    border: none;
    border-radius: var(--ck-radius-full);
    cursor: pointer;
}

.search-overlay__input {
    flex: 1;
    height: 48px;
    padding: 0 var(--ck-space-4);
    font-size: 1rem;
    background: var(--ck-paper-warm);
    border: none;
    border-radius: var(--ck-radius-full);
    outline: none;
}

.search-overlay__input:focus {
    box-shadow: 0 0 0 2px var(--ck-accent);
}

.search-overlay__results {
    flex: 1;
    overflow-y: auto;
}

/* ===========================================
   MOBILE INGREDIENTS CHECKLIST
   =========================================== */

@media (max-width: 768px) {
    .ingredients-box {
        border-radius: var(--ck-radius-md);
        padding: var(--ck-space-4);
    }

    .ingredients-list li {
        padding: var(--ck-space-4) 0;
        /* Larger tap targets on mobile */
        min-height: 48px;
    }

    .ingredients-list li::before {
        width: 24px;
        height: 24px;
    }
}

/* ===========================================
   PULL TO REFRESH HINT
   =========================================== */

body.is-pulling::before {
    content: '';
    position: fixed;
    top: var(--ck-mobile-header);
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--ck-paper-pure);
    border-radius: var(--ck-radius-full);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    animation: pull-indicator 0.5s ease;
}

@keyframes pull-indicator {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(10px);
    }
}

/* ===========================================
   ACCESSIBILITY - TOUCH TARGETS
   =========================================== */

@media (max-width: 768px) {
    /* Touch targets only on standalone interactive controls */
    .header-btn,
    .btn,
    .floating-action-btn,
    .recipe-action-sticky-btn,
    input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ===========================================
   DARK MODE MOBILE ADJUSTMENTS
   =========================================== */

@media (max-width: 768px) {
    .dark-mode .mobile-bottom-bar {
        background: var(--ck-paper);
        border-color: var(--ck-paper-cream);
    }

    .dark-mode .recipe-actions-sticky {
        background: var(--ck-paper-warm);
    }

    .dark-mode .search-overlay {
        background: var(--ck-paper);
    }

    .dark-mode .search-overlay__input {
        background: var(--ck-paper-warm);
        color: var(--ck-ink);
    }
}

/* ===========================================
   LANDSCAPE MOBILE
   =========================================== */

@media (max-width: 900px) and (orientation: landscape) {
    .recipe-hero {
        min-height: 70vh;
    }

    .recipe-card-featured {
        aspect-ratio: 21/9;
    }

    .mobile-bottom-bar {
        height: 50px;
    }

    .mobile-bottom-bar__item svg {
        width: 20px;
        height: 20px;
    }

    .mobile-bottom-bar__item span {
        display: none;
    }
}
