/**
 * TionStation Mobile Enhanced CSS
 * PWA-like mobile experience with bottom navigation, gestures, optimized touch targets
 * @version 2.0.0
 */

/* =====================================================
   MOBILE BOTTOM NAVIGATION
   ===================================================== */
.tion-mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: rgba(10, 14, 39, 0.96);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
}

.tion-mobile-nav.tion-nav-hidden {
    transform: translateY(100%);
}

.tion-mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    color: #718096;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-width: 56px;
    min-height: 48px;
    font-family: inherit;
}

.tion-mobile-nav-item .material-icons-round {
    font-size: 24px;
    transition: all 0.2s ease;
}

.tion-mobile-nav-label {
    font-size: 10px;
    font-weight: 500;
    margin-top: 2px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tion-mobile-nav-item.active {
    color: #00D9FF;
}

.tion-mobile-nav-item.active .material-icons-round {
    transform: scale(1.1);
}

.tion-mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: linear-gradient(135deg, #00D9FF, #0066FF);
    border-radius: 0 0 4px 4px;
}

.tion-mobile-nav-item:active {
    transform: scale(0.92);
    color: #00D9FF;
}

/* =====================================================
   MOBILE SLIDE-OUT DRAWER
   ===================================================== */
.tion-mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
}

.tion-mobile-drawer.open {
    display: block;
}

.tion-mobile-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.tion-mobile-drawer.open .tion-mobile-drawer-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.tion-mobile-drawer-content {
    position: absolute;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: #0D1128;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

.tion-mobile-drawer.open .tion-mobile-drawer-content {
    right: 0;
}

.tion-mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.1), rgba(0, 217, 255, 0.05));
}

.tion-drawer-logo {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #00D9FF, #0066FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.tion-mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: #A0AEC0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tion-mobile-drawer-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.tion-mobile-drawer-body {
    padding: 20px 0;
}

/* Drawer User Area */
.tion-drawer-user-area {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    margin: 0 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.tion-drawer-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0066FF, #00D9FF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tion-drawer-avatar .material-icons-round {
    font-size: 24px;
    color: white;
}

.tion-drawer-username {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: white;
}

.tion-drawer-login-link {
    font-size: 13px;
    color: #00D9FF;
    text-decoration: none;
}

/* Drawer Navigation */
.tion-drawer-nav {
    padding: 0 12px;
}

.tion-drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: #A0AEC0;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-size: 15px;
    font-weight: 500;
}

.tion-drawer-nav-item:hover,
.tion-drawer-nav-item:active {
    background: rgba(0, 217, 255, 0.08);
    color: white;
}

.tion-drawer-nav-item .material-icons-round {
    font-size: 22px;
    color: #00D9FF;
    opacity: 0.8;
}

/* Drawer Divider */
.tion-drawer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 16px 20px;
}

/* Drawer Settings */
.tion-drawer-settings {
    padding: 0 12px;
}

.tion-drawer-setting-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: #A0AEC0;
    font-size: 14px;
}

.tion-drawer-setting-item .material-icons-round {
    font-size: 20px;
    color: #718096;
}

.tion-drawer-setting-item span:nth-child(2) {
    flex: 1;
}

/* Toggle Switch */
.tion-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.tion-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tion-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    transition: 0.3s;
    border-radius: 24px;
}

.tion-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.tion-toggle-switch input:checked + .tion-toggle-slider {
    background: linear-gradient(135deg, #0066FF, #00D9FF);
}

.tion-toggle-switch input:checked + .tion-toggle-slider::before {
    transform: translateX(20px);
}

/* Font Size Controls */
.tion-font-size-controls {
    display: flex;
    gap: 6px;
}

.tion-font-size-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #A0AEC0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tion-font-size-btn:active {
    background: rgba(0, 217, 255, 0.2);
    color: white;
}

/* =====================================================
   SHARE SHEET (Bottom Sheet Style)
   ===================================================== */
.tion-share-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10002;
}

.tion-share-sheet.open {
    display: block;
}

.tion-share-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.tion-share-sheet.open .tion-share-sheet-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.tion-share-sheet-content {
    position: absolute;
    bottom: -400px;
    left: 0;
    right: 0;
    background: #151B3D;
    border-radius: 20px 20px 0 0;
    padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 60vh;
}

.tion-share-sheet.open .tion-share-sheet-content {
    bottom: 0;
}

.tion-share-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.tion-share-sheet-title {
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin-bottom: 24px;
    text-align: center;
}

.tion-share-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.tion-share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.tion-share-item-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.tion-share-item:active .tion-share-item-icon {
    transform: scale(0.9);
}

.tion-share-item span:last-child {
    font-size: 12px;
    color: #A0AEC0;
    font-weight: 500;
}

/* =====================================================
   SEARCH OVERLAY (Mobile Optimized)
   ===================================================== */
.tion-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10003;
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tion-search-overlay.open {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

.tion-search-overlay-inner {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tion-search-overlay-header {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
}

.tion-search-form {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 0 16px;
    transition: border-color 0.2s ease;
}

.tion-search-form:focus-within {
    border-color: rgba(0, 217, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.tion-search-icon {
    color: #718096;
    font-size: 24px;
    flex-shrink: 0;
}

.tion-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 17px;
    padding: 16px 12px;
    font-family: 'Noto Sans KR', sans-serif;
}

.tion-search-input::placeholder {
    color: #718096;
}

.tion-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: #A0AEC0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.tion-search-close:active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Search Suggestions */
.tion-search-suggestions {
    padding: 24px 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tion-search-trending h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #718096;
    margin-bottom: 16px;
    font-weight: 600;
}

.tion-search-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tion-search-tag {
    display: inline-block;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    color: #A0AEC0;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.tion-search-tag:active {
    background: rgba(0, 217, 255, 0.15);
    border-color: rgba(0, 217, 255, 0.3);
    color: #00D9FF;
}

/* Search Results */
.tion-search-results {
    list-style: none;
    padding: 0;
}

.tion-search-result-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tion-search-result-item a {
    display: flex;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.tion-search-result-thumb {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.tion-search-result-info {
    flex: 1;
    min-width: 0;
}

.tion-search-result-title {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tion-search-result-excerpt {
    font-size: 13px;
    color: #718096;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tion-search-result-date {
    font-size: 12px;
    color: #4A5568;
    margin-top: 4px;
}

/* =====================================================
   MOBILE RESPONSIVE OVERRIDES
   ===================================================== */
@media (max-width: 768px) {
    /* Show mobile navigation */
    .tion-mobile-nav {
        display: flex;
    }

    /* Add bottom padding for fixed nav */
    body.tion-mobile {
        padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    }

    /* Hide desktop elements on mobile */
    .tion-pc-floating-controls {
        display: none !important;
    }

    /* Improve touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
    }

    /* Better tap feedback */
    a:active, button:active {
        opacity: 0.85;
    }

    /* Reading time badge - mobile */
    .tion-reading-time-badge {
        font-size: 13px;
        padding: 10px 16px;
        margin-bottom: 20px;
    }

    /* Scroll to top - position above bottom nav */
    .tion-scroll-top {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
        right: 16px !important;
    }

    /* PWA Install Banner - position above bottom nav */
    .tion-pwa-install-banner {
        bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Improve content readability on mobile */
    .wp-block-post-content,
    .entry-content {
        font-size: 16px;
        line-height: 1.8;
        word-break: keep-all;
    }

    .wp-block-post-content p,
    .entry-content p {
        margin-bottom: 1.5em;
    }

    .wp-block-post-content h2,
    .entry-content h2 {
        font-size: 22px;
        margin-top: 2em;
        margin-bottom: 0.8em;
    }

    .wp-block-post-content h3,
    .entry-content h3 {
        font-size: 19px;
        margin-top: 1.8em;
        margin-bottom: 0.6em;
    }

    /* Full-width images on mobile */
    .wp-block-post-content img,
    .entry-content img {
        max-width: 100%;
        height: auto;
        border-radius: 10px;
    }

    /* Improve code blocks on mobile */
    .wp-block-code {
        font-size: 13px;
        padding: 16px;
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Better blockquotes on mobile */
    blockquote, .wp-block-quote {
        padding: 16px 20px;
        margin: 1.5em 0;
        border-radius: 0 12px 12px 0;
    }

    /* Mobile-optimized tables */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    /* Pull-to-refresh indicator */
    .tion-ptr-indicator {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(135deg, #00D9FF, #0066FF);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.3s ease;
        z-index: 99999;
    }

    .tion-ptr-indicator.active {
        transform: scaleX(1);
        animation: ptrPulse 1.5s ease-in-out infinite;
    }

    @keyframes ptrPulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }

    /* Mobile card improvements */
    .feature-card,
    .pricing-card,
    .stat-card {
        border-radius: 16px;
    }

    /* Smooth scroll behavior */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide horizontal scrollbar */
    body {
        overflow-x: hidden;
    }

    /* Improve header on mobile */
    header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
}

/* =====================================================
   PWA STANDALONE MODE (Launched from home screen)
   ===================================================== */
.tion-pwa-standalone .tion-mobile-drawer-header {
    padding-top: calc(48px + env(safe-area-inset-top, 0px));
}

.tion-pwa-standalone .tion-search-overlay-header {
    padding-top: calc(48px + env(safe-area-inset-top, 0px));
}

.tion-pwa-standalone header {
    padding-top: env(safe-area-inset-top, 0px);
}

/* =====================================================
   SMALL PHONES (< 375px)
   ===================================================== */
@media (max-width: 374px) {
    .tion-mobile-nav-item {
        min-width: 44px;
        padding: 6px 8px;
    }

    .tion-mobile-nav-label {
        font-size: 9px;
    }

    .tion-share-sheet-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* =====================================================
   LANDSCAPE MODE ON MOBILE
   ===================================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .tion-mobile-nav {
        padding: 4px 0;
    }

    .tion-mobile-nav-label {
        display: none;
    }

    .tion-mobile-nav-item {
        min-height: 40px;
    }

    body.tion-mobile {
        padding-bottom: 46px;
    }
}

/* =====================================================
   TABLET SPECIFIC (768px - 1024px)
   ===================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .tion-mobile-nav {
        display: none;
    }

    .tion-mobile-drawer {
        display: none !important;
    }
}

/* =====================================================
   HAPTIC FEEDBACK ANIMATION
   ===================================================== */
@keyframes tapFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.tion-tap-feedback {
    animation: tapFeedback 0.15s ease;
}

/* =====================================================
   MOBILE SKELETON LOADING
   ===================================================== */
.tion-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 37%,
        rgba(255, 255, 255, 0.04) 63%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease infinite;
    border-radius: 8px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =====================================================
   MOBILE SWIPE INDICATOR
   ===================================================== */
.tion-swipe-indicator {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60px;
    background: rgba(0, 217, 255, 0.3);
    border-radius: 4px;
    z-index: 9998;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.tion-swipe-indicator.left { left: 2px; }
.tion-swipe-indicator.right { right: 2px; }
