/**
 * Single Post Styles
 * Location: /post/assets/style.css
 * Revised: Modern UI/UX Standards
 */

/* ============================================================================
   VARIABLES & THEME
   ============================================================================ */
:root {
    /* Brand Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    /* Semantic Colors */
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --success: #10b981;
    --success-bg: #ecfdf5;
    
    /* Neutrals */
    --text-main: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --border-light: #e5e7eb;
    
    /* Spacing & Layout */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows (Soft/Modern) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Transitions */
    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   RESET & GLOBAL
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

/* Accessibility Focus Ring */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================================
   CONTAINER
   ============================================================================ */

.single-post-container {
    max-width: 720px; /* Tighter width for better reading experience */
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
}

/* ============================================================================
   LOADING & ERROR STATES
   ============================================================================ */

.loading-container, .error-container {
    min-height: 60vh; /* Don't force full 100vh inside a component */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.76, 0.35, 0.2, 0.7) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Error State Polish */
.error-icon {
    font-size: 3rem; /* Fallback if SVG sizing fails */
    color: var(--danger);
    margin-bottom: 20px;
    background: var(--danger-bg);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.error-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 24px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-left: -12px; /* Visual alignment correction */
    transition: var(--transition-base);
}

.back-link:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    transform: translateX(-4px);
}

/* ============================================================================
   SINGLE POST CARD
   ============================================================================ */

.single-post-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.02); /* Subtle border for high res displays */
}

/* ============================================================================
   REPOST BADGE
   ============================================================================ */

.repost-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.repost-badge svg {
    width: 16px;
    height: 16px;
}

/* ============================================================================
   POST HEADER
   ============================================================================ */

.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
}

.post-author-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.author-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--border-light);
}

.author-details {
    display: flex;
    flex-direction: column;
}

.author-details h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.author-username {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-time {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ============================================================================
   POST MEDIA & CONTENT
   ============================================================================ */

.post-content-area {
    padding: 0 24px 24px 24px;
    font-size: 1.05rem;
    color: #374151; /* Slightly softer black */
    line-height: 1.7;
    white-space: pre-wrap;
}

.post-media {
    width: 100%;
    background: #000;
    margin-bottom: 0;
    position: relative;
    /* Maintain generic aspect ratio wrapper could go here */
}

.post-media img,
.post-media video {
    width: 100%;
    max-height: 700px;
    display: block;
    object-fit: contain;
}

/* ============================================================================
   STATS & REACTIONS
   ============================================================================ */

.post-stats {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    gap: 20px;
}

.post-stats strong {
    color: var(--text-main);
    font-weight: 700;
}

.post-reactions {
    display: flex;
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.reaction-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    flex: 1; /* Stretch buttons on mobile, even distribution */
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition-base);
}

.reaction-btn:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

.reaction-btn:active {
    transform: scale(0.97);
}

/* Active States */
.reaction-btn.liked {
    color: var(--danger);
    background: var(--danger-bg);
}

.reaction-btn.reposted {
    color: var(--success);
    background: var(--success-bg);
}

/* ============================================================================
   COMMENTS SECTION
   ============================================================================ */

.comments-section {
    padding: 24px;
    background: #fcfcfd; /* Very subtle contrast from white card */
}

.comments-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

/* Input Wrapper */
.comment-input-wrapper {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    background: white;
    padding: 8px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.comment-input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    font-size: 0.95rem;
    resize: none; /* If textarea */
    color: var(--text-main);
}

.comment-input:focus {
    outline: none;
}

.comment-input::placeholder {
    color: var(--text-tertiary);
}

.btn-submit {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition-base);
    align-self: flex-start;
}

.btn-submit:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.btn-submit:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Comments List */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.comment-item {
    display: flex;
    gap: 14px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border-light);
}

.comment-content {
    background: var(--bg-body);
    padding: 12px 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
    flex: 1;
}

.comment-author-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.comment-author {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.comment-text {
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.5;
}

.no-comments {
    text-align: center;
    padding: 40px;
    background: var(--bg-body);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    border: 1px dashed var(--border-light);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 640px) {
    .single-post-container {
        padding: 0;
        max-width: 100%;
    }
    
    .single-post-card {
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid var(--border-light);
        border-bottom: 1px solid var(--border-light);
    }

    .post-header {
        padding: 16px;
    }

    .author-avatar {
        width: 44px;
        height: 44px;
    }

    .post-content-area {
        padding: 0 16px 20px 16px;
        font-size: 1rem;
    }
    
    .reaction-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .comments-section {
        padding: 20px 16px;
    }
    
    .back-link {
        margin: 16px 0 16px 16px;
    }
}