/* Mobile-First Home Page CSS */

/* CSS Variables for Mobile-First Design */
:root {
  --primary-color: #1DA1F2;
  --primary-dark: #1a91da; /* Added for hover states */
  --secondary-color: #657786;
  --accent-color: #FF6B6B;
  --success-color: #1DB954;
  --warning-color: #FFB020;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f4;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --text-primary: #14171a;
  --text-secondary: #536471;
  --text-muted: #8b98a5;
  --border-color: #e1e8ed;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 50px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 70px;
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
}

/* Dark Mode Variables */
.dark {
  --bg-primary: #000000;
  --bg-secondary: #16181c;
  --bg-tertiary: #1e2328;
  --bg-overlay: rgba(0, 0, 0, 0.8);
  --text-primary: #ffffff;
  --text-secondary: #8b98a5;
  --text-muted: #6e767d;
  --border-color: #2f3336;
  --shadow-sm: 0 1px 3px rgba(255, 255, 255, 0.1);
  --shadow-md: 0 4px 12px rgba(255, 255, 255, 0.15);
  --shadow-lg: 0 8px 25px rgba(255, 255, 255, 0.2);
}

/* Global Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 16px;
  overflow-x: hidden;
  padding-top: calc(var(--header-height) + var(--safe-area-top));
  min-height: 100vh;
  transition: var(--transition);
}

/* Modern Home Header */
.home-header {
  position: fixed;
  top: var(--safe-area-top);
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.home-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1), transparent 50%);
  pointer-events: none;
}

/* Header Left: Logo */
.header-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.logo {
  height: 40px;
  width: auto;
  transition: var(--transition);
  filter: brightness(-1) invert(1);
}

.logo:active {
  transform: scale(0.95);
}

/* Header Center */
.header-center {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  position: relative;
  z-index: 1;
}

/* Header Right: Search */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.search-bar {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-bar:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.search-bar:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
}

.search-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: var(--transition);
}

/* Main Content Area */
main {
  padding: 0 16px;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modern Articles Grid */
#articles-container {
  display: grid;
  grid-template-columns: 1fr; /* Full width on mobile */
  gap: 16px;
  margin-top: 16px;
  padding: 0;
  width: 100%;
}

/* Mobile Article Cards */
.article-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); /* Rounded corners for the whole card */
  overflow: hidden; /* Important for image border-radius */
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column; /* Stack image and content vertically */
  width: 100%; /* Ensure full width on mobile */
}

.article-card:hover {
  transform: translateY(-2px); /* Subtle lift on hover */
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color); /* Highlight border on hover */
}

.article-card:active {
  transform: translateY(0); /* Reset transform on click */
}

/* NEW: Article Image Container for 16:9 Aspect Ratio */
.article-image-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* This creates the 16:9 aspect ratio (9 / 16 * 100%) */
  overflow: hidden; /* Ensures image stays within its bounds */
  /* Apply top-left and top-right border-radius here to match the card */
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
}

/* Article Image (inside article-image-container) */
.article-card .article-image {
  position: absolute; /* Position the image absolutely within its container */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%; /* Fill the padded container */
  object-fit: cover; /* Crop as needed to fill the container without distorting */
  display: block;
  cursor: pointer;
  transition: var(--transition);
}

.article-card:hover .article-image { /* Apply hover effect to the image itself */
  transform: scale(1.02);
}

/* Wrapper for content below the image (title, meta, stats) */
.article-card-body-wrapper {
  padding: 16px; /* Consistent padding for the content section */
  flex-grow: 1; /* Allows this section to take up remaining vertical space */
  display: flex;
  flex-direction: column;
}

/* Article Title */
.article-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0; /* Space below title */
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box; /* For multi-line ellipsis */
  -webkit-line-clamp: 2; /* Limit title to 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left; /* Titles are typically left-aligned */
}

/* Article Description (if present, used in profile/user-profile) */
.card-description {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 12px; /* Space above stats */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit description to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1; /* Allows it to grow if needed */
}


/* Article Meta - Container for author info and counts (e.g., date, visibility badge) */
.article-card .article-meta {
    display: flex;
    justify-content: space-between; /* Pushes elements to opposite ends */
    align-items: center;
    font-size: 0.9em;
    color: var(--text-muted); /* Muted text color for meta info */
    flex-wrap: wrap; /* Allow wrapping */
    padding-top: 12px; /* Space above separator line */
    border-top: 1px solid var(--border-color); /* Separator line */
}

/* Author Info Grouping (image + name) - This is the `div.left` from your HTML */
.article-card .article-meta .left {
  display: flex;
  align-items: center;
  gap: 8px; /* Space between pic and name */
  flex-grow: 1; /* Allow it to take available horizontal space */
  min-width: 0; /* Important for text ellipsis inside */
}

/* Author Image */
.article-card .article-meta .left .uploader-pic {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0; /* Prevent image from shrinking */
}

/* Author Name */
.article-card .article-meta .left .uploader-name { /* Target the span directly */
  font-weight: 500;
  white-space: nowrap; /* Keep name on one line */
  overflow: hidden;
  text-overflow: ellipsis; /* Truncate long names */
  color: var(--text-primary); /* Use primary text color for name */
}

/* Author Handle (if you have one) */
.article-card .article-meta .left .user-handle { /* Assumed class for handle if you add one */
    font-size: 0.8em; /* Smaller font for handle */
    color: var(--text-muted); /* Muted color */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}


/* Counts Container (Views and Comments) */
.article-card .article-meta .counts {
    display: flex;
    gap: 10px; /* Reduced gap between counts for compactness */
    align-items: center;
    flex-shrink: 0; /* Prevent counts from shrinking */
    margin-left: auto; /* Push to the right */
}

.view-count, .comment-count {
  background: var(--bg-secondary);
  padding: 5px 8px; /* Slightly less padding for compactness */
  border-radius: var(--radius-lg);
  font-size: 11px; /* Slightly smaller font size */
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 3px; /* Reduced gap between icon and number */
  flex-shrink: 0;
  cursor: pointer; /* Keep cursor pointer if they're clickable, else default */
  transition: var(--transition);
  border: 1px solid var(--border-color);
  font-weight: 500;
}

.view-count:hover, .comment-count:hover {
  background: var(--bg-tertiary);
  color: var(--primary-color);
}
.view-count:active, .comment-count:active {
  transform: scale(0.95);
}

.view-count i, .comment-count i,
.view-count .count-number, .comment-count .count-number {
  margin: 0;
  font-size: inherit;
  line-height: 1;
}

/* Card Stats (used in profile/user-profile for views/comments on articles) */
.article-card .card-stats {
    display: flex;
    justify-content: flex-end; /* Push counts to the right */
    gap: 12px;
    margin-top: 12px;
    font-size: 0.85em;
    color: var(--text-secondary);
    padding-top: 12px; /* Add padding to separate from description */
    border-top: 1px solid var(--border-color); /* Add separator line */
}

.article-card .card-stats .view-count,
.article-card .card-stats .comment-count {
    background: var(--bg-secondary);
    padding: 5px 10px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    font-weight: 500;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.article-card .card-stats .view-count i,
.article-card .card-stats .comment-count i {
    color: var(--text-muted);
}
.article-card .card-stats .count-number {
    font-weight: 600;
}

/* Responsive Design */
@media (min-width: 480px) {
  main {
    padding: 0 24px;
  }
  
  #articles-container {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on wider mobile/small tablet */
    gap: 20px;
  }
  
  /* Responsive image height, will scale with width due to aspect ratio container */
  /* .article-card img { height: 180px; } */
}

@media (min-width: 768px) {
  :root {
    --header-height: 80px;
  }
  
  .home-header {
    padding: 0 32px;
  }
  
  .logo {
    height: 45px;
  }
  
  main {
    padding: 0 32px;
  }
  
  #articles-container {
    grid-template-columns: repeat(3, 1fr); /* 3 columns on tablet/desktop */
    gap: 24px;
  }

  /* .article-card img { height: 180px; } */ /* Height controlled by aspect ratio container */
}

@media (min-width: 1024px) {
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
  }
  
  #articles-container {
    grid-template-columns: repeat(4, 1fr); /* 4 columns on larger desktop */
    gap: 28px;
  }
  
  /* .article-card img { height: 220px; } */ /* Height controlled by aspect ratio container */
}

@media (min-width: 1200px) {
  #articles-container {
    grid-template-columns: repeat(5, 1fr); /* 5 columns on very large screens */
  }
}
/* --- Skeleton Loader Styles --- */

.article-card.skeleton {
  pointer-events: none; /* Make skeletons non-interactive */
}

/* Animated background for skeleton elements */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Skeleton image container */
.article-image-container.skeleton-img { /* This targets the container for the image skeleton */
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  position: relative;
  background-color: var(--bg-tertiary); /* Base color for image skeleton */
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite; /* Changed to skeleton-shimmer */
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
}

/* Skeleton for card body content wrapper */
.article-card.skeleton .article-card-body-wrapper {
  padding: 16px; /* Match actual card body padding */
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Skeleton text lines */
.skeleton-text {
  background-color: var(--bg-tertiary);
  height: 16px; /* Base height for text lines */
  margin-bottom: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}
.skeleton-text.long { width: 95%; height: 20px; } /* Taller for title */
.skeleton-text.short { width: 55%; height: 16px; margin-bottom: 16px; } /* Shorter, more space below */
.skeleton-text.medium { width: 70%; }
.skeleton-text.very-short { width: 25%; }

/* Skeleton for round profile pics (author image) */
.skeleton-text.small-round {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
    background-color: var(--bg-tertiary);
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

/* Skeleton for card meta (date, visibility badge) */
.article-card.skeleton .card-meta {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    align-items: center;
    margin-top: 0;
    margin-bottom: 8px;
    color: transparent;
}
.article-card.skeleton .card-meta .skeleton-text {
    height: 12px;
    width: 50px;
}


/* Skeleton for views/comments stats */
.article-card.skeleton .card-stats {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    color: transparent;
}
.article-card.skeleton .card-stats .skeleton-text {
    width: 60px;
    height: 24px;
    border-radius: var(--radius-lg);
}


/* Utility Classes */
.hide {
  display: none !important;
}

.text-center {
  text-align: center;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 768px) {
  .container {
    padding: 0 32px;
  }
}
/* --- Modern Signup Prompt Styles (Should be in home.css if it's specific to home) --- */

#signupPrompt {
  padding: 32px 24px;
  margin: 24px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  animation: slideInUp 0.8s ease-out forwards;
  will-change: transform, opacity;
}

#signupPrompt::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 0%, rgba(29, 161, 242, 0.05), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#signupPrompt.hide {
  display: none !important;
}

#signupPrompt h3 {
  margin: 0 0 16px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

#signupPrompt p {
  margin: 0 0 24px 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

.signup-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  position: relative;
  z-index: 1;
}

.signup-options .btn {
  width: 100%;
  max-width: 320px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-decoration: none;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  min-height: 52px;
  position: relative;
  overflow: hidden;
}

.signup-options .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease-in-out;
}

.signup-options .btn:hover::before {
  left: 100%;
}

.signup-options .btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.signup-options .btn:active {
  transform: translateY(0) scale(0.98);
}

.signup-email {
  background: linear-gradient(135deg, var(--primary-color) 0%, #1a91da 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

.signup-email:hover {
  background: linear-gradient(135deg, #1a91da 0%, #1570b8 100%);
}

.signup-google {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.signup-google:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
}

.signup-google img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* --- Responsive Adjustments for Signup Prompt --- */

@media (min-width: 768px) {
  #signupPrompt {
    max-width: 600px;
    margin: 32px auto;
    padding: 40px 32px;
  }
  
  .signup-options {
    flex-direction: row;
    gap: 16px;
  }
  
  .signup-options .btn {
    flex: 1;
    max-width: none;
  }
}

/* --- Dark Mode Styles for Signup Prompt --- */

.dark #signupPrompt {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-color: var(--border-color);
  box-shadow: var(--shadow-lg);
}

.dark #signupPrompt::before {
  background: radial-gradient(circle at 50% 0%, rgba(29, 161, 242, 0.1), transparent 70%);
}

.dark .signup-google {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.dark .signup-google:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
}