/* ============================================
   Pinnacle — Mobile-First Responsive CSS
   Complete override for all screen sizes
   ============================================ */

/* ── Base Mobile Reset ── */
* { -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body { overflow-x: hidden; }
img { max-width: 100%; height: auto; }

/* ============================================
   NAVBAR — Mobile
   ============================================ */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0,0,0,.08);
}

.nav-inner {
    height: 56px;
    padding: 0 14px;
    gap: 10px;
    display: flex;
    align-items: center;
}

/* Logo — always visible */
.nav-logo {
    font-size: 18px;
    flex-shrink: 0;
}
.nav-logo svg { width: 24px; height: 24px; }

/* Search — hide on mobile, show on tablet+ */
.nav-search { display: none; }

/* Hide text labels on small screens */
.btn-label { display: none; }

/* Nav actions spacing */
.nav-actions {
    margin-left: auto;
    gap: 4px;
    display: flex;
    align-items: center;
}

/* Mobile: show search icon & hamburger */
.mobile-menu-btn {
    display: flex !important;
    width: 40px; height: 40px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* Create button — icon only on mobile */
.create-btn {
    width: 36px; height: 36px;
    padding: 0;
    border-radius: 10px;
    justify-content: center;
}
.create-btn span { display: none; }

/* Avatar button */
.avatar-btn { padding: 3px; }
.nav-avatar { width: 30px; height: 30px; }

/* Login/Signup buttons */
.login-btn { padding: 7px 10px; font-size: 13px; }
.signup-btn { padding: 7px 12px; font-size: 13px; }

/* Dropdown menus — mobile friendly */
.dropdown-menu {
    right: 0;
    min-width: 200px;
    max-width: calc(100vw - 24px);
    border-radius: 14px;
}

/* Notification menu full-ish width on mobile */
.notif-menu {
    right: -60px;
    width: 300px;
    max-width: calc(100vw - 20px);
}

/* Profile menu */
.profile-menu {
    right: 0;
    width: 220px;
}

/* Categories menu */
.categories-menu {
    right: -40px;
    width: 240px;
}

/* ── Mobile Search Overlay ── */
.nav-search.mobile-open {
    display: flex !important;
    position: fixed;
    top: 56px; left: 0; right: 0;
    background: var(--surface);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.nav-search.mobile-open .search-form {
    width: 100%;
    max-width: 100%;
}

/* ============================================
   MAIN CONTENT — push below fixed navbar
   ============================================ */
.main-content {
    padding-top: 56px;
    min-height: calc(100vh - 56px);
}

/* ============================================
   FEED LAYOUT
   ============================================ */
.feed-layout {
    display: block;
    padding: 14px;
    gap: 0;
}

/* Sidebar — hidden on mobile */
.sidebar { display: none !important; }

/* Feed controls */
.feed-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.feed-title {
    font-size: 20px;
    flex: 1;
    min-width: 0;
}

.sort-select {
    font-size: 13px;
    padding: 7px 10px;
    border-radius: 10px;
    height: 36px;
}

.view-toggle {
    display: none; /* hide on mobile, show on tablet */
}

/* ============================================
   MASONRY GRID — Mobile single column
   ============================================ */
.masonry-grid {
    columns: 1 !important;
    column-gap: 0;
}

/* ============================================
   POST CARD — Mobile optimized
   ============================================ */
.post-card {
    border-radius: 14px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    overflow: hidden;
    background: var(--surface);
}

.post-card:hover {
    transform: none; /* disable hover lift on mobile */
}

/* Image */
.post-card-img img {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
}

/* Body */
.post-card-body {
    padding: 12px 14px 8px;
}

.post-card-meta {
    margin-bottom: 8px;
    gap: 8px;
}

.post-author-avatar { width: 26px; height: 26px; }
.post-author-name { font-size: 13px; }
.post-time { font-size: 11px; }

.post-category-badge {
    font-size: 10px;
    padding: 2px 7px;
    margin-bottom: 6px;
}

.post-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 5px;
    -webkit-line-clamp: 2;
}

.post-excerpt {
    font-size: 13px;
    line-height: 1.5;
    -webkit-line-clamp: 3;
    color: var(--text-secondary);
}

.post-tags {
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.post-tag {
    font-size: 11px;
    padding: 2px 7px;
}

/* Footer */
.post-card-footer {
    padding: 8px 14px;
    gap: 8px;
    border-top: 1px solid var(--border-light);
}

.post-stat {
    font-size: 13px;
    padding: 5px 6px;
    gap: 4px;
}

.post-stat svg { width: 14px; height: 14px; }

/* Text post */
.text-post .post-card-body { padding: 14px; }
.text-post .post-title { font-size: 16px; }

/* ============================================
   POST DETAIL PAGE
   ============================================ */
.post-detail-layout {
    display: block !important;
    padding: 12px 12px 40px;
    grid-template-columns: none;
    gap: 0;
    max-width: 100%;
}

.post-detail-card {
    border-radius: 14px;
    margin-bottom: 16px;
}

.post-detail-hero img {
    max-height: 240px;
    width: 100%;
    object-fit: cover;
}

.post-detail-content {
    padding: 16px;
}

.post-detail-title {
    font-size: 20px !important;
    line-height: 1.3;
    margin-bottom: 12px;
}

.post-detail-meta {
    flex-wrap: wrap;
    gap: 10px;
}

.author-info { gap: 8px; }
.author-avatar { width: 34px; height: 34px; }
.author-name { font-size: 14px; }
.author-username { font-size: 12px; }

.post-detail-body {
    font-size: 15px;
    line-height: 1.7;
    margin-top: 14px;
}

/* Action bar — scrollable on mobile */
.post-detail-actions {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.post-detail-actions::-webkit-scrollbar { display: none; }

.action-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 10px;
    flex-shrink: 0;
    white-space: nowrap;
    gap: 5px;
}

.action-btn svg { width: 16px; height: 16px; }

.share-group {
    margin-left: auto;
    flex-shrink: 0;
    gap: 6px;
}

.share-btn-sm {
    width: 34px; height: 34px;
}

/* Post detail sidebar — show below on mobile */
.post-detail-sidebar {
    margin-top: 0;
}

/* Author card */
.author-card {
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 14px;
}
.author-card-avatar { width: 60px; height: 60px; }
.author-card-name { font-size: 15px; }
.author-stats { gap: 20px; }
.author-stat .stat-num { font-size: 16px; }

/* Related posts */
.related-grid { gap: 10px; }
.related-card img { height: 110px; }
.related-card-title { font-size: 13px; }

/* ============================================
   COMMENTS
   ============================================ */
.comments-section {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.section-title { font-size: 15px; margin-bottom: 14px; }

.comment-form {
    gap: 10px;
    margin-bottom: 18px;
}

.comment-form-avatar { width: 30px; height: 30px; }

.comment-textarea {
    font-size: 14px;
    padding: 9px 12px;
    border-radius: 10px;
}

.comment-item { gap: 10px; margin-bottom: 16px; }
.comment-avatar { width: 30px; height: 30px; }
.comment-username { font-size: 13px; }
.comment-time { font-size: 11px; }
.comment-text { font-size: 13px; padding: 9px 12px; border-radius: 0 10px 10px 10px; }

.replies-list {
    margin-left: 40px;
    padding-left: 12px;
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
    padding: 14px;
    align-items: flex-start;
    padding-top: 30px;
    background: var(--surface-2);
}

.auth-card {
    padding: 24px 18px;
    border-radius: 18px;
    width: 100%;
    max-width: 100%;
    box-shadow: var(--shadow);
}

.auth-logo { font-size: 20px; margin-bottom: 20px; }
.auth-title { font-size: 20px; }
.auth-subtitle { font-size: 13px; margin-bottom: 20px; }
.auth-footer { font-size: 13px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; margin-bottom: 5px; }
.form-input {
    padding: 11px 13px;
    font-size: 15px; /* prevent zoom on iOS */
    border-radius: 10px;
    -webkit-appearance: none;
}
.form-row { grid-template-columns: 1fr; gap: 0; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 10px;
    min-height: 42px; /* touch target */
}
.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
    min-height: 46px;
}
.btn-sm {
    padding: 7px 13px;
    font-size: 13px;
    min-height: 34px;
}

/* ============================================
   PROFILE PAGE
   ============================================ */
.profile-header-card {
    border-radius: 16px;
    margin-bottom: 16px;
}

.profile-cover { height: 130px; border-radius: 16px 16px 0 0; }

.profile-info-section {
    padding: 0 16px 18px;
    margin-top: -36px;
    flex-wrap: wrap;
    gap: 12px;
}

.profile-avatar {
    width: 76px; height: 76px;
    border-width: 3px;
}

.profile-details {
    width: 100%;
    padding-bottom: 0;
    margin-top: 8px;
}

.profile-username { font-size: 20px; }
.profile-handle { font-size: 13px; margin-bottom: 6px; }
.profile-bio { font-size: 13px; }

.profile-stats {
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.profile-stat .stat-num { font-size: 17px; }
.profile-stat .stat-label { font-size: 11px; }

.profile-actions {
    width: 100%;
    margin-left: 0;
    gap: 8px;
    padding-bottom: 0;
}
.profile-actions .btn { flex: 1; justify-content: center; }

/* Profile tabs */
.profile-tabs-row {
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
}
.profile-tabs-row::-webkit-scrollbar { display: none; }

/* ============================================
   CREATE POST
   ============================================ */
.create-page {
    padding: 12px;
    max-width: 100%;
}

.create-card { border-radius: 16px; }

.create-header {
    padding: 16px 16px 0;
}
.create-title { font-size: 18px; margin-bottom: 12px; }

.post-type-tab {
    font-size: 13px;
    padding: 10px 8px;
    gap: 4px;
}
.post-type-tab svg { width: 14px; height: 14px; }

.create-body { padding: 16px; }

.upload-zone {
    padding: 24px 16px;
}
.upload-zone svg { width: 32px; height: 32px; }
.upload-zone p { font-size: 13px; }

.tags-container { min-height: 42px; }
.tags-input { font-size: 15px; } /* prevent iOS zoom */

/* ============================================
   SETTINGS PAGE
   ============================================ */
.settings-layout {
    display: block;
    padding: 12px;
}

/* Settings nav — horizontal scroll on mobile */
.settings-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 0 0 12px 0;
    position: static;
    white-space: nowrap;
}
.settings-nav::-webkit-scrollbar { display: none; }

.settings-nav-item {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    flex-shrink: 0;
    width: auto;
}

.settings-nav-item:hover,
.settings-nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
}

.settings-panel {
    padding: 18px;
    border-radius: 14px;
}
.settings-section-title { font-size: 15px; }

.avatar-upload-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

/* ============================================
   SEARCH PAGE
   ============================================ */
.search-page {
    padding: 14px;
    max-width: 100%;
}

.search-header { margin-bottom: 20px; }
.search-query { font-size: 20px; }
.search-meta { font-size: 13px; }

.search-header .search-form {
    max-width: 100% !important;
    margin-top: 14px;
}

.search-header .search-form input {
    padding: 12px 0 !important;
    font-size: 15px;
}

/* People cards — stack on mobile */
.search-people-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================
   SAVED PAGE
   ============================================ */
.saved-layout {
    padding: 14px;
    max-width: 100%;
}

/* ============================================
   ADMIN PANEL — Mobile
   ============================================ */
.admin-layout {
    display: block;
    min-height: auto;
}

/* Admin sidebar — horizontal scrollable tabs */
.admin-sidebar {
    position: static;
    height: auto;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    white-space: nowrap;
    background: var(--surface);
}
.admin-sidebar::-webkit-scrollbar { display: none; }

.admin-sidebar-title { display: none; }

.admin-nav-item {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.admin-nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
}
.admin-nav-item.active::before { display: none; }

.admin-main {
    padding: 14px;
    overflow-x: auto;
}

.admin-page-title { font-size: 19px; margin-bottom: 16px; }

/* Stats grid — 2 col on mobile */
.stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 14px 12px;
    gap: 10px;
    border-radius: 12px;
}
.stat-icon { width: 36px; height: 36px; border-radius: 8px; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-card-num { font-size: 20px; }
.stat-card-label { font-size: 11px; }

/* Data tables — horizontal scroll */
.data-table { font-size: 13px; }
.data-table th { font-size: 11px; padding: 10px 10px; }
.data-table td { padding: 10px 10px; }

/* Admin dashboard grid — stack */
.admin-layout .admin-main > div[style*="grid-template-columns:1fr 1fr"] {
    display: block !important;
}
.admin-layout .admin-main > div[style*="grid-template-columns:1fr 1fr"] > div {
    margin-bottom: 20px;
}

/* Admin moderation cards */
.admin-post-card > div {
    flex-direction: column !important;
}
.admin-post-card img {
    width: 100% !important;
    height: 180px !important;
    object-fit: cover;
}

/* Moderation action buttons */
.table-actions { flex-wrap: wrap; gap: 4px; }
.table-actions .btn { font-size: 12px; }

/* Modal */
.modal {
    margin: 16px;
    border-radius: 16px;
    padding: 20px;
    max-width: calc(100vw - 32px);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-container {
    top: 62px;
    right: 12px;
    left: 12px;
    max-width: 100%;
}
.flash-message {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer { padding: 18px 0; margin-top: 30px; }
.footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 0 16px;
}
.footer-brand { font-size: 15px; }
.footer-links { gap: 14px; flex-wrap: wrap; }
.footer-links a { font-size: 13px; }
.footer-copy { font-size: 12px; margin-left: 0; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state { padding: 40px 16px; }
.empty-state svg { width: 48px; height: 48px; }
.empty-state h3 { font-size: 16px; }
.empty-state p { font-size: 13px; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination { gap: 4px; flex-wrap: wrap; padding: 16px 0; }
.page-btn { min-width: 34px; height: 34px; font-size: 13px; }

/* ============================================
   PENDING BANNER
   ============================================ */
.pending-banner {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 6px;
}

/* ============================================
   TABLET — 640px+
   ============================================ */
@media (min-width: 640px) {
    html { font-size: 15px; }

    .navbar { height: 60px; }
    .nav-inner { height: 60px; padding: 0 18px; }
    .main-content { padding-top: 60px; }

    .nav-search {
        display: flex;
        flex: 1;
        max-width: 300px;
    }
    .mobile-menu-btn { display: none !important; }
    .nav-search.mobile-open { display: none !important; }
    .btn-label { display: inline; }

    .create-btn {
        width: auto; height: auto;
        padding: 8px 16px;
    }
    .create-btn span { display: inline; }

    .nav-avatar { width: 32px; height: 32px; }

    .masonry-grid { columns: 2 !important; column-gap: 14px; }
    .feed-layout { padding: 18px; }
    .view-toggle { display: flex; }

    .form-row { grid-template-columns: 1fr 1fr; gap: 14px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }

    .profile-info-section { flex-wrap: nowrap; }
    .profile-details { width: auto; margin-top: 0; }
    .profile-actions { width: auto; margin-left: auto; }

    .auth-page { padding: 24px; align-items: center; }
    .auth-card { max-width: 420px; }

    .create-page { padding: 20px; }
    .settings-layout {
        display: grid;
        grid-template-columns: 180px 1fr;
        gap: 20px;
        padding: 20px;
    }
    .settings-nav {
        flex-direction: column;
        overflow-x: visible;
        position: sticky;
        top: 76px;
    }
    .settings-nav-item { flex-shrink: unset; }

    .post-detail-layout { padding: 20px; }
    .post-detail-title { font-size: 24px !important; }
    .post-detail-hero img { max-height: 360px; }

    .admin-sidebar {
        padding: 12px 16px;
    }
    .admin-main { padding: 20px; }

    .flash-container {
        left: auto;
        max-width: 340px;
    }
}

/* ============================================
   DESKTOP — 1024px+
   ============================================ */
@media (min-width: 1024px) {
    html { font-size: 16px; }

    .navbar { height: 64px; }
    .nav-inner { height: 64px; padding: 0 20px; }
    .main-content { padding-top: 64px; }

    .nav-search { max-width: 440px; }
    .nav-avatar { width: 34px; height: 34px; }

    .feed-layout {
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: 28px;
        padding: 24px 20px;
        max-width: 1280px;
        margin: 0 auto;
    }

    .sidebar { display: block !important; }
    .masonry-grid { columns: 3 !important; column-gap: 16px; }

    .post-detail-layout {
        display: grid !important;
        grid-template-columns: 1fr 320px;
        gap: 28px;
        max-width: 1060px;
        margin: 0 auto;
        padding: 28px 20px;
    }

    .post-detail-title { font-size: 28px !important; }
    .post-detail-hero img { max-height: 480px; }

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

    .admin-layout {
        display: grid;
        grid-template-columns: 240px 1fr;
        min-height: calc(100vh - 64px);
    }
    .admin-sidebar {
        display: flex !important;
        flex-direction: column;
        position: sticky;
        top: 64px;
        height: calc(100vh - 64px);
        overflow-y: auto;
        padding: 20px 0;
        border-right: 1px solid var(--border);
        border-bottom: none;
        gap: 0;
        white-space: normal;
        background: var(--surface);
    }
    .admin-sidebar-title { display: block; }
    .admin-nav-item {
        border-radius: 0;
        background: none;
        border: none;
        white-space: normal;
    }
    .admin-nav-item.active::before { display: block; }

    .settings-layout {
        grid-template-columns: 200px 1fr;
        gap: 24px;
        padding: 32px 20px;
        max-width: 800px;
        margin: 0 auto;
    }
    .settings-nav {
        top: 84px;
    }
}

/* ============================================
   LARGE DESKTOP — 1280px+
   ============================================ */
@media (min-width: 1280px) {
    .masonry-grid { columns: 4 !important; }
    .feed-layout { padding: 28px 20px; }
    .stats-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) {
    /* Remove hover-only effects on touch */
    .post-card:hover { transform: none; box-shadow: var(--shadow-sm); }
    .post-card:hover .post-card-img img { transform: none; }
    .post-card:hover .post-card-img-overlay { opacity: 0; }
    .btn:hover { transform: none; }
    .create-btn:hover { transform: none; }
    .nav-logo:hover { opacity: 1; }

    /* Always show action overlay on touch */
    .post-card .post-card-img-overlay { display: none; }

    /* Better tap targets */
    .post-stat { min-height: 36px; }
    .comment-action { min-height: 32px; min-width: 44px; justify-content: center; }
    .dropdown-item { min-height: 44px; }
    .admin-nav-item { min-height: 40px; }
}

/* ============================================
   SAFE AREA — iPhone notch/home indicator
   ============================================ */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
    .site-footer {
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   DARK MODE MOBILE TWEAKS
   ============================================ */
[data-theme="dark"] .post-card {
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
[data-theme="dark"] .navbar {
    box-shadow: 0 1px 8px rgba(0,0,0,.4);
}
[data-theme="dark"] .admin-sidebar {
    background: var(--surface);
}

/* ============================================
   UTILITY
   ============================================ */
.hide-mobile { display: none !important; }
@media (min-width: 640px) { .hide-mobile { display: unset !important; } }
.show-mobile { display: block !important; }
@media (min-width: 640px) { .show-mobile { display: none !important; } }

