/* Mobile-first polish shared by the public Jacques AO pages. */
@media (max-width: 820px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    header {
        padding: 0.8rem 0 !important;
    }

    .header-wrapper,
    .header-content,
    .header-inner {
        width: 100%;
        max-width: 100%;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .header-wrapper,
    .header-content {
        flex-direction: column;
    }

    .logo {
        font-size: 1.25rem !important;
        line-height: 1.2;
        max-width: 100%;
    }

    .nav-container,
    .header-tools,
    nav {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start !important;
        gap: 0.55rem !important;
    }

    nav {
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    nav ul {
        width: max-content;
        min-width: 100%;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        gap: 0.55rem !important;
        overflow-x: auto;
        padding-bottom: 0.2rem !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    nav ul::-webkit-scrollbar {
        display: none;
    }

    nav li {
        flex: 0 0 auto;
    }

    nav a {
        display: inline-flex;
        align-items: center;
        min-height: 2.25rem;
        margin-left: 0 !important;
        padding: 0.35rem 0.68rem;
        border: 1px solid var(--border-color);
        border-radius: 999px;
        background: var(--bg-card, var(--bg-primary));
        font-size: 0.88rem !important;
        line-height: 1.2;
        white-space: nowrap;
    }

    .lang-switch {
        border-left: 0 !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
        gap: 0.35rem !important;
        flex-wrap: nowrap;
    }

    .lang-btn {
        min-height: 2.2rem;
        padding: 0.35rem 0.58rem !important;
        border-radius: 999px !important;
    }

    .theme-toggle {
        width: 2.2rem !important;
        min-width: 2.2rem;
        height: 2.2rem !important;
    }

    .container,
    main,
    .section,
    .content-section,
    .hero,
    footer {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .container {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .hero {
        padding-top: 2.4rem !important;
        padding-bottom: 2rem !important;
    }

    h1,
    .hero h1 {
        font-size: clamp(1.8rem, 8vw, 2.35rem) !important;
        line-height: 1.15 !important;
        overflow-wrap: anywhere;
    }

    h2,
    .section-title {
        overflow-wrap: anywhere;
    }

    .section-title {
        font-size: 1.55rem !important;
        margin-bottom: 1.25rem !important;
    }

    .posts-grid,
    .posts-list,
    .book-grid,
    .topic-grid,
    .twin-grid,
    .stats-grid,
    .org-chart,
    .phase-goals,
    .asset-grid,
    .related-grid,
    .post-links,
    .note-layout,
    .resource-links,
    .architecture-diagram,
    .layer ul {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .post-card,
    .book-card,
    .topic-card,
    .twin-card,
    .company-card,
    .phase-card,
    .goal-item,
    .stat-card,
    .asset-card,
    .journal-entry,
    .layer,
    .resource-link,
    .related-card,
    .post-link-card,
    .progress-container,
    .roadmap-container,
    .book-note-content,
    article {
        padding: 1.1rem !important;
        border-radius: 16px !important;
    }

    .post-card-image-link {
        margin: -1.1rem -1.1rem 1rem !important;
    }

    .post-meta,
    .book-header,
    .phase-header,
    .progress-header,
    .section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.55rem !important;
    }

    .category-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 0.35rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

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

    .tab-btn {
        flex: 0 0 auto;
    }

    .reading-actions,
    .hero .social-links {
        width: 100%;
        justify-content: flex-start !important;
        flex-wrap: wrap;
    }

    .social-link {
        width: auto;
        max-width: 100%;
    }

    .post-cover {
        margin-top: 1rem !important;
        border-radius: 16px !important;
    }

    .post-content,
    .book-note-content,
    .note-main,
    .note-sidebar {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .post-content pre,
    .book-note-content pre,
    .note-table {
        max-width: 100%;
        overflow-x: auto;
    }

    .note-table {
        display: block;
        white-space: nowrap;
    }

    footer {
        margin-top: 2rem !important;
    }
}

@media (max-width: 430px) {
    .header-wrapper,
    .header-content,
    .header-inner {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .lang-btn {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .post-card,
    .book-card,
    .topic-card,
    .twin-card,
    article {
        padding: 1rem !important;
    }

    .post-card-image-link {
        margin: -1rem -1rem 0.95rem !important;
    }

    .about-stats {
        grid-template-columns: 1fr !important;
    }
}
