/* ===========================================
   INDEX PAGE STYLES - Homepage post cards
   =========================================== */

/* ===========================================
   CREATE POST DRAWER - Right side panel
   =========================================== */
.drawer-overlay {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.block-editor-drawer {
    position: fixed;
    top: 60px;
    right: 0;
    width: 80%;
    max-width: 1600px;
    height: calc(100vh - 60px);
    background: #fff;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.block-editor-drawer.open {
    transform: translateX(0);
}

.block-editor-drawer .block-editor-header {
    padding: 16px 24px;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: white;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.block-editor-drawer .block-editor-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: white;
}

.block-editor-drawer .block-editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon.drawer-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    color: white;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.drawer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.block-editor-drawer .block-editor-layout-drawer {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.block-editor-drawer .block-sidebar {
    width: 200px;
    flex-shrink: 0;
    padding: 16px;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    flex-direction: column;
}

.block-editor-drawer .block-sidebar-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.block-editor-drawer .block-sidebar-actions .btn {
    width: 100%;
    justify-content: center;
}

/* Publish button - primary blue */
.block-editor-drawer .block-sidebar-actions .btn-primary,
.block-editor-drawer .block-sidebar-actions .btn[onclick*="publish"] {
    background: #3b82f6;
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.2s;
}

.block-editor-drawer .block-sidebar-actions .btn-primary:hover,
.block-editor-drawer .block-sidebar-actions .btn[onclick*="publish"]:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* Secondary/clear button */
.block-editor-drawer .block-sidebar-actions .btn-secondary,
.block-editor-drawer .block-sidebar-actions .btn[onclick*="clear"] {
    background: rgba(30, 41, 59, 0.1);
    border: 1px solid #cbd5e1;
    color: #334155;
}

.block-editor-drawer .block-sidebar-actions .btn-secondary:hover,
.block-editor-drawer .block-sidebar-actions .btn[onclick*="clear"]:hover {
    background: rgba(30, 41, 59, 0.15);
    border-color: #94a3b8;
}

.block-editor-drawer .block-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px;
    min-width: 0;
}

.block-editor-drawer .block-preview-panel {
    width: 600px;
    flex-shrink: 0;
    padding: 1px;
    border-left: 1px solid #e5e7eb;
    overflow-y: auto;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}

/* Responsive drawer */
@media (max-width: 1200px) {
    .block-editor-drawer {
        width: 85%;
    }

    .block-editor-drawer .block-preview-panel {
        width: 280px;
    }
}

@media (max-width: 900px) {
    .block-editor-drawer {
        width: 100%;
    }

    .block-editor-drawer .block-preview-panel {
        display: none;
    }

    .block-editor-drawer .block-sidebar {
        width: 180px;
    }
}

@media (max-width: 600px) {
    .block-editor-drawer {
        top: 0;
        height: 100vh;
        z-index: 1001;
    }

    .drawer-overlay {
        top: 0;
        z-index: 1001;
    }

    .block-editor-drawer .block-editor-header {
        padding: 12px 16px;
    }

    .block-editor-drawer .block-editor-header h2 {
        font-size: 1rem;
    }

    .block-editor-drawer .block-editor-actions {
        gap: 6px;
    }

    .block-editor-drawer .block-editor-actions .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .block-editor-drawer .block-editor-layout-drawer {
        flex-direction: column;
    }

    /* Sidebar as collapsible dropdown on mobile */
    .block-editor-drawer .block-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding: 0;
        display: block;
        position: relative;
        background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
        max-height: 44px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .block-editor-drawer .block-sidebar.expanded {
        max-height: 500px;
        overflow-y: auto;
    }

    .block-editor-drawer .block-sidebar h4 {
        width: 100%;
        margin: 0;
        padding: 12px 16px;
        font-size: 0.8rem;
        background: transparent;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .block-editor-drawer .block-sidebar h4::after {
        content: '▼';
        font-size: 0.6rem;
        transition: transform 0.3s;
    }

    .block-editor-drawer .block-sidebar.expanded h4::after {
        transform: rotate(180deg);
    }

    .block-editor-drawer .block-sidebar .block-add-btn {
        display: flex;
        width: 100%;
        padding: 10px 16px;
        font-size: 0.85rem;
        margin-bottom: 0;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .block-editor-drawer .block-sidebar .block-add-btn:last-of-type {
        border-bottom: none;
    }

    .block-editor-drawer .block-sidebar .block-add-btn svg {
        width: 16px;
        height: 16px;
    }

    .block-editor-drawer .block-sidebar-section {
        width: 100%;
        margin-top: 0;
        padding: 12px 16px;
        border-top: 1px solid #e5e7eb;
    }

    .block-editor-drawer .block-sidebar-section h4 {
        padding: 0;
        margin-bottom: 8px;
    }

    .block-editor-drawer .block-sidebar-section h4::after {
        display: none;
    }

    .block-editor-drawer .block-sidebar-section textarea {
        font-size: 0.9rem;
    }

    .block-editor-drawer .block-sidebar-actions {
        padding: 12px 16px;
        margin-top: 0;
        flex-direction: row;
        gap: 8px;
    }

    .block-editor-drawer .block-sidebar-actions .btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .block-editor-drawer .block-editor-main {
        padding: 12px;
        flex: 1;
        min-height: 0;
    }

    .block-editor-drawer .block-title-input {
        font-size: 1.1rem;
        padding: 10px 12px;
    }

    .block-editor-drawer .block-canvas {
        min-height: 200px;
    }

    .block-editor-drawer .block-item {
        padding: 10px;
    }

    .block-editor-drawer .block-controls {
        gap: 4px;
    }

    .block-editor-drawer .block-control-btn {
        padding: 4px;
    }

    .block-editor-drawer .block-add-footer {
        padding: 8px 0;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .block-editor-drawer .block-editor-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .block-editor-drawer .block-editor-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .block-editor-drawer .block-sidebar .block-add-btn span:not(.sr-only) {
        display: none;
    }

    .block-editor-drawer .block-sidebar .block-add-btn {
        padding: 10px;
    }
}

/* ===========================================
   END CREATE POST DRAWER
   =========================================== */

/* Posts grid layout */
section.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}

/* Posts grid responsiveness */
@media (max-width: 768px) {
    section.posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
        gap: 16px;
        margin-top: 16px;
    }
}

@media (max-width: 480px) {
    section.posts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 12px;
    }
}

article.post {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.post .card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.post-author-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.post-header {
    margin-bottom: 16px;
}

.post-header h3 {
    margin: 0;
    font-size: clamp(1.1rem, 1.35rem, 1.35rem);
    font-weight: 700;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
}

.post-header h3 a {
    transition: color 0.2s;
    color: #111827;
    text-decoration: none;
}

.post-header h3 a:hover {
    color: var(--accent);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.post-meta .author {
    font-weight: 600;
    color: #111827;
}

.post-meta .meta-dot {
    color: #d1d5db;
}

.post-meta .date {
    color: var(--muted);
    font-size: 0.8rem;
}

.post-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

.post:hover .post-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Post excerpt on homepage */
.post-excerpt {
    color: #4b5563;
    line-height: 1.7;
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    height: 105px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    position: relative;
}

/* Like button */
.like-btn {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 5;
    pointer-events: none;
}

.like-btn svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
    color: #ef4444;
    pointer-events: auto;
}

.like-btn:hover svg {
    transform: scale(1.2);
    filter: drop-shadow(0 6px 12px rgba(239, 68, 68, 0.4));
}

.like-btn[data-liked="true"] svg {
    color: #ef4444;
}

.post:hover .like-btn {
    opacity: 1;
}

/* Like bubble animation */
.like-bubble {
    position: fixed;
    top: 80px;
    right: -400px;
    pointer-events: none;
    z-index: 1000;
    animation: floatAcross 5s ease-in-out forwards;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(239, 68, 68, 0.3);
    max-width: 400px;
}

.like-bubble-heart {
    flex-shrink: 0;
}

.like-bubble-heart svg {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 8px rgba(239, 68, 68, 0.4));
    color: #ef4444;
}

.like-bubble-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.like-bubble-title {
    font-weight: 700;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #ec4899, #8b5cf6, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.like-bubble-user {
    font-size: 0.8rem;
    color: #6b7280;
    white-space: nowrap;
}

@keyframes floatAcross {
    0% {
        right: -400px;
        opacity: 0;
        transform: translateY(0) rotate(0deg) scale(0.8);
    }

    10% {
        opacity: 1;
        transform: translateY(-10px) rotate(2deg) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-20px) rotate(-2deg) scale(1);
    }

    90% {
        opacity: 0.9;
    }

    100% {
        right: 100%;
        opacity: 0;
        transform: translateY(-30px) rotate(3deg) scale(0.9);
    }
}

/* Post footer */
.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    margin-top: auto;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    height: 45px;
}

.post-footer .post-stats {
    display: flex;
    gap: 16px;
    color: var(--muted);
}

.post-footer .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.post-footer .stat-item svg {
    opacity: 0.7;
}

.post-footer .read-more {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    padding: 6px 12px;
    border-radius: 6px;
}

.post-footer .read-more:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

/* Post message content formatting */
.post-message {
    line-height: 1.6;
    margin: 12px 0;
    word-wrap: break-word;
}

.post-message h1,
.post-message h2,
.post-message h3 {
    margin: 16px 0 8px 0;
    font-weight: 700;
}

.post-message h1 {
    font-size: 1.8rem;
}

.post-message h2 {
    font-size: 1.5rem;
}

.post-message h3 {
    font-size: 1.2rem;
}

.post-message ul {
    margin: 12px 0;
    padding-left: 24px;
    list-style: none;
}

.post-message li {
    margin: 4px 0;
}

.post-message blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--muted);
    font-style: italic;
    display: block;
}

.post-message a {
    color: var(--accent);
    text-decoration: underline;
}

.post-message strong {
    font-weight: 700;
}

.post-message em {
    font-style: italic;
}

.image-container {
    margin: 20px 0;
    text-align: left;
}

.post-message img.post-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Stat item helper */
.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-item svg {
    flex-shrink: 0;
}

/* ===========================================
   POST CARD RESPONSIVE STYLES
   =========================================== */
@media (max-width: 768px) {
    .post .card {
        padding: 16px;
    }

    .post-header h3 {
        font-size: 1.15rem;
    }

    .post-excerpt {
        font-size: 0.9rem;
        height: 90px;
        -webkit-line-clamp: 4;
    }

    .post-footer {
        font-size: 0.8rem;
        height: 40px;
    }

    .post-footer .post-stats {
        gap: 12px;
    }

    .post-meta {
        font-size: 0.8rem;
    }

    .like-btn svg {
        width: 40px;
        height: 40px;
    }

    .like-bubble {
        padding: 10px 16px;
        max-width: 320px;
    }

    .like-bubble-heart svg {
        width: 26px;
        height: 26px;
    }

    .like-bubble-title {
        font-size: 0.85rem;
    }

    .like-bubble-user {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .post .card {
        padding: 14px;
    }

    .post-author-section {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .post-header {
        margin-bottom: 12px;
    }

    .post-header h3 {
        font-size: 1.05rem;
        -webkit-line-clamp: 2;
    }

    .post-excerpt {
        font-size: 0.85rem;
        height: 75px;
        margin-bottom: 12px;
    }

    .post-footer {
        font-size: 0.75rem;
        padding-top: 10px;
        height: 36px;
    }

    .post-footer .post-stats {
        gap: 10px;
    }

    .post-footer .read-more {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .post-meta {
        font-size: 0.75rem;
        gap: 6px;
    }

    .post-controls {
        top: 10px;
        right: 10px;
        gap: 4px;
    }

    .like-btn svg {
        width: 36px;
        height: 36px;
    }

    .like-bubble {
        padding: 8px 12px;
        max-width: 280px;
        gap: 8px;
    }

    .like-bubble-heart svg {
        width: 22px;
        height: 22px;
    }

    .like-bubble-title {
        font-size: 0.8rem;
    }

    .like-bubble-user {
        font-size: 0.7rem;
    }
}