/* YYMOLI: Ho Chi Minh City Microblog Template - Optimized v2.0
   Colors: Sunset Orange (#FF5722), Saigon Teal (#008080), Grab Green (#00B14F)
*/

:root {
    --primary-orange: #FF5722;
    --saigon-teal: #008080;
    --grab-green: #00B14F;
    --bg-light: #F8F9FA;
    --text-dark: #2D3436;
    --text-muted: #636e72;
    --white: #FFFFFF;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography & Global Elements --- */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

a { 
    text-decoration: none; 
    color: inherit; 
    transition: color var(--transition);
}

button { 
    cursor: pointer; 
    transition: all var(--transition);
    border: none;
    background: none;
    font-family: inherit;
}

/* Inherit fonts for form elements - Better mobile consistency */
input,
button,
select,
textarea {
    font: inherit;
}

/* --- Header & Navigation --- */
.navbar {
    background: var(--white);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #eee;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.logo {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--primary-orange);
    letter-spacing: -1px;
    transition: transform var(--transition);
}

.logo:active {
    transform: scale(0.95);
}

/* --- Button Components --- */
.btn-follow {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--primary-orange);
    background: transparent;
    color: var(--primary-orange);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition);
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-follow:hover {
    background: var(--primary-orange);
    color: var(--white);
    transform: translateY(-1px);
}

.btn-follow:active {
    transform: scale(0.95);
}

.btn-follow.following {
    background: var(--text-muted);
    border-color: var(--text-muted);
    color: var(--white);
}

/* --- Hero & Filters --- */
.hero {
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('https://images.unsplash.com/photo-1555944190-25593859235e?auto=format&fit=crop&w=800&q=80');
    background-size: cover;
    background-position: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--white);
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hero input {
    width: 100%;
    max-width: 500px;
    padding: 12px 20px;
    border-radius: 30px;
    border: none;
    margin-top: 15px;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: box-shadow var(--transition), transform var(--transition);
}

.hero input:focus {
    outline: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.filter-header {
    background: var(--white);
    padding: 15px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 60px;
    z-index: 100;
}

.district-scroller {
    display: flex;
    overflow-x: auto;
    padding: 0 20px;
    gap: 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.district-scroller::-webkit-scrollbar { display: none; }

.dist-pill {
    white-space: nowrap;
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: var(--white);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
    transition: all var(--transition);
    cursor: pointer;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
}

.dist-pill:hover {
    border-color: var(--primary-orange);
    color: var(--primary-orange);
    transform: translateY(-1px);
}

.dist-pill.active {
    background: var(--primary-orange);
    color: var(--white);
    border-color: var(--primary-orange);
    box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
}

/* --- Masonry Feed Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 15px;
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

.mini-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    will-change: transform;
    cursor: pointer;
}

.mini-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

.mini-card:active { 
    transform: scale(0.98); 
}

.card-img {
    position: relative;
    height: 180px;
    overflow: hidden;
    background: #f0f0f0;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
    will-change: transform;
}

.mini-card:hover .card-img img {
    transform: scale(1.05);
}

.price-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-dark);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-content { 
    padding: 12px; 
}

.card-content h4 {
    font-size: 0.95rem;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.likes {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: 12px;
    transition: all var(--transition);
    user-select: none;
    min-height: 32px;
    min-width: 44px;
    justify-content: center;
}

.likes:hover {
    background: rgba(255, 87, 34, 0.1);
}

.heart-active { 
    color: var(--primary-orange); 
}

/* --- Detail Page Layout --- */
.detail-container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--white);
    min-height: 100vh;
    padding-bottom: 80px;
}

.image-gallery {
    position: relative;
}

.image-gallery img {
    width: 100%;
    aspect-ratio: 4/5;
    object-fit: cover;
    background: #f0f0f0;
}

.image-count {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.post-body { 
    padding: 25px 20px; 
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.avatar { 
    width: 48px; 
    height: 48px; 
    border-radius: 50%; 
    object-fit: cover;
    border: 2px solid var(--bg-light);
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.user-info strong {
    font-size: 0.95rem;
    color: var(--text-dark);
}

.user-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.post-title {
    font-size: 1.5rem;
    margin-bottom: 16px;
    line-height: 1.3;
    color: var(--text-dark);
}

.post-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-dark);
    margin-bottom: 20px;
}

.post-text p {
    margin-bottom: 12px;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tag {
    background: rgba(255, 87, 34, 0.1);
    color: var(--primary-orange);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition);
    cursor: pointer;
}

.tag:hover {
    background: var(--primary-orange);
    color: white;
    transform: translateY(-1px);
}

.location-card {
    background: #f0f2f5;
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 25px;
    transition: transform var(--transition);
}

.location-card:hover {
    transform: translateX(4px);
}

.loc-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.loc-details {
    flex: 1;
    min-width: 0;
}

.loc-details strong {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 4px;
}

.loc-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.btn-grab {
    background: var(--grab-green);
    color: var(--white);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 700;
    margin-left: auto;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(0, 177, 79, 0.3);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-grab:hover {
    background: #009940;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 177, 79, 0.4);
}

.btn-grab:active {
    transform: scale(0.95);
}

/* --- Comments Section --- */
.comments-section {
    margin-top: 24px;
}

.comments-section h4 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.comment {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 12px;
    transition: background var(--transition);
}

.comment:hover {
    background: #e8eaed;
}

.comment img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment strong {
    font-size: 0.85rem;
    display: block;
    margin-bottom: 4px;
}

.comment p {
    font-size: 0.85rem;
    color: var(--text-dark);
    line-height: 1.4;
    margin: 0;
}

/* --- Interactions & Animations --- */
.interaction-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 700px;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #eee;
    z-index: 1001;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all var(--transition);
    color: var(--text-muted);
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
}

.stat:hover {
    background: rgba(255, 87, 34, 0.1);
    color: var(--primary-orange);
}

.stat span {
    font-size: 0.75rem;
    font-weight: 600;
}

.heart-active { 
    color: var(--primary-orange); 
    animation: heartPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.fab-post {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom));
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-orange);
    color: white;
    font-size: 30px;
    border: none;
    box-shadow: 0 6px 20px rgba(255, 87, 34, 0.4);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    will-change: transform;
}

.fab-post:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 24px rgba(255, 87, 34, 0.5);
}

.fab-post:active {
    transform: scale(0.9);
}

/* --- Category Page Specific --- */
.category-header {
    background: white;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.stats-bar {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.sub-nav {
    display: flex;
    gap: 20px;
    padding: 12px 20px;
    background: #fff;
    overflow-x: auto;
    border-bottom: 1px solid #eee;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.sub-nav a {
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 8px 0;
    position: relative;
    font-weight: 500;
    transition: color var(--transition);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.sub-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-orange);
    transition: width var(--transition);
}

.sub-nav a:hover {
    color: var(--text-dark);
}

.sub-nav a.active {
    color: var(--primary-orange);
    font-weight: 600;
}

.sub-nav a.active::after {
    width: 100%;
}

/* --- Utility Classes --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- Desktop Refinements --- */
@media (min-width: 768px) {
    .card-grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 16px;
        padding: 20px;
    }
    
    .hero { 
        padding: 80px 20px; 
        min-height: 350px;
    }
    
    .mini-card:hover {
        transform: translateY(-8px);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1a1a1a;
        --text-dark: #f5f5f5;
        --text-muted: #a0a0a0;
        --white: #2d2d2d;
    }
    
    .navbar, .filter-header {
        background-color: rgba(45, 45, 45, 0.95);
        border-color: #444;
    }
    
    .mini-card, .location-card, .comment {
        background: #2d2d2d;
    }
    
    .sub-nav {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .category-header {
        background: #2d2d2d;
        border-color: #444;
    }
}