/**
 * TetHub — Shared Components
 * Canonical, reusable UI component classes for every page.
 * Requires theme.css (CSS variables) to be loaded first.
 *
 * Contents:
 *   1. Skeleton loaders
 *   2. Spinner
 *   3. Avatar
 *   4. Badge / dot
 *   5. Button variants
 *   6. Action buttons (like · comment · save · share)
 *   7. Empty-state  
 *   8. Load-more
 *   9. Page-content wrapper (sets warm page bg on every route)
 */

/* ============================================================
   1. SKELETON LOADERS
   ============================================================ */

/* Base shimmer animation */
.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    overflow: hidden;
}

@keyframes skeleton-shimmer {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* Post-card skeleton wrapper */
.post-skeleton {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-text-group {
    flex: 1;
}

.skeleton-text {
    height: 0.875rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-text.short { width: 55%; }
.skeleton-text.medium { width: 75%; }

.skeleton-line {
    background: var(--bg-tertiary);
    border-radius: 4px;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-image {
    width: 100%;
    height: 280px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-media {
    width: 100%;
    height: 300px;
    background: var(--bg-tertiary);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-content   { padding: 1rem; }
.skeleton-author-info { flex: 1; }

.skeleton-stats {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.skeleton-actions {
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 1rem;
}

.skeleton-comments { padding: 1rem; }

.skeleton-comment-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}


/* ============================================================
   2. SPINNER
   ============================================================ */

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spinner-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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


/* ============================================================
   3. AVATAR
   ============================================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    overflow: hidden;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-xs  { width: 24px;  height: 24px;  font-size: 0.625rem; }
.avatar-sm  { width: 32px;  height: 32px;  font-size: 0.75rem;  }
.avatar-md  { width: 40px;  height: 40px;  font-size: 0.875rem; }
.avatar-lg  { width: 48px;  height: 48px;  font-size: 1rem;     }
.avatar-xl  { width: 64px;  height: 64px;  font-size: 1.25rem;  }
.avatar-2xl { width: 80px;  height: 80px;  font-size: 1.5rem;   }


/* ============================================================
   4. BADGE / DOT
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.2em 0.5em;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary { background: var(--primary);  color: #fff; }
.badge-danger  { background: var(--danger);   color: #fff; }
.badge-warning { background: var(--warning);  color: #fff; }
.badge-success { background: var(--success);  color: #fff; }
.badge-neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Notification dot (no number) */
.badge-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--danger);
    border: 2px solid var(--bg-primary);
}


/* ============================================================
   5. BUTTON VARIANTS
   ============================================================ */

/* Shared base */
.btn-base,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger,
.btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #a00d11;
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

/* Sizes */
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.75rem;   font-size: 1rem;      }
.btn-xl { padding: 1rem 2rem;         font-size: 1.0625rem; }

/* Full-width */
.btn-block { width: 100%; }

/* Pill shape */
.btn-pill { border-radius: var(--radius-full); }

/* Loading / disabled state */
.btn-loading,
button[disabled] {
    pointer-events: none;
    opacity: 0.65;
}


/* ============================================================
   6. ACTION BUTTONS (like · comment · save · share)
   Base styles + active-state colours live in post-actions.css
   which is loaded globally via base-modern.html.
   They already reference var(--like-color) / var(--save-color)
   so no overrides are needed here.
   ============================================================ */


/* ============================================================
   7. EMPTY STATE
   ============================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1.25rem;
    line-height: 1;
}

.empty-state h3,
.empty-state-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.625rem;
}

.empty-state p,
.empty-state-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    max-width: 420px;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}


/* ============================================================
   8. LOAD MORE
   ============================================================ */

.load-more {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.load-more-btn {
    padding: 0.75rem 2rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.load-more-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}


/* ============================================================
   9. PAGE-CONTENT WRAPPER
   Ensures the warm beige page background is visible on ALL
   pages regardless of per-template overrides.
   Templates that intentionally use a white full-bleed layout
   (e.g. product detail) should add class="page-white" to
   their top-level wrapper instead of overriding body bg.
   ============================================================ */

/* Default: warm beige background for the whole page already
   set on <body> in base-modern.html.  This class lets specific
   sections opt into a white/card surface. */
.surface {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.surface-flat {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
}

/* Utility: section divider (8 px warm strip between card sections) */
.section-gap {
    height: 8px;
    background: var(--bg-secondary);
}
