/* =================================================================
   MOBILE.CSS  —  Complete Mobile & Responsive Styles
   -----------------------------------------------------------------
   Breakpoints:
     900px  Tablet landscape  (bento grid 2-col)
     768px  Mobile            (main breakpoint — shows bottom nav)
     480px  Small phone       (compact adjustments)

   KEY ARCHITECTURE NOTE:
   The mobile nav is a <div class="mobile-nav"> NOT a <nav> element.
   This is intentional — layout.css has nav { position:fixed; top:0 }
   which would override bottom:0 and stretch the bar full-screen.
   Using a div entirely avoids that cascade conflict.
   ================================================================= */

/* ================================================================
   MOBILE BOTTOM NAV
   - Hidden on desktop (display:none)
   - Shown as a fixed bottom bar at ≤768px
   - position, top, and height all explicitly set to prevent
     any inherited layout from the desktop nav rules
   ================================================================ */
.mobile-nav {
    /* Hidden by default — shown via media query */
    display: none;

    /* Explicit positioning — no inheritance from nav{} rules */
    position: fixed;
    top: auto;       /* override in case any cascade sets top:0 */
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;    /* never stretch */
    width: 100%;

    /* Visual */
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 2px solid var(--card-border);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    z-index: 1001;   /* above desktop nav z-index:1000 */

    /* Layout */
    flex-direction: row;
    justify-content: space-around;
    align-items: center;

    /* Spacing + notched-phone safe area */
    padding: 0.4rem 0.25rem;
    padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
}

/* ── Individual nav links ─────────────────────────────────────── */
.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;

    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;

    /* 44px minimum tap target */
    padding: 0.4rem 0.5rem;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;

    border-radius: 8px;
    transition: color 0.2s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent; /* no blue flash on tap */
}

.mobile-nav-link i {
    font-size: 1.2rem;
    line-height: 1;
    transition: color 0.2s ease, filter 0.2s ease;
}

/* ── Active state ─────────────────────────────────────────────── */
.mobile-nav-link.active {
    color: var(--accent-primary);
}

.mobile-nav-link.active i {
    filter: drop-shadow(0 0 6px var(--accent-primary));
}

/* Small active indicator bar above the icon — always reserve the space */
.mobile-nav-link::before {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: transparent;
    border-radius: 2px;
    margin-bottom: 2px;
}

.mobile-nav-link.active::before {
    background: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary);
}

/* ── Press feedback ───────────────────────────────────────────── */
.mobile-nav-link:active {
    color: var(--accent-primary);
    background: var(--accent-glow);
    transform: scale(0.92);
}

/* ================================================================
   MOBILE PLAY NOTICE  (base — hidden; shown inside 768px block)
   ================================================================ */
.mobile-play-notice {
    display: none;
}


/* ================================================================
   900px — TABLET LANDSCAPE
   ================================================================ */
@media (max-width: 900px) {
    .bento-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ================================================================
   768px — MAIN MOBILE BREAKPOINT
   ================================================================ */
@media (max-width: 768px) {

    /* ── CRITICAL FIX ───────────────────────────────────────────
       The .reveal animation starts at opacity:0 and requires JS
       to add the .active class. On mobile this causes completely
       blank pages if JS is slow or delayed. Disable the animation
       entirely on mobile — content is always immediately visible.
       ─────────────────────────────────────────────────────────── */
    .reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    /* ── NAV ─────────────────────────────────────────────────── */
    .mobile-nav  { display: flex; }
    .nav-links   { display: none; }

    /* ── GLOBAL SPACING ──────────────────────────────────────── */
    /* All page-content sections clear the fixed bottom nav */
    .page-content { padding-bottom: 6rem; }
    footer        { padding-bottom: 5rem; }

    /* ── HERO PAGE ───────────────────────────────────────────── */
    .hero {
        padding: 5.5rem 1.25rem 4.5rem;
        min-height: unset;
        align-items: flex-start;
    }

    .hero-content { max-width: 100%; }

    .profile-img {
        width: 90px;
        height: 90px;
        margin-bottom: 1rem;
    }

    .hero-content h1 { font-size: 2rem; }
    .hero-content h2 { font-size: 0.95rem; margin-bottom: 0.75rem; }
    .hero-content p  { font-size: 0.9rem;  margin-bottom: 1.25rem; }

    /* Hero social buttons: 2-column grid */
    .hero-btns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
        margin-bottom: 1.25rem;
        /* reset any flex-direction from earlier rules */
        flex-direction: unset;
        align-items: unset;
        width: 100%;
    }

    /* Primary CTA "Get In Touch" spans both columns */
    .hero-btns > *:first-child {
        grid-column: 1 / -1;
    }

    .hero-btns .btn,
    .hero-btns .btn-outline {
        width: 100%;
        justify-content: center;
        padding: 0.65rem 0.5rem;
        font-size: 0.82rem;
    }

    /* Ticker is decorative — keep it but smaller */
    .tech-ticker   { margin-top: 0.75rem; }
    .ticker-wrapper span { font-size: 0.75rem; }

    /* ── GENERAL GRIDS ───────────────────────────────────────── */
    .grid        { grid-template-columns: 1fr; }
    .bento-grid  { grid-template-columns: 1fr; }
    .bento-large { grid-row: span 1; }

    /* ── SECTION TITLES ──────────────────────────────────────── */
    .section-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        margin-bottom: 1.75rem;
    }

    /* ── CONTACT PAGE ────────────────────────────────────────── */
    .contact-methods {
        flex-direction: column;
        align-items: stretch;
    }
    .contact-btn { width: 100%; }

    /* ── STACK PAGE ──────────────────────────────────────────── */
    /* Extra bottom padding so content clears the bottom pill nav */
    .stack-page-content { padding-bottom: 9rem; }

    /* Pin the skill category pill row above the mobile nav bar */
    .infinite-scroll-container.scrolled-mode,
    .infinite-scroll-container.compact {
        position: fixed !important;
        top: auto !important;
        bottom: 60px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        border-radius: 0 !important;
        border-top: 1px solid var(--card-border) !important;
        border-bottom: none !important;
        box-shadow: none !important;
        z-index: 999;
        padding: 0.5rem 0.75rem !important;
        /* Swipeable carousel */
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        background: var(--nav-bg) !important;
    }

    /* Hide scrollbar track on the pill carousel */
    .infinite-scroll-container.scrolled-mode::-webkit-scrollbar,
    .infinite-scroll-container.compact::-webkit-scrollbar { display: none; }

    /* Ensure pills stay in a single non-wrapping row */
    .infinite-scroll-container.scrolled-mode .scrolling-wrapper,
    .infinite-scroll-container.compact .scrolling-wrapper {
        display: flex !important;
        flex-wrap: nowrap !important;
        width: max-content !important;
        padding: 0.15rem 0.25rem !important;
        gap: 0.5rem !important;
    }

    /* Stack detail content: break out of container padding → full viewport width */
    .details-display-area {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
    }
    .detail-content {
        padding: 0.75rem 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: hidden;
    }

    /* Project row cards: edge-to-edge with minimal side padding */
    .detail-content .project-row {
        padding: 1rem 0.75rem !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        margin-bottom: 0.75rem !important;
    }

    /* Force all inline display:grid blocks inside detail-content to 1-column */
    .detail-content [style*="display:grid"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .scroll-placeholder.active { height: 3.5rem; }

    /* ── DEMOS PAGE ──────────────────────────────────────────── */
    .demos-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    /* On mobile, disable the 3D flip layout so cards grow to fit their content.
       The flip buttons still work — they toggle the back face visibility instead. */
    .demo-card-flipper   { min-height: unset; transform-style: flat; }
    .demo-card-front,
    .demo-card-back      { position: relative; inset: auto; backface-visibility: visible; -webkit-backface-visibility: visible; }
    .demo-card-front     { min-height: 420px; }
    .demo-card-back      { transform: none; display: none; }
    .demo-card-flip-container.flipped .demo-card-flipper { transform: none; }
    .demo-card-flip-container.flipped .demo-card-front   { display: none; }
    .demo-card-flip-container.flipped .demo-card-back    { display: flex; }

    .demo-filters { gap: 0.5rem; }

    .demo-filter-btn {
        padding: 0.35rem 0.85rem;
        font-size: 0.8rem;
    }

    /* Games need keyboard & mouse — show disabled button with mobile label */
    .demo-play-btn { pointer-events: none !important; cursor: not-allowed !important; opacity: 0.55 !important; }
    .demo-play-btn .play-label   { display: none; }
    .demo-play-btn .mobile-label { display: inline-flex; align-items: center; gap: 0.4rem; }
    .mobile-play-notice          { display: none; }

    /* ── GALLERY PAGE ────────────────────────────────────────── */
    .gallery-grid {
        columns: 2 150px;
        gap: 0.5rem;
    }

    /* ── GLOBAL ──────────────────────────────────────────────── */
    /* Less top padding — desktop nav is ~62px tall; 4.5rem gives comfortable clearance */
    .page-content { padding-top: 4.5rem; }

    /* ── BLOG PAGE ───────────────────────────────────────────── */
    /* Blog hero: tighter top padding on mobile */
    .blog-hero { padding: 4.5rem 0 1.5rem; }
    .blog-hero-subtitle { font-size: 0.88rem; padding: 0 1.25rem; }

    /* Filter chips: single scrollable row instead of multi-line wrap */
    .blog-filter-scroll {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.15rem;
    }
    .blog-filter-scroll::-webkit-scrollbar { display: none; }

    /* Sort + tag + results row: stack vertically */
    .blog-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        padding-top: 0.75rem;
    }
    .blog-sort-select { width: 100%; }
    .blog-results-count { margin-left: 0; }

    /* Blog section: extra bottom clearance for mobile nav */
    .blog-section { padding-bottom: 8rem; }

    /* Peek button: visible on mobile — touch users can't hover */
    .blog-card-peek-btn { display: flex; }

    /* Blog modal: slide up as a bottom sheet on mobile */
    .blog-modal-overlay { padding: 0; align-items: flex-end; }
    .blog-modal {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 94vh;
    }
    /* Keep close button clear of content */
    .blog-modal-header-pad { padding-right: 2.75rem; }
    /* Larger tap target for close */
    .blog-modal-close { width: 40px; height: 40px; font-size: 1.25rem; }

    /* Comments popup: bottom padding so text input clears the mobile nav */
    .blog-comments-popup-body { padding-bottom: 6rem; }

    /* ── DEMOS EMBED MODAL ───────────────────────────────────── */
    /* Full-screen embed on mobile — iframe fills the whole viewport */
    .embed-modal { padding: 0; }
    .embed-modal-inner {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    .embed-modal-body {
        flex: 1;
        padding-top: 0;
        min-height: 0;
        position: relative;
    }
    .embed-modal-body iframe {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }
}

/* ================================================================
   480px — SMALL PHONE
   ================================================================ */
@media (max-width: 480px) {
    .container { padding: 0 0.75rem; }

    /* Project detail panel: maximum width on small screens */
    .details-display-area { margin-left: -0.75rem; margin-right: -0.75rem; }
    .detail-content { padding: 0.5rem 0; }
    .detail-content .project-row { padding: 0.75rem 0.5rem !important; }

    .hero-content h1 { font-size: 1.75rem; }

    /* Single-column gallery on very narrow screens */
    .gallery-grid { columns: 1; }

    /* Compact demo cards */
    .demo-card-info    { padding: 1rem; }

    /* Pill tags */
    .card-tag {
        font-size: 0.68rem;
        padding: 0.12rem 0.42rem;
    }

    /* Controls back-face: stack keyboard/mouse columns vertically */
    .controls-sections {
        grid-template-columns: 1fr !important;
    }

    /* Blog filter chips: more compact on narrow phones */
    .blog-filter-chip {
        padding: 0.3rem 0.6rem;
        font-size: 0.72rem;
        gap: 0.25rem;
    }
}
